| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748 |
- import 'package:bot_toast/bot_toast.dart';
- import 'package:flutter/cupertino.dart';
- import 'package:flutter/material.dart';
- import 'package:provider/provider.dart';
- import 'package:twong/providers/setting.dart';
- import 'package:twong/router/index.dart';
- import 'package:twong/utils/index.dart';
- class SettingInfo {
- String name;
- IconData icon;
- Function onTap;
- String route;
- Widget subText;
- SettingInfo(this.name, this.icon, this.subText, {this.onTap, this.route});
- }
- class SettingConfig {
- static List<SettingInfo> get data {
- return [
- SettingInfo("账号信息", Icons.account_circle, null, route: RouteNames.account),
- SettingInfo("隐私设置", Icons.policy, null, route: RouteNames.private),
- SettingInfo("检查更新", Icons.update, Consumer<SettingModel>(
- builder: (context, model, child) => Text(model.version, style: TextStyle(color: Colors.grey))
- ), onTap: checkUpdate),
- SettingInfo("清除缓存", Icons.delete, Consumer<SettingModel>(
- builder: (context, model, child) => Text(model.cacheSize, style: TextStyle(color: Colors.grey))
- ), onTap: clearCache),
- SettingInfo("关于我们", Icons.info, null, route: RouteNames.about),
- ];
- }
- static void checkUpdate() {
- Utils.loading();
- Utils.checkUpdate();
- }
- static void clearCache() {
- Cache.clearFiles().then((value){
- Provider.of<SettingModel>(Cache.context, listen: false).updateCache(value);
- BotToast.showText(text: "清理成功");
- }).catchError((err) {
- Log.e(err);
- BotToast.showText(text: "清理失败");
- });
- }
- }
|