fix(study): the explanation has an open book, the hints the light bulb
Both pills showed a light bulb. The explanation's now has the open book that Add explanation has in the composer. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01MMm7usAo6q9ZZRoPkWjoxi Signed-off-by: Tizian 「ティツィアーン」 <raisondetredev@pm.me>
This commit is contained in:
parent
c002a07011
commit
e6580e7812
2 changed files with 18 additions and 4 deletions
|
|
@ -12,6 +12,7 @@ class const HintsButton({required final List<RichContent> hints, super.key})
|
||||||
Widget build(BuildContext context) => hints.isEmpty
|
Widget build(BuildContext context) => hints.isEmpty
|
||||||
? const SizedBox.shrink()
|
? const SizedBox.shrink()
|
||||||
: _Pill(
|
: _Pill(
|
||||||
|
icon: LucideIcons.lightbulb,
|
||||||
label: AppLocalizations.of(context).cardHints,
|
label: AppLocalizations.of(context).cardHints,
|
||||||
onPressed: () => showAdaptiveSheet<void>(
|
onPressed: () => showAdaptiveSheet<void>(
|
||||||
context,
|
context,
|
||||||
|
|
@ -20,7 +21,9 @@ class const HintsButton({required final List<RichContent> hints, super.key})
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A card's [explanation] as a pill to open it; nothing without.
|
/// A card's [explanation] as a pill to open it; nothing without. An open
|
||||||
|
/// book, as Add explanation has in the composer, tells it from the hints'
|
||||||
|
/// light bulb.
|
||||||
class const ExplanationButton({
|
class const ExplanationButton({
|
||||||
required final RichContent? explanation,
|
required final RichContent? explanation,
|
||||||
super.key,
|
super.key,
|
||||||
|
|
@ -30,6 +33,7 @@ class const ExplanationButton({
|
||||||
final l10n = AppLocalizations.of(context);
|
final l10n = AppLocalizations.of(context);
|
||||||
return switch (explanation) {
|
return switch (explanation) {
|
||||||
final explanation? => _Pill(
|
final explanation? => _Pill(
|
||||||
|
icon: LucideIcons.bookOpen,
|
||||||
label: l10n.cardExplanation,
|
label: l10n.cardExplanation,
|
||||||
onPressed: () => showAdaptiveSheet<void>(
|
onPressed: () => showAdaptiveSheet<void>(
|
||||||
context,
|
context,
|
||||||
|
|
@ -44,8 +48,9 @@ class const ExplanationButton({
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A light bulb and [label] on an outlined pill, in muted colours.
|
/// [icon] and [label] on an outlined pill, in muted colours.
|
||||||
class const _Pill({
|
class const _Pill({
|
||||||
|
required final IconData icon,
|
||||||
required final String label,
|
required final String label,
|
||||||
required final VoidCallback onPressed,
|
required final VoidCallback onPressed,
|
||||||
}) extends StatelessWidget {
|
}) extends StatelessWidget {
|
||||||
|
|
@ -54,7 +59,7 @@ class const _Pill({
|
||||||
final colors = Theme.of(context).colorScheme;
|
final colors = Theme.of(context).colorScheme;
|
||||||
return OutlinedButton.icon(
|
return OutlinedButton.icon(
|
||||||
onPressed: onPressed,
|
onPressed: onPressed,
|
||||||
icon: const Icon(LucideIcons.lightbulb, size: 16),
|
icon: Icon(icon, size: 16),
|
||||||
label: Text(label),
|
label: Text(label),
|
||||||
style: OutlinedButton.styleFrom(
|
style: OutlinedButton.styleFrom(
|
||||||
foregroundColor: colors.onSurfaceVariant,
|
foregroundColor: colors.onSurfaceVariant,
|
||||||
|
|
|
||||||
|
|
@ -304,7 +304,8 @@ void main() {
|
||||||
});
|
});
|
||||||
|
|
||||||
testWidgets('hints open from under the question, one at a time; the '
|
testWidgets('hints open from under the question, one at a time; the '
|
||||||
'explanation comes with the answer', (tester) async {
|
"explanation comes with the answer, an open book to the hints' light "
|
||||||
|
'bulb', (tester) async {
|
||||||
await cards.create(
|
await cards.create(
|
||||||
'japanese',
|
'japanese',
|
||||||
CardContent(
|
CardContent(
|
||||||
|
|
@ -330,6 +331,14 @@ void main() {
|
||||||
|
|
||||||
await tester.tap(find.text('Show answer'));
|
await tester.tap(find.text('Show answer'));
|
||||||
await tester.pumpAndSettle();
|
await tester.pumpAndSettle();
|
||||||
|
expect(
|
||||||
|
find.widgetWithIcon(OutlinedButton, LucideIcons.lightbulb),
|
||||||
|
findsOneWidget,
|
||||||
|
);
|
||||||
|
expect(
|
||||||
|
find.widgetWithIcon(OutlinedButton, LucideIcons.bookOpen),
|
||||||
|
findsOneWidget,
|
||||||
|
);
|
||||||
await tester.tap(find.text('Explanation'));
|
await tester.tap(find.text('Explanation'));
|
||||||
await tester.pumpAndSettle();
|
await tester.pumpAndSettle();
|
||||||
expect(
|
expect(
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue