import 'package:get/get.dart';
import 'package:easy_refresh/easy_refresh.dart';
import 'package:kaer_with_panels/app/utils/kr_log_util.dart';
import '../../../services/api_service/kr_api.user.dart';
import '../../../utils/kr_common_util.dart';
import '../../../common/app_run_data.dart';
import 'package:package_info_plus/package_info_plus.dart';
import 'package:kaer_with_panels/app/services/kr_subscribe_service.dart';

class HIMenuController extends GetxController {
  /// 订阅服务
  final KRSubscribeService kr_subscribeService = KRSubscribeService();
  // 版本号
  final RxString kr_version = ''.obs;
  final RxString kr_buildNumber = ''.obs;
  final RxBool kr_showBuild = false.obs;

  @override
  void onInit() {
    super.onInit();
    // 预加载客服系统
    KRCommonUtil.kr_warmUpCustomerService();
    _kr_getVersion();
  }

  // 获取版本号
  Future<void> _kr_getVersion() async {
    final PackageInfo packageInfo = await PackageInfo.fromPlatform();
    kr_version.value = packageInfo.version;
    kr_buildNumber.value = packageInfo.buildNumber;
  }

  void toggleVersionDisplay() {
    kr_showBuild.value = !kr_showBuild.value;
  }
}
