import 'package:get/get.dart'; import '../../../../config/translations/strings_enum.dart'; import '../../../../utils/awesome_notifications_helper.dart'; import '../../../controllers/api_controller.dart'; import '../../../dialog/loading/loading_dialog.dart'; class SettingController extends GetxController { final apiController = Get.find(); // 自动重连开关 final _autoReconnect = true.obs; bool get autoReconnect => _autoReconnect.value; set autoReconnect(bool value) => _autoReconnect.value = value; final _pushNotifications = false.obs; bool get pushNotifications => _pushNotifications.value; set pushNotifications(bool value) => _pushNotifications.value = value; @override void onInit() { super.onInit(); _initPushNotifications(); } Future _initPushNotifications() async { pushNotifications = await AwesomeNotificationsHelper.checkNotificationPermission(); } Future showNotificationConfigPage() async { await AwesomeNotificationsHelper.showNotificationConfigPage(); _initPushNotifications(); } // 处理退出登录 Future handleLogout() async { await LoadingDialog.show( context: Get.context!, loadingText: Strings.loggingOut.tr, successText: Strings.logoutSuccessful.tr, onRequest: () async { // 执行你的异步请求 await apiController.logout(); }, onSuccess: () { // 成功后的操作 Get.back(); }, ); } // 处理删除账户 Future handleDeleteAccount() async { await LoadingDialog.show( context: Get.context!, loadingText: Strings.deletingAccount.tr, successText: Strings.deleteAccountSuccessful.tr, onRequest: () async { // 执行你的异步请求 await apiController.deleteAccount(); }, onSuccess: () { // 成功后的操作 Get.back(); }, ); } }