import 'package:fis_i18n/i18n.dart';
import 'package:fis_jsonrpc/services/index.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';

class UserIdAuthApplyState {
  /// 可编辑状态集合
  static final _editableStates = <ApplyStateEnum>[
    ApplyStateEnum.NotApply,
    ApplyStateEnum.Refused,
  ];

  final Rx<bool> _loading = Rx(false);
  final Rx<bool> _isNeedShowLabel = Rx(false);
  final Rx<String> _idCardFront = Rx('');
  final Rx<String> _idCardBack = Rx('');
  final Rx<String> _doctorCard = Rx('');
  final Rx<String> _applyCode = Rx('');
  final Rx<ApplyStateEnum> _applyState = Rx(ApplyStateEnum.NotApply);
  final Rx<String> _refuseNote = Rx('');
  final Rx<bool> _inEditing = Rx(false);
  final Rx<List<String>> _lables = Rx(<String>[]);
  final RxList<String> _selectedLables = RxList<String>();
  final Rx<String> _label = Rx('');

  ///标签列表
  List<String> get labels => _lables.value;
  set labels(List<String> values) => _lables.value = values;

  ///已选的标签
  List<String> get selectedLables => _selectedLables;
  set selectedLables(List<String> values) => _selectedLables.value = values;

  /// 标签
  String get label => _label.value;
  set label(String val) => _label.value = val;

  /// 身份证正面
  String get idCardFront => _idCardFront.value;
  set idCardFront(String val) => _idCardFront.value = val;

  /// 身份证反面
  String get idCardBack => _idCardBack.value;
  set idCardBack(String val) => _idCardBack.value = val;

  /// 医师执照
  String get doctorCard => _doctorCard.value;
  set doctorCard(String val) => _doctorCard.value = val;

  /// 申请状态
  set applyState(ApplyStateEnum value) => _applyState(value);
  ApplyStateEnum get applyState => _applyState.value;

  /// 拒绝原因
  String get refuseNote => _refuseNote.value;
  set refuseNote(String val) => _refuseNote.value = val;

  /// 申请角色编码
  String get applyCode => _applyCode.value;
  set applyCode(String val) => _applyCode.value = val;

  /// 编辑中
  bool get inEditing => _inEditing.value;
  set inEditing(bool val) => _inEditing.value = val;

  /// 是否显示擅长领域字段
  bool get isNeedShowLabel => _isNeedShowLabel.value;
  set isNeedShowLabel(bool val) => _isNeedShowLabel.value = val;

  bool get loading => _loading.value;
  set loading(bool val) => _loading.value = val;

  /// 可编辑
  bool get editable => _editableStates.contains(applyState);

  /// 状态描述
  String get applyStateDescription {
    switch (applyState) {
      case ApplyStateEnum.NotApply:
        return i18nBook.user.unApplyment.t;
      case ApplyStateEnum.Applying:
        return i18nBook.user.underVerification.t;
      case ApplyStateEnum.Refused:
        return i18nBook.user.refused.t;
      case ApplyStateEnum.Passed:
        return i18nBook.user.passed.t;
    }
  }

  /// 是否已通过审核
  bool get applyPassed => applyState == ApplyStateEnum.Passed;
}

class ApplyRoleInfo {
  final _name = "".obs;
  final _descriptionArray = <String>[].obs;
  final _iconUrl = ''.obs;
  final _startColor = Colors.white.obs;
  final _endColor = Colors.white.obs;
  final _qualification = RoleQualificationEnum.NoNeed.obs;
  final _fieldShowType = RoleShowTypeEnum.NotShow.obs;

  /// 名称
  String get name => _name.value;
  set name(String val) => _name.value = val;

  /// 描述集合
  List<String> get descriptionArray => _descriptionArray;
  set descriptionArray(List<String> val) => _descriptionArray(val);

  /// 图标Url
  String get iconUrl => _iconUrl.value;
  set iconUrl(String val) => _iconUrl.value = val;

  /// 渐变起始色
  Color get startColor => _startColor.value;
  set startColor(Color val) => _startColor.value = val;

  /// 渐变终止色
  Color get endColor => _endColor.value;
  set endColor(Color val) => _endColor.value = val;

  /// 资质文件需求
  RoleQualificationEnum get qualification => _qualification.value;
  set qualification(RoleQualificationEnum val) => _qualification.value = val;

  /// 显示擅长领域枚举
  RoleShowTypeEnum get fieldShowType => _fieldShowType.value;
  set fieldShowType(RoleShowTypeEnum val) => _fieldShowType.value = val;

  /// 是否需要身份证
  bool get isNeedIdCard =>
      qualification == RoleQualificationEnum.Both ||
      qualification == RoleQualificationEnum.ID;

  /// 是否需要医师资格证
  bool get isNeedDocCard =>
      qualification == RoleQualificationEnum.Both ||
      qualification == RoleQualificationEnum.DocLicense;
}
