Skip to content

Commit

Permalink
✨ View mode has added filtering function
Browse files Browse the repository at this point in the history
  • Loading branch information
ilgnefz committed Oct 17, 2024
1 parent 54d5a65 commit 90f24ec
Show file tree
Hide file tree
Showing 14 changed files with 93 additions and 43 deletions.
1 change: 0 additions & 1 deletion lib/config/global.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import 'package:flutter/material.dart';
import 'package:once_power/constants/keys.dart';
import 'package:once_power/constants/num.dart';
import 'package:once_power/constants/text.dart';
import 'package:once_power/utils/regedit.dart';
import 'package:once_power/utils/utils.dart';
import 'package:shortcut_menu_extender/shortcut_menu_extender.dart';
import 'package:window_manager/window_manager.dart';
Expand Down
10 changes: 10 additions & 0 deletions lib/core/file.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import 'dart:io';
import 'package:charset/charset.dart';
import 'package:exif/exif.dart';
import 'package:file_selector/file_selector.dart';
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:nanoid/nanoid.dart';
import 'package:once_power/constants/constants.dart';
Expand All @@ -19,6 +20,7 @@ import 'package:once_power/provider/select.dart';
import 'package:once_power/provider/toggle.dart';
import 'package:once_power/utils/utils.dart';
import 'package:once_power/widgets/common/notification.dart';
import 'package:once_power/widgets/content_bar/type_detail_panel.dart';
import 'package:path/path.dart' as path;
import 'package:pinyin/pinyin.dart';

Expand Down Expand Up @@ -162,6 +164,14 @@ void toggleSortType(WidgetRef ref) {
updateExtension(ref);
}

void showAllType(BuildContext context, [bool needPop = false]) async {
if (needPop) Navigator.of(context).pop();
await showDialog(
context: context,
builder: (BuildContext context) => const TypeDetailPanel(),
);
}

