Skip to content

Commit 31a3f3f

Browse files
committed
app: add help document
1 parent 29de64b commit 31a3f3f

21 files changed

+522
-307
lines changed

app/lib/api/file/pages/file_list.dart

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import 'package:maple_file/common/utils/util.dart';
1212
import 'package:maple_file/common/utils/time.dart';
1313
import 'package:maple_file/common/utils/path.dart';
1414
import 'package:maple_file/common/widgets/dialog.dart';
15+
import 'package:maple_file/common/widgets/responsive.dart';
1516
import 'package:maple_file/common/providers/selection.dart';
1617
import 'package:maple_file/generated/proto/api/file/file.pb.dart';
1718

@@ -131,17 +132,18 @@ class _FileListState extends ConsumerState<FileList> {
131132
: null,
132133
title: Text(title),
133134
actions: [
134-
IconButton(
135-
icon: Badge(
136-
label: Text('$taskCount'),
137-
isLabelVisible: taskCount > 0,
138-
backgroundColor: Theme.of(context).primaryColor,
139-
child: const Icon(Icons.swap_vert_circle_outlined),
135+
if (Breakpoint.isSmall(context))
136+
IconButton(
137+
icon: Badge(
138+
label: Text('$taskCount'),
139+
isLabelVisible: taskCount > 0,
140+
backgroundColor: Theme.of(context).primaryColor,
141+
child: const Icon(Icons.swap_vert_circle_outlined),
142+
),
143+
onPressed: () {
144+
Navigator.pushNamed(context, '/task/list');
145+
},
140146
),
141-
onPressed: () {
142-
Navigator.pushNamed(context, '/task/list');
143-
},
144-
),
145147
const FilePopupAction(),
146148
],
147149
);

app/lib/api/file/pages/repo_list.dart

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,6 @@ class _RepoListState extends ConsumerState<RepoList> {
2929
Card(
3030
child: Column(
3131
children: [
32-
ListTile(
33-
title: Text("存储库".tr()),
34-
dense: true,
35-
),
3632
CustomAsyncValue(
3733
value: ref.watch(repoProvider),
3834
builder: (items) => Column(

app/lib/api/file/pages/setting_download.dart

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,6 @@ class _FileSettingDownloadState extends ConsumerState<FileSettingDownload> {
5050
Card(
5151
child: Column(
5252
children: [
53-
ListTile(
54-
title: Text("文件下载".tr()),
55-
dense: true,
56-
),
5753
ListTile(
5854
title: Text('默认保存路径'.tr()),
5955
subtitle: setting.downloadPath == null

app/lib/api/file/pages/setting_theme.dart

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,7 @@ class _FileSettingThemeState extends ConsumerState<FileSettingTheme> {
143143
],
144144
),
145145
onTap: () async {
146+
final appearance = ref.read(appearanceProvider);
146147
final result = await showListDialog2<FlexScheme>(
147148
context,
148149
height: MediaQuery.sizeOf(context).height * 0.618,
@@ -155,19 +156,19 @@ class _FileSettingThemeState extends ConsumerState<FileSettingTheme> {
155156
width: 24,
156157
decoration: BoxDecoration(
157158
color:
158-
defaultFlexScheme.primaryColor(context),
159+
appearance.scheme.primaryColor(context),
159160
borderRadius: const BorderRadius.all(
160161
Radius.circular(12)),
161162
),
162163
),
163164
selected: setting.iconColor == null,
164165
onTap: () {
165-
Navigator.of(context).pop(defaultFlexScheme);
166+
Navigator.of(context).pop(appearance.scheme);
166167
},
167168
),
168169
for (final scheme in FlexScheme.values)
169170
ListTile(
170-
title: Text(scheme.name),
171+
title: Text(scheme.name.capitalize),
171172
leading: Container(
172173
height: 24,
173174
width: 24,
@@ -188,7 +189,7 @@ class _FileSettingThemeState extends ConsumerState<FileSettingTheme> {
188189
if (result != null) {
189190
ref.read(fileSettingProvider.notifier).update((state) {
190191
return state.copyWith(
191-
iconColor: result.name == defaultFlexScheme.name
192+
iconColor: result.name == appearance.scheme.name
192193
? null
193194
: result.name,
194195
);
Lines changed: 48 additions & 150 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
import 'package:flutter/material.dart';
2-
import 'package:flutter/services.dart';
32
import 'package:flutter_riverpod/flutter_riverpod.dart';
43

54
import 'package:maple_file/app/i18n.dart';
6-
import 'package:maple_file/common/widgets/dialog.dart';
5+
import 'package:maple_file/common/widgets/form.dart';
76
import 'package:maple_file/common/widgets/custom.dart';
87

98
import '../providers/file_setting.dart';
@@ -16,14 +15,6 @@ class FileSettingUpload extends ConsumerStatefulWidget {
1615
}
1716

1817
class _FileSettingUploadState extends ConsumerState<FileSettingUpload> {
19-
final TextEditingController _controller = TextEditingController();
20-
21-
@override
22-
void dispose() {
23-
_controller.dispose();
24-
super.dispose();
25-
}
26-
2718
@override
2819
Widget build(BuildContext context) {
2920
return Scaffold(
@@ -57,11 +48,7 @@ class _FileSettingUploadState extends ConsumerState<FileSettingUpload> {
5748
child: Column(
5849
children: [
5950
ListTile(
60-
title: Text("文件上传".tr()),
61-
dense: true,
62-
),
63-
ListTile(
64-
title: const Text('自动重命名'),
51+
title: Text('自动重命名'.tr()),
6552
trailing: Switch(
6653
value: setting.uploadRename,
6754
onChanged: (bool value) async {
@@ -72,56 +59,34 @@ class _FileSettingUploadState extends ConsumerState<FileSettingUpload> {
7259
),
7360
),
7461
if (setting.uploadRename)
75-
ListTile(
76-
title: const Text('重命名格式'),
77-
trailing: Text(setting.uploadFormat == ""
78-
? "{filename}{extension}"
79-
: setting.uploadFormat),
80-
onTap: () async {
81-
_controller.text = setting.uploadFormat;
82-
83-
final result = await showEditingDialog(
84-
context,
85-
"重命名格式",
86-
controller: _controller,
87-
helper: buildHelper(),
88-
);
89-
if (result != null) {
90-
ref.read(fileSettingProvider.notifier).update((state) {
91-
return state.copyWith(uploadFormat: result);
92-
});
93-
}
62+
CustomFormField(
63+
type: CustomFormFieldType.path,
64+
label: '重命名格式'.tr(),
65+
value: setting.uploadFormat,
66+
subtitle: Text(
67+
"默认为 {path}".tr(args: {
68+
"path": "{filename}{extension}",
69+
}),
70+
style: const TextStyle(fontSize: 12),
71+
),
72+
onTap: (result) {
73+
ref.read(fileSettingProvider.notifier).update((state) {
74+
return state.copyWith(uploadFormat: result);
75+
});
9476
},
9577
),
96-
ListTile(
97-
title: const Text('分片大小'),
98-
subtitle: const Text(
99-
'文件上传分片大小',
100-
style: TextStyle(fontSize: 10),
101-
),
102-
trailing: Wrap(
103-
crossAxisAlignment: WrapCrossAlignment.center,
104-
children: [
105-
Text("${setting.uploadSliceSize}KB"),
106-
],
78+
CustomFormField(
79+
type: CustomFormFieldType.number,
80+
label: '分片大小'.tr(),
81+
value: "${setting.uploadSliceSize}",
82+
subtitle: Text(
83+
'文件上传分片大小(单位:KB)'.tr(),
84+
style: const TextStyle(fontSize: 12),
10785
),
108-
onTap: () async {
109-
_controller.text = setting.uploadSliceSize.toString();
110-
111-
final result = await showEditingDialog(
112-
context,
113-
"分片大小(单位:KB)",
114-
controller: _controller,
115-
keyboardType: TextInputType.number,
116-
inputFormatters: [
117-
FilteringTextInputFormatter.digitsOnly,
118-
],
119-
);
120-
if (result != null) {
121-
ref.read(fileSettingProvider.notifier).update((state) {
122-
return state.copyWith(uploadSliceSize: int.parse(result));
123-
});
124-
}
86+
onTap: (result) {
87+
ref.read(fileSettingProvider.notifier).update((state) {
88+
return state.copyWith(uploadSliceSize: int.parse(result));
89+
});
12590
},
12691
),
12792
],
@@ -130,68 +95,31 @@ class _FileSettingUploadState extends ConsumerState<FileSettingUpload> {
13095
Card(
13196
child: Column(
13297
children: [
133-
const ListTile(
134-
title: Text("文件限制"),
135-
dense: true,
136-
),
137-
ListTile(
138-
title: const Text('大小限制'),
139-
subtitle: const Text(
140-
'0表示不限制',
141-
style: TextStyle(fontSize: 10),
142-
),
143-
trailing: Wrap(
144-
crossAxisAlignment: WrapCrossAlignment.center,
145-
children: [
146-
Text("${setting.uploadLimitSize}MB"),
147-
],
98+
CustomFormField(
99+
type: CustomFormFieldType.number,
100+
label: '大小限制'.tr(),
101+
value: "${setting.uploadLimitSize}",
102+
subtitle: Text(
103+
'0表示不限制(单位:MB)'.tr(),
104+
style: const TextStyle(fontSize: 12),
148105
),
149-
onTap: () async {
150-
_controller.text = setting.uploadLimitSize.toString();
151-
152-
final result = await showEditingDialog(
153-
context,
154-
"大小限制(单位:MB)",
155-
controller: _controller,
156-
keyboardType: TextInputType.number,
157-
inputFormatters: [
158-
FilteringTextInputFormatter.digitsOnly,
159-
],
160-
);
161-
if (result != null) {
162-
ref.read(fileSettingProvider.notifier).update((state) {
163-
return state.copyWith(uploadLimitSize: int.parse(result));
164-
});
165-
}
106+
onTap: (result) {
107+
ref.read(fileSettingProvider.notifier).update((state) {
108+
return state.copyWith(uploadLimitSize: int.parse(result));
109+
});
166110
},
167111
),
168-
ListTile(
169-
title: const Text('格式限制'),
170-
subtitle: const Text(
171-
'多个格式使用逗号分隔。例如: .mp4,.png',
172-
style: TextStyle(fontSize: 10),
112+
CustomFormField(
113+
label: '格式限制'.tr(),
114+
value: setting.uploadLimitType,
115+
subtitle: Text(
116+
'多个格式使用逗号分隔。例如: .mp4,.png'.tr(),
117+
style: const TextStyle(fontSize: 12),
173118
),
174-
trailing: Wrap(
175-
crossAxisAlignment: WrapCrossAlignment.center,
176-
children: [
177-
Text(setting.uploadLimitType == ""
178-
? "未设置"
179-
: setting.uploadLimitType),
180-
],
181-
),
182-
onTap: () async {
183-
_controller.text = setting.uploadLimitType;
184-
185-
final result = await showEditingDialog(
186-
context,
187-
"格式限制",
188-
controller: _controller,
189-
);
190-
if (result != null) {
191-
ref.read(fileSettingProvider.notifier).update((state) {
192-
return state.copyWith(uploadLimitType: result);
193-
});
194-
}
119+
onTap: (result) {
120+
ref.read(fileSettingProvider.notifier).update((state) {
121+
return state.copyWith(uploadLimitType: result);
122+
});
195123
},
196124
),
197125
],
@@ -200,34 +128,4 @@ class _FileSettingUploadState extends ConsumerState<FileSettingUpload> {
200128
],
201129
);
202130
}
203-
204-
Widget buildHelper() {
205-
Map<String, String> formats = {
206-
"文件名": "{filename}",
207-
"文件扩展": "{extension}",
208-
"年": "{time:year}",
209-
"月": "{time:month}",
210-
"日": "{time:day}",
211-
"时": "{time:hour}",
212-
"分": "{time:minute}",
213-
"秒": "{time:second}",
214-
};
215-
return Wrap(
216-
spacing: 4,
217-
runSpacing: 4,
218-
children: [
219-
for (final key in formats.keys)
220-
ActionChip(
221-
label: Text(key),
222-
labelStyle: TextStyle(
223-
fontSize: kDefaultFontSize * 0.875,
224-
color: Theme.of(context).primaryColor,
225-
),
226-
onPressed: () {
227-
_controller.text = "${_controller.text}${formats[key]}";
228-
},
229-
),
230-
],
231-
);
232-
}
233131
}

app/lib/api/file/widgets/file_tree.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ class FileTreeState extends ConsumerState<FileTree> {
9292
child: const Icon(Icons.expand_more, size: 18)),
9393
)
9494
: null,
95-
onTap: () {
95+
onTap: () async {
9696
if (!PathUtil.isDir(file.name, type: file.type)) {
9797
navigatorState(context).popAndPushNamed(
9898
'/file/preview',
@@ -117,7 +117,7 @@ class FileTreeState extends ConsumerState<FileTree> {
117117
}
118118
path = filepath.posix.join(widget.path, path);
119119

120-
final files = ref.refresh(fileProvider(path)).valueOrNull ?? [];
120+
final files = await ref.refresh(fileProvider(path).future);
121121
node.children.clear();
122122
for (final file in files) {
123123
node.children.add(CustomTreeNode<File>(

0 commit comments

Comments
 (0)