import 'package:fis_jsonrpc/rpc.dart';
import 'package:get/get.dart';

import 'entitys/Image_info.dart';
import 'entitys/image_page.dart';
import 'entitys/image_state.dart';

class ImagePoolState {
  final Rx<String> _recordCode = Rx('');
  final Rx<int> _column = Rx(3);
  final Rx<int> _currentPageIndex = Rx(0);
  final Rx<RemedicalListResult> _cloudImages = Rx(RemedicalListResult());
  final Rx<int> _selectedIndex = Rx(0);
  final RxList<int> _playImages = RxList(<int>[]);
  final RxList<int> _pageIndexs = RxList(<int>[]);
  final RxMap<int, ImageState> _imageCanPlay = RxMap<int, ImageState>();
  final RxMap<int, bool> _isShowPlayIcon = RxMap<int, bool>();
  final RxList<ExamImageInfo> _imageInfos = RxList<ExamImageInfo>();
  final RxMap<int, ImagePage> _imagePags = RxMap<int, ImagePage>();
  final Rx<bool> _isShowLoading = Rx(true);
  final Rx<bool> _isExporting = Rx(false);
  final Rx<bool> _isExportFinish = Rx(false);
  final Rx<bool> _isSelectAllImages = Rx(false);
  final RxList<MeasureExportDetailDTO> _selectedImages =
      RxList<MeasureExportDetailDTO>();
  final Rx<List<RemedicalAISelectedInfoDTO>> _remedicalAISelectedInfos =
      Rx(<RemedicalAISelectedInfoDTO>[]);

  ///是否导出完成
  bool get isExportFinish => _isExportFinish.value;
  set isExportFinish(bool v) => _isExportFinish.value = v;

  String measureDataDownloadUrl = '';

  ///是否全选
  bool get isSelectAllImages => _isSelectAllImages.value;
  set isSelectAllImages(bool v) => _isSelectAllImages.value = v;

  ///是否在导出中
  bool get isExporting => _isExporting.value;
  set isExporting(bool v) => _isExporting.value = v;

  ///选中的要导出的测量图像
  List<MeasureExportDetailDTO> get selectedImages => _selectedImages;
  set selectedImages(List<MeasureExportDetailDTO> v) =>
      _selectedImages.value = v;

  /// 是否显示加载中【如果已完成加载，就不显示加载圆环，如果数据为空，会显示暂无数据】
  bool get isShowLoading => _isShowLoading.value;
  set isShowLoading(bool value) => _isShowLoading.value = value;

  ///当前页数
  int get currentPageIndex => _currentPageIndex.value;
  set currentPageIndex(int v) => _currentPageIndex.value = v;

  ///图像池分页
  Map<int, ImagePage> get imagePags => _imagePags;
  set imagePags(Map<int, ImagePage> value) => _imagePags.value = value;

  ///用户所选择播放的图像位置,用于区分自动播放的图像
  List<int> get userPlayImages => _playImages;
  set userPlayImages(List<int> value) => _playImages.value = value;

  ///页码
  List<int> get pageIndexs => _pageIndexs;
  set pageIndexs(List<int> value) => _pageIndexs.value = value;

  ///是否显示播放Icon
  Map<int, bool> get isShowPlayIconMap => _isShowPlayIcon;
  set isShowPlayIconMap(Map<int, bool> value) => _isShowPlayIcon.value = value;

  ///图像播放状态
  Map<int, ImageState> get canPlayImages => _imageCanPlay;
  set canPlayImages(Map<int, ImageState> value) => _imageCanPlay.value = value;

  ///所有图像集合
  List<ExamImageInfo> get imageInfos => _imageInfos;
  set imageInfos(List<ExamImageInfo> value) => _imageInfos.value = value;

  ///列数
  int get column => _column.value;
  set column(int v) => _column.value = v;

  ///选择Tab位置
  int get selectedIndex => _selectedIndex.value;
  set selectedIndex(int value) => _selectedIndex.value = value;

  ///云端图像
  set cloudImages(RemedicalListResult value) => _cloudImages.value = value;
  RemedicalListResult get cloudImages => _cloudImages.value;

  /// 病例Code
  set recordCode(String value) => _recordCode.value = value;
  String get recordCode => _recordCode.value;

  ///病人Code
  String patientCode = '';

  ///测量图像
  final RxList<RemedicalMeasuredInfoDTO> _remedicalMeasured =
      RxList<RemedicalMeasuredInfoDTO>();

  /// 测量图像
  set remedicalMeasured(List<RemedicalMeasuredInfoDTO> value) =>
      _remedicalMeasured.value = value;
  List<RemedicalMeasuredInfoDTO> get remedicalMeasured => _remedicalMeasured;

  /// AI图像
  set remedicalAISelectedInfos(List<RemedicalAISelectedInfoDTO> value) =>
      _remedicalAISelectedInfos(value);
  List<RemedicalAISelectedInfoDTO> get remedicalAISelectedInfos =>
      _remedicalAISelectedInfos.value;
}
