setting_page.dart
3.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
import 'package:flustars/flustars.dart';
import 'package:flutter/material.dart';
import 'package:Parlando/res/constant.dart';
import 'package:Parlando/res/resources.dart';
import 'package:Parlando/routers/fluro_navigator.dart';
import 'package:Parlando/setting/widgets/exit_dialog.dart';
import 'package:Parlando/setting/widgets/update_dialog.dart';
import 'package:Parlando/util/device_utils.dart';
import 'package:Parlando/widgets/click_item.dart';
import 'package:Parlando/widgets/my_app_bar.dart';
import '../setting_router.dart';
class SettingPage extends StatefulWidget {
const SettingPage({Key? key}) : super(key: key);
@override
_SettingPageState createState() => _SettingPageState();
}
class _SettingPageState extends State<SettingPage> {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: MyAppBar(
homeMenuHeader: Container(
alignment: Alignment.center,
width: double.infinity,
child: const Text(
"设置",
style: TextStyle(
color: Colors.white,
),
),
),
),
body: Column(
children: <Widget>[
Gaps.vGap5,
ClickItem(
title: '账号管理',
onTap: () =>
NavigatorUtils.push(context, SettingRouter.accountManagerPage),
),
if (Device.isMobile)
ClickItem(
title: '清除缓存',
content: '23.5MB',
onTap: () {},
),
ClickItem(
title: '夜间模式',
content: _getCurrentTheme(),
onTap: () => NavigatorUtils.push(context, SettingRouter.themePage),
),
ClickItem(
title: '多语言',
content: _getCurrentLocale(),
onTap: () => NavigatorUtils.push(context, SettingRouter.localePage),
),
if (Device.isMobile)
ClickItem(
title: '检查更新',
onTap: _showUpdateDialog,
),
ClickItem(
title: '关于我们',
onTap: () => NavigatorUtils.push(context, SettingRouter.aboutPage),
),
ClickItem(
title: '退出当前账号',
onTap: _showExitDialog,
),
],
),
);
}
String _getCurrentTheme() {
final String? theme = SpUtil.getString(Constant.theme);
String themeMode;
switch (theme) {
case 'Dark':
themeMode = '开启';
break;
case 'Light':
themeMode = '关闭';
break;
default:
themeMode = '跟随系统';
break;
}
return themeMode;
}
String _getCurrentLocale() {
final String? locale = SpUtil.getString(Constant.locale);
String localeMode;
switch (locale) {
case 'zh':
localeMode = '中文';
break;
case 'en':
localeMode = 'English';
break;
default:
localeMode = '跟随系统';
break;
}
return localeMode;
}
void _showExitDialog() {
showDialog<void>(context: context, builder: (_) => const ExitDialog());
}
void _showUpdateDialog() {
showDialog<void>(
context: context,
barrierDismissible: false,
builder: (_) => const UpdateDialog());
}
}