From 1886e30dd74882c3733733414f2edadc631a8c6c Mon Sep 17 00:00:00 2001 From: Kelrap Date: Wed, 24 Jul 2024 14:33:17 -0400 Subject: [PATCH] Make analytics buttons flexible --- .../analytics/analytics_view_button.dart | 58 ++++++++++--------- .../analytics/time_span_menu_button.dart | 54 ++++++++--------- 2 files changed, 59 insertions(+), 53 deletions(-) diff --git a/lib/pangea/pages/analytics/analytics_view_button.dart b/lib/pangea/pages/analytics/analytics_view_button.dart index c98bf47fc..5b4f46d03 100644 --- a/lib/pangea/pages/analytics/analytics_view_button.dart +++ b/lib/pangea/pages/analytics/analytics_view_button.dart @@ -13,36 +13,40 @@ class AnalyticsViewButton extends StatelessWidget { @override Widget build(BuildContext context) { - return PopupMenuButton( - tooltip: L10n.of(context)!.changeAnalyticsView, - initialValue: value, - onSelected: (BarChartViewSelection? view) { - if (view == null) { - debugPrint("when is view null?"); - return; - } - onChange(view); - }, - itemBuilder: (BuildContext context) => BarChartViewSelection.values - .map>( - (BarChartViewSelection view) { - return PopupMenuItem( - value: view, - child: Text(view.string(context)), - ); - }).toList(), - child: TextButton.icon( - label: Text( - value.string(context), - style: TextStyle( + return Flexible( + child: PopupMenuButton( + tooltip: L10n.of(context)!.changeAnalyticsView, + initialValue: value, + onSelected: (BarChartViewSelection? view) { + if (view == null) { + debugPrint("when is view null?"); + return; + } + onChange(view); + }, + itemBuilder: (BuildContext context) => BarChartViewSelection.values + .map>( + (BarChartViewSelection view) { + return PopupMenuItem( + value: view, + child: Text( + view.string(context), + ), + ); + }).toList(), + child: TextButton.icon( + label: Text( + value.string(context), + style: TextStyle( + color: Theme.of(context).colorScheme.onSurface, + ), + ), + icon: Icon( + value.icon, color: Theme.of(context).colorScheme.onSurface, ), + onPressed: null, ), - icon: Icon( - value.icon, - color: Theme.of(context).colorScheme.onSurface, - ), - onPressed: null, ), ); } diff --git a/lib/pangea/pages/analytics/time_span_menu_button.dart b/lib/pangea/pages/analytics/time_span_menu_button.dart index 32f6668bc..eae5416b0 100644 --- a/lib/pangea/pages/analytics/time_span_menu_button.dart +++ b/lib/pangea/pages/analytics/time_span_menu_button.dart @@ -14,35 +14,37 @@ class TimeSpanMenuButton extends StatelessWidget { @override Widget build(BuildContext context) { - return PopupMenuButton( - tooltip: L10n.of(context)!.changeDateRange, - initialValue: value, - onSelected: (TimeSpan? timeSpan) { - if (timeSpan == null) { - debugPrint("when is timeSpan null?"); - return; - } - onChange(timeSpan); - }, - itemBuilder: (BuildContext context) => - TimeSpan.values.map>((TimeSpan timeSpan) { - return PopupMenuItem( - value: timeSpan, - child: Text(timeSpan.string(context)), - ); - }).toList(), - child: TextButton.icon( - label: Text( - value.string(context), - style: TextStyle( + return Flexible( + child: PopupMenuButton( + tooltip: L10n.of(context)!.changeDateRange, + initialValue: value, + onSelected: (TimeSpan? timeSpan) { + if (timeSpan == null) { + debugPrint("when is timeSpan null?"); + return; + } + onChange(timeSpan); + }, + itemBuilder: (BuildContext context) => + TimeSpan.values.map>((TimeSpan timeSpan) { + return PopupMenuItem( + value: timeSpan, + child: Text(timeSpan.string(context)), + ); + }).toList(), + child: TextButton.icon( + label: Text( + value.string(context), + style: TextStyle( + color: Theme.of(context).colorScheme.onSurface, + ), + ), + icon: Icon( + Icons.calendar_month_outlined, color: Theme.of(context).colorScheme.onSurface, ), + onPressed: null, ), - icon: Icon( - Icons.calendar_month_outlined, - color: Theme.of(context).colorScheme.onSurface, - ), - onPressed: null, ), ); }