merge: latest PR #1488 mobile resolve action layout

This commit is contained in:
Levi committed 2026-09-08 22:14:14 +08:00
commit b0aecdcfc6
5 files changed
+140 -13

No files matched your search

@@ -376,9 +376,7 @@ void main() {
expect(submitted?.opts?.name, isEmpty);
});
testWidgets('resolved task keeps rename empty and uses a single-line intrinsic create action', (
WidgetTester tester,
) async {
testWidgets('resolved task keeps rename empty and uses equal-width single-line actions', (WidgetTester tester) async {
tester.view.physicalSize = const Size(700, 700);
tester.view.devicePixelRatio = 1;
addTearDown(tester.view.resetPhysicalSize);
@@ -422,6 +420,10 @@ void main() {
expect(createText.data, 'Create');
expect(createText.maxLines, 1);
expect(createText.softWrap, isFalse);
expect(
tester.getSize(find.byKey(const ValueKey('resolve-cancel-button'))),
tester.getSize(find.byKey(const ValueKey('resolve-create-button'))),
);
expect(tester.takeException(), isNull);
});
@@ -0,0 +1,77 @@
import 'package:flutter/widgets.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:gopeed/features/tasks/presentation/widgets/resolve_task_actions.dart';
import 'package:gopeed/l10n/l10n.dart';
import 'package:gopeed/shared/theme/app_component_themes.dart';
import 'package:gopeed/shared/theme/app_theme.dart';
import 'package:gopeed/shared/widgets/app_loading_button.dart';
import 'package:shadcn_flutter/shadcn_flutter.dart' as shad;
void main() {
for (final width in [390.0, 1024.0]) {
for (final language in ['en', 'zh', 'de']) {
testWidgets('resolve actions stay equal at $width in $language, including loading', (tester) async {
tester.view.physicalSize = Size(width, 760);
tester.view.devicePixelRatio = 1;
addTearDown(tester.view.resetPhysicalSize);
addTearDown(tester.view.resetDevicePixelRatio);
var submitting = false;
var cancelled = false;
await tester.pumpWidget(
shad.ShadcnApp(
localizationsDelegates: AppLocalizations.localizationsDelegates,
supportedLocales: AppLocalizations.supportedLocales,
theme: AppTheme.light(),
materialTheme: AppTheme.materialLight(),
home: Builder(
builder: (context) => Localizations.override(
context: context,
locale: Locale(language),
delegates: const [AppLocalizations.delegate],
child: AppComponentThemes(
child: Center(
child: StatefulBuilder(
builder: (context, setState) => shad.AlertDialog(
padding: const EdgeInsets.all(18),
content: SizedBox(width: width < 760 ? width - 32 : 720, height: 100),
actions: [
Flexible(
child: ResolveTaskActions(
submitting: submitting,
onCancel: () => cancelled = true,
onCreate: () => setState(() => submitting = true),
),
),
],
),
),
),
),
),
),
),
);
await tester.pumpAndSettle();
final cancel = find.byKey(const ValueKey('resolve-cancel-button'));
final create = find.byKey(const ValueKey('resolve-create-button'));
final cancelRect = tester.getRect(cancel);
final createRect = tester.getRect(create);
expect(cancelRect.size, createRect.size);
expect(cancelRect.center.dy, createRect.center.dy);
expect(cancelRect.left, greaterThanOrEqualTo(0));
expect(createRect.right, lessThanOrEqualTo(width));
expect(find.text(appLocalizationsFor(language).createAction), findsOneWidget);
await tester.tap(cancel);
expect(cancelled, isTrue);
await tester.tap(create);
await tester.pump();
await tester.pump(const Duration(milliseconds: 200));
expect(tester.widget<AppLoadingButton>(create).loading, isTrue);
expect(tester.widget<shad.SecondaryButton>(cancel).onPressed, isNull);
expect(tester.getRect(cancel), cancelRect);
expect(tester.getRect(create), createRect);
expect(tester.takeException(), isNull);
});
}
}
}