fix(dictionary): a Greek letter found opens no empty sheet of strokes
Tapping a letter of the Greek alphabet among the dictionary's results opened the character sheet, which could only say that there's no stroke order for it. A letter of an alphabet has no strokes drawn, so the dictionary now offers the tap only for characters of a script whose strokes are drawn (Han characters, kana, Hangul), as a studied character's answer does. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Tizian 「ティツィアーン」 <raisondetredev@pm.me>
This commit is contained in:
parent
fd783df649
commit
e1032caf7e
2 changed files with 52 additions and 12 deletions
|
|
@ -15,6 +15,7 @@ import 'package:halkyon_learn_flutter/src/feature/dictionary/model/dictionary.da
|
||||||
import 'package:halkyon_learn_flutter/src/feature/dictionary/widget/dictionary_lookup_sheet.dart';
|
import 'package:halkyon_learn_flutter/src/feature/dictionary/widget/dictionary_lookup_sheet.dart';
|
||||||
import 'package:halkyon_learn_flutter/src/feature/dictionary/widget/dictionary_word_tile.dart';
|
import 'package:halkyon_learn_flutter/src/feature/dictionary/widget/dictionary_word_tile.dart';
|
||||||
import 'package:halkyon_learn_flutter/src/feature/dictionary/widget/studyset_dictionary.dart';
|
import 'package:halkyon_learn_flutter/src/feature/dictionary/widget/studyset_dictionary.dart';
|
||||||
|
import 'package:halkyon_learn_flutter/src/feature/kanji/model/hangul.dart';
|
||||||
import 'package:halkyon_learn_flutter/src/feature/kanji/model/radical.dart';
|
import 'package:halkyon_learn_flutter/src/feature/kanji/model/radical.dart';
|
||||||
import 'package:halkyon_learn_flutter/src/feature/kanji/widget/character_sheet.dart';
|
import 'package:halkyon_learn_flutter/src/feature/kanji/widget/character_sheet.dart';
|
||||||
import 'package:lucide_icons_flutter/lucide_icons.dart';
|
import 'package:lucide_icons_flutter/lucide_icons.dart';
|
||||||
|
|
@ -311,7 +312,8 @@ class const _Results({required final DictionaryState state})
|
||||||
}
|
}
|
||||||
|
|
||||||
/// [items] to add, or marked as in the studyset; a character shows how it
|
/// [items] to add, or marked as in the studyset; a character shows how it
|
||||||
/// is written when tapped.
|
/// is written when tapped, but for a letter of an alphabet (Greek's),
|
||||||
|
/// which has no strokes drawn.
|
||||||
class const _Items({
|
class const _Items({
|
||||||
required final List<DictionaryItem> items,
|
required final List<DictionaryItem> items,
|
||||||
required final DictionaryState state,
|
required final DictionaryState state,
|
||||||
|
|
@ -327,18 +329,21 @@ class const _Items({
|
||||||
return dictionaryItemTile(
|
return dictionaryItemTile(
|
||||||
word,
|
word,
|
||||||
onTap: switch (word) {
|
onTap: switch (word) {
|
||||||
final DictionaryCharacter character => () => showCharacterSheet(
|
final DictionaryCharacter character
|
||||||
context,
|
when hasDrawnScript(character.headword) =>
|
||||||
character.headword,
|
() => showCharacterSheet(
|
||||||
facts: (
|
context,
|
||||||
meanings: character.meaningsShown,
|
character.headword,
|
||||||
onReadings: character.onReadings,
|
facts: (
|
||||||
kunReadings: character.kunReadings,
|
meanings: character.meaningsShown,
|
||||||
marks: characterMarks(l10n, character),
|
onReadings: character.onReadings,
|
||||||
|
kunReadings: character.kunReadings,
|
||||||
|
marks: characterMarks(l10n, character),
|
||||||
|
),
|
||||||
|
language: character.language,
|
||||||
),
|
),
|
||||||
language: character.language,
|
// A letter of an alphabet (Greek's) has no strokes drawn.
|
||||||
),
|
DictionaryCharacter() || DictionaryWord() => null,
|
||||||
DictionaryWord() => null,
|
|
||||||
},
|
},
|
||||||
trailing: state.inStudyset.contains(word.ref)
|
trailing: state.inStudyset.contains(word.ref)
|
||||||
? Tooltip(
|
? Tooltip(
|
||||||
|
|
|
||||||
|
|
@ -394,6 +394,41 @@ void main() {
|
||||||
expect(find.text('N5 · Grade 2'), findsOneWidget);
|
expect(find.text('N5 · Grade 2'), findsOneWidget);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
testWidgets('a Greek letter found opens no sheet of its strokes: none are '
|
||||||
|
'drawn', (tester) async {
|
||||||
|
await show(
|
||||||
|
tester,
|
||||||
|
id: 'greek',
|
||||||
|
dictionaries: FakeDictionaryGateway(
|
||||||
|
available: [wiktionaryEl, greekAlphabet],
|
||||||
|
words: [
|
||||||
|
character(
|
||||||
|
'Α α',
|
||||||
|
labels: ['greek'],
|
||||||
|
romaji: 'a',
|
||||||
|
name: 'άλφα (alpha)',
|
||||||
|
of: greekAlphabet,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
await addMaterial(tester, 'From the dictionary');
|
||||||
|
await tester.tap(find.text('Alphabet'));
|
||||||
|
await settle(tester);
|
||||||
|
await tester.enterText(find.byType(TextField).hitTestable(), 'α');
|
||||||
|
await tester.pump(const Duration(milliseconds: 300));
|
||||||
|
await tester.pumpAndSettle();
|
||||||
|
|
||||||
|
await tester.tap(find.text('Α α').hitTestable());
|
||||||
|
await tester.pumpAndSettle();
|
||||||
|
|
||||||
|
expect(
|
||||||
|
find.text("There's no stroke order for this character."),
|
||||||
|
findsNothing,
|
||||||
|
);
|
||||||
|
expect(find.text('Play again'), findsNothing);
|
||||||
|
});
|
||||||
|
|
||||||
testWidgets('Look up fills a character card with its meanings, readings '
|
testWidgets('Look up fills a character card with its meanings, readings '
|
||||||
'and tags', (tester) async {
|
'and tags', (tester) async {
|
||||||
await show(tester, dictionaries: withKanji());
|
await show(tester, dictionaries: withKanji());
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue