import 'package:flutter/material.dart';
import 'package:flyinsono/lab/mock_data/mock_rpc.dart';
import 'package:flyinsono/lab/pages/lab_image/controller.dart';
import 'package:flyinsono/lab/pages/lab_image/urm_data_processor/index.dart';
import 'package:flyinsono/lab/pages/lab_image/widgets/image_operate_panel/adjust_panel_config.dart';
import 'package:flyinsono/lab/pages/lab_image/widgets/urm_result_overlay/controller.dart';
import 'package:get/get.dart';

import 'image_play_slider.dart';

class ImagePlayProgress extends GetView<LabImageController> {
  @override
  Widget build(BuildContext context) {
    return GetBuilder(
      id: URMResultOverlayController.imagePlayProgressId,
      init: controller,
      builder: (_) {
        var selectedImageType = controller.state.imageType;
        bool isShowProgressBar = selectedImageType == ImageType.URM_Result &&
            controller.imageOperatePanelController.urmImageType ==
                UrmImageType.Video;
        if (isShowProgressBar) {
          AdjustNumberItemInfo numberItem = URMConfig.createNumberItem(
              URMConfig.urmVideoIndexConfig, (operation) {
            controller.operatePanelHandler(operation);
          });
          return ImagePlaySlider(
            key: ValueKey(numberItem.itemKey),
            minValue: numberItem.min,
            maxValue: numberItem.max,
            currentValue: numberItem.currentValue,
            onSleepHandler: controller.onSleepHandler,
            onChanged: (value) {
              numberItem.currentValue = value;
              numberItem.onChanged?.call(value);
            },
          );
        } else {
          return SizedBox.shrink();
        }
      },
    );
  }
}
