From ca7cd827e116376c0bfedd542130bf04cb89ba96 Mon Sep 17 00:00:00 2001 From: Ulises M <30765968+lbux@users.noreply.github.com> Date: Fri, 1 Aug 2025 23:40:07 -0700 Subject: [PATCH] fix: Standardize precision used in communityRating (#424) Co-authored-by: PartyDonut --- lib/models/item_base_model.dart | 48 +++++++++---------- .../components/overview_header.dart | 2 +- lib/screens/shared/media/poster_widget.dart | 10 ++-- 3 files changed, 29 insertions(+), 31 deletions(-) diff --git a/lib/models/item_base_model.dart b/lib/models/item_base_model.dart index 54b42d1..164eb21 100644 --- a/lib/models/item_base_model.dart +++ b/lib/models/item_base_model.dart @@ -68,32 +68,28 @@ class ItemBaseModel with ItemBaseModelMappable { } Widget? subTitle(SortingOptions options) => switch (options) { - SortingOptions.parentalRating => overview.parentalRating != null - ? Row( - children: [ - const Icon( - IconsaxPlusBold.star_1, - size: 14, - color: Colors.yellowAccent, - ), - const SizedBox(width: 6), - Text((overview.parentalRating ?? 0.0).toString()) - ], - ) - : null, - SortingOptions.communityRating => overview.communityRating != null - ? Row( - children: [ - const Icon( - IconsaxPlusBold.star_1, - size: 14, - color: Colors.yellowAccent, - ), - const SizedBox(width: 6), - Text((overview.communityRating ?? 0.0).toString()) - ], - ) - : null, + SortingOptions.parentalRating => Row( + children: [ + const Icon( + IconsaxPlusBold.star_1, + size: 14, + color: Colors.yellowAccent, + ), + const SizedBox(width: 6), + Text(overview.parentalRating?.toString() ?? "--"), + ], + ), + SortingOptions.communityRating => Row( + children: [ + const Icon( + IconsaxPlusBold.star_1, + size: 14, + color: Colors.yellowAccent, + ), + const SizedBox(width: 6), + Text(overview.communityRating?.toStringAsFixed(2) ?? "--"), + ], + ), _ => null, }; diff --git a/lib/screens/details_screens/components/overview_header.dart b/lib/screens/details_screens/components/overview_header.dart index 7e9a2a1..9ad29e4 100644 --- a/lib/screens/details_screens/components/overview_header.dart +++ b/lib/screens/details_screens/components/overview_header.dart @@ -130,7 +130,7 @@ class OverviewHeader extends ConsumerWidget { color: Theme.of(context).colorScheme.primary, ), Text( - communityRating?.toStringAsFixed(1) ?? "", + communityRating?.toStringAsFixed(2) ?? "", style: subStyle, ), ], diff --git a/lib/screens/shared/media/poster_widget.dart b/lib/screens/shared/media/poster_widget.dart index 79a6404..669b3e6 100644 --- a/lib/screens/shared/media/poster_widget.dart +++ b/lib/screens/shared/media/poster_widget.dart @@ -83,13 +83,15 @@ class PosterWidget extends ConsumerWidget { ), ), Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ if (subTitle != null) ...[ - Opacity( - opacity: opacity, - child: subTitle!, + Flexible( + child: Opacity( + opacity: opacity, + child: subTitle!, + ), ), - const Spacer() ], if (poster.subText?.isNotEmpty ?? false) Flexible(