| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869 |
- 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<ApiController>();
- // 自动重连开关
- 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<void> _initPushNotifications() async {
- pushNotifications =
- await AwesomeNotificationsHelper.checkNotificationPermission();
- }
- Future<void> showNotificationConfigPage() async {
- await AwesomeNotificationsHelper.showNotificationConfigPage();
- _initPushNotifications();
- }
- // 处理退出登录
- Future<void> 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<void> handleDeleteAccount() async {
- await LoadingDialog.show(
- context: Get.context!,
- loadingText: Strings.deletingAccount.tr,
- successText: Strings.deleteAccountSuccessful.tr,
- onRequest: () async {
- // 执行你的异步请求
- await apiController.deleteAccount();
- },
- onSuccess: () {
- // 成功后的操作
- Get.back();
- },
- );
- }
- }
|