mod: show text scale subtitle

This commit is contained in:
bggRGjQaUbCoE
2024-09-01 10:12:15 +08:00
parent 2aa372da04
commit 098f5764d4
5 changed files with 30 additions and 18 deletions

View File

@@ -23,7 +23,6 @@ class AboutPage extends StatefulWidget {
class _AboutPageState extends State<AboutPage> { class _AboutPageState extends State<AboutPage> {
final AboutController _aboutController = Get.put(AboutController()); final AboutController _aboutController = Get.put(AboutController());
String cacheSize = '';
@override @override
void initState() { void initState() {
@@ -34,9 +33,7 @@ class _AboutPageState extends State<AboutPage> {
Future<void> getCacheSize() async { Future<void> getCacheSize() async {
final res = await CacheManage().loadApplicationCache(); final res = await CacheManage().loadApplicationCache();
cacheSize = res; _aboutController.cacheSize.value = res;
if (!mounted) return;
setState(() => {});
} }
@override @override
@@ -170,7 +167,12 @@ class _AboutPageState extends State<AboutPage> {
}, },
leading: const Icon(Icons.delete_outline), leading: const Icon(Icons.delete_outline),
title: const Text('清除缓存'), title: const Text('清除缓存'),
subtitle: Text('图片及网络缓存 $cacheSize', style: subTitleStyle), subtitle: Obx(
() => Text(
'图片及网络缓存 ${_aboutController.cacheSize.value}',
style: subTitleStyle,
),
),
), ),
ListTile( ListTile(
title: const Text('导入/导出设置'), title: const Text('导入/导出设置'),
@@ -303,6 +305,7 @@ class AboutController extends GetxController {
RxBool isLoading = true.obs; RxBool isLoading = true.obs;
LatestDataModel? data; LatestDataModel? data;
RxInt count = 0.obs; RxInt count = 0.obs;
RxString cacheSize = ''.obs;
@override @override
void onInit() { void onInit() {

View File

@@ -149,6 +149,7 @@ class ColorSelectController extends GetxController {
RxInt type = 0.obs; RxInt type = 0.obs;
late final List<Map<String, dynamic>> colorThemes; late final List<Map<String, dynamic>> colorThemes;
RxInt currentColor = 0.obs; RxInt currentColor = 0.obs;
RxDouble currentTextScale = 1.0.obs;
@override @override
void onInit() { void onInit() {
@@ -159,6 +160,8 @@ class ColorSelectController extends GetxController {
type.value = dynamicColor.value ? 0 : 1; type.value = dynamicColor.value ? 0 : 1;
currentColor.value = currentColor.value =
setting.get(SettingBoxKey.customColor, defaultValue: 0); setting.get(SettingBoxKey.customColor, defaultValue: 0);
currentTextScale.value =
setting.get(SettingBoxKey.defaultTextScale, defaultValue: 1.0);
super.onInit(); super.onInit();
} }
} }

View File

@@ -30,7 +30,7 @@ class _FontSizeSelectPageState extends State<FontSizeSelectPage> {
setFontSize() { setFontSize() {
setting.put(SettingBoxKey.defaultTextScale, currentSize); setting.put(SettingBoxKey.defaultTextScale, currentSize);
Get.forceAppUpdate(); Get.forceAppUpdate();
Get.back(); Get.back(result: currentSize);
} }
@override @override
@@ -67,7 +67,7 @@ class _FontSizeSelectPageState extends State<FontSizeSelectPage> {
.colorScheme .colorScheme
.primary .primary
.withOpacity(0.3))), .withOpacity(0.3))),
color: Theme.of(context).colorScheme.background, color: Theme.of(context).colorScheme.surface,
), ),
child: Row( child: Row(
children: [ children: [

View File

@@ -359,9 +359,20 @@ class _StyleSettingState extends State<StyleSetting> {
), ),
ListTile( ListTile(
dense: false, dense: false,
onTap: () => Get.toNamed('/fontSizeSetting'), onTap: () async {
dynamic result = await Get.toNamed('/fontSizeSetting');
if (result != null) {
colorSelectController.currentTextScale.value = result;
}
},
title: Text('字体大小', style: titleStyle), title: Text('字体大小', style: titleStyle),
leading: const Icon(Icons.format_size_outlined), leading: const Icon(Icons.format_size_outlined),
subtitle: Obx(() => Text(
colorSelectController.currentTextScale.value == 1.0
? '默认'
: colorSelectController.currentTextScale.value.toString(),
style: subTitleStyle,
)),
), ),
ListTile( ListTile(
dense: false, dense: false,

View File

@@ -77,8 +77,8 @@ class CacheManage {
} }
// 清除缓存 // 清除缓存
Future<bool> clearCacheAll(BuildContext context) async { Future<void> clearCacheAll(BuildContext context) async {
bool cleanStatus = await showDialog( await showDialog(
context: context, context: context,
builder: (context) { builder: (context) {
return AlertDialog( return AlertDialog(
@@ -99,10 +99,8 @@ class CacheManage {
try { try {
// 清除缓存 图片缓存 // 清除缓存 图片缓存
await clearLibraryCache(); await clearLibraryCache();
Timer(const Duration(milliseconds: 500), () { SmartDialog.dismiss().then((res) {
SmartDialog.dismiss().then((res) { SmartDialog.showToast('清除成功');
SmartDialog.showToast('清除成功');
});
}); });
} catch (err) { } catch (err) {
SmartDialog.dismiss(); SmartDialog.dismiss();
@@ -114,10 +112,7 @@ class CacheManage {
], ],
); );
}, },
).then((res) { );
return true;
});
return cleanStatus;
} }
/// 清除 Documents 目录下的 DioCache.db /// 清除 Documents 目录下的 DioCache.db