/*
 * @Author: XianKaiQun
 * @Date: 2020-04-01 09:02:50
 * @LastEditors: wuwei 
 * @LastEditTime: 2025-03-13 17:44:11
 * @Descripttion: 域名秘钥等常量
 */

import 'dart:io';
import 'package:package_info_plus/package_info_plus.dart';
// import 'package:wisdom_cli/wisdom_cli.dart';
import 'env.dart' as env;
export 'package:package_info_plus/package_info_plus.dart';

class _Config {
  _Config({
    required this.baseURL,
    // required this.amapIosKey,
    // required this.amapAndKey,
    // required this.bmapIosKey,
    // required this.bmapAndKey,
    // required this.jpushIosKey,
    // required this.jpushAndKey,
  });
  final String baseURL;

  ///IOS高德 (2024.07.05已去除)
  // final String amapIosKey;

  ///android高德（Android还需要在/android/app/build.gradle配置）(2024.07.05已去除)
  // final String amapAndKey;

  ///IOS百度地图
  // final String bmapIosKey;

  ///android百度地图（Android还需要在/android/app/build.gradle配置）
  // final String bmapAndKey;

  ///Ios极光推送
  // final String jpushIosKey;

  ///android极光推送（Android还需要在/android/app/build.gradle配置）
  // final String jpushAndKey;
}

final _test = _Config(
  baseURL: 'https://wy-test.huiguanjia.cn/9ad134a361f8d778/',
  // amapIosKey: '96447224d7ce6a099f9b100c14b8584a',
  // amapAndKey: '27b7d28dab0c4857b9177c7a59cf33f2',
  // bmapIosKey: 'Oa8GWARg5hX1NymZFkoEyNjYjRESYA9A',
  // bmapAndKey: 'D5sf2hXHa4qczmP4KHNkejUdsH2lh7Am',
  // jpushIosKey: '163cf8502893e809bad8f796',
  // jpushAndKey: '41b513e2ee2ef56590a0115a',
);
final _prod = _Config(
  baseURL: 'https://m.huiguanjia.cn/9ad134a361f8d778/',
  // amapIosKey: '96447224d7ce6a099f9b100c14b8584a',
  // amapAndKey: '27b7d28dab0c4857b9177c7a59cf33f2',
  // bmapIosKey: 'Oa8GWARg5hX1NymZFkoEyNjYjRESYA9A',
  // bmapAndKey: 'lrkZs4kiUEVXNfC6F9vojHXVOwkVUapd',
  // jpushIosKey: '163cf8502893e809bad8f796',
  // jpushAndKey: '163cf8502893e809bad8f796',
);

///APP环境、各种配置信息
class APPConfig {
  APPConfig._();

  ///是不是Release环境
  static bool get isRelease => const bool.fromEnvironment('dart.vm.product');

  static _Config get _config => env.isProdEnv! ? _prod : _test;

  ///是不是生产环境
  static bool? get isProdEnv => env.isProdEnv;

  ///是不是测试环境
  static bool get isTestEnv => !isProdEnv!;

  ///是不是安卓
  static bool get isAndroid => Platform.isAndroid;

  ///是不是IOS
  static bool get isIOS => Platform.isIOS;

  /// URL
  static String get baseURL => _config.baseURL;

  ///高德KEY(已自动区分ios andorid dev prod)(2024.07.05已去除)
  // static String get amapKey =>
  //     isAndroid ? _config.amapAndKey : _config.amapIosKey;

  ///百度地图KEY(已自动区分ios andorid dev prod)(2024.07.05已去除)
  // static String get bmapKey =>
  //     isAndroid ? _config.bmapAndKey : _config.bmapIosKey;

  ///极光推送(已自动区分 ios andorid dev prod)
  // static String get jpushKey =>
  //     isAndroid ? _config.jpushAndKey : _config.jpushIosKey;
}

class AppDeviceInfo {
  AppDeviceInfo._();
  // static Future getDeviceId() async {
  //    bool _isReadPrivacy = WisStorageUtil.get(key: 'isReadPrivacy') ?? false;
  //   // 添加隐私合规检查
  //   if (!_isReadPrivacy) {
  //     return;
  //   }
    
  //   Map map = Map();
  //   if (Platform.isAndroid) {
  //     var re = await DeviceInfoPlugin().androidInfo;
  //     map.addAll({'id': re.id, 'model': re.model});
  //   } else {
  //     var re = await DeviceInfoPlugin().iosInfo;
  //     map.addAll({'id': re.identifierForVendor, 'model': re.name});
  //   }
  //   return map;
  // }

  // static Future getAndroidInfo() async {
  //   return DeviceInfoPlugin().androidInfo;
  // }

  // static Future getIosInfo() async {
  //   return DeviceInfoPlugin().iosInfo;
  // }
}

class AppPackageInfo {
  static late AppPackageInfo _instance;

  AppPackageInfo._(); // 私有构造函数
  static AppPackageInfo get instance {
    _instance = AppPackageInfo._();
    return _instance;
  }
 Future<PackageInfo> getPackageInfo() async {
    final _packageInfo = await PackageInfo.fromPlatform();
    return _packageInfo;
  }
  ///App信息
  Future<String> getPackageInfoVersion() async {
    final _packageInfo = await PackageInfo.fromPlatform();
    return _packageInfo.version;
  }

  ///App信息
  Future<String> getPackageInfoBuildVersion() async {
    final _packageInfo = await PackageInfo.fromPlatform();
    return _packageInfo.buildNumber;
  }
}
