✨ Cache management
This commit is contained in:
		| @@ -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." | ||||
| } | ||||
|   | ||||
| @@ -729,5 +729,9 @@ | ||||
|   "runtimeLogs": "运行时日志", | ||||
|   "runtimeLogsOpen": "打开日志文件", | ||||
|   "runtimeLogsDescription": "显示运行时的日志记录。", | ||||
|   "signinResetPasswordHint": "请输入用户名/电子邮箱地址以帮助我们找到您的帐户并重置密码。" | ||||
|   "signinResetPasswordHint": "请输入用户名/电子邮箱地址以帮助我们找到您的帐户并重置密码。", | ||||
|   "cacheSize": "缓存资源大小", | ||||
|   "cacheDelete": "清除缓存", | ||||
|   "cacheDeleteDescription": "从磁盘中移除缓存的图片和其他资源,内容将从服务器重新下载。", | ||||
|   "cacheDeleted": "所有缓存已被清除。" | ||||
| } | ||||
|   | ||||
| @@ -729,5 +729,9 @@ | ||||
|   "runtimeLogs": "運行時日誌", | ||||
|   "runtimeLogsOpen": "打開日誌文件", | ||||
|   "runtimeLogsDescription": "顯示運行時的日誌記錄。", | ||||
|   "signinResetPasswordHint": "請輸入用户名/電子郵箱地址以幫助我們找到您的帳户並重置密碼。" | ||||
|   "signinResetPasswordHint": "請輸入用户名/電子郵箱地址以幫助我們找到您的帳户並重置密碼。", | ||||
|   "cacheSize": "緩存資源大小", | ||||
|   "cacheDelete": "清除緩存", | ||||
|   "cacheDeleteDescription": "從磁盤中移除緩存的圖片和其他資源,內容將從服務器重新下載。", | ||||
|   "cacheDeleted": "所有緩存已被清除。" | ||||
| } | ||||
|   | ||||
| @@ -729,5 +729,9 @@ | ||||
|   "runtimeLogs": "運行時日誌", | ||||
|   "runtimeLogsOpen": "打開日誌文件", | ||||
|   "runtimeLogsDescription": "顯示運行時的日誌記錄。", | ||||
|   "signinResetPasswordHint": "請輸入用戶名/電子郵箱地址以幫助我們找到您的帳戶並重置密碼。" | ||||
|   "signinResetPasswordHint": "請輸入用戶名/電子郵箱地址以幫助我們找到您的帳戶並重置密碼。", | ||||
|   "cacheSize": "緩存資源大小", | ||||
|   "cacheDelete": "清除緩存", | ||||
|   "cacheDeleteDescription": "從磁盤中移除緩存的圖片和其他資源,內容將從服務器重新下載。", | ||||
|   "cacheDeleted": "所有緩存已被清除。" | ||||
| } | ||||
|   | ||||
| @@ -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<SettingsScreen> { | ||||
|                     .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), | ||||
|   | ||||
| @@ -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" | ||||
|   | ||||
| @@ -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: | ||||
|   | ||||
		Reference in New Issue
	
	Block a user