mirror of
https://github.com/GopeedLab/gopeed.git
synced 2026-11-19 06:43:42 +00:00
feat: new ui (#1455)
This commit is contained in:
742 files changed
+59951
-5934
No files matched your search
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,62 @@
|
||||
import 'package:flutter/widgets.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:shadcn_flutter/shadcn_flutter.dart' as shad;
|
||||
|
||||
import '../../../../core/utils/file_explorer.dart';
|
||||
import '../../../../shared/theme/app_palette.dart';
|
||||
import '../../../../shared/widgets/app_toast.dart';
|
||||
import '../../../../shared/widgets/detail/app_detail_surface.dart';
|
||||
import '../../../../l10n/l10n.dart';
|
||||
import '../../application/tasks_controller.dart';
|
||||
import '../../domain/task_record.dart';
|
||||
import '../widgets/task_drawer.dart';
|
||||
|
||||
class TaskDetailsPage extends ConsumerWidget {
|
||||
const TaskDetailsPage({super.key, required this.taskId, this.initialTask});
|
||||
|
||||
final String taskId;
|
||||
final TaskRecord? initialTask;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
final tasksAsync = ref.watch(tasksControllerProvider);
|
||||
TaskRecord? task = initialTask;
|
||||
for (final item in tasksAsync.value?.tasks ?? const <TaskRecord>[]) {
|
||||
if (item.id == taskId) {
|
||||
task = item;
|
||||
break;
|
||||
}
|
||||
}
|
||||
final palette = AppPalette.of(context);
|
||||
|
||||
return AppDetailPage(
|
||||
title: context.l10n.taskDetails,
|
||||
onBack: () => context.canPop() ? context.pop() : context.go('/'),
|
||||
child: task == null
|
||||
? Center(
|
||||
child: tasksAsync.isLoading
|
||||
? const shad.CircularProgressIndicator()
|
||||
: Text(context.l10n.taskNotFound, style: TextStyle(color: palette.textMuted, fontSize: 13)),
|
||||
)
|
||||
: TaskDetailsView(
|
||||
key: ValueKey(task.id),
|
||||
task: task,
|
||||
mobile: true,
|
||||
onOpenStorage: () => FileExplorer.reveal(task!.storagePath),
|
||||
onUpdateUrl: (url) async {
|
||||
try {
|
||||
await ref
|
||||
.read(tasksControllerProvider.notifier)
|
||||
.updateUrl(task!.id, url, headers: task.requestHeaders);
|
||||
} catch (error) {
|
||||
if (context.mounted) {
|
||||
showAppToast(context, error.toString(), type: AppToastType.error);
|
||||
}
|
||||
rethrow;
|
||||
}
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,86 @@
|
||||
import 'package:flutter/material.dart' show Icons;
|
||||
import 'package:flutter/widgets.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:shadcn_flutter/shadcn_flutter.dart' as shad;
|
||||
|
||||
import '../../../../l10n/l10n.dart';
|
||||
import '../../../../shared/theme/app_palette.dart';
|
||||
import '../../../../shared/widgets/app_tooltip.dart';
|
||||
import '../../application/tasks_controller.dart';
|
||||
import '../../domain/task_record.dart';
|
||||
import '../widgets/task_file_manager.dart';
|
||||
|
||||
class TaskFilesPage extends ConsumerWidget {
|
||||
const TaskFilesPage({super.key, required this.taskId, this.initialTask});
|
||||
|
||||
final String taskId;
|
||||
final TaskRecord? initialTask;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
final tasksAsync = ref.watch(tasksControllerProvider);
|
||||
TaskRecord? task = initialTask;
|
||||
for (final item in tasksAsync.value?.tasks ?? const <TaskRecord>[]) {
|
||||
if (item.id == taskId) {
|
||||
task = item;
|
||||
break;
|
||||
}
|
||||
}
|
||||
final palette = AppPalette.of(context);
|
||||
|
||||
return shad.Scaffold(
|
||||
backgroundColor: palette.bg,
|
||||
child: ColoredBox(
|
||||
color: palette.bg,
|
||||
child: Column(
|
||||
children: [
|
||||
SafeArea(
|
||||
bottom: false,
|
||||
child: Container(
|
||||
height: 52,
|
||||
padding: const EdgeInsets.symmetric(horizontal: 8),
|
||||
decoration: BoxDecoration(
|
||||
border: Border(bottom: BorderSide(color: palette.border)),
|
||||
),
|
||||
child: Row(
|
||||
children: [
|
||||
SizedBox(
|
||||
width: 44,
|
||||
child: AppTooltip(
|
||||
message: context.l10n.close,
|
||||
child: shad.IconButton.ghost(
|
||||
onPressed: () => context.canPop() ? context.pop() : context.go('/tasks/$taskId'),
|
||||
icon: Icon(Icons.arrow_back, size: 20, color: palette.textPrimary),
|
||||
),
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
child: Text(
|
||||
task?.name ?? context.l10n.taskDetailsFilesTab,
|
||||
textAlign: TextAlign.center,
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: TextStyle(color: palette.textPrimary, fontSize: 16, fontWeight: FontWeight.w700),
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 44),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
child: task == null
|
||||
? Center(
|
||||
child: tasksAsync.isLoading
|
||||
? const shad.CircularProgressIndicator()
|
||||
: Text(context.l10n.taskNotFound, style: TextStyle(color: palette.textMuted, fontSize: 13)),
|
||||
)
|
||||
: TaskFileManagerView(task: task),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user