1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374 |
- import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
- import 'package:get/get.dart';
- import 'package:plugin_platform/engine/directory/directory_util.dart';
- import 'package:shared/utils/util.dart';
- import 'package:widgets/dialog/app_default_dialog.dart';
- import 'setting_state.dart';
- class SettingController extends GetxController {
- final SettingState state = SettingState();
- /// 退出登录的弹窗
- Future<void> showLogoutDialog() async {
- SmartDialog.show(
- usePenetrate: false,
- keepSingle :true,
- builder: (context) =>
- AppDefaultDialog(
- "你确定你要退出登录吗?".tr,
- confirmAction: () {
- // 调用接口退出登录
- _userLogout();
- },
- ),
- );
- }
- /// 调用接口退出登录
- void _userLogout() async {
- // SmartDialog.showLoading();
- // HttpResult result = await mainRepository.userLogout();
- // SmartDialog.dismiss(status: SmartStatus.loading);
- //
- // //处理数据
- // if (result.isSuccess) {
- // Log.d("退出登录 => 成功");
- // UserService.to.handleLogoutParams();
- // Get.offAllNamed(RouterPath.AUTH_LOGIN); //关闭全部页面进入登录页面,不能改
- // } else {
- // Log.d("退出登录 => 失败:${result.errorMsg}");
- // }
- }
- @override
- void onReady() {
- super.onReady();
- calculateCacheSize();
- }
- //计算当前 App 的 Cache 缓存
- void calculateCacheSize() async {
- final size = await DirectoryUtil.getAppCacheSize();
- state.appSize = DirectoryUtil.formatBytes(size);
- update();
- }
- //清除缓存
- void clearCache() async {
- SmartDialog.show(
- usePenetrate: false,
- builder: (context) => AppDefaultDialog(
- "你确定你要清除应用缓存吗?".tr,
- confirmAction: () async {
- await DirectoryUtil.clearAppCache();
- state.appSize = '0 B';
- update();
- },
- ),
- );
- }
- }
|