mirror of
https://github.com/GopeedLab/gopeed.git
synced 2026-11-15 12:53:41 +00:00
Merge branch 'main' into codex/fix-settings-script-path-picker
This commit is contained in:
52 files changed
+762
-144
No files matched your search
@@ -79,7 +79,7 @@ class _GopeedAppState extends ConsumerState<GopeedApp> with WidgetsBindingObserv
|
||||
return shad.ShadcnApp.router(
|
||||
debugShowCheckedModeBanner: false,
|
||||
disableBrowserContextMenu: false,
|
||||
onGenerateTitle: (context) => context.l10n.appTitle,
|
||||
title: 'Gopeed',
|
||||
theme: AppTheme.light(themeColor),
|
||||
darkTheme: AppTheme.dark(themeColor),
|
||||
materialTheme: isLightTheme ? AppTheme.materialLight(themeColor) : AppTheme.materialDark(themeColor),
|
||||
|
||||
@@ -28,6 +28,13 @@ class AndroidForegroundService {
|
||||
),
|
||||
);
|
||||
|
||||
// Android 13+ requires runtime permission to show the service notification.
|
||||
// A denial only hides it from the notification drawer; the service can run.
|
||||
final permission = await FlutterForegroundTask.checkNotificationPermission();
|
||||
if (permission == NotificationPermission.denied) {
|
||||
await FlutterForegroundTask.requestNotificationPermission();
|
||||
}
|
||||
|
||||
if (await FlutterForegroundTask.isRunningService) {
|
||||
_throwOnFailure(await FlutterForegroundTask.restartService());
|
||||
return;
|
||||
|
||||
@@ -2,14 +2,14 @@ import 'dart:async';
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_local_notifications/flutter_local_notifications.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:path_provider/path_provider.dart';
|
||||
import 'package:path/path.dart' as path;
|
||||
|
||||
import '../../core/common/task_event.dart';
|
||||
import '../../core/libgopeed_boot.dart';
|
||||
import '../../l10n/l10n.dart';
|
||||
import '../../util/log_util.dart';
|
||||
import '../../util/util.dart';
|
||||
import 'app_runtime_controller.dart';
|
||||
|
||||
@@ -28,13 +28,19 @@ class AppNotificationController extends AsyncNotifier<AppNotificationState> {
|
||||
StreamSubscription<TaskEvent>? _taskEventSubscription;
|
||||
var _notificationId = 0;
|
||||
|
||||
@visibleForTesting
|
||||
Stream<TaskEvent> get taskEvents => LibgopeedBoot.instance.taskEvents;
|
||||
|
||||
@override
|
||||
Future<AppNotificationState> build() async {
|
||||
final runtime = ref.watch(appRuntimeControllerProvider).value;
|
||||
if (runtime == null || kIsWeb || !Util.isDesktop()) {
|
||||
return const AppNotificationState();
|
||||
}
|
||||
await _initNotifications(appLocalizationsFor(runtime.downloaderConfig.extra.locale));
|
||||
await _initNotifications(
|
||||
appLocalizationsFor(runtime.downloaderConfig.extra.locale),
|
||||
requestPermissions: runtime.downloaderConfig.extra.desktopNotification,
|
||||
);
|
||||
_listenTaskEvents();
|
||||
ref.onDispose(() {
|
||||
unawaited(_taskEventSubscription?.cancel());
|
||||
@@ -42,11 +48,13 @@ class AppNotificationController extends AsyncNotifier<AppNotificationState> {
|
||||
return const AppNotificationState(started: true);
|
||||
}
|
||||
|
||||
Future<void> _initNotifications(AppLocalizations locale) async {
|
||||
const darwin = DarwinInitializationSettings(
|
||||
requestAlertPermission: false,
|
||||
Future<void> _initNotifications(AppLocalizations locale, {required bool requestPermissions}) async {
|
||||
// The runtime is watched, so enabling notifications in settings also
|
||||
// requests authorization. macOS remembers previously granted/denied access.
|
||||
final darwin = DarwinInitializationSettings(
|
||||
requestAlertPermission: requestPermissions,
|
||||
requestBadgePermission: false,
|
||||
requestSoundPermission: false,
|
||||
requestSoundPermission: requestPermissions,
|
||||
);
|
||||
final linux = LinuxInitializationSettings(
|
||||
defaultActionName: locale.open,
|
||||
@@ -56,13 +64,27 @@ class AppNotificationController extends AsyncNotifier<AppNotificationState> {
|
||||
String? windowsIconPath;
|
||||
try {
|
||||
if (Util.isWindows()) {
|
||||
final byteData = await rootBundle.load('assets/icon/icon.ico');
|
||||
final tempDir = await getTemporaryDirectory();
|
||||
final file = File('${tempDir.path}/notification_icon.ico');
|
||||
await file.writeAsBytes(byteData.buffer.asUint8List(byteData.offsetInBytes, byteData.lengthInBytes));
|
||||
windowsIconPath = file.path;
|
||||
// Windows requires a file path for IconUri, so use the bundled PNG
|
||||
// beside the executable rather than copying it to another directory.
|
||||
final file = File(
|
||||
path.join(
|
||||
path.dirname(Platform.resolvedExecutable),
|
||||
'data',
|
||||
'flutter_assets',
|
||||
'assets',
|
||||
'icon',
|
||||
'icon_512.png',
|
||||
),
|
||||
);
|
||||
if (await file.exists()) {
|
||||
windowsIconPath = file.absolute.path;
|
||||
} else {
|
||||
logger.w('Windows notification icon not found: ${file.path}');
|
||||
}
|
||||
}
|
||||
} catch (_) {}
|
||||
} catch (error, stackTrace) {
|
||||
logger.w('prepare Windows notification icon failed', error, stackTrace);
|
||||
}
|
||||
|
||||
final windows = WindowsInitializationSettings(
|
||||
appName: 'Gopeed',
|
||||
@@ -78,7 +100,7 @@ class AppNotificationController extends AsyncNotifier<AppNotificationState> {
|
||||
|
||||
void _listenTaskEvents() {
|
||||
_taskEventSubscription?.cancel();
|
||||
_taskEventSubscription = LibgopeedBoot.instance.taskEvents.listen((event) async {
|
||||
_taskEventSubscription = taskEvents.listen((event) async {
|
||||
final runtime = ref.read(appRuntimeControllerProvider).value;
|
||||
if (runtime?.downloaderConfig.extra.desktopNotification == false) return;
|
||||
final locale = appLocalizationsFor(runtime?.downloaderConfig.extra.locale ?? '');
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
import 'package:flutter/widgets.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import '../../features/tasks/application/task_list_navigation.dart';
|
||||
|
||||
import '../../features/extensions/presentation/pages/extensions_page.dart';
|
||||
import '../../features/extensions/presentation/pages/extension_details_page.dart';
|
||||
@@ -17,6 +19,13 @@ import 'shells/main_shell.dart';
|
||||
class AppRouter {
|
||||
static final GlobalKey<NavigatorState> rootNavigatorKey = GlobalKey<NavigatorState>();
|
||||
|
||||
static void showDownloadingTasks() {
|
||||
final context = rootNavigatorKey.currentContext;
|
||||
if (context == null || !context.mounted) return;
|
||||
ProviderScope.containerOf(context, listen: false).read(taskListNavigationProvider.notifier).showDownloading();
|
||||
GoRouter.of(context).go('/');
|
||||
}
|
||||
|
||||
static GoRouter build(WebAuthController webAuthController) {
|
||||
return GoRouter(
|
||||
navigatorKey: rootNavigatorKey,
|
||||
|
||||
@@ -16,12 +16,18 @@ import '../window/app_window_appearance.dart';
|
||||
import 'capability_rpc.dart';
|
||||
import 'gopeed_capability.dart';
|
||||
import 'storage_capability.dart';
|
||||
import 'app_navigation_capability.dart';
|
||||
import '../../app/router/app_router.dart';
|
||||
|
||||
class AppCapabilities {
|
||||
AppCapabilities(CapabilityInvoker invoker) : gopeed = GopeedService(invoker), storage = AppStorageService(invoker);
|
||||
AppCapabilities(CapabilityInvoker invoker)
|
||||
: gopeed = GopeedService(invoker),
|
||||
storage = AppStorageService(invoker),
|
||||
navigation = AppNavigationService(invoker);
|
||||
|
||||
final GopeedService gopeed;
|
||||
final AppStorageService storage;
|
||||
final AppNavigationService navigation;
|
||||
}
|
||||
|
||||
class LocalAppCapabilities {
|
||||
@@ -29,6 +35,10 @@ class LocalAppCapabilities {
|
||||
registry = CapabilityRegistry(codecs);
|
||||
_bindGopeed(registry);
|
||||
_bindStorage(registry);
|
||||
registry.bind(NavigationMethods.showDownloadingTasks, (_) {
|
||||
AppRouter.showDownloadingTasks();
|
||||
return const RpcUnit();
|
||||
});
|
||||
capabilities = AppCapabilities(LocalCapabilityInvoker(registry));
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
import 'capability_rpc.dart';
|
||||
|
||||
abstract final class NavigationMethods {
|
||||
static const showDownloadingTasks = RpcMethod<RpcUnit, RpcUnit>('navigation.tasks.downloading');
|
||||
}
|
||||
|
||||
class AppNavigationService {
|
||||
const AppNavigationService(this._invoker);
|
||||
|
||||
final CapabilityInvoker _invoker;
|
||||
|
||||
Future<void> showDownloadingTasks() async {
|
||||
await _invoker.invoke(NavigationMethods.showDownloadingTasks, const RpcUnit());
|
||||
}
|
||||
}
|
||||
@@ -16,6 +16,7 @@ class AppWindowBootstrap {
|
||||
await windowManager.ensureInitialized();
|
||||
|
||||
final windowOptions = WindowOptions(
|
||||
title: 'Gopeed',
|
||||
size: const Size(1024, 768),
|
||||
center: true,
|
||||
skipTaskbar: false,
|
||||
@@ -74,8 +75,8 @@ class AppWindowBootstrap {
|
||||
|
||||
static String subWindowTitle(AppWindowType type, AppLocalizations l10n) {
|
||||
return switch (type) {
|
||||
AppWindowType.createTask => '${l10n.create} - Gopeed',
|
||||
_ => l10n.appTitle,
|
||||
AppWindowType.createTask => 'Gopeed - ${l10n.create}',
|
||||
_ => 'Gopeed',
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -633,6 +633,7 @@ class _Toolbar extends StatelessWidget {
|
||||
final search = AppTextField(
|
||||
key: const ValueKey('extension-search-input'),
|
||||
controller: searchController,
|
||||
padding: MediaQuery.sizeOf(context).width >= Breakpoints.mobile ? AppDesignTokens.compactTextFieldPadding : null,
|
||||
placeholder: Text(context.l10n.searchExtensions, style: TextStyle(color: palette.searchHint)),
|
||||
features: [shad.InputFeature.leading(Icon(Icons.search_rounded, size: 16, color: palette.textMuted))],
|
||||
onSubmitted: onSearch,
|
||||
|
||||
@@ -19,6 +19,7 @@ import '../../../../shared/widgets/responsive_navigation_layout.dart';
|
||||
import '../../../../l10n/l10n.dart';
|
||||
import '../../../../util/util.dart';
|
||||
import '../../../tasks/application/tasks_controller.dart';
|
||||
import '../../../tasks/application/task_list_navigation.dart';
|
||||
import '../../../tasks/application/pending_update_task.dart';
|
||||
import '../../../tasks/application/task_batch_selection_controller.dart';
|
||||
import '../../../tasks/domain/task_record.dart';
|
||||
@@ -86,6 +87,11 @@ class _HomePageState extends ConsumerState<HomePage> {
|
||||
Widget build(BuildContext context) {
|
||||
final palette = AppPalette.of(context);
|
||||
final tasksAsync = ref.watch(tasksControllerProvider);
|
||||
ref.listen(taskListNavigationProvider, (_, _) {
|
||||
_searchController.clear();
|
||||
_setActiveFilter(_TaskFilter.downloading);
|
||||
setState(() => _batchMode = false);
|
||||
});
|
||||
final tasksState = tasksAsync.value;
|
||||
final tasks = tasksState?.tasks ?? const <TaskRecord>[];
|
||||
final filteredTasks = _filteredTasks(tasks);
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
|
||||
final taskListNavigationProvider = NotifierProvider<TaskListNavigation, int>(TaskListNavigation.new);
|
||||
|
||||
// A request also resets an already-visible list's filter, search and selection.
|
||||
class TaskListNavigation extends Notifier<int> {
|
||||
@override
|
||||
int build() => 0;
|
||||
|
||||
void showDownloading() => state++;
|
||||
}
|
||||
@@ -29,9 +29,9 @@ import '../../../../shared/theme/app_design_tokens.dart';
|
||||
import '../../../../shared/theme/app_palette.dart';
|
||||
import '../../../../shared/widgets/app_choice_segmented_control.dart';
|
||||
import '../../../../shared/widgets/app_http_headers_editor.dart';
|
||||
import '../../../../shared/widgets/app_loading_button.dart';
|
||||
import '../../../../shared/widgets/app_number_input.dart';
|
||||
import '../../../../shared/widgets/app_path_picker_field.dart';
|
||||
import '../../../../shared/widgets/app_primary_button.dart';
|
||||
import '../../../../shared/widgets/app_text_field.dart';
|
||||
import '../../../../shared/widgets/app_tooltip.dart';
|
||||
import '../../../../shared/widgets/app_toast.dart';
|
||||
@@ -39,6 +39,7 @@ import '../../../../l10n/l10n.dart';
|
||||
import '../../../../util/util.dart';
|
||||
import '../../application/pending_create_task.dart';
|
||||
import '../widgets/resolve_file_tree.dart';
|
||||
import '../widgets/resolve_task_actions.dart';
|
||||
|
||||
class CreateTaskWindowPage extends ConsumerStatefulWidget {
|
||||
const CreateTaskWindowPage({super.key, this.windowController, this.initialTask});
|
||||
@@ -87,6 +88,7 @@ class _CreateTaskWindowPageState extends ConsumerState<CreateTaskWindowPage> {
|
||||
String _configuredDownloadDirectory = '';
|
||||
String _fileDataUri = '';
|
||||
bool _programmaticUrlChange = false;
|
||||
String _lastUrlText = '';
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
@@ -172,10 +174,15 @@ class _CreateTaskWindowPageState extends ConsumerState<CreateTaskWindowPage> {
|
||||
}
|
||||
|
||||
void _handleUrlChanged() {
|
||||
if (!_programmaticUrlChange && _fileDataUri.isNotEmpty) {
|
||||
_fileDataUri = '';
|
||||
final urlText = _urlController.text;
|
||||
if (urlText != _lastUrlText) {
|
||||
_lastUrlText = urlText;
|
||||
_renameController.clear();
|
||||
if (!_programmaticUrlChange && _fileDataUri.isNotEmpty) {
|
||||
_fileDataUri = '';
|
||||
}
|
||||
}
|
||||
_recognizeMagnetUri(_urlController.text.trim());
|
||||
_recognizeMagnetUri(urlText.trim());
|
||||
}
|
||||
|
||||
void _applyInitialTask(CreateTask? task) {
|
||||
@@ -220,9 +227,6 @@ class _CreateTaskWindowPageState extends ConsumerState<CreateTaskWindowPage> {
|
||||
}
|
||||
}
|
||||
if (opts != null) {
|
||||
if (opts.name.isNotEmpty) {
|
||||
_renameController.text = opts.name;
|
||||
}
|
||||
if (opts.path.isNotEmpty) {
|
||||
_directoryController.text = opts.path;
|
||||
}
|
||||
@@ -370,18 +374,12 @@ class _CreateTaskWindowPageState extends ConsumerState<CreateTaskWindowPage> {
|
||||
const SizedBox(height: 16),
|
||||
_FormRow(
|
||||
label: context.l10n.connections,
|
||||
child: Align(
|
||||
alignment: Alignment.centerLeft,
|
||||
child: SizedBox(
|
||||
width: AppDesignTokens.settingsNumberControlWidth,
|
||||
child: AppNumberInput(
|
||||
fieldKey: const ValueKey('create-task-connections-input'),
|
||||
controller: _connectionsController,
|
||||
min: 1,
|
||||
max: 256,
|
||||
hintText: context.l10n.enterCount,
|
||||
),
|
||||
),
|
||||
child: AppNumberInput(
|
||||
fieldKey: const ValueKey('create-task-connections-input'),
|
||||
controller: _connectionsController,
|
||||
min: 1,
|
||||
max: 256,
|
||||
hintText: context.l10n.enterCount,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
@@ -396,10 +394,6 @@ class _CreateTaskWindowPageState extends ConsumerState<CreateTaskWindowPage> {
|
||||
pickerKey: const ValueKey('create-task-directory-picker'),
|
||||
controller: _directoryController,
|
||||
hintText: context.l10n.chooseDownloadDirectory,
|
||||
filled: true,
|
||||
border: Border.all(color: palette.border),
|
||||
borderRadius: BorderRadius.circular(AppDesignTokens.controlRadius),
|
||||
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 10),
|
||||
onChanged: (_) {
|
||||
if (_asDefaultPath) {
|
||||
setState(() => _asDefaultPath = false);
|
||||
@@ -707,16 +701,12 @@ class _CreateTaskWindowPageState extends ConsumerState<CreateTaskWindowPage> {
|
||||
child: SizedBox(width: 68, child: Center(child: Text(context.l10n.cancel))),
|
||||
),
|
||||
const SizedBox(width: 12),
|
||||
AppPrimaryButton(
|
||||
onPressed: _creating ? null : _confirm,
|
||||
child: SizedBox(
|
||||
width: 68,
|
||||
child: Center(
|
||||
child: _creating
|
||||
? const SizedBox.square(dimension: 14, child: CircularProgressIndicator())
|
||||
: Text(context.l10n.confirm),
|
||||
),
|
||||
),
|
||||
AppLoadingButton(
|
||||
key: const ValueKey('create-task-confirm-button'),
|
||||
onPressed: _confirm,
|
||||
loading: _creating,
|
||||
variant: AppLoadingButtonVariant.primary,
|
||||
child: SizedBox(width: 68, child: Center(child: Text(context.l10n.confirm))),
|
||||
),
|
||||
],
|
||||
),
|
||||
@@ -737,6 +727,19 @@ class _CreateTaskWindowPageState extends ConsumerState<CreateTaskWindowPage> {
|
||||
await windowManager.close();
|
||||
}
|
||||
|
||||
Future<void> _finishCreation() async {
|
||||
if (widget.windowController != null) {
|
||||
// Navigation is best-effort after a successful submission. A navigation
|
||||
// failure must not leave a completed form available for resubmission.
|
||||
try {
|
||||
await ref.read(appCapabilitiesProvider).navigation.showDownloadingTasks();
|
||||
} catch (error) {
|
||||
debugPrint('Unable to select downloading tasks: $error');
|
||||
}
|
||||
}
|
||||
await _closeWindow();
|
||||
}
|
||||
|
||||
Future<void> _loadDefaults() async {
|
||||
try {
|
||||
final config = await ref.read(gopeedServiceProvider).getConfig();
|
||||
@@ -863,7 +866,7 @@ class _CreateTaskWindowPageState extends ConsumerState<CreateTaskWindowPage> {
|
||||
);
|
||||
}),
|
||||
);
|
||||
await _closeWindow();
|
||||
await _finishCreation();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -871,7 +874,6 @@ class _CreateTaskWindowPageState extends ConsumerState<CreateTaskWindowPage> {
|
||||
final options = _buildOptions();
|
||||
final result = await ref.read(gopeedServiceProvider).resolve(ResolveTask(req: request, opts: options));
|
||||
if (!mounted) return;
|
||||
_syncResolvedName(result);
|
||||
final created = await _showResolveDialog(request, result);
|
||||
if (!created) {
|
||||
if (mounted) {
|
||||
@@ -879,7 +881,7 @@ class _CreateTaskWindowPageState extends ConsumerState<CreateTaskWindowPage> {
|
||||
}
|
||||
return;
|
||||
}
|
||||
await _closeWindow();
|
||||
await _finishCreation();
|
||||
} catch (error) {
|
||||
if (mounted) {
|
||||
_showToast(error.toString());
|
||||
@@ -1156,19 +1158,11 @@ class _CreateTaskWindowPageState extends ConsumerState<CreateTaskWindowPage> {
|
||||
),
|
||||
),
|
||||
actions: [
|
||||
SecondaryButton(
|
||||
onPressed: submitting ? null : () => closeOverlay(dialogContext, false),
|
||||
child: SizedBox(width: 68, child: Center(child: Text(dialogContext.l10n.cancel))),
|
||||
),
|
||||
AppPrimaryButton(
|
||||
onPressed: submitting ? null : submit,
|
||||
child: SizedBox(
|
||||
width: 68,
|
||||
child: Center(
|
||||
child: submitting
|
||||
? const SizedBox.square(dimension: 14, child: CircularProgressIndicator())
|
||||
: Text(dialogContext.l10n.create),
|
||||
),
|
||||
flutter.Flexible(
|
||||
child: ResolveTaskActions(
|
||||
submitting: submitting,
|
||||
onCancel: () => closeOverlay(dialogContext, false),
|
||||
onCreate: submit,
|
||||
),
|
||||
),
|
||||
],
|
||||
@@ -1331,12 +1325,6 @@ class _CreateTaskWindowPageState extends ConsumerState<CreateTaskWindowPage> {
|
||||
filterController.dispose();
|
||||
}
|
||||
|
||||
void _syncResolvedName(ResolveResult result) {
|
||||
if (_renameController.text.trim().isEmpty && result.res.name.trim().isNotEmpty) {
|
||||
_renameController.text = result.res.name;
|
||||
}
|
||||
}
|
||||
|
||||
void _setUrlText(String value, {String fileDataUri = ''}) {
|
||||
_programmaticUrlChange = true;
|
||||
_urlController.text = value;
|
||||
@@ -1678,17 +1666,12 @@ class _WindowTextField extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final palette = AppPalette.of(context);
|
||||
return AppTextField(
|
||||
controller: controller,
|
||||
hintText: hintText,
|
||||
keyboardType: keyboardType,
|
||||
inputFormatters: inputFormatters,
|
||||
obscureText: obscureText,
|
||||
filled: true,
|
||||
border: Border.all(color: palette.border),
|
||||
borderRadius: BorderRadius.circular(4),
|
||||
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 10),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -61,6 +61,8 @@ class _ResolveFileTreeState extends State<ResolveFileTree> {
|
||||
child: FileTreeView<int>(
|
||||
items: _treeItems,
|
||||
keyPrefix: 'resolve-tree',
|
||||
rowHeight: _resolveTreeRowHeight,
|
||||
contentTextStyle: _resolveFileNameStyle,
|
||||
headerLeading: ExcludeFocus(
|
||||
child: Checkbox(
|
||||
state: allSelected
|
||||
@@ -336,3 +338,5 @@ extension on _FileTypeFilter {
|
||||
const _videoExts = <String>{'mp4', 'mkv', 'avi', 'mov', 'wmv', 'flv', 'webm', 'm4v'};
|
||||
const _audioExts = <String>{'mp3', 'flac', 'wav', 'aac', 'm4a', 'ogg', 'ape'};
|
||||
const _imageExts = <String>{'jpg', 'jpeg', 'png', 'gif', 'bmp', 'webp', 'svg'};
|
||||
const _resolveTreeRowHeight = 36.0;
|
||||
const _resolveFileNameStyle = TextStyle(fontSize: 14, height: 1.25);
|
||||
@@ -0,0 +1,50 @@
|
||||
import 'package:shadcn_flutter/shadcn_flutter.dart';
|
||||
import 'package:flutter/widgets.dart' as flutter;
|
||||
|
||||
import '../../../../l10n/l10n.dart';
|
||||
import '../../../../shared/theme/app_design_tokens.dart';
|
||||
import '../../../../shared/widgets/app_loading_button.dart';
|
||||
|
||||
class ResolveTaskActions extends StatelessWidget {
|
||||
const ResolveTaskActions({super.key, required this.submitting, required this.onCancel, required this.onCreate});
|
||||
|
||||
final bool submitting;
|
||||
final VoidCallback onCancel;
|
||||
final VoidCallback onCreate;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
// Size both actions from the wider translated label, including while the
|
||||
// create button replaces its label with a loader.
|
||||
return IntrinsicWidth(
|
||||
child: flutter.Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
flutter.Expanded(
|
||||
child: ConstrainedBox(
|
||||
constraints: const BoxConstraints(minWidth: AppDesignTokens.dialogActionMinWidth),
|
||||
child: SecondaryButton(
|
||||
key: const ValueKey('resolve-cancel-button'),
|
||||
onPressed: submitting ? null : onCancel,
|
||||
child: Text(context.l10n.cancel, maxLines: 1, softWrap: false),
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(width: AppDesignTokens.space8),
|
||||
flutter.Expanded(
|
||||
child: ConstrainedBox(
|
||||
constraints: const BoxConstraints(minWidth: AppDesignTokens.dialogActionMinWidth),
|
||||
child: AppLoadingButton(
|
||||
key: const ValueKey('resolve-create-button'),
|
||||
onPressed: onCreate,
|
||||
loading: submitting,
|
||||
variant: AppLoadingButtonVariant.primary,
|
||||
child: Text(context.l10n.createAction, maxLines: 1, softWrap: false),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -18,6 +18,7 @@
|
||||
"exit": "خروج",
|
||||
"pressBackAgainToExit": "اضغط زر الرجوع مرة أخرى للخروج",
|
||||
"create": "إنشاء مهمة",
|
||||
"createAction": "إنشاء",
|
||||
"directDownload": "تنزيل مباشر",
|
||||
"advancedOptions": "خيارات متقدمة",
|
||||
"followSettings": "اتباع الإعدادات",
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
"exit": "Çıxış",
|
||||
"pressBackAgainToExit": "Çıxmaq üçün yenidən geri düyməsinə basın",
|
||||
"create": "Tapşırıq yarat",
|
||||
"createAction": "Yarat",
|
||||
"directDownload": "Birbaşa Endirmə",
|
||||
"advancedOptions": "Əlavə Seçimlər",
|
||||
"followSettings": "Parametrlərə uyğun",
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
"exit": "Surt",
|
||||
"pressBackAgainToExit": "Torna a prémer enrere per sortir",
|
||||
"create": "Crea una tasca",
|
||||
"createAction": "Crea",
|
||||
"directDownload": "Baixada directa",
|
||||
"advancedOptions": "Opcions avançades",
|
||||
"followSettings": "Segueix la configuració",
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
"exit": "Beenden",
|
||||
"pressBackAgainToExit": "Drücken Sie erneut Zurück, um die App zu beenden",
|
||||
"create": "Aufgabe Erstellen",
|
||||
"createAction": "Erstellen",
|
||||
"directDownload": "Direkter Download",
|
||||
"advancedOptions": "Erweiterte Einstellungen",
|
||||
"followSettings": "Einstellungen Folgen",
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
"exit": "Exit",
|
||||
"pressBackAgainToExit": "Press back again to exit",
|
||||
"create": "Create Task",
|
||||
"createAction": "Create",
|
||||
"directDownload": "Direct Download",
|
||||
"advancedOptions": "Advanced Options",
|
||||
"followSettings": "Follow Settings",
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
"exit": "Salir",
|
||||
"pressBackAgainToExit": "Pulsa Atrás de nuevo para salir",
|
||||
"create": "Crear Tarea",
|
||||
"createAction": "Crear",
|
||||
"directDownload": "Descarga Directa",
|
||||
"advancedOptions": "Opciones Avanzadas",
|
||||
"followSettings": "Siga las opciones",
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
"exit": "خروج",
|
||||
"pressBackAgainToExit": "برای خروج دوباره دکمه بازگشت را فشار دهید",
|
||||
"create": "ایجاد کار",
|
||||
"createAction": "ایجاد",
|
||||
"directDownload": "دانلود مستقیم",
|
||||
"advancedOptions": "گزینه های پیشرفته",
|
||||
"followSettings": "تنظیمات را دنبال کنید",
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
"exit": "Quitter",
|
||||
"pressBackAgainToExit": "Appuyez à nouveau sur Retour pour quitter",
|
||||
"create": "Créer une tâche",
|
||||
"createAction": "Créer",
|
||||
"directDownload": "Téléchargement direct",
|
||||
"advancedOptions": "Options avancées",
|
||||
"followSettings": "Suivre les paramètres",
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
"exit": "Kilépés",
|
||||
"pressBackAgainToExit": "Nyomja meg újra a Vissza gombot a kilépéshez",
|
||||
"create": "Feladat létrehozása",
|
||||
"createAction": "Létrehozás",
|
||||
"directDownload": "Közvetlen letöltés",
|
||||
"advancedOptions": "Haladó beállítások",
|
||||
"followSettings": "Beállítások követése",
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
"exit": "Keluar",
|
||||
"pressBackAgainToExit": "Tekan kembali sekali lagi untuk keluar",
|
||||
"create": "Membuat Tugas",
|
||||
"createAction": "Buat",
|
||||
"directDownload": "Unduhan Langsung",
|
||||
"advancedOptions": "Pengaturan Lanjutan",
|
||||
"followSettings": "Mengikuti Pengaturan",
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
"exit": "Uscita",
|
||||
"pressBackAgainToExit": "Premi di nuovo Indietro per uscire",
|
||||
"create": "Crea attività",
|
||||
"createAction": "Crea",
|
||||
"directDownload": "Scaricamento diretto",
|
||||
"advancedOptions": "Opzioni avanzate",
|
||||
"followSettings": "Seguire le impostazioni",
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
"exit": "終了",
|
||||
"pressBackAgainToExit": "もう一度戻るボタンを押すと終了します",
|
||||
"create": "タスクを作成",
|
||||
"createAction": "作成",
|
||||
"directDownload": "直接ダウンロード",
|
||||
"advancedOptions": "詳細オプション",
|
||||
"followSettings": "設定に従う",
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
"exit": "종료",
|
||||
"pressBackAgainToExit": "종료하려면 뒤로 버튼을 한 번 더 누르세요",
|
||||
"create": "작업 생성",
|
||||
"createAction": "생성",
|
||||
"directDownload": "바로 다운로드",
|
||||
"advancedOptions": "고급 옵션",
|
||||
"followSettings": "설정값 사용",
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
"exit": "Wyjście",
|
||||
"pressBackAgainToExit": "Naciśnij ponownie Wstecz, aby wyjść",
|
||||
"create": "Utwórz zadanie",
|
||||
"createAction": "Utwórz",
|
||||
"directDownload": "Pobieranie bezpośrednie",
|
||||
"advancedOptions": "Zaawansowane",
|
||||
"followSettings": "Podążaj za ustawieniami",
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
"exit": "Sair",
|
||||
"pressBackAgainToExit": "Prima novamente Voltar para sair",
|
||||
"create": "Criar Tarefa",
|
||||
"createAction": "Criar",
|
||||
"directDownload": "Download Direto",
|
||||
"advancedOptions": "Opções Avançadas",
|
||||
"followSettings": "Seguir as Configurações",
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
"exit": "Выход",
|
||||
"pressBackAgainToExit": "Нажмите «Назад» ещё раз, чтобы выйти",
|
||||
"create": "Создать задачу",
|
||||
"createAction": "Создать",
|
||||
"directDownload": "Прямая загрузка",
|
||||
"advancedOptions": "Расширенные опции",
|
||||
"followSettings": "По умолчанию",
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
"exit": "வெளியேறு",
|
||||
"pressBackAgainToExit": "வெளியேற மீண்டும் பின்செல் பொத்தானை அழுத்தவும்",
|
||||
"create": "பணியை உருவாக்கு",
|
||||
"createAction": "உருவாக்கு",
|
||||
"directDownload": "நேரடி பதிவிறக்கம்",
|
||||
"advancedOptions": "மேம்பட்ட விருப்பங்கள்",
|
||||
"followSettings": "அமைப்புகளைப் பின்தொடரவும்",
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
"exit": "Çıkış",
|
||||
"pressBackAgainToExit": "Çıkmak için tekrar geri tuşuna basın",
|
||||
"create": "İşlem Oluştur",
|
||||
"createAction": "Oluştur",
|
||||
"directDownload": "Direkt İndir",
|
||||
"advancedOptions": "Gelişmiş Seçenekler",
|
||||
"followSettings": "Ayarları Takip Et",
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
"exit": "Вихід",
|
||||
"pressBackAgainToExit": "Натисніть «Назад» ще раз, щоб вийти",
|
||||
"create": "Створити завдання",
|
||||
"createAction": "Створити",
|
||||
"directDownload": "Пряме завантаження",
|
||||
"advancedOptions": "Додаткові параметри",
|
||||
"followSettings": "За замовчуванням",
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
"exit": "Thoát",
|
||||
"pressBackAgainToExit": "Nhấn quay lại lần nữa để thoát",
|
||||
"create": "Tạo nhiệm vụ",
|
||||
"createAction": "Tạo",
|
||||
"directDownload": "Tải trực tiếp",
|
||||
"advancedOptions": "Tùy chọn nâng cao",
|
||||
"followSettings": "Theo thiết lập",
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
"exit": "退出",
|
||||
"pressBackAgainToExit": "再按一次返回键退出应用",
|
||||
"create": "创建任务",
|
||||
"createAction": "创建",
|
||||
"directDownload": "直接下载",
|
||||
"advancedOptions": "高级选项",
|
||||
"followSettings": "跟随设置",
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
"exit": "退出",
|
||||
"pressBackAgainToExit": "再按一次返回鍵退出應用程式",
|
||||
"create": "建立任務",
|
||||
"createAction": "建立",
|
||||
"directDownload": "直接下載",
|
||||
"advancedOptions": "進階選項",
|
||||
"followSettings": "跟隨設定",
|
||||
|
||||
@@ -18,42 +18,50 @@ class AppComponentThemes extends StatelessWidget {
|
||||
align: 1,
|
||||
border: Border.all(color: theme.colorScheme.ring.withValues(alpha: 0.65), width: 1),
|
||||
),
|
||||
child: shad.ComponentTheme<shad.SecondaryButtonTheme>(
|
||||
data: shad.SecondaryButtonTheme(
|
||||
decoration: (context, states, value) {
|
||||
final decoration = switch (value) {
|
||||
final BoxDecoration decoration => decoration,
|
||||
_ => BoxDecoration(borderRadius: BorderRadius.circular(theme.radiusMd)),
|
||||
};
|
||||
if (states.contains(WidgetState.disabled)) {
|
||||
return decoration.copyWith(color: palette.surfaceSoft);
|
||||
}
|
||||
if (theme.brightness == Brightness.light) {
|
||||
final background = Color.alphaBlend(palette.textPrimary.withValues(alpha: 0.08), palette.surfaceSoft);
|
||||
final hoverBackground = Color.alphaBlend(
|
||||
palette.textPrimary.withValues(alpha: 0.13),
|
||||
palette.surfaceSoft,
|
||||
);
|
||||
return decoration.copyWith(color: states.contains(WidgetState.hovered) ? hoverBackground : background);
|
||||
}
|
||||
return value;
|
||||
},
|
||||
textStyle: (context, states, value) => states.contains(WidgetState.disabled)
|
||||
? value.copyWith(color: palette.textMuted.withValues(alpha: 0.62))
|
||||
: value,
|
||||
iconTheme: (context, states, value) => states.contains(WidgetState.disabled)
|
||||
? value.copyWith(color: palette.textMuted.withValues(alpha: 0.62))
|
||||
: value,
|
||||
child: shad.ComponentTheme<shad.TextFieldTheme>(
|
||||
data: shad.TextFieldTheme(
|
||||
filled: true,
|
||||
border: Border.all(color: palette.border),
|
||||
borderRadius: BorderRadius.circular(AppDesignTokens.controlRadius),
|
||||
padding: AppDesignTokens.textFieldPadding,
|
||||
),
|
||||
child: shad.ComponentTheme<shad.CheckboxTheme>(
|
||||
data: shad.CheckboxTheme(
|
||||
size: AppDesignTokens.checkboxSize,
|
||||
gap: AppDesignTokens.checkboxLabelGap,
|
||||
borderColor: theme.brightness == Brightness.dark ? palette.textMuted : palette.border,
|
||||
child: shad.ComponentTheme<shad.SecondaryButtonTheme>(
|
||||
data: shad.SecondaryButtonTheme(
|
||||
decoration: (context, states, value) {
|
||||
final decoration = switch (value) {
|
||||
final BoxDecoration decoration => decoration,
|
||||
_ => BoxDecoration(borderRadius: BorderRadius.circular(theme.radiusMd)),
|
||||
};
|
||||
if (states.contains(WidgetState.disabled)) {
|
||||
return decoration.copyWith(color: palette.surfaceSoft);
|
||||
}
|
||||
if (theme.brightness == Brightness.light) {
|
||||
final background = Color.alphaBlend(palette.textPrimary.withValues(alpha: 0.08), palette.surfaceSoft);
|
||||
final hoverBackground = Color.alphaBlend(
|
||||
palette.textPrimary.withValues(alpha: 0.13),
|
||||
palette.surfaceSoft,
|
||||
);
|
||||
return decoration.copyWith(color: states.contains(WidgetState.hovered) ? hoverBackground : background);
|
||||
}
|
||||
return value;
|
||||
},
|
||||
textStyle: (context, states, value) => states.contains(WidgetState.disabled)
|
||||
? value.copyWith(color: palette.textMuted.withValues(alpha: 0.62))
|
||||
: value,
|
||||
iconTheme: (context, states, value) => states.contains(WidgetState.disabled)
|
||||
? value.copyWith(color: palette.textMuted.withValues(alpha: 0.62))
|
||||
: value,
|
||||
),
|
||||
child: shad.ComponentTheme<shad.ToastTheme>(
|
||||
data: const shad.ToastTheme(toastConstraints: BoxConstraints(maxWidth: 420)),
|
||||
child: child,
|
||||
child: shad.ComponentTheme<shad.CheckboxTheme>(
|
||||
data: shad.CheckboxTheme(
|
||||
size: AppDesignTokens.checkboxSize,
|
||||
gap: AppDesignTokens.checkboxLabelGap,
|
||||
borderColor: theme.brightness == Brightness.dark ? palette.textMuted : palette.border,
|
||||
),
|
||||
child: shad.ComponentTheme<shad.ToastTheme>(
|
||||
data: const shad.ToastTheme(toastConstraints: BoxConstraints(maxWidth: 420)),
|
||||
child: child,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
@@ -10,6 +10,7 @@ class AppDesignTokens {
|
||||
static const double contentHeaderHeight = 48;
|
||||
static const double taskRowHeight = 72;
|
||||
static const double controlRadius = 4;
|
||||
static const double dialogActionMinWidth = 100;
|
||||
static const double checkboxSize = 18;
|
||||
static const double checkboxLabelGap = 10;
|
||||
static const double taskDetailsDrawerMinWidth = 440;
|
||||
@@ -21,6 +22,9 @@ class AppDesignTokens {
|
||||
static const double settingsFormControlWidth = 420;
|
||||
static const double settingsNumberControlWidth = 168;
|
||||
static const double settingsItemMinLabelWidth = 160;
|
||||
static const EdgeInsets textFieldPadding = EdgeInsets.symmetric(horizontal: 12, vertical: 11);
|
||||
static const EdgeInsets compactTextFieldPadding = EdgeInsets.symmetric(horizontal: 12, vertical: 6);
|
||||
static const EdgeInsets numberTextFieldPadding = EdgeInsets.symmetric(horizontal: 12, vertical: 10);
|
||||
|
||||
static const EdgeInsets pagePadding = EdgeInsets.symmetric(horizontal: 32);
|
||||
static const EdgeInsets sidebarPadding = EdgeInsets.symmetric(horizontal: 16);
|
||||
|
||||
@@ -30,7 +30,15 @@ class AppLoadingButton extends StatelessWidget {
|
||||
final palette = AppPalette.of(context);
|
||||
final replaceChild = loading && icon == null;
|
||||
final leading = loading && icon != null ? _LoadingIcon(variant: variant) : icon;
|
||||
final effectiveChild = replaceChild ? _LoadingIcon(variant: variant) : child;
|
||||
final effectiveChild = replaceChild
|
||||
? Stack(
|
||||
alignment: Alignment.center,
|
||||
children: [
|
||||
ExcludeSemantics(child: Opacity(opacity: 0, child: child)),
|
||||
Positioned.fill(child: _LoadingIcon(variant: variant)),
|
||||
],
|
||||
)
|
||||
: child;
|
||||
final content = leading == null
|
||||
? effectiveChild
|
||||
: Row(
|
||||
|
||||
@@ -2,6 +2,7 @@ import 'package:flutter/services.dart';
|
||||
import 'package:flutter/widgets.dart';
|
||||
import 'package:shadcn_flutter/shadcn_flutter.dart' as shad;
|
||||
|
||||
import '../theme/app_design_tokens.dart';
|
||||
import 'app_text_field.dart';
|
||||
|
||||
/// A bounded numeric text field with the app's standard spinner controls.
|
||||
@@ -91,6 +92,7 @@ class _AppNumberInputState extends State<AppNumberInput> {
|
||||
: TextInputType.number,
|
||||
inputFormatters: formatters,
|
||||
enabled: widget.enabled,
|
||||
padding: AppDesignTokens.numberTextFieldPadding,
|
||||
features: [
|
||||
shad.InputFeature.spinner(
|
||||
step: widget.step,
|
||||
|
||||
Reference in new issue
Block a user