import 'package:fis_jsonrpc/rpc.dart';
import 'package:flyinsono/architecture/states/states.dart';
import 'package:flyinsono/managers/interfaces/entities/live_course.dart';
import 'package:flyinsono/managers/interfaces/entities/live_course_membel.dart';
import 'package:get/get.dart';
import 'package:fis_lib_media_rt/interface/index.dart';

class LiveCourseState {
  // 课程Code
  final _courseCode = RxString('');
  // 课程详情
  final Rx<CourseInfoDetailDTO?> _courseDetail = Rx<CourseInfoDetailDTO?>(null);
  // 直播课
  final Rx<LiveCourse?> _liveCourse = Rx<LiveCourse?>(null);
  //是否录制
  final RxBool _startRecord = RxBool(false);

  ///是否桌面分享
  final RxBool _isDesktopShare = RxBool(false);

  ///是否设备分享
  final RxBool _isDeviceShare = RxBool(false);

  ///主频道
  final Rx<IChannel?> _mainChannel = Rx(null);

  ///拉流地址
  final RxString? _pullUrl = RxString('');

  ///设备成员
  final RxString _deviceCode = RxString('');

  final RxString _shareTip = RxString('');

  final RxBool _isLoadingDevice = RxBool(false);

  final Rx<ShareInfoDTO?> _shareInfoDTO = Rx<ShareInfoDTO?>(null);

  ///是否合图模式
  final Rx<bool> _isMergedMode = Rx(false);

  /// 是否为合图模式
  bool get isMergedMode => _isMergedMode.value;
  set isMergedMode(bool v) => _isMergedMode.value = v;

  ShareInfoDTO? get shareInfo => _shareInfoDTO.value;
  set shareInfo(ShareInfoDTO? v) => _shareInfoDTO.value = v;

  String get shareTip => _shareTip.value;
  set shareTip(String v) => _shareTip.value = v;

  String? get deviceCode => _deviceCode.value;
  set deviceCode(String? v) => _deviceCode.value = v ?? '';

  bool get isLoadingDevice => _isLoadingDevice.value;
  set isLoadingDevice(bool v) => _isLoadingDevice.value = v;

  String? get pullUrl => _pullUrl?.value;
  set pullUrl(String? v) => _pullUrl?.value = v ?? '';

  ///主频道
  IChannel? get mainChannel => _mainChannel.value;
  set mainChannel(IChannel? v) => _mainChannel.value = v;

  ///教师编码
  String get teacherCode => courseDetail?.teacherCode ?? '';

  ///当前角色是否是老师
  bool get isTeacher => teacherCode == Store.user.code;

  //设备分享
  bool get isDeviceShare => _isDeviceShare.value;
  set isDeviceShare(bool v) => _isDeviceShare.value = v;

  ///桌面分享
  bool get isLocalDesktopShare => _isDesktopShare.value;
  set isLocalDesktopShare(bool v) => _isDesktopShare.value = v;

  ///是否录制
  bool get startRecord => _startRecord.value;
  set startRecord(bool v) => _startRecord.value = v;

  ///课程房间成员
  final RxList<FLiveCourseMember> _liveCourseMembers = RxList([]);

  List<FLiveCourseMember> get liveCourseMembers => _liveCourseMembers;
  set liveCourseMembers(List<FLiveCourseMember> v) =>
      _liveCourseMembers.value = v;

  LiveCourse? get liveCourse => _liveCourse.value;
  set liveCourse(LiveCourse? v) => _liveCourse.value = v;

  CourseInfoDetailDTO? get courseDetail => _courseDetail.value;
  set courseDetail(CourseInfoDetailDTO? v) => _courseDetail.value = v;

  set courseCode(String value) => _courseCode.value = value;
  String get courseCode => _courseCode.value;
}
