This commit is contained in:
unknown 2018-07-01 03:54:59 -07:00
parent 573f7bb377
commit a64253b9b0
2 changed files with 33 additions and 28 deletions

View File

@ -83,10 +83,10 @@ class AppDrawer extends StatelessWidget {
Row( Row(
children: <Widget>[ children: <Widget>[
Expanded( Expanded(
child: viewModel.companies.length > 1 && ! viewModel.isLoading child: viewModel.companies.length > 1 &&
? _multipleCompanies !viewModel.isLoading
: _singleCompany ? _multipleCompanies
), : _singleCompany),
], ],
), ),
], ],
@ -94,12 +94,12 @@ class AppDrawer extends StatelessWidget {
color: Colors.white10, color: Colors.white10,
), ),
DrawerTile( DrawerTile(
icon: FontAwesomeIcons.tachometerAlt, icon: FontAwesomeIcons.tachometerAlt,
title: AppLocalization.of(context).dashboard, title: AppLocalization.of(context).dashboard,
onTap: () { onTap: () {
navigator.pop(); navigator.pop();
store.dispatch(ViewDashboard(context)); store.dispatch(ViewDashboard(context));
}, },
), ),
DrawerTile( DrawerTile(
icon: FontAwesomeIcons.users, icon: FontAwesomeIcons.users,
@ -107,7 +107,8 @@ class AppDrawer extends StatelessWidget {
onTap: () => navigator.pushReplacementNamed(ClientScreen.route), onTap: () => navigator.pushReplacementNamed(ClientScreen.route),
onCreateTap: () { onCreateTap: () {
navigator.pop(); navigator.pop();
store.dispatch(EditClient(client: ClientEntity(), context: context)); store.dispatch(
EditClient(client: ClientEntity(), context: context));
}, },
), ),
DrawerTile( DrawerTile(
@ -116,7 +117,8 @@ class AppDrawer extends StatelessWidget {
onTap: () => navigator.pushReplacementNamed(ProductScreen.route), onTap: () => navigator.pushReplacementNamed(ProductScreen.route),
onCreateTap: () { onCreateTap: () {
navigator.pop(); navigator.pop();
store.dispatch(EditProduct(product: ProductEntity(), context: context)); store.dispatch(
EditProduct(product: ProductEntity(), context: context));
}, },
), ),
DrawerTile( DrawerTile(
@ -125,7 +127,8 @@ class AppDrawer extends StatelessWidget {
onTap: () => navigator.pushReplacementNamed(InvoiceScreen.route), onTap: () => navigator.pushReplacementNamed(InvoiceScreen.route),
onCreateTap: () { onCreateTap: () {
navigator.pop(); navigator.pop();
store.dispatch(EditInvoice(invoice: InvoiceEntity(), context: context)); store.dispatch(
EditInvoice(invoice: InvoiceEntity(), context: context));
}, },
), ),
DrawerTile( DrawerTile(
@ -171,10 +174,12 @@ class DrawerTile extends StatelessWidget {
leading: Icon(icon, size: 22.0), leading: Icon(icon, size: 22.0),
title: Text(title), title: Text(title),
onTap: () => onTap(), onTap: () => onTap(),
trailing: onCreateTap == null ? null : IconButton( trailing: onCreateTap == null
icon: Icon(Icons.add_circle_outline), ? null
onPressed: onCreateTap, : IconButton(
), icon: Icon(Icons.add_circle_outline),
onPressed: onCreateTap,
),
); );
} }
} }

View File

@ -45,11 +45,11 @@ class _EntityDropdownState extends State<EntityDropdown> {
super.dispose(); super.dispose();
} }
_showOptions() { void _showOptions() {
widget.onFilterChanged(''); widget.onFilterChanged('');
var localization = AppLocalization.of(context); var localization = AppLocalization.of(context);
_headerRow() { Widget _headerRow() {
return Row( return Row(
children: <Widget>[ children: <Widget>[
Padding( Padding(
@ -70,27 +70,27 @@ class _EntityDropdownState extends State<EntityDropdown> {
), ),
), ),
IconButton( IconButton(
icon: Icon(Icons.close), icon: const Icon(Icons.close),
onPressed: () => Navigator.pop(context), onPressed: () => Navigator.pop(context),
) )
], ],
); );
} }
_entityList(store) { Widget _entityList(Store<AppState> store) {
return Column( return Column(
mainAxisSize: MainAxisSize.min, mainAxisSize: MainAxisSize.min,
children: widget.entityList children: widget.entityList
.getRange(0, min(6, widget.entityList.length)) .getRange(0, min(6, widget.entityList.length))
.map((entityId) { .map((entityId) {
var entity = widget.entityMap[entityId]; final entity = widget.entityMap[entityId];
var filter = final filter =
store.state.getUIState(widget.entityType).dropdownFilter; store.state.getUIState(widget.entityType).dropdownFilter;
var subtitle = null; String subtitle;
var matchField = entity.matchesSearchField(filter); final matchField = entity.matchesSearchField(filter);
if (matchField != null) { if (matchField != null) {
var field = localization.lookup(matchField); final field = localization.lookup(matchField);
var value = entity.matchesSearchValue(filter); final value = entity.matchesSearchValue(filter);
subtitle = '$field: $value'; subtitle = '$field: $value';
} }
return ListTile( return ListTile(
@ -141,7 +141,7 @@ class _EntityDropdownState extends State<EntityDropdown> {
controller: _textController, controller: _textController,
decoration: InputDecoration( decoration: InputDecoration(
labelText: widget.labelText, labelText: widget.labelText,
suffixIcon: Icon(Icons.search), suffixIcon: const Icon(Icons.search),
), ),
), ),
), ),