75 lines
1.8 KiB
Dart
75 lines
1.8 KiB
Dart
part of 'data_entry.dart';
|
|
|
|
class YokutangoEntry extends DataEntry {
|
|
final List<JapaneseWord> japanese;
|
|
final List<NorwegianWord> norwegian;
|
|
|
|
const YokutangoEntry({required this.japanese, required this.norwegian});
|
|
|
|
YokutangoEntry.fromJson(Map<String, dynamic> json)
|
|
: japanese = (json['japanese'] as List)
|
|
.map((e) => JapaneseWord.fromJson(e))
|
|
.toList(),
|
|
norwegian = (json['norwegian'] as List)
|
|
.map((e) => NorwegianWord.fromJson(e))
|
|
.toList();
|
|
|
|
@override
|
|
String toString() {
|
|
return "${japanese.join(" ### ")} - ${norwegian.join(" ### ")}";
|
|
}
|
|
|
|
YokutangoEntry.empty()
|
|
: japanese = [JapaneseWord.empty()],
|
|
norwegian = [NorwegianWord.empty()];
|
|
}
|
|
|
|
class JapaneseWord {
|
|
final String word;
|
|
final String? romaji;
|
|
final List<String>? hints;
|
|
|
|
const JapaneseWord({
|
|
required this.word,
|
|
this.romaji,
|
|
this.hints,
|
|
});
|
|
|
|
JapaneseWord.fromJson(Map<String, dynamic> json)
|
|
: word = json['word'],
|
|
romaji = json['romaji'],
|
|
hints = (json['hints'] as List?)?.map((e) => e as String).toList();
|
|
|
|
@override
|
|
String toString() {
|
|
return word +
|
|
((romaji != null) ? "/$romaji" : "") +
|
|
((hints != null) ? " (${hints!.join(", ")})" : "");
|
|
}
|
|
|
|
JapaneseWord.empty()
|
|
: word = "",
|
|
romaji = "",
|
|
hints = [];
|
|
}
|
|
|
|
class NorwegianWord {
|
|
final String word;
|
|
final List<String>? hints;
|
|
|
|
const NorwegianWord({required this.word, this.hints});
|
|
|
|
NorwegianWord.fromJson(Map<String, dynamic> json)
|
|
: word = json['word'],
|
|
hints = (json['hints'] as List?)?.map((e) => e as String).toList();
|
|
|
|
@override
|
|
String toString() {
|
|
return word + ((hints != null) ? " (${hints!.join(", ")})" : "");
|
|
}
|
|
|
|
NorwegianWord.empty()
|
|
: word = "",
|
|
hints = [];
|
|
}
|