mirror of
https://github.com/GopeedLab/gopeed.git
synced 2026-11-16 13:23:41 +00:00
Merge branch 'GopeedLab:main' into main
This commit is contained in:
commit
ee9b16794e
61 files changed
+2211
-456
No files matched your search
@@ -133,7 +133,7 @@ class TaskRecord {
|
||||
status: status,
|
||||
downloaded: _formatBytes(downloadedBytes),
|
||||
total: totalBytes > 0 ? _formatBytes(totalBytes) : null,
|
||||
speed: task.progress.speed > 0 ? TransferRateFormatter.format(task.progress.speed).text : null,
|
||||
speed: totalBytes > 0 || task.progress.speed > 0 ? TransferRateFormatter.format(task.progress.speed).text : null,
|
||||
uploadSpeed: task.uploading ? TransferRateFormatter.format(task.progress.uploadSpeed).text : null,
|
||||
remainingSeconds: _remainingSeconds(task, totalBytes, downloadedBytes),
|
||||
downloadDuration: task.progress.used > 0 ? Duration(microseconds: (task.progress.used + 999) ~/ 1000) : null,
|
||||
|
||||
@@ -37,6 +37,8 @@ import '../../../../shared/widgets/app_toast.dart';
|
||||
import '../../../../l10n/l10n.dart';
|
||||
import '../../../../util/util.dart';
|
||||
import '../../application/pending_create_task.dart';
|
||||
import '../../application/task_list_navigation.dart';
|
||||
import '../widgets/history_search_field.dart';
|
||||
import '../widgets/create_task_action_buttons.dart';
|
||||
import '../widgets/resolve_file_tree.dart';
|
||||
|
||||
@@ -687,24 +689,27 @@ class _CreateTaskWindowPageState extends ConsumerState<CreateTaskWindowPage> {
|
||||
),
|
||||
),
|
||||
),
|
||||
Container(
|
||||
padding: const EdgeInsets.fromLTRB(24, 12, 24, 20),
|
||||
decoration: BoxDecoration(
|
||||
border: Border(top: BorderSide(color: palette.border)),
|
||||
),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
CreateTaskActionButtons(
|
||||
submitting: _creating,
|
||||
onCancel: _closeWindow,
|
||||
onSubmit: _confirm,
|
||||
cancelLabel: context.l10n.cancel,
|
||||
submitLabel: context.l10n.confirm,
|
||||
cancelButtonKey: const ValueKey('create-task-cancel-button'),
|
||||
submitButtonKey: const ValueKey('create-task-confirm-button'),
|
||||
),
|
||||
],
|
||||
SafeArea(
|
||||
top: false,
|
||||
child: Container(
|
||||
padding: const EdgeInsets.fromLTRB(24, 12, 24, 20),
|
||||
decoration: BoxDecoration(
|
||||
border: Border(top: BorderSide(color: palette.border)),
|
||||
),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
CreateTaskActionButtons(
|
||||
submitting: _creating,
|
||||
onCancel: _closeWindow,
|
||||
onSubmit: _confirm,
|
||||
cancelLabel: context.l10n.cancel,
|
||||
submitLabel: context.l10n.confirm,
|
||||
cancelButtonKey: const ValueKey('create-task-cancel-button'),
|
||||
submitButtonKey: const ValueKey('create-task-confirm-button'),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
@@ -732,6 +737,8 @@ class _CreateTaskWindowPageState extends ConsumerState<CreateTaskWindowPage> {
|
||||
} catch (error) {
|
||||
debugPrint('Unable to select downloading tasks: $error');
|
||||
}
|
||||
} else {
|
||||
ref.read(taskListNavigationProvider.notifier).showDownloading();
|
||||
}
|
||||
await _closeWindow();
|
||||
}
|
||||
@@ -1244,20 +1251,9 @@ class _CreateTaskWindowPageState extends ConsumerState<CreateTaskWindowPage> {
|
||||
height: screenSize.height < 560 ? screenSize.height * 0.55 : 360,
|
||||
child: Column(
|
||||
children: [
|
||||
SizedBox(
|
||||
height: 38,
|
||||
child: AppTextField(
|
||||
key: const ValueKey('create-history-filter'),
|
||||
controller: filterController,
|
||||
placeholder: Text(
|
||||
dialogContext.l10n.searchHistory,
|
||||
style: TextStyle(color: palette.searchHint, fontSize: 13),
|
||||
),
|
||||
features: [
|
||||
InputFeature.leading(Icon(Icons.search_rounded, size: 15, color: palette.textMuted)),
|
||||
],
|
||||
onChanged: (value) => setDialogState(() => filterQuery = value),
|
||||
),
|
||||
HistorySearchField(
|
||||
controller: filterController,
|
||||
onChanged: (value) => setDialogState(() => filterQuery = value),
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
Expanded(
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
import 'package:shadcn_flutter/shadcn_flutter.dart';
|
||||
|
||||
import '../../../../l10n/l10n.dart';
|
||||
import '../../../../shared/theme/app_design_tokens.dart';
|
||||
import '../../../../shared/theme/app_palette.dart';
|
||||
import '../../../../shared/widgets/app_text_field.dart';
|
||||
|
||||
class HistorySearchField extends StatelessWidget {
|
||||
const HistorySearchField({super.key, required this.controller, required this.onChanged});
|
||||
|
||||
final TextEditingController controller;
|
||||
final ValueChanged<String> onChanged;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final palette = AppPalette.of(context);
|
||||
const textStyle = TextStyle(fontSize: 13);
|
||||
return ConstrainedBox(
|
||||
// Allow large accessibility text to grow instead of clipping the line.
|
||||
constraints: const BoxConstraints(minHeight: 38),
|
||||
child: AppTextField(
|
||||
key: const ValueKey('create-history-filter'),
|
||||
controller: controller,
|
||||
style: textStyle,
|
||||
padding: AppDesignTokens.compactTextFieldPadding,
|
||||
placeholder: Text(
|
||||
context.l10n.searchHistory,
|
||||
// Match the editable text metrics so the cursor and hint align.
|
||||
style: textStyle.copyWith(color: palette.searchHint),
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
features: [InputFeature.leading(Icon(Icons.search_rounded, size: 15, color: palette.textMuted))],
|
||||
onChanged: onChanged,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -3,6 +3,7 @@ import 'package:flutter/material.dart' show Colors, Icons;
|
||||
import 'package:flutter/widgets.dart';
|
||||
import 'package:shadcn_flutter/shadcn_flutter.dart' as shad;
|
||||
|
||||
import '../../../../../core/window/app_window_chrome.dart';
|
||||
import '../../../../../shared/theme/app_design_tokens.dart';
|
||||
import '../../../../../shared/theme/app_palette.dart';
|
||||
import '../../../domain/task_record.dart';
|
||||
@@ -237,7 +238,10 @@ class _ProgressContent extends StatelessWidget {
|
||||
TaskStatus.downloading => [(Icons.pause, onPause), (Icons.close, onDelete)],
|
||||
TaskStatus.paused => [(Icons.play_arrow, onResume), (Icons.close, onDelete)],
|
||||
TaskStatus.failed => [(Icons.refresh, onResume), (Icons.delete_outline, onDelete)],
|
||||
TaskStatus.completed => [(Icons.folder_open_outlined, null), (Icons.delete_outline, onDelete)],
|
||||
TaskStatus.completed => [
|
||||
if (AppWindowChrome.isDesktopWindow) (Icons.folder_open_outlined, null),
|
||||
(Icons.delete_outline, onDelete),
|
||||
],
|
||||
};
|
||||
|
||||
return actions
|
||||
@@ -306,7 +310,10 @@ class _CompletedContent extends StatelessWidget {
|
||||
TaskStatus.downloading => [(Icons.pause, null), (Icons.close, onDelete)],
|
||||
TaskStatus.paused => [(Icons.play_arrow, null), (Icons.close, onDelete)],
|
||||
TaskStatus.failed => [(Icons.refresh, null), (Icons.delete_outline, onDelete)],
|
||||
TaskStatus.completed => [(Icons.folder_open_outlined, onReveal), (Icons.delete_outline, onDelete)],
|
||||
TaskStatus.completed => [
|
||||
if (AppWindowChrome.isDesktopWindow) (Icons.folder_open_outlined, onReveal),
|
||||
(Icons.delete_outline, onDelete),
|
||||
],
|
||||
};
|
||||
|
||||
return actions
|
||||
|
||||
@@ -2,6 +2,7 @@ import 'package:flutter/material.dart' show Colors, Icons;
|
||||
import 'package:flutter/widgets.dart';
|
||||
import 'package:shadcn_flutter/shadcn_flutter.dart' as shad;
|
||||
|
||||
import '../../../../../core/window/app_window_chrome.dart';
|
||||
import '../../../../../shared/theme/app_design_tokens.dart';
|
||||
import '../../../../../shared/theme/app_palette.dart';
|
||||
import '../../../domain/task_record.dart';
|
||||
@@ -171,7 +172,10 @@ class _TaskCardMobileState extends State<TaskCardMobile> {
|
||||
TaskStatus.downloading => [(Icons.pause, widget.onPause), (Icons.close, widget.onDelete)],
|
||||
TaskStatus.paused => [(Icons.play_arrow, widget.onResume), (Icons.close, widget.onDelete)],
|
||||
TaskStatus.failed => [(Icons.refresh, widget.onResume), (Icons.delete_outline, widget.onDelete)],
|
||||
TaskStatus.completed => [(Icons.folder_open_outlined, widget.onReveal), (Icons.delete_outline, widget.onDelete)],
|
||||
TaskStatus.completed => [
|
||||
if (AppWindowChrome.isDesktopWindow) (Icons.folder_open_outlined, widget.onReveal),
|
||||
(Icons.delete_outline, widget.onDelete),
|
||||
],
|
||||
};
|
||||
|
||||
return actions
|
||||
|
||||
@@ -95,14 +95,18 @@ class TaskCardFooter extends StatelessWidget {
|
||||
children: [
|
||||
Expanded(
|
||||
child: Text(
|
||||
task.total != null ? '${task.downloaded} / ${task.total}' : context.l10n.unknownSize,
|
||||
task.total != null
|
||||
? '${task.downloaded} / ${task.total}'
|
||||
: task.downloadedBytes == 0
|
||||
? context.l10n.unknownSize
|
||||
: task.downloaded,
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: TextStyle(color: leftColor, fontSize: 10, height: 1),
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 12),
|
||||
if (task.speed != null && !isError) ...[
|
||||
if (task.speed != null) ...[
|
||||
_TaskTransferSpeed(icon: Icons.south, value: task.speed!, color: metaColor),
|
||||
const SizedBox(width: 8),
|
||||
TickDivider(color: palette.progressTrack),
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
import 'package:shadcn_flutter/shadcn_flutter.dart' as shad;
|
||||
import 'package:flutter/material.dart' show Icons;
|
||||
import 'package:flutter/widgets.dart';
|
||||
|
||||
import '../../../../l10n/l10n.dart';
|
||||
import '../../../../shared/theme/app_design_tokens.dart';
|
||||
import '../../../../shared/widgets/app_primary_button.dart';
|
||||
|
||||
/// Shared creation action for task headers and empty-list guidance.
|
||||
class TaskCreateButton extends StatelessWidget {
|
||||
const TaskCreateButton({super.key, required this.onPressed, this.minHeight = 0, this.compact = false});
|
||||
|
||||
final VoidCallback onPressed;
|
||||
final double minHeight;
|
||||
final bool compact;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return ConstrainedBox(
|
||||
constraints: BoxConstraints(minHeight: minHeight),
|
||||
child: AppPrimaryButton(
|
||||
onPressed: onPressed,
|
||||
size: compact ? shad.ButtonSize.small : shad.ButtonSize.normal,
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Icon(Icons.add, size: compact ? 16 : null),
|
||||
SizedBox(width: compact ? AppDesignTokens.space4 : AppDesignTokens.space8),
|
||||
Flexible(
|
||||
child: Text(
|
||||
context.l10n.create,
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: compact ? const TextStyle(fontSize: 13) : null,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:flutter/foundation.dart' show TargetPlatform, defaultTargetPlatform, kIsWeb;
|
||||
import 'package:flutter/material.dart' show Colors, Icons;
|
||||
import 'package:flutter/material.dart' show Colors, Icons, SelectionArea;
|
||||
import 'package:flutter/widgets.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:shadcn_flutter/shadcn_flutter.dart' as shad;
|
||||
@@ -122,7 +122,7 @@ class _TaskDetailsViewState extends ConsumerState<TaskDetailsView> {
|
||||
? AppDesignTokens.taskDetailsMobilePadding
|
||||
: AppDesignTokens.taskDetailsDesktopPadding;
|
||||
final runtimeStatus = _tabIndex == 1 ? ref.watch(taskRuntimeStatusProvider(widget.task.id)).value : null;
|
||||
return Column(
|
||||
final content = Column(
|
||||
children: [
|
||||
Container(
|
||||
height: 48,
|
||||
@@ -204,6 +204,7 @@ class _TaskDetailsViewState extends ConsumerState<TaskDetailsView> {
|
||||
),
|
||||
],
|
||||
);
|
||||
return SelectionArea(key: const ValueKey('task-details-selection-area'), child: content);
|
||||
}
|
||||
|
||||
bool get _canOpenStoragePath {
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
import 'package:shadcn_flutter/shadcn_flutter.dart';
|
||||
|
||||
import '../../../../l10n/l10n.dart';
|
||||
import '../../../../shared/theme/app_palette.dart';
|
||||
import '../../../../shared/widgets/app_tooltip.dart';
|
||||
|
||||
/// Keeps the action inside the localized sentence, including RTL word order.
|
||||
class TaskEmptyCreateHint extends StatelessWidget {
|
||||
const TaskEmptyCreateHint({super.key, required this.onCreateTask});
|
||||
|
||||
final VoidCallback onCreateTask;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
const actionMarker = '\uFFFC';
|
||||
final parts = context.l10n.emptyTaskCreateHint(actionMarker).split(actionMarker);
|
||||
return Text.rich(
|
||||
TextSpan(
|
||||
children: [
|
||||
TextSpan(text: parts.first.trimRight()),
|
||||
WidgetSpan(
|
||||
alignment: PlaceholderAlignment.middle,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 8),
|
||||
child: AppTooltip(
|
||||
message: context.l10n.create,
|
||||
child: Semantics(
|
||||
label: context.l10n.create,
|
||||
child: SizedBox.square(
|
||||
dimension: 30,
|
||||
child: IconButton.outline(
|
||||
key: const ValueKey('tasks-empty-create-button'),
|
||||
density: ButtonDensity.compact,
|
||||
onPressed: onCreateTask,
|
||||
icon: const Icon(Icons.add, size: 16),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
TextSpan(text: parts.last.trimLeft()),
|
||||
],
|
||||
),
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(color: AppPalette.of(context).textMuted, fontSize: 13),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,35 +1,45 @@
|
||||
import 'package:flutter/widgets.dart';
|
||||
|
||||
import '../../../../shared/theme/app_palette.dart';
|
||||
import '../../../../shared/theme/app_design_tokens.dart';
|
||||
import 'task_empty_create_hint.dart';
|
||||
import '../../../../l10n/l10n.dart';
|
||||
|
||||
class TaskEmptyState extends StatelessWidget {
|
||||
const TaskEmptyState({super.key, this.message});
|
||||
const TaskEmptyState({super.key, this.message, this.onCreateTask});
|
||||
|
||||
final String? message;
|
||||
final VoidCallback? onCreateTask;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final palette = AppPalette.of(context);
|
||||
return Center(
|
||||
child: ConstrainedBox(
|
||||
constraints: const BoxConstraints(maxWidth: 360),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(24),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
CustomPaint(
|
||||
key: const ValueKey('task-empty-illustration'),
|
||||
size: const Size(148, 108),
|
||||
painter: _TaskEmptyIllustrationPainter(palette: palette),
|
||||
),
|
||||
const SizedBox(height: 18),
|
||||
Text(
|
||||
message ?? context.l10n.emptyTaskList,
|
||||
style: TextStyle(color: palette.textPrimary, fontSize: 17, fontWeight: FontWeight.w700),
|
||||
),
|
||||
],
|
||||
child: SingleChildScrollView(
|
||||
child: ConstrainedBox(
|
||||
constraints: const BoxConstraints(maxWidth: 360),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(24),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
CustomPaint(
|
||||
key: const ValueKey('task-empty-illustration'),
|
||||
size: const Size(148, 108),
|
||||
painter: _TaskEmptyIllustrationPainter(palette: palette),
|
||||
),
|
||||
const SizedBox(height: 18),
|
||||
Text(
|
||||
message ?? context.l10n.emptyTaskList,
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(color: palette.textPrimary, fontSize: 17, fontWeight: FontWeight.w700),
|
||||
),
|
||||
if (onCreateTask != null) ...[
|
||||
const SizedBox(height: AppDesignTokens.space24),
|
||||
TaskEmptyCreateHint(onCreateTask: onCreateTask!),
|
||||
],
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
Reference in new issue
Block a user