Merge branch 'train-maps' into integration

This commit is contained in:
Tizian 「ティツィアーン」 2026-11-03 23:13:32 +01:00
commit 10744bcd56
Signed by: raisondetredev
GPG key ID: 07F6FCF405488B64
2 changed files with 1588 additions and 360 deletions

View file

@ -6,11 +6,13 @@ import 'package:material_ui/material_ui.dart';
/// A question mark beside a section's or a setting's title that keeps its
/// explanation out of the everyday view: a tap opens [message] in a small
/// dialog, under [title] where given (decided 3 Nov 2026: what explains,
/// rather than what is the person's own, is one tap away). For a field's
/// short hint, [FieldInfoButton]'s tooltip.
/// rather than what is the person's own, is one tap away), with [action]
/// beside OK where there is more to read elsewhere. For a field's short
/// hint, [FieldInfoButton]'s tooltip.
class const HelpButton(
final String message, {
final String? title,
final ({String label, VoidCallback onPressed})? action,
super.key,
}) extends StatelessWidget {
@override
@ -26,6 +28,8 @@ class const HelpButton(
title: title == null ? null : Text(title!),
content: SingleChildScrollView(child: Text(message)),
actions: [
if (action case (:final label, :final onPressed))
TextButton(onPressed: onPressed, child: Text(label)),
TextButton(
onPressed: () => Navigator.of(context).pop(),
child: Text(MaterialLocalizations.of(context).okButtonLabel),

View file

@ -26,4 +26,22 @@ void main() {
await tester.pumpAndSettle();
expect(find.text('How sources are cited.'), findsNothing);
});
testWidgets('an action offered stands beside OK', (tester) async {
var read = false;
await tester.pumpWidget(
testApp(
Scaffold(
body: HelpButton(
'Map by OpenFreeMap.',
action: (label: 'What it keeps', onPressed: () => read = true),
),
),
),
);
await tester.tap(find.byType(HelpButton));
await tester.pumpAndSettle();
await tester.tap(find.text('What it keeps'));
expect(read, isTrue);
expect(find.text('OK'), findsOneWidget);
});
}