getAllHtmlPitch static method
- {required AppModel appModel,
- required DictionaryHeading heading}
Returns Furigana for multiple DictionaryPitch.
Implementation
static String getAllHtmlPitch(
{required AppModel appModel, required DictionaryHeading heading}) {
List<Dictionary> dictionaries = appModel.dictionaries;
Map<String, bool> dictionaryNamesByHidden = Map<String, bool>.fromEntries(
dictionaries
.map((e) => MapEntry(e.name, e.isHidden(appModel.targetLanguage))));
Map<String, int> dictionaryNamesByOrder = Map<String, int>.fromEntries(
dictionaries.map((e) => MapEntry(e.name, e.order)));
List<DictionaryPitch> pitches = heading.pitches
.where(
(entry) => !dictionaryNamesByHidden[entry.dictionary.value!.name]!)
.toList();
pitches.sort((a, b) => dictionaryNamesByOrder[a.dictionary.value!.name]!
.compareTo(dictionaryNamesByOrder[b.dictionary.value!.name]!));
if (pitches.isEmpty) {
return '';
}
StringBuffer html = StringBuffer();
pitches.forEachIndexed((index, pitch) {
html.write(
PitchSvg._pitchSvg(
heading.reading,
PitchSvg._pitchValueToPatt(heading.reading, pitch.downstep),
),
);
if (index != pitches.length - 1) {
html.write('<br>');
}
});
return html.toString();
}