From 2f290f0c86e513d159f078d9946bdc1d2a2d2327 Mon Sep 17 00:00:00 2001 From: Pacalini <141402887+Pacalini@users.noreply.github.com> Date: Fri, 22 Nov 2024 16:47:50 +0800 Subject: [PATCH] universal: style improvements (#67) --- assets/translation.json | 36 +++++++------ lib/components/menu.dart | 9 +++- lib/components/message.dart | 4 ++ lib/pages/comic_source_page.dart | 5 +- lib/pages/favorites/local_favorites_page.dart | 50 +++++++++++-------- .../favorites/network_favorites_page.dart | 6 +-- lib/pages/history_page.dart | 1 + 7 files changed, 69 insertions(+), 42 deletions(-) diff --git a/assets/translation.json b/assets/translation.json index d8226a3..4e1e046 100644 --- a/assets/translation.json +++ b/assets/translation.json @@ -41,9 +41,14 @@ "Select a folder": "选择一个文件夹", "Folder": "文件夹", "Confirm": "确认", - "Are you sure you want to delete this comic?": "您确定要删除这部漫画吗?", - "Are you sure you want to delete @a selected comics?": "您确定要删除 @a 部漫画吗?", + "Remove comic from favorite?": "从收藏中移除漫画?", + "Move": "移动", + "Move to folder": "移动到文件夹", + "Copy to folder": "复制到文件夹", + "Delete Comic": "删除漫画", + "Delete @c comics?": "删除 @c 本漫画?", "Add comic source": "添加漫画源", + "Delete comic source '@n' ?": "删除漫画源 '@n' ?", "Select file": "选择文件", "View list": "查看列表", "Open help": "打开帮助", @@ -132,7 +137,8 @@ "Block": "屏蔽", "Add new favorite to": "添加新收藏到", "Move favorite after reading": "阅读后移动收藏", - "Are you sure you want to delete this folder?" : "确定要删除这个收藏夹吗?", + "Delete folder?" : "刪除文件夾?", + "Delete folder '@f' ?" : "删除文件夹 '@f' ?", "Import from file": "从文件导入", "Failed to import": "导入失败", "Cache Limit": "缓存限制", @@ -215,7 +221,7 @@ "Authorization Required": "需要身份验证", "Sync": "同步", "The folder is Linked to @source": "文件夹已关联到 @source", - "Source Folder": "源收藏夹", + "Source Folder": "源文件夹", "Use a config file": "使用配置文件", "Comic Source list": "漫画源列表", "View": "查看", @@ -235,9 +241,7 @@ "Also remove files on disk": "同时删除磁盘上的文件", "New version available": "有新版本可用", "A new version is available. Do you want to update now?" : "有新版本可用。您要现在更新吗?", - "No new version available": "没有新版本可用", - "Move": "移动", - "Move to favorites": "移动至收藏" + "No new version available": "没有新版本可用" }, "zh_TW": { "Home": "首頁", @@ -283,9 +287,14 @@ "Select a folder": "選擇一個文件夾", "Folder": "文件夾", "Confirm": "確認", - "Are you sure you want to delete this comic?": "您確定要刪除這部漫畫嗎?", - "Are you sure you want to delete @a selected comics?": "您確定要刪除 @a 部漫畫嗎?", + "Remove comic from favorite?": "從收藏中移除漫畫?", + "Move": "移動", + "Move to folder": "移動到文件夾", + "Copy to folder": "複製到文件夾", + "Delete Comic": "刪除漫畫", + "Delete @c comics?": "刪除 @c 本漫畫?", "Add comic source": "添加漫畫源", + "Delete comic source '@n' ?": "刪除漫畫源 '@n' ?", "Select file": "選擇文件", "View list": "查看列表", "Open help": "打開幫助", @@ -372,7 +381,8 @@ "Block": "屏蔽", "Add new favorite to": "添加新收藏到", "Move favorite after reading": "閱讀後移動收藏", - "Are you sure you want to delete this folder?" : "確定要刪除這個收藏夾嗎?", + "Delete folder?" : "刪除文件夾?", + "Delete folder '@f' ?" : "刪除文件夾 '@f' ?", "Import from file": "從文件匯入", "Failed to import": "匯入失敗", "Cache Limit": "緩存限制", @@ -455,7 +465,7 @@ "Authorization Required": "需要身份驗證", "Sync": "同步", "The folder is Linked to @source": "文件夾已關聯到 @source", - "Source Folder": "源收藏夾", + "Source Folder": "源文件夾", "Use a config file": "使用配置文件", "Comic Source list": "漫畫源列表", "View": "查看", @@ -475,8 +485,6 @@ "Also remove files on disk": "同時刪除磁盤上的文件", "New version available": "有新版本可用", "A new version is available. Do you want to update now?" : "有新版本可用。您要現在更新嗎?", - "No new version available": "沒有新版本可用", - "Move": "移動", - "Move to favorites": "移動至收藏" + "No new version available": "沒有新版本可用" } } \ No newline at end of file diff --git a/lib/components/menu.dart b/lib/components/menu.dart index 027c116..1e13448 100644 --- a/lib/components/menu.dart +++ b/lib/components/menu.dart @@ -92,9 +92,13 @@ class _MenuRoute extends PopupRoute { Icon( entry.icon, size: 18, + color: entry.color ), const SizedBox(width: 12), - Text(entry.text), + Text( + entry.text, + style: TextStyle(color: entry.color) + ), ], ), ), @@ -119,7 +123,8 @@ class _MenuRoute extends PopupRoute { class MenuEntry { final String text; final IconData? icon; + final Color? color; final void Function() onClick; - MenuEntry({required this.text, this.icon, required this.onClick}); + MenuEntry({required this.text, this.icon, this.color, required this.onClick}); } diff --git a/lib/components/message.dart b/lib/components/message.dart index d1fb8aa..0024956 100644 --- a/lib/components/message.dart +++ b/lib/components/message.dart @@ -135,6 +135,7 @@ Future showConfirmDialog({ required String content, required void Function() onConfirm, String confirmText = "Confirm", + Color? btnColor, }) { return showDialog( context: context, @@ -147,6 +148,9 @@ Future showConfirmDialog({ context.pop(); onConfirm(); }, + style: FilledButton.styleFrom( + backgroundColor: btnColor, + ), child: Text(confirmText.tl), ), ], diff --git a/lib/pages/comic_source_page.dart b/lib/pages/comic_source_page.dart index 2ae6a71..efd1b6c 100644 --- a/lib/pages/comic_source_page.dart +++ b/lib/pages/comic_source_page.dart @@ -231,7 +231,10 @@ class _BodyState extends State<_Body> { showConfirmDialog( context: App.rootContext, title: "Delete".tl, - content: "Are you sure you want to delete it?".tl, + content: "Delete comic source '@n' ?".tlParams({ + "n": source.name, + }), + btnColor: context.colorScheme.error, onConfirm: () { var file = File(source.filePath); file.delete(); diff --git a/lib/pages/favorites/local_favorites_page.dart b/lib/pages/favorites/local_favorites_page.dart index 1ca103b..1a9d784 100644 --- a/lib/pages/favorites/local_favorites_page.dart +++ b/lib/pages/favorites/local_favorites_page.dart @@ -149,22 +149,6 @@ class _LocalFavoritesPageState extends State<_LocalFavoritesPage> { ), MenuButton( entries: [ - MenuEntry( - icon: Icons.delete_outline, - text: "Delete Folder".tl, - onClick: () { - showConfirmDialog( - context: App.rootContext, - title: "Delete".tl, - content: - "Are you sure you want to delete this folder?".tl, - onConfirm: () { - favPage.setFolder(false, null); - LocalFavoritesManager().deleteFolder(widget.folder); - favPage.folderList?.updateFolders(); - }, - ); - }), MenuEntry( icon: Icons.edit_outlined, text: "Rename".tl, @@ -233,6 +217,26 @@ class _LocalFavoritesPageState extends State<_LocalFavoritesPage> { } }); }), + MenuEntry( + icon: Icons.delete_outline, + text: "Delete Folder".tl, + color: context.colorScheme.error, + onClick: () { + showConfirmDialog( + context: App.rootContext, + title: "Delete".tl, + content: + "Delete folder '@f' ?".tlParams({ + "f": widget.folder, + }), + btnColor: context.colorScheme.error, + onConfirm: () { + favPage.setFolder(false, null); + LocalFavoritesManager().deleteFolder(widget.folder); + favPage.folderList?.updateFolders(); + }, + ); + }), ], ), ], @@ -256,12 +260,12 @@ class _LocalFavoritesPageState extends State<_LocalFavoritesPage> { actions: [ MenuButton(entries: [ MenuEntry( - icon: Icons.star, - text: "Add to favorites".tl, + icon: Icons.drive_file_move, + text: "Move to folder".tl, onClick: () => favoriteOption('move')), MenuEntry( - icon: Icons.drive_file_move, - text: "Move to favorites".tl, + icon: Icons.copy, + text: "Copy to folder".tl, onClick: () => favoriteOption('add')), MenuEntry( icon: Icons.select_all, @@ -277,13 +281,15 @@ class _LocalFavoritesPageState extends State<_LocalFavoritesPage> { onClick: invertSelection), MenuEntry( icon: Icons.delete_outline, - text: "Delete Folder".tl, + text: "Delete Comic".tl, + color: context.colorScheme.error, onClick: () { showConfirmDialog( context: context, title: "Delete".tl, content: - "Are you sure you want to delete this comic?".tl, + "Delete @c comics?".tlParams({"c": selectedComics.length}), + btnColor: context.colorScheme.error, onConfirm: () { _deleteComicWithId(); }, diff --git a/lib/pages/favorites/network_favorites_page.dart b/lib/pages/favorites/network_favorites_page.dart index b842d55..b11e803 100644 --- a/lib/pages/favorites/network_favorites_page.dart +++ b/lib/pages/favorites/network_favorites_page.dart @@ -19,8 +19,8 @@ Future _deleteComic( bool loading = false; return StatefulBuilder(builder: (context, setState) { return ContentDialog( - title: "Delete".tl, - content: Text("Are you sure you want to delete this comic?".tl) + title: "Remove".tl, + content: Text("Remove comic from favorite?".tl) .paddingHorizontal(16), actions: [ Button.filled( @@ -424,7 +424,7 @@ class _FolderTile extends StatelessWidget { return StatefulBuilder(builder: (context, setState) { return ContentDialog( title: "Delete".tl, - content: Text("Are you sure you want to delete this folder?".tl) + content: Text("Delete folder?".tl) .paddingHorizontal(16), actions: [ Button.filled( diff --git a/lib/pages/history_page.dart b/lib/pages/history_page.dart index f7e07c0..05c9466 100644 --- a/lib/pages/history_page.dart +++ b/lib/pages/history_page.dart @@ -111,6 +111,7 @@ class _HistoryPageState extends State { MenuEntry( icon: Icons.remove, text: 'Remove'.tl, + color: context.colorScheme.error, onClick: () { if (c.sourceKey.startsWith("Invalid")) { HistoryManager().remove(