Hide blue circle on company dropdown when closed

This commit is contained in:
Hillel Coren 2021-10-26 13:25:49 +03:00
parent fe02eeaeb4
commit 4e564b4be0
2 changed files with 13 additions and 2 deletions

View File

@ -8,6 +8,7 @@ class AppDropdownButton<T> 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<T> 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<T> extends StatelessWidget {
isExpanded: true,
isDense: labelText != null,
onChanged: enabled ? onChanged : null,
selectedItemBuilder: selectedItemBuilder,
items: [
if (_showBlank || isEmpty)
DropdownMenuItem<T>(

View File

@ -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<String>(
key: ValueKey(kSelectCompanyDropdownKey),
value: viewModel.selectedCompanyIndex,
selectedItemBuilder: (context) => state.companies
.map((company) =>
_companyListItem(company, showAccentColor: false))
.toList(),
items: [
...state.companies
.map((CompanyEntity company) => DropdownMenuItem<String>(