Reworked filters

This commit is contained in:
Hillel Coren 2020-07-15 06:15:59 +03:00
parent 4e9f2f9b31
commit adae8737a4
6 changed files with 298 additions and 354 deletions

View File

@ -253,8 +253,8 @@ class MainScreen extends StatelessWidget {
continue;
}
final entity = state.getEntityMap(item.entityType)[item.id]
as BaseEntity;
final entity =
state.getEntityMap(item.entityType)[item.id] as BaseEntity;
if (entity == null || !entity.isActive) {
continue;
}
@ -274,8 +274,7 @@ class MainScreen extends StatelessWidget {
switch (history.entityType) {
case EntityType.dashboard:
store.dispatch(
ViewDashboard(navigator: Navigator.of(context)));
store.dispatch(ViewDashboard(navigator: Navigator.of(context)));
break;
case EntityType.reports:
store.dispatch(ViewReports(navigator: Navigator.of(context)));
@ -683,15 +682,21 @@ class _EntityFilter extends StatelessWidget {
opacity: show ? 1 : 0,
duration: Duration(milliseconds: kDefaultAnimationDuration),
curve: Curves.easeInOutCubic,
child: Row(
children: filterEntity == null
? []
: [
SizedBox(width: 4),
Expanded(
child: Align(
child: filterEntity == null
? Container(
color: Theme.of(context).cardColor,
)
: AppBar(
leading: IconButton(
tooltip: localization.preview,
icon: Icon(Icons.chrome_reader_mode),
onPressed: () => store.dispatch(
UserPreferencesChanged(fullHeightFilter: true)),
),
title: Align(
alignment: Alignment.centerLeft,
child: FlatButton(
padding: const EdgeInsets.only(left: 0),
child: Text(
'${localization.lookup('$filterEntityType')} ${filterEntity.listDisplayName}',
style: TextStyle(fontSize: 17),
@ -705,7 +710,7 @@ class _EntityFilter extends StatelessWidget {
),
),
),
),
actions: [
PopupMenuButton<EntityType>(
child: Row(
children: [
@ -760,7 +765,7 @@ class _EntityFilter extends StatelessWidget {
entityId: uiState.filterEntityId,
entityType: uiState.filterEntityType,
)),
),
)
],
),
),

View File

@ -156,51 +156,12 @@ class MenuDrawer extends StatelessWidget {
},
);
/*
final _expandedCompanySelector = viewModel.companies.isEmpty
? SizedBox()
: DropdownButtonHideUnderline(
child: DropdownButton<String>(
isExpanded: true,
icon: Icon(Icons.arrow_drop_down),
value: viewModel.selectedCompanyIndex,
items: [
...viewModel.companies
.map((CompanyEntity company) => DropdownMenuItem<String>(
value:
(viewModel.companies.indexOf(company)).toString(),
child: _companyListItem(company),
))
.toList(),
if (viewModel.state.userCompany.isAdmin)
DropdownMenuItem<String>(
value: null,
child: Row(
children: <Widget>[
SizedBox(width: 2),
Icon(Icons.add_circle, size: 32),
SizedBox(width: 28),
Text(localization.addCompany),
],
),
),
],
onChanged: (value) {
if (value == null) {
viewModel.onAddCompany(context);
} else {
viewModel.onCompanyChanged(
context, value, viewModel.companies[int.parse(value)]);
}
},
));
*/
return AnimatedContainer(
width: state.isMenuCollapsed ? 65 : kDrawerWidth,
duration: Duration(
milliseconds:
state.prefState.fullHeightFilter ? 0 : kDefaultAnimationDuration),
milliseconds: state.uiState.filterEntityType != null
? 0
: kDefaultAnimationDuration),
curve: Curves.easeInOutCubic,
child: Drawer(
child: SafeArea(

View File

@ -51,10 +51,14 @@ class ViewScaffold extends StatelessWidget {
entity.entityType == state.uiState.filterEntityType) {
leading = IconButton(
icon: Icon(Icons.clear),
onPressed: () => store
.dispatch(UserPreferencesChanged(fullHeightFilter: false)),
/*
onPressed: () => store.dispatch(FilterByEntity(
entityType: state.uiState.filterEntityType,
entityId: state.uiState.filterEntityId,
)),
*/
);
} else if (isSettings) {
leading = IconButton(

View File

@ -158,14 +158,6 @@ class _DeviceSettingsState extends State<DeviceSettings> {
activeColor: Theme.of(context).accentColor,
),
*/
SwitchListTile(
title: Text(localization.fullHeightFilter),
value: prefState.fullHeightFilter,
onChanged: (value) =>
viewModel.onFullHeightFilterChanged(context, value),
secondary: Icon(Icons.filter_list),
activeColor: Theme.of(context).accentColor,
),
viewModel.state.company.isModuleEnabled(EntityType.task)
? SwitchListTile(
title:

View File

@ -47,8 +47,6 @@ class DeviceSettingsVM {
@required this.authenticationSupported,
@required this.onMenuModeChanged,
@required this.onHistoryModeChanged,
@required this.onFullHeightFilterChanged,
@required this.onFullWidthEditorChanged,
});
static DeviceSettingsVM fromStore(Store<AppState> store) {
@ -103,12 +101,6 @@ class DeviceSettingsVM {
onHistoryModeChanged: (context, value) async {
store.dispatch(UserPreferencesChanged(historyMode: value));
},
onFullHeightFilterChanged: (context, value) async {
store.dispatch(UserPreferencesChanged(fullHeightFilter: value));
},
onFullWidthEditorChanged: (context, value) async {
store.dispatch(UserPreferencesChanged(fullWidthEditor: value));
},
onLayoutChanged: (BuildContext context, AppLayout value) async {
if (store.state.prefState.appLayout == value) {
return;
@ -158,8 +150,6 @@ class DeviceSettingsVM {
final AppState state;
final Function(BuildContext) onLogoutTap;
final Function(BuildContext) onRefreshTap;
final Function(BuildContext, bool) onFullHeightFilterChanged;
final Function(BuildContext, bool) onFullWidthEditorChanged;
final Function(BuildContext, bool) onDarkModeChanged;
final Function(BuildContext, AppLayout) onLayoutChanged;
final Function(BuildContext, AppSidebarMode) onMenuModeChanged;

View File

@ -73,8 +73,6 @@ mixin LocalizationsProvider on LocaleCodeAware {
'deleted_payment_term': 'Successfully deleted payment term',
'removed_payment_term': 'Successfully removed payment term',
'restored_payment_term': 'Successfully restored payment term',
'full_width_editor': 'Full Width Editor',
'full_height_filter': 'Full Height Filter',
'email_sign_in': 'Sign in with email',
'change': 'Change',
'change_to_mobile_layout': 'Change to the mobile layout?',
@ -38695,12 +38693,6 @@ mixin LocalizationsProvider on LocaleCodeAware {
String get emailSignIn => _localizedValues[localeCode]['email_sign_in'] ?? '';
String get fullWidthEditor =>
_localizedValues[localeCode]['full_width_editor'] ?? '';
String get fullHeightFilter =>
_localizedValues[localeCode]['full_height_filter'] ?? '';
String get configurePaymentTerms =>
_localizedValues[localeCode]['configure_payment_terms'] ?? '';