diff --git a/lib/screens/home/top_items/top_items_section.dart b/lib/screens/home/top_items/top_items_section.dart index da0ccd8..5749f5d 100644 --- a/lib/screens/home/top_items/top_items_section.dart +++ b/lib/screens/home/top_items/top_items_section.dart @@ -90,27 +90,16 @@ class TopItemsSection extends StatelessWidget { return values; } - final lineChartData = lineData(); - final total = lineChartData.map((e) => e["value"]).reduce((a, b) => a + b); - - final Widget noItems = Padding( - padding: const EdgeInsets.only( - bottom: 20, - top: 10 - ), - child: Text( - AppLocalizations.of(context)!.noItems, - style: TextStyle( - fontSize: 16, - color: Theme.of(context).colorScheme.onSurfaceVariant, - ), - ), - ); + final List> lineChartData = lineData(); + final mapData = lineChartData.map((e) => e["value"]); + final List total = mapData.isNotEmpty + ? mapData.reduce((a, b) => a + b) + : []; return SizedBox( child: Column( children: [ - if (data.isEmpty) noItems, + if (data.isEmpty) _NoData(label: label), if (data.isNotEmpty && width > 700) Padding( padding: EdgeInsets.only(bottom: withChart == false ? 16 : 0), child: Row( @@ -321,4 +310,38 @@ class _ItemsList extends StatelessWidget { )).toList() ); } +} + +class _NoData extends StatelessWidget { + final String label; + + const _NoData({ + required this.label + }); + + @override + Widget build(BuildContext context) { + return Column( + children: [ + Text( + label, + overflow: TextOverflow.ellipsis, + style: TextStyle( + fontSize: 18, + fontWeight: FontWeight.w500, + color: Theme.of(context).colorScheme.onSurface + ), + ), + const SizedBox(height: 24), + Text( + AppLocalizations.of(context)!.noDataThisSection, + style: TextStyle( + fontSize: 16, + color: Theme.of(context).colorScheme.onSurfaceVariant, + ), + ), + const SizedBox(height: 16), + ], + ); + } } \ No newline at end of file