diff --git a/lib/data/models/entities.dart b/lib/data/models/entities.dart index e7a35d4d6..97dc8ff26 100644 --- a/lib/data/models/entities.dart +++ b/lib/data/models/entities.dart @@ -203,6 +203,8 @@ class EntityType extends EnumClass { String get snakeCase => toSnakeCase(toString()); + bool get hasFullWidthViewer => [EntityType.client].contains(this); + static BuiltSet get values => _$typeValues; static EntityType valueOf(String name) => _$typeValueOf(name); diff --git a/lib/redux/app/app_actions.dart b/lib/redux/app/app_actions.dart index 536b49c93..4db734b79 100644 --- a/lib/redux/app/app_actions.dart +++ b/lib/redux/app/app_actions.dart @@ -125,6 +125,12 @@ class ToggleEditorLayout implements PersistPrefs { final EntityType entityType; } +class ToggleViewerLayout implements PersistPrefs { + ToggleViewerLayout(this.entityType); + + final EntityType entityType; +} + class TogglePreviewSidebar {} class UpdateUserPreferences implements PersistPrefs { diff --git a/lib/redux/ui/pref_reducer.dart b/lib/redux/ui/pref_reducer.dart index 9a2a7bb91..f9871f002 100644 --- a/lib/redux/ui/pref_reducer.dart +++ b/lib/redux/ui/pref_reducer.dart @@ -79,6 +79,8 @@ PrefState prefReducer( ..customColors.replace(customColorsReducer(state.customColors, action)) ..useSidebarEditor .replace(sidebarEditorReducer(state.useSidebarEditor, action)) + ..useSidebarViewer + .replace(sidebarViewerReducer(state.useSidebarViewer, action)) ..sortFields.replace(sortFieldsReducer(state.sortFields, action)) ..editAfterSaving = editAfterSavingReducer(state.editAfterSaving, action) ..enableTouchEvents = @@ -172,6 +174,17 @@ Reducer> sidebarEditorReducer = combineReducers([ }), ]); +Reducer> sidebarViewerReducer = combineReducers([ + TypedReducer, ToggleViewerLayout>((value, action) { + final entityType = action.entityType.baseType; + if (value.containsKey(entityType)) { + return value.rebuild((b) => b..[entityType] = !value[entityType]); + } else { + return value.rebuild((b) => b..[entityType] = true); + } + }), +]); + Reducer menuVisibleReducer = combineReducers([ TypedReducer((value, action) { return action.sidebar == AppSidebar.menu ? !value : value; diff --git a/lib/ui/app/entity_top_filter.dart b/lib/ui/app/entity_top_filter.dart index 21b5aba74..1d8509ae9 100644 --- a/lib/ui/app/entity_top_filter.dart +++ b/lib/ui/app/entity_top_filter.dart @@ -6,6 +6,7 @@ import 'package:flutter_redux/flutter_redux.dart'; import 'package:invoiceninja_flutter/ui/app/icon_text.dart'; import 'package:invoiceninja_flutter/ui/app/screen_imports.dart'; import 'package:invoiceninja_flutter/utils/icons.dart'; +import 'package:material_design_icons_flutter/material_design_icons_flutter.dart'; import 'package:overflow_view/overflow_view.dart'; // Project imports: @@ -215,9 +216,17 @@ class EntityTopFilter extends StatelessWidget { ), ), ), + SizedBox(width: 4), if (!prefState .isViewerFullScreen(filterEntityType)) ...[ - SizedBox(width: 4), + if (filterEntityType.hasFullWidthViewer) + IconButton( + onPressed: () { + store.dispatch(ToggleViewerLayout( + uiState.filterEntityType)); + }, + icon: Icon(MdiIcons.chevronDown), + ), IconButton( icon: Icon( Icons.clear, @@ -227,8 +236,14 @@ class EntityTopFilter extends StatelessWidget { FilterByEntity(entity: uiState.filterEntity), ), ), - SizedBox(width: 4), - ], + ] else + IconButton( + onPressed: () { + store.dispatch( + ToggleViewerLayout(uiState.filterEntityType)); + }, + icon: Icon(MdiIcons.chevronUp), + ), ], ), ), @@ -389,7 +404,6 @@ class EntityTopFilterHeader extends StatelessWidget { FilterByEntity(entity: uiState.filterEntity), ), ), - SizedBox(width: 4), ], ), ); diff --git a/lib/ui/app/list_scaffold.dart b/lib/ui/app/list_scaffold.dart index 4b52f8804..2da92155b 100644 --- a/lib/ui/app/list_scaffold.dart +++ b/lib/ui/app/list_scaffold.dart @@ -10,7 +10,6 @@ import 'package:invoiceninja_flutter/redux/app/app_actions.dart'; import 'package:invoiceninja_flutter/redux/app/app_state.dart'; import 'package:invoiceninja_flutter/redux/dashboard/dashboard_actions.dart'; import 'package:invoiceninja_flutter/redux/settings/settings_actions.dart'; -import 'package:invoiceninja_flutter/redux/ui/pref_state.dart'; import 'package:invoiceninja_flutter/ui/app/app_bottom_bar.dart'; import 'package:invoiceninja_flutter/ui/app/history_drawer_vm.dart'; import 'package:invoiceninja_flutter/utils/localization.dart';