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.value,
@required this.onChanged, @required this.onChanged,
@required this.items, @required this.items,
this.selectedItemBuilder,
this.labelText, this.labelText,
this.showBlank, this.showBlank,
this.blankValue = '', this.blankValue = '',
@ -21,6 +22,7 @@ class AppDropdownButton<T> extends StatelessWidget {
final bool showBlank; final bool showBlank;
final bool enabled; final bool enabled;
final dynamic blankValue; final dynamic blankValue;
final DropdownButtonBuilder selectedItemBuilder;
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
@ -40,6 +42,7 @@ class AppDropdownButton<T> extends StatelessWidget {
isExpanded: true, isExpanded: true,
isDense: labelText != null, isDense: labelText != null,
onChanged: enabled ? onChanged : null, onChanged: enabled ? onChanged : null,
selectedItemBuilder: selectedItemBuilder,
items: [ items: [
if (_showBlank || isEmpty) if (_showBlank || isEmpty)
DropdownMenuItem<T>( DropdownMenuItem<T>(

View File

@ -74,7 +74,10 @@ class MenuDrawer extends StatelessWidget {
) )
: Image.asset('assets/images/icon.png', width: MenuDrawer.LOGO_WIDTH); : 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 final userCompany = state.userCompanyStates
.firstWhere( .firstWhere(
(userCompanyState) => userCompanyState.company.id == company.id) (userCompanyState) => userCompanyState.company.id == company.id)
@ -94,7 +97,8 @@ class MenuDrawer extends StatelessWidget {
overflow: TextOverflow.ellipsis, overflow: TextOverflow.ellipsis,
), ),
), ),
if (userCompany.settings.accentColor != null && if (showAccentColor &&
userCompany.settings.accentColor != null &&
state.companies.length > 1) state.companies.length > 1)
Container( Container(
padding: const EdgeInsets.only(right: 2), padding: const EdgeInsets.only(right: 2),
@ -174,6 +178,10 @@ class MenuDrawer extends StatelessWidget {
child: AppDropdownButton<String>( child: AppDropdownButton<String>(
key: ValueKey(kSelectCompanyDropdownKey), key: ValueKey(kSelectCompanyDropdownKey),
value: viewModel.selectedCompanyIndex, value: viewModel.selectedCompanyIndex,
selectedItemBuilder: (context) => state.companies
.map((company) =>
_companyListItem(company, showAccentColor: false))
.toList(),
items: [ items: [
...state.companies ...state.companies
.map((CompanyEntity company) => DropdownMenuItem<String>( .map((CompanyEntity company) => DropdownMenuItem<String>(