From 57f7fbf258f74abed180b6a7252417474f24a389 Mon Sep 17 00:00:00 2001 From: h7x4 Date: Sun, 23 Jan 2022 03:45:53 +0100 Subject: [PATCH] Fix jlpt level --- .../search/search_results_body/search_card.dart | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/lib/components/search/search_results_body/search_card.dart b/lib/components/search/search_results_body/search_card.dart index fb7681e..739d88c 100644 --- a/lib/components/search/search_results_body/search_card.dart +++ b/lib/components/search/search_results_body/search_card.dart @@ -47,6 +47,13 @@ class _SearchResultCardState extends State { widget.result.attribution.jmnedict || (widget.result.attribution.dbpedia != null); + String? get jlptLevel { + if (widget.result.jlpt.isEmpty) return null; + final jlpt = List.from(widget.result.jlpt); + jlpt.sort(); + return jlpt.last; + } + Widget get _header => IntrinsicWidth( child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, @@ -60,11 +67,7 @@ class _SearchResultCardState extends State { orElse: () => '', ), ), - // TODO: find the lowest level in the list. - JLPTBadge( - jlptLevel: - widget.result.jlpt.isEmpty ? null : widget.result.jlpt[0], - ), + JLPTBadge(jlptLevel: jlptLevel), CommonBadge(isCommon: widget.result.isCommon ?? false) ], ) @@ -83,22 +86,18 @@ class _SearchResultCardState extends State { AudioPlayer(audio: extendedData.audio.first), const SizedBox(height: 10), ], - Senses( senses: widget.result.senses, extraData: extendedData?.meanings, ), - if (widget.otherForms.isNotEmpty) ...[ const SizedBox(height: 20), OtherForms(forms: widget.otherForms), ], - if (extendedData != null && extendedData.notes.isNotEmpty) ...[ const SizedBox(height: 20), Notes(notes: extendedData.notes), ], - if (links.isNotEmpty || hasAttribution) ...[ const SizedBox(height: 20), Links(