From 75462fe2bea7a6c730ce47ba47f0e12c1f993679 Mon Sep 17 00:00:00 2001 From: Levi Date: Sat, 12 Sep 2026 17:27:44 +0800 Subject: [PATCH] fix(ui): make mobile task creation button compact --- .../home/presentation/pages/home_page.dart | 3 ++- .../widgets/task_create_button.dart | 18 ++++++++++++++---- ui/flutter/test/widget_test.dart | 2 +- 3 files changed, 17 insertions(+), 6 deletions(-) diff --git a/ui/flutter/lib/features/home/presentation/pages/home_page.dart b/ui/flutter/lib/features/home/presentation/pages/home_page.dart index 4728259d..896e56ef 100644 --- a/ui/flutter/lib/features/home/presentation/pages/home_page.dart +++ b/ui/flutter/lib/features/home/presentation/pages/home_page.dart @@ -827,7 +827,8 @@ class _MobileTasksHeader extends StatelessWidget { child: TaskCreateButton( key: const ValueKey('tasks-mobile-create-button'), onPressed: onAddTask, - minHeight: 44, + minHeight: 34, + compact: true, ), ), const SizedBox(width: 8), diff --git a/ui/flutter/lib/features/tasks/presentation/widgets/task_create_button.dart b/ui/flutter/lib/features/tasks/presentation/widgets/task_create_button.dart index 44e9bd3e..465b7c2c 100644 --- a/ui/flutter/lib/features/tasks/presentation/widgets/task_create_button.dart +++ b/ui/flutter/lib/features/tasks/presentation/widgets/task_create_button.dart @@ -1,3 +1,4 @@ +import 'package:shadcn_flutter/shadcn_flutter.dart' as shad; import 'package:flutter/material.dart' show Icons; import 'package:flutter/widgets.dart'; @@ -7,10 +8,11 @@ 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}); + 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) { @@ -18,12 +20,20 @@ class TaskCreateButton extends StatelessWidget { constraints: BoxConstraints(minHeight: minHeight), child: AppPrimaryButton( onPressed: onPressed, + size: compact ? shad.ButtonSize.small : shad.ButtonSize.normal, child: Row( mainAxisSize: MainAxisSize.min, children: [ - const Icon(Icons.add), - const SizedBox(width: AppDesignTokens.space8), - Flexible(child: Text(context.l10n.create, maxLines: 1, overflow: TextOverflow.ellipsis)), + 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, + ), + ), ], ), ), diff --git a/ui/flutter/test/widget_test.dart b/ui/flutter/test/widget_test.dart index d47b99b1..2482a753 100644 --- a/ui/flutter/test/widget_test.dart +++ b/ui/flutter/test/widget_test.dart @@ -440,7 +440,7 @@ void main() { expect(find.text('Failed 0'), findsOneWidget); expect(find.text('Create Task'), findsNWidgets(2)); final headerCreate = find.byKey(const ValueKey('tasks-mobile-create-button')); - expect(tester.getSize(headerCreate).height, greaterThanOrEqualTo(44)); + expect(tester.getSize(headerCreate).height, 34); expect(tester.getBottomLeft(headerCreate).dy, lessThan(tester.getTopLeft(find.text('Downloading 0')).dy)); for (final size in [const Size(320, 568), const Size(768, 1024)]) { tester.view.physicalSize = size;