diff --git a/assets/translations/en-US.json b/assets/translations/en-US.json index 44db9b4..4718f8a 100644 --- a/assets/translations/en-US.json +++ b/assets/translations/en-US.json @@ -731,5 +731,9 @@ "debugLogging": "Runtime Logs", "runtimeLogsOpen": "Open Logs", "runtimeLogsDescription": "Show the runtime logs to help debugging.", - "signinResetPasswordHint": "Please enter the username / email address to help us to find your account and reset your password." + "signinResetPasswordHint": "Please enter the username / email address to help us to find your account and reset your password.", + "cacheSize": "Cache Size", + "cacheDelete": "Clean Cache", + "cacheDeleteDescription": "Remove the cached images and other resources from your disk, the content will be downloaded from server again.", + "cacheDeleted": "All cache has been cleaned up." } diff --git a/assets/translations/zh-CN.json b/assets/translations/zh-CN.json index 51130e0..ff9e43f 100644 --- a/assets/translations/zh-CN.json +++ b/assets/translations/zh-CN.json @@ -729,5 +729,9 @@ "runtimeLogs": "运行时日志", "runtimeLogsOpen": "打开日志文件", "runtimeLogsDescription": "显示运行时的日志记录。", - "signinResetPasswordHint": "请输入用户名/电子邮箱地址以帮助我们找到您的帐户并重置密码。" + "signinResetPasswordHint": "请输入用户名/电子邮箱地址以帮助我们找到您的帐户并重置密码。", + "cacheSize": "缓存资源大小", + "cacheDelete": "清除缓存", + "cacheDeleteDescription": "从磁盘中移除缓存的图片和其他资源,内容将从服务器重新下载。", + "cacheDeleted": "所有缓存已被清除。" } diff --git a/assets/translations/zh-HK.json b/assets/translations/zh-HK.json index 87f646b..f29b7b6 100644 --- a/assets/translations/zh-HK.json +++ b/assets/translations/zh-HK.json @@ -729,5 +729,9 @@ "runtimeLogs": "運行時日誌", "runtimeLogsOpen": "打開日誌文件", "runtimeLogsDescription": "顯示運行時的日誌記錄。", - "signinResetPasswordHint": "請輸入用户名/電子郵箱地址以幫助我們找到您的帳户並重置密碼。" + "signinResetPasswordHint": "請輸入用户名/電子郵箱地址以幫助我們找到您的帳户並重置密碼。", + "cacheSize": "緩存資源大小", + "cacheDelete": "清除緩存", + "cacheDeleteDescription": "從磁盤中移除緩存的圖片和其他資源,內容將從服務器重新下載。", + "cacheDeleted": "所有緩存已被清除。" } diff --git a/assets/translations/zh-TW.json b/assets/translations/zh-TW.json index 7ea5150..6dda408 100644 --- a/assets/translations/zh-TW.json +++ b/assets/translations/zh-TW.json @@ -729,5 +729,9 @@ "runtimeLogs": "運行時日誌", "runtimeLogsOpen": "打開日誌文件", "runtimeLogsDescription": "顯示運行時的日誌記錄。", - "signinResetPasswordHint": "請輸入用戶名/電子郵箱地址以幫助我們找到您的帳戶並重置密碼。" + "signinResetPasswordHint": "請輸入用戶名/電子郵箱地址以幫助我們找到您的帳戶並重置密碼。", + "cacheSize": "緩存資源大小", + "cacheDelete": "清除緩存", + "cacheDeleteDescription": "從磁盤中移除緩存的圖片和其他資源,內容將從服務器重新下載。", + "cacheDeleted": "所有緩存已被清除。" } diff --git a/lib/screens/settings.dart b/lib/screens/settings.dart index 22add6d..1468de7 100644 --- a/lib/screens/settings.dart +++ b/lib/screens/settings.dart @@ -6,6 +6,7 @@ import 'package:easy_localization/easy_localization.dart'; import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; +import 'package:flutter_cache_manager/flutter_cache_manager.dart'; import 'package:flutter_colorpicker/flutter_colorpicker.dart'; import 'package:go_router/go_router.dart'; import 'package:google_fonts/google_fonts.dart'; @@ -580,6 +581,37 @@ class _SettingsScreenState extends State { .fontSize(17) .tr() .padding(horizontal: 20, bottom: 4), + ListTile( + leading: const Icon(Symbols.home_storage), + contentPadding: const EdgeInsets.symmetric(horizontal: 24), + title: Text('cacheSize').tr(), + subtitle: FutureBuilder( + future: DefaultCacheManager().store.getCacheSize(), + builder: (context, snapshot) { + if (!snapshot.hasData || kIsWeb) { + return Text('unknown').tr(); + } + return Text( + snapshot.data!.formatBytes(), + style: GoogleFonts.robotoMono(), + ); + }, + ), + ), + ListTile( + leading: const Icon(Symbols.cleaning_services), + contentPadding: const EdgeInsets.symmetric(horizontal: 24), + title: Text('cacheDelete').tr(), + subtitle: Text('cacheDeleteDescription').tr(), + trailing: const Icon(Symbols.chevron_right), + onTap: () async { + await DefaultCacheManager().emptyCache(); + if (!context.mounted) return; + HapticFeedback.heavyImpact(); + context.showSnackbar('cacheDeleted'.tr()); + setState(() {}); + }, + ), ListTile( leading: const Icon(Symbols.database), contentPadding: const EdgeInsets.symmetric(horizontal: 24), diff --git a/pubspec.lock b/pubspec.lock index 0eee680..4a68546 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -679,7 +679,7 @@ packages: source: hosted version: "3.2.2" flutter_cache_manager: - dependency: transitive + dependency: "direct main" description: name: flutter_cache_manager sha256: "400b6592f16a4409a7f2bb929a9a7e38c72cceb8ffb99ee57bbf2cb2cecf8386" diff --git a/pubspec.yaml b/pubspec.yaml index c5dc197..02081b3 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -133,6 +133,7 @@ dependencies: talker_flutter: ^4.6.14 talker_dio_logger: ^4.6.14 talker: ^4.6.14 + flutter_cache_manager: ^3.4.1 dev_dependencies: flutter_test: