初始化提交
This commit is contained in:
+43
@@ -0,0 +1,43 @@
|
||||
import 'package:get/get.dart';
|
||||
import 'package:kaer_with_panels/app/common/app_config.dart';
|
||||
import 'package:kaer_with_panels/app/utils/kr_country_util.dart';
|
||||
|
||||
import '../../../services/singbox_imp/kr_sing_box_imp.dart';
|
||||
|
||||
class KRCountrySelectorController extends GetxController {
|
||||
// 使用 KRCountry 枚举来加载国家
|
||||
final RxList<KRCountry> kr_countries = <KRCountry>[].obs;
|
||||
// 当前选中的国家
|
||||
final Rx<KRCountry> kr_selectedCountry = KRCountry.cn.obs;
|
||||
|
||||
@override
|
||||
void onInit() {
|
||||
super.onInit();
|
||||
kr_selectedCountry.value = KRCountryUtil.kr_currentCountry.value;
|
||||
kr_loadCountries();
|
||||
}
|
||||
|
||||
// 加载国家数据
|
||||
void kr_loadCountries() {
|
||||
kr_countries.value = KRCountryUtil.kr_getSupportedCountries();
|
||||
|
||||
}
|
||||
|
||||
// 选择国家
|
||||
Future<void> kr_selectCountry(KRCountry country) async {
|
||||
kr_selectedCountry.value = country;
|
||||
// try {
|
||||
// await KRSingBoxImp().kr_updateCountry(country);
|
||||
// // Get.back();
|
||||
// } catch (err) {
|
||||
|
||||
// }
|
||||
}
|
||||
|
||||
@override
|
||||
void onClose() {
|
||||
// TODO: implement onClose
|
||||
super.onClose();
|
||||
KRSingBoxImp().kr_updateCountry(kr_selectedCountry.value);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user