void deleteAll(WidgetRef ref) {
ref.read(fileListProvider.notifier).clear();
ref.read(countProvider.notifier).clear();
Expand Down
22 changes: 13 additions & 9 deletions lib/generated/intl/messages_en.dart
Original file line number Diff line number Diff line change
Expand Up @@ -29,21 +29,24 @@ class MessageLookup extends MessageLookupByLibrary {
static String m3(count, total) =>
"${count} out of ${total} selected renames failed";

static String m4(total, count) => "${total} files ${count} selected";
static String m4(count, total) => "Selected ${count}/${total}";

static String m5(version) => "New version ${version} can be updated";

static String m6(name) => "No longer exists in ${name}";

static String m7(count) => "Removed ${count} non-image files";
static String m7(count, uncheck) =>
"The selected ${count} files have been successfully moved, and ${uncheck} unselected files have not been moved. You can go to another menu to select and continue the operation";

static String m8(total) =>
static String m8(count) => "Removed ${count} non-image files";

static String m9(total) =>
"All ${total} selected items have been successfully renamed";

static String m9(count, total) =>
static String m10(count, total) =>
"${count} out of ${total} selected undo renames failed";

static String m10(total) =>
static String m11(total) =>
"All ${total} selected items have been successfully undone";

final messages = _notInlinedMessages(_notInlinedMessages);
Expand Down Expand Up @@ -157,6 +160,7 @@ class MessageLookup extends MessageLookupByLibrary {
MessageLookupByLibrary.simpleMessage("Organized successfully"),
"organizedSuccessfullyInfo": MessageLookupByLibrary.simpleMessage(
"Successfully moved all files"),
"organizedSuccessfullyInfo2": m7,
"organizingFailed":
MessageLookupByLibrary.simpleMessage("Organizing failed"),
"organizingFailedInfo":
Expand All @@ -168,7 +172,7 @@ class MessageLookup extends MessageLookupByLibrary {
MessageLookupByLibrary.simpleMessage("Add prefix content"),
"regeditTip": MessageLookupByLibrary.simpleMessage(
"Open right-click shortcut menu (When the software is not running, the Windows system only allows one file path to be passed in at a time, so when the software is not running, only one folder path is allowed to be passed in. You can place all files in one folder. If multiple files are passed in at once, please place the shortcut of the software in the \"Send To\" folder (open File Explorer, enter \"shell: sendto\" in the address bar and press enter), and use \"Send to\" to pass in)"),
"removeNonImage": m7,
"removeNonImage": m8,
"renameLogs": MessageLookupByLibrary.simpleMessage("rename logs"),
"renameName": MessageLookupByLibrary.simpleMessage("Rename name"),
"replace": MessageLookupByLibrary.simpleMessage("Replace"),
Expand All @@ -194,7 +198,7 @@ class MessageLookup extends MessageLookupByLibrary {
"Successfully deleted all empty folders"),
"successful":
MessageLookupByLibrary.simpleMessage("Renaming successful"),
"successfulNum": m8,
"successfulNum": m9,
"suffix": MessageLookupByLibrary.simpleMessage("Suffix"),
"suffixContent":
MessageLookupByLibrary.simpleMessage("Add suffix content"),
Expand All @@ -219,10 +223,10 @@ class MessageLookup extends MessageLookupByLibrary {
"undo": MessageLookupByLibrary.simpleMessage("Undo"),
"undoFailed":
MessageLookupByLibrary.simpleMessage("Undo rename failed"),
"undoFailedNum": m9,
"undoFailedNum": m10,
"undoSuccessful":
MessageLookupByLibrary.simpleMessage("Undo Successful"),
"undoSuccessfulNum": m10,
"undoSuccessfulNum": m11,
"unselect": MessageLookupByLibrary.simpleMessage("Unselect"),
"uploadCSV": MessageLookupByLibrary.simpleMessage(
"Upload CSV and TXT files with \",\" separating old and new names, or OPLOG file generated by OncePower"),
Expand Down
22 changes: 13 additions & 9 deletions lib/generated/intl/messages_zh_CN.dart
Original file line number Diff line number Diff line change
Expand Up @@ -28,19 +28,22 @@ class MessageLookup extends MessageLookupByLibrary {

static String m3(count, total) => "选中 ${total} 个中 ${count} 个重命名失败";

static String m4(total, count) => "${total} 个文件已选择 ${count} 个";
static String m4(count, total) => "已选择 ${count}/${total}";

static String m5(version) => "新的版本 ${version} 可以更新";

static String m6(name) => "在 ${name} 中已不存在";

static String m7(count) => "已移除${count}个非图片文件";
static String m7(count, uncheck) =>
"已成功移动所选择的 ${count} 个文件,${uncheck} 个未选择的文件未移动,可前往其他菜单选中后继续操作";

static String m8(total) => "选中的 ${total} 个已全部重命名成功";
static String m8(count) => "已移除${count}个非图片文件";

static String m9(count, total) => "选中 ${total} 个中 ${count} 个取消重命名失败";
static String m9(total) => "选中的 ${total} 个已全部重命名成功";

static String m10(total) => "选中的 ${total} 个已全部撤销重命名";
static String m10(count, total) => "选中 ${total} 个中 ${count} 个取消重命名失败";

static String m11(total) => "选中的 ${total} 个已全部撤销重命名";

final messages = _notInlinedMessages(_notInlinedMessages);
static Map<String, Function> _notInlinedMessages(_) => <String, Function>{
Expand Down Expand Up @@ -136,6 +139,7 @@ class MessageLookup extends MessageLookupByLibrary {
"organizedSuccessfully": MessageLookupByLibrary.simpleMessage("整理成功"),
"organizedSuccessfullyInfo":
MessageLookupByLibrary.simpleMessage("已成功移动所有文件"),
"organizedSuccessfullyInfo2": m7,
"organizingFailed": MessageLookupByLibrary.simpleMessage("整理失败"),
"organizingFailedInfo":
MessageLookupByLibrary.simpleMessage("以下几个移动失败"),
Expand All @@ -145,7 +149,7 @@ class MessageLookup extends MessageLookupByLibrary {
"prefixContent": MessageLookupByLibrary.simpleMessage("添加前缀内容"),
"regeditTip": MessageLookupByLibrary.simpleMessage(
"开启右键快捷菜单(软件未运行时windows系统只允许一次传入一个文件路径,所以未运行本软件时只允许传入一个文件夹路径,你可以将所有文件放置到一个文件夹中。若想一次传入多个请将该软件的快捷方式放置在\"发送到\"文件夹下(打开文件资源管理器,在地址栏中输入 shell:sendto 并回车),使用\"发送到\"传入)"),
"removeNonImage": m7,
"removeNonImage": m8,
"renameLogs": MessageLookupByLibrary.simpleMessage("重命名日志"),
"renameName": MessageLookupByLibrary.simpleMessage("重命名名称"),
"replace": MessageLookupByLibrary.simpleMessage("替换"),
Expand All @@ -163,7 +167,7 @@ class MessageLookup extends MessageLookupByLibrary {
"start": MessageLookupByLibrary.simpleMessage("开始"),
"successInfo": MessageLookupByLibrary.simpleMessage("已成功删除所有空文件夹"),
"successful": MessageLookupByLibrary.simpleMessage("重命名成功"),
"successfulNum": m8,
"successfulNum": m9,
"suffix": MessageLookupByLibrary.simpleMessage("后缀"),
"suffixContent": MessageLookupByLibrary.simpleMessage("添加后缀内容"),
"swapPrefixDesc": MessageLookupByLibrary.simpleMessage("交换前缀和递增数字位置"),
Expand All @@ -180,9 +184,9 @@ class MessageLookup extends MessageLookupByLibrary {
"tvSeriesInfo": MessageLookupByLibrary.simpleMessage("获取剧集信息"),
"undo": MessageLookupByLibrary.simpleMessage("撤销"),
"undoFailed": MessageLookupByLibrary.simpleMessage("撤销重命名失败"),
"undoFailedNum": m9,
"undoFailedNum": m10,
"undoSuccessful": MessageLookupByLibrary.simpleMessage("已成功撤销"),
"undoSuccessfulNum": m10,
"undoSuccessfulNum": m11,
"unselect": MessageLookupByLibrary.simpleMessage("取消选择"),
"uploadCSV": MessageLookupByLibrary.simpleMessage(
"上传以\",\"分隔新旧名称的csv、txt文件或本软件生成的oplog文件"),
Expand Down
18 changes: 14 additions & 4 deletions lib/generated/l10n.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion lib/l10n/intl_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -103,10 +103,11 @@
"organizedSuccessfully": "Organized successfully",
"organizingFailed": "Organizing failed",
"organizedSuccessfullyInfo":"Successfully moved all files",
"organizedSuccessfullyInfo2":"The selected {count} files have been successfully moved, and {uncheck} unselected files have not been moved. You can go to another menu to select and continue the operation",
"organizingFailedInfo": "The following moves failed",
"restartTip": "Restart takes effect",
"viewMode": "View mode",
"fileCount": "{total} files {count} selected",
"fileCount": "Selected {count}/{total}",
"select": "Select",
"unselect": "Unselect",
"delete": "Delete",
Expand Down
3 changes: 2 additions & 1 deletion lib/l10n/intl_zh_CN.arb
Original file line number Diff line number Diff line change
Expand Up @@ -103,10 +103,11 @@
"organizedSuccessfully": "整理成功",
"organizingFailed": "整理失败",
"organizedSuccessfullyInfo":"已成功移动所有文件",
"organizedSuccessfullyInfo2":"已成功移动所选择的 {count} 个文件,{uncheck} 个未选择的文件未移动,可前往其他菜单选中后继续操作",
"organizingFailedInfo": "以下几个移动失败",
"restartTip": "重启生效",
"viewMode": "视图模式",
"fileCount": "{total} 个文件已选择 {count}",
"fileCount": "已选择 {count}/{total}",
"select": "选择",
"unselect": "取消选择",
"delete": "删除",
Expand Down
14 changes: 12 additions & 2 deletions lib/views/action_bar/organize/organize_button.dart
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,12 @@ class OrganizeButton extends ConsumerWidget {

void organizeFolder() async {
List<FileInfo> files = ref.watch(fileListProvider);
int uncheckedCount = 0;
for (var file in files) {
if (!file.checked) {
uncheckedCount++;
continue;
}
if (file.type.isFolder) {
if (!Directory(file.filePath).existsSync()) {
errorList.add(
Expand Down Expand Up @@ -130,8 +135,13 @@ class OrganizeButton extends ConsumerWidget {
ref.read(costProvider.notifier).update(cost);
if (!context.mounted) return;
NotificationType type = errorList.isEmpty
? SuccessNotification(S.of(context).organizedSuccessfully,
S.of(context).organizedSuccessfullyInfo)
? SuccessNotification(
S.of(context).organizedSuccessfully,
uncheckedCount == 0
? S.of(context).organizedSuccessfullyInfo
: S
.of(context)
.organizedSuccessfullyInfo2(count, uncheckedCount))
: ErrorNotification(S.of(context).organizingFailed,
S.of(context).organizingFailedInfo, errorList);
NotificationMessage.show(type);
Expand Down
11 changes: 1 addition & 10 deletions lib/views/content_bar/rename/filter_file_btn.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import 'package:once_power/model/enum.dart';
import 'package:once_power/provider/file.dart';
import 'package:once_power/core/rename.dart';
import 'package:once_power/widgets/common/easy_checkbox.dart';
import 'package:once_power/widgets/content_bar/type_detail_panel.dart';

class FilterFileBtn extends ConsumerWidget {
const FilterFileBtn({super.key});
Expand All @@ -23,14 +22,6 @@ class FilterFileBtn extends ConsumerWidget {
Navigator.of(context).pop();
}

void showAllType() async {
Navigator.of(context).pop();
await showDialog(
context: context,
builder: (BuildContext context) => const TypeDetailPanel(),
);
}

DropdownMenuItem easyDropdownItem(
String label, Color color, GestureTapCallback onTap) {
return DropdownMenuItem(
Expand Down Expand Up @@ -89,7 +80,7 @@ class FilterFileBtn extends ConsumerWidget {
easyDropdownItem(
allExtLabel,
Theme.of(context).primaryColor,
showAllType,
() => showAllType(context, true),
),
],
onChanged: (v) {},
Expand Down
21 changes: 18 additions & 3 deletions lib/views/content_bar/rename/view_model/view_model_title_bar.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import 'package:once_power/model/enum.dart';
import 'package:once_power/provider/file.dart';
import 'package:once_power/provider/toggle.dart';
import 'package:once_power/widgets/common/click_icon.dart';
import 'package:once_power/widgets/content_bar/normal_tile.dart';
import 'package:once_power/widgets/content_bar/check_tile.dart';

class ViewModeTitleBar extends ConsumerWidget {
const ViewModeTitleBar({super.key});
Expand All @@ -16,11 +16,16 @@ class ViewModeTitleBar extends ConsumerWidget {
Widget build(BuildContext context, WidgetRef ref) {
int total = ref.watch(fileListProvider).length;
int selected = ref.watch(selectFileProvider);
final String title = S.of(context).fileCount(total, selected);
final String title = S.of(context).fileCount(selected, total);

return Row(
children: [
NormalTile(label: title, padding: EdgeInsets.zero),
CheckTile(
check: ref.watch(selectAllProvider),
label: title,
fontSize: 14,
onChanged: (v) => selectAll(ref),
),
const Spacer(),
ClickIcon(
svg: ref.watch(fileSortTypeProvider).value,
Expand All @@ -29,6 +34,16 @@ class ViewModeTitleBar extends ConsumerWidget {
color: AppColors.icon,
onTap: () => toggleSortType(ref),
),
SizedBox(
width: AppNum.deleteBtnS,
child: Center(
child: IconButton(
onPressed: () => showAllType(context),
color: AppColors.icon,
icon: const Icon(Icons.filter_alt_rounded),
),
),
),
SizedBox(
width: AppNum.deleteBtnS,
child: Center(
Expand Down
1 change: 0 additions & 1 deletion lib/widgets/content_bar/detail_ext_area.dart
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ class DetailExtArea extends ConsumerWidget {

return Column(
children: [
const SizedBox(height: AppNum.mediumG),
Stack(
alignment: Alignment.center,
children: [
Expand Down
2 changes: 1 addition & 1 deletion lib/widgets/content_bar/type_detail_panel.dart
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class TypeDetailPanel extends ConsumerWidget {
child: Column(
children: [
Text(titleLabel, style: titleStyle),
const SizedBox(height: AppNum.smallG),
const SizedBox(height: AppNum.largeG),
Expanded(
child: SingleChildScrollView(
child: Column(
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
# In Windows, build-name is used as the major, minor, and patch parts
# of the product and file versions while build-number is used as the build suffix.
version: 2.10.0+0
version: 2.10.1+0

environment:
sdk: '>=3.0.6 <4.0.0'
Expand Down
6 changes: 6 additions & 0 deletions version.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
{
"info": [{
"version": "2.10.1",
"description": [
"视图模式添加了过滤功能",
"整理模式不再移动未选中的文件或文件夹"
]
},{
"version": "2.10.0",
"description": [
"添加了通过系统右键菜单添加文件的功能",
Expand Down

0 comments on commit 90f24ec

Please sign in to comment.