Address tester feedback: snackbar, filter dialog, text scaling
- Rule-deleted snackbar now auto-dismisses (persist: false) and snackbar actions use a high-contrast colour in both themes - Add-rule dialog keeps the floating label visible with the keyboard up - Dismiss focus/keyboard before swapping tab routes - Repeater status: full-width tiles on phones, no shrink-to-fit values, multi-part stats on separate lines, drop "0 days" from durations - App bar titles respect the system font size instead of scaling down; contacts controls grow with text scale; larger nav labels - Fix duplicated flood value in Japanese duplicates string
This commit is contained in:
1 parent
394df3109b
commit
03495effe6
49 files changed
+304
-39
No files matched your search
@@ -0,0 +1,57 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:meshcore_open/theme/mesh_theme.dart';
|
||||
|
||||
double _contrast(Color a, Color b) {
|
||||
final la = a.computeLuminance();
|
||||
final lb = b.computeLuminance();
|
||||
final hi = la > lb ? la : lb;
|
||||
final lo = la > lb ? lb : la;
|
||||
return (hi + 0.05) / (lo + 0.05);
|
||||
}
|
||||
|
||||
void main() {
|
||||
test('snackbar action text is readable in light and dark themes', () {
|
||||
for (final theme in [MeshTheme.light(), MeshTheme.dark()]) {
|
||||
final sb = theme.snackBarTheme;
|
||||
expect(sb.actionTextColor, isNotNull);
|
||||
expect(
|
||||
_contrast(sb.actionTextColor!, sb.backgroundColor!),
|
||||
greaterThanOrEqualTo(4.5),
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
testWidgets('snackbar with action and persist:false auto-dismisses', (
|
||||
tester,
|
||||
) async {
|
||||
late BuildContext ctx;
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
theme: MeshTheme.light(),
|
||||
home: Scaffold(
|
||||
body: Builder(
|
||||
builder: (c) {
|
||||
ctx = c;
|
||||
return const SizedBox();
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
ScaffoldMessenger.of(ctx).showSnackBar(
|
||||
SnackBar(
|
||||
content: const Text('Rule deleted'),
|
||||
duration: const Duration(seconds: 6),
|
||||
persist: false,
|
||||
action: SnackBarAction(label: 'Undo', onPressed: () {}),
|
||||
),
|
||||
);
|
||||
await tester.pump();
|
||||
await tester.pump(const Duration(milliseconds: 500));
|
||||
expect(find.text('Rule deleted'), findsOneWidget);
|
||||
await tester.pump(const Duration(seconds: 7));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.text('Rule deleted'), findsNothing);
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:meshcore_open/l10n/app_localizations.dart';
|
||||
import 'package:meshcore_open/widgets/filter_rule_dialog.dart';
|
||||
|
||||
void main() {
|
||||
for (final scale in [1.0, 2.0]) {
|
||||
testWidgets('floating label is not clipped with keyboard (scale $scale)', (
|
||||
tester,
|
||||
) async {
|
||||
tester.view.physicalSize = const Size(1080, 1400);
|
||||
tester.view.devicePixelRatio = 2.75;
|
||||
addTearDown(tester.view.reset);
|
||||
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
localizationsDelegates: AppLocalizations.localizationsDelegates,
|
||||
supportedLocales: AppLocalizations.supportedLocales,
|
||||
builder: (context, child) {
|
||||
final mq = MediaQuery.of(context);
|
||||
return MediaQuery(
|
||||
data: mq.copyWith(
|
||||
textScaler: TextScaler.linear(scale),
|
||||
viewInsets: const EdgeInsets.only(bottom: 150),
|
||||
),
|
||||
child: child!,
|
||||
);
|
||||
},
|
||||
home: Builder(
|
||||
builder: (context) => TextButton(
|
||||
onPressed: () => showFilterRuleDialog(context),
|
||||
child: const Text('open'),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
await tester.tap(find.text('open'));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
final scrollRect = tester.getRect(find.byType(SingleChildScrollView));
|
||||
final labelRect = tester.getRect(find.byType(InputDecorator));
|
||||
// The floating label sits above the field box; the scroll viewport must
|
||||
// start above the field with room for it.
|
||||
final fieldTop = labelRect.top;
|
||||
expect(fieldTop - scrollRect.top, greaterThanOrEqualTo(8 * scale));
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user