Skip to content

Commit

Permalink
Add updateTagTranslation display
Browse files Browse the repository at this point in the history
  • Loading branch information
lifegpc authored Oct 3, 2024
1 parent ec4d385 commit f7a000b
Show file tree
Hide file tree
Showing 8 changed files with 1,080 additions and 772 deletions.
1,608 changes: 920 additions & 688 deletions lib/api/client.g.dart

Large diffs are not rendered by default.

30 changes: 29 additions & 1 deletion lib/api/task.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ enum TaskType {
@JsonValue(3)
fixGalleryPage,
@JsonValue(4)
import;
import,
@JsonValue(5)
updateTagTranslation;

String text(BuildContext context) {
final i18n = AppLocalizations.of(context)!;
Expand All @@ -30,6 +32,8 @@ enum TaskType {
return i18n.fixGalleryPageTask;
case TaskType.import:
return i18n.importTask;
case TaskType.updateTagTranslation:
return i18n.updateTagTranslation;
}
}
}
Expand Down Expand Up @@ -183,6 +187,23 @@ class TaskImportProgress implements TaskProgressBasicType {
Map<String, dynamic> toJson() => _$TaskImportProgressToJson(this);
}

@JsonSerializable()
class TaskUpdateTagTranslationProgress implements TaskProgressBasicType {
const TaskUpdateTagTranslationProgress({
required this.addedTag,
required this.totalTag,
});
@JsonKey(name: 'added_tag')
final int addedTag;
@JsonKey(name: 'total_tag')
final int totalTag;
factory TaskUpdateTagTranslationProgress.fromJson(
Map<String, dynamic> json) =>
_$TaskUpdateTagTranslationProgressFromJson(json);
Map<String, dynamic> toJson() =>
_$TaskUpdateTagTranslationProgressToJson(this);
}

class TaskProgress {
const TaskProgress({
required this.type,
Expand Down Expand Up @@ -231,6 +252,13 @@ class TaskProgress {
detail: TaskImportProgress.fromJson(
json['detail'] as Map<String, dynamic>),
);
case 5:
return TaskProgress(
type: TaskType.updateTagTranslation,
taskId: taskId,
detail: TaskUpdateTagTranslationProgress.fromJson(
json['detail'] as Map<String, dynamic>),
);
default:
throw ArgumentError.value(type, 'type', 'Invalid task type');
}
Expand Down
15 changes: 15 additions & 0 deletions lib/api/task.g.dart

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

8 changes: 8 additions & 0 deletions lib/components/task.dart
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@ class _TaskView extends State<TaskView> {
case TaskType.import:
final progress = widget.task.progress as TaskImportProgress;
return progress.importedPage / progress.totalPage;
case TaskType.updateTagTranslation:
final progress =
widget.task.progress as TaskUpdateTagTranslationProgress;
return progress.addedTag / progress.totalTag;
}
}

Expand Down Expand Up @@ -98,6 +102,10 @@ class _TaskView extends State<TaskView> {
return Text("${i18n.importTask} $title",
maxLines: 1, overflow: TextOverflow.ellipsis);
}
if (typ == TaskType.updateTagTranslation) {
return Text(i18n.updateTagTranslation,
maxLines: 1, overflow: TextOverflow.ellipsis);
}
return Container();
}

Expand Down
54 changes: 32 additions & 22 deletions lib/dialog/task_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -104,28 +104,34 @@ class _TaskPage extends State<TaskPage> {
_KeyValue(i18n.taskId, widget.id.toString(), fontSize: 16),
Divider(indent: indent, endIndent: endIndent),
_KeyValue(i18n.taskType, typ.text(context), fontSize: 16),
Divider(indent: indent, endIndent: endIndent),
Row(children: [
SizedBox(
width: 80,
child: Center(
child: Text(i18n.gid,
textAlign: TextAlign.center,
style: TextStyle(color: cs.primary, fontSize: 16)))),
Expanded(
child: allowLink
? SelectableText.rich(TextSpan(
text: gid,
style: TextStyle(color: cs.secondary, fontSize: 16),
mouseCursor: SystemMouseCursors.click,
recognizer: TapGestureRecognizer()
..onTap = () {
context.push("/gallery/${task.base.gid}",
extra: GalleryPageExtra(title: title));
}))
: SelectableText(gid,
style: TextStyle(color: cs.secondary, fontSize: 16))),
]),
gid.isEmpty
? Container()
: Divider(indent: indent, endIndent: endIndent),
gid.isEmpty
? Container()
: Row(children: [
SizedBox(
width: 80,
child: Center(
child: Text(i18n.gid,
textAlign: TextAlign.center,
style:
TextStyle(color: cs.primary, fontSize: 16)))),
Expanded(
child: allowLink
? SelectableText.rich(TextSpan(
text: gid,
style: TextStyle(color: cs.secondary, fontSize: 16),
mouseCursor: SystemMouseCursors.click,
recognizer: TapGestureRecognizer()
..onTap = () {
context.push("/gallery/${task.base.gid}",
extra: GalleryPageExtra(title: title));
}))
: SelectableText(gid,
style:
TextStyle(color: cs.secondary, fontSize: 16))),
]),
task.base.token.isEmpty
? Container()
: Divider(indent: indent, endIndent: endIndent),
Expand Down Expand Up @@ -244,6 +250,10 @@ class _TaskPage extends State<TaskPage> {
final p = task.progress as TaskImportProgress;
now = p.importedPage;
total = p.totalPage;
case TaskType.updateTagTranslation:
final p = task.progress as TaskUpdateTagTranslationProgress;
now = p.addedTag;
total = p.totalTag;
default:
}
if (total == 0) return Container();
Expand Down
3 changes: 2 additions & 1 deletion lib/l10n/app_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -327,5 +327,6 @@
"editExpireTime": "Edit expire time",
"share": "Share",
"failedChangeExpireTime": "Failed to change expired time: ",
"failedShareGallery": "Failed to share gallery: "
"failedShareGallery": "Failed to share gallery: ",
"updateTagTranslation": "Update tag's translation"
}
3 changes: 2 additions & 1 deletion lib/l10n/app_zh.arb
Original file line number Diff line number Diff line change
Expand Up @@ -327,5 +327,6 @@
"editExpireTime": "修改过期时间",
"share": "分享",
"failedChangeExpireTime": "修改过期时间失败:",
"failedShareGallery": "分享画廊失败:"
"failedShareGallery": "分享画廊失败:",
"updateTagTranslation": "更新标签的翻译"
}
Loading

0 comments on commit f7a000b

Please sign in to comment.