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:
Tizian 「ティツィアーン」 2026-10-14 17:50:15 +02:00
commit e1032caf7e
Signed by: raisondetredev
GPG key ID: 07F6FCF405488B64
2 changed files with 52 additions and 12 deletions

View file

@ -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_word_tile.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/widget/character_sheet.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
/// 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({
required final List<DictionaryItem> items,
required final DictionaryState state,
@ -327,7 +329,9 @@ class const _Items({
return dictionaryItemTile(
word,
onTap: switch (word) {
final DictionaryCharacter character => () => showCharacterSheet(
final DictionaryCharacter character
when hasDrawnScript(character.headword) =>
() => showCharacterSheet(
context,
character.headword,
facts: (
@ -338,7 +342,8 @@ class const _Items({
),
language: character.language,
),
DictionaryWord() => null,
// A letter of an alphabet (Greek's) has no strokes drawn.
DictionaryCharacter() || DictionaryWord() => null,
},
trailing: state.inStudyset.contains(word.ref)
? Tooltip(

View file

@ -394,6 +394,41 @@ void main() {
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 '
'and tags', (tester) async {
await show(tester, dictionaries: withKanji());