From 4e564b4be0b38b876fde8537de7d858ac6a476c3 Mon Sep 17 00:00:00 2001 From: Hillel Coren Date: Tue, 26 Oct 2021 13:25:49 +0300 Subject: [PATCH] Hide blue circle on company dropdown when closed --- lib/ui/app/forms/app_dropdown_button.dart | 3 +++ lib/ui/app/menu_drawer.dart | 12 ++++++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/lib/ui/app/forms/app_dropdown_button.dart b/lib/ui/app/forms/app_dropdown_button.dart index fcf95d8c6..aec6947f8 100644 --- a/lib/ui/app/forms/app_dropdown_button.dart +++ b/lib/ui/app/forms/app_dropdown_button.dart @@ -8,6 +8,7 @@ class AppDropdownButton extends StatelessWidget { @required this.value, @required this.onChanged, @required this.items, + this.selectedItemBuilder, this.labelText, this.showBlank, this.blankValue = '', @@ -21,6 +22,7 @@ class AppDropdownButton extends StatelessWidget { final bool showBlank; final bool enabled; final dynamic blankValue; + final DropdownButtonBuilder selectedItemBuilder; @override Widget build(BuildContext context) { @@ -40,6 +42,7 @@ class AppDropdownButton extends StatelessWidget { isExpanded: true, isDense: labelText != null, onChanged: enabled ? onChanged : null, + selectedItemBuilder: selectedItemBuilder, items: [ if (_showBlank || isEmpty) DropdownMenuItem( diff --git a/lib/ui/app/menu_drawer.dart b/lib/ui/app/menu_drawer.dart index 6eddc17d6..63c396d9d 100644 --- a/lib/ui/app/menu_drawer.dart +++ b/lib/ui/app/menu_drawer.dart @@ -74,7 +74,10 @@ class MenuDrawer extends StatelessWidget { ) : Image.asset('assets/images/icon.png', width: MenuDrawer.LOGO_WIDTH); - Widget _companyListItem(CompanyEntity company) { + Widget _companyListItem( + CompanyEntity company, { + bool showAccentColor = true, + }) { final userCompany = state.userCompanyStates .firstWhere( (userCompanyState) => userCompanyState.company.id == company.id) @@ -94,7 +97,8 @@ class MenuDrawer extends StatelessWidget { overflow: TextOverflow.ellipsis, ), ), - if (userCompany.settings.accentColor != null && + if (showAccentColor && + userCompany.settings.accentColor != null && state.companies.length > 1) Container( padding: const EdgeInsets.only(right: 2), @@ -174,6 +178,10 @@ class MenuDrawer extends StatelessWidget { child: AppDropdownButton( key: ValueKey(kSelectCompanyDropdownKey), value: viewModel.selectedCompanyIndex, + selectedItemBuilder: (context) => state.companies + .map((company) => + _companyListItem(company, showAccentColor: false)) + .toList(), items: [ ...state.companies .map((CompanyEntity company) => DropdownMenuItem(