From eb6bc091020137af861762162ec8e834a7b6f7d4 Mon Sep 17 00:00:00 2001 From: tamslo Date: Fri, 29 Nov 2024 00:33:32 +0100 Subject: [PATCH] feat(app): use same icon as for report also for expansion tiles --- app/lib/common/widgets/drug_list/builder.dart | 20 +++++++++++++++++-- .../common/widgets/pretty_expansion_tile.dart | 3 +++ 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/app/lib/common/widgets/drug_list/builder.dart b/app/lib/common/widgets/drug_list/builder.dart index 6720f687..032ad6f8 100644 --- a/app/lib/common/widgets/drug_list/builder.dart +++ b/app/lib/common/widgets/drug_list/builder.dart @@ -82,6 +82,7 @@ class DrugList extends HookWidget { useLine: false, ); final currentlyExpanded = otherDrugsExpanded.value ?? false; + final currentlyEnabled = filter.query.isBlank; final drugLists = [ if (activeDrugsList != null) ...[ ListTile( @@ -100,12 +101,27 @@ class DrugList extends HookWidget { ...[ PrettyExpansionTile( title: otherDrugsHeader, - enabled: filter.query.isBlank, - initiallyExpanded: currentlyExpanded || !filter.query.isBlank, + enabled: currentlyEnabled, + initiallyExpanded: currentlyExpanded || !currentlyEnabled, onExpansionChanged: (value) => otherDrugsExpanded.value = value, visualDensity: VisualDensity.compact, titlePadding: EdgeInsets.zero, childrenPadding: EdgeInsets.zero, + icon: drugActivityChangeable + ? SizedBox.shrink() + : ResizedIconButton( + size: PharMeTheme.largeSpace, + disabledBackgroundColor: currentlyEnabled + ? PharMeTheme.buttonColor + : PharMeTheme.onSurfaceColor, + iconWidgetBuilder: (size) => Icon( + currentlyExpanded + ? Icons.arrow_drop_up + : Icons.arrow_drop_down, + size: size, + color: PharMeTheme.surfaceColor, + ), + ), children: allDrugsList, ), ], diff --git a/app/lib/common/widgets/pretty_expansion_tile.dart b/app/lib/common/widgets/pretty_expansion_tile.dart index 6ad6f52d..0fdcdfef 100644 --- a/app/lib/common/widgets/pretty_expansion_tile.dart +++ b/app/lib/common/widgets/pretty_expansion_tile.dart @@ -9,6 +9,7 @@ class PrettyExpansionTile extends StatelessWidget { this.visualDensity, this.titlePadding, this.childrenPadding, + this.icon, this.initiallyExpanded = false, this.enabled = true, }); @@ -20,6 +21,7 @@ class PrettyExpansionTile extends StatelessWidget { final VisualDensity? visualDensity; final EdgeInsets? titlePadding; final EdgeInsets? childrenPadding; + final Widget? icon; final bool initiallyExpanded; final bool enabled; @@ -35,6 +37,7 @@ class PrettyExpansionTile extends StatelessWidget { initiallyExpanded: initiallyExpanded, title: title, iconColor: PharMeTheme.iconColor, + trailing: icon, collapsedIconColor: PharMeTheme.iconColor, onExpansionChanged: onExpansionChanged, visualDensity: visualDensity,