feat(ui): the question mark's explanation offers a link beside OK
HelpButton takes an action, a label and what it does, shown beside OK where there is more to read elsewhere, as what a map's source keeps (Train's ADR 0030, D63). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Tizian 「ティツィアーン」 <raisondetredev@pm.me>
This commit is contained in:
parent
55fc245859
commit
30dd8c96eb
2 changed files with 24 additions and 2 deletions
|
|
@ -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
|
/// 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
|
/// explanation out of the everyday view: a tap opens [message] in a small
|
||||||
/// dialog, under [title] where given (decided 3 Nov 2026: what explains,
|
/// 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
|
/// rather than what is the person's own, is one tap away), with [action]
|
||||||
/// short hint, [FieldInfoButton]'s tooltip.
|
/// beside OK where there is more to read elsewhere. For a field's short
|
||||||
|
/// hint, [FieldInfoButton]'s tooltip.
|
||||||
class const HelpButton(
|
class const HelpButton(
|
||||||
final String message, {
|
final String message, {
|
||||||
final String? title,
|
final String? title,
|
||||||
|
final ({String label, VoidCallback onPressed})? action,
|
||||||
super.key,
|
super.key,
|
||||||
}) extends StatelessWidget {
|
}) extends StatelessWidget {
|
||||||
@override
|
@override
|
||||||
|
|
@ -26,6 +28,8 @@ class const HelpButton(
|
||||||
title: title == null ? null : Text(title!),
|
title: title == null ? null : Text(title!),
|
||||||
content: SingleChildScrollView(child: Text(message)),
|
content: SingleChildScrollView(child: Text(message)),
|
||||||
actions: [
|
actions: [
|
||||||
|
if (action case (:final label, :final onPressed))
|
||||||
|
TextButton(onPressed: onPressed, child: Text(label)),
|
||||||
TextButton(
|
TextButton(
|
||||||
onPressed: () => Navigator.of(context).pop(),
|
onPressed: () => Navigator.of(context).pop(),
|
||||||
child: Text(MaterialLocalizations.of(context).okButtonLabel),
|
child: Text(MaterialLocalizations.of(context).okButtonLabel),
|
||||||
|
|
|
||||||
|
|
@ -26,4 +26,22 @@ void main() {
|
||||||
await tester.pumpAndSettle();
|
await tester.pumpAndSettle();
|
||||||
expect(find.text('How sources are cited.'), findsNothing);
|
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);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue