From 83ec81cf0cb360183c6d2e38c9c6792a2ad4d8fb Mon Sep 17 00:00:00 2001 From: Hillel Coren Date: Tue, 12 Nov 2019 22:28:57 +0200 Subject: [PATCH] History --- lib/ui/app/history_drawer.dart | 26 ++++++++++ lib/ui/app/history_drawer_vm.dart | 49 +++++++++++++++++++ lib/ui/app/list_scaffold.dart | 4 +- lib/ui/app/main_screen.dart | 11 +++-- .../app/{app_drawer.dart => menu_drawer.dart} | 6 +-- ...app_drawer_vm.dart => menu_drawer_vm.dart} | 8 +-- lib/ui/dashboard/dashboard_view.dart | 4 +- starter.sh | 8 +-- 8 files changed, 98 insertions(+), 18 deletions(-) create mode 100644 lib/ui/app/history_drawer.dart create mode 100644 lib/ui/app/history_drawer_vm.dart rename lib/ui/app/{app_drawer.dart => menu_drawer.dart} (99%) rename lib/ui/app/{app_drawer_vm.dart => menu_drawer_vm.dart} (89%) diff --git a/lib/ui/app/history_drawer.dart b/lib/ui/app/history_drawer.dart new file mode 100644 index 000000000..f866e89e8 --- /dev/null +++ b/lib/ui/app/history_drawer.dart @@ -0,0 +1,26 @@ +import 'package:flutter/foundation.dart'; +import 'package:flutter/material.dart'; +import 'package:invoiceninja_flutter/ui/app/history_drawer_vm.dart'; + +class HistoryDrawer extends StatelessWidget { + const HistoryDrawer({ + Key key, + @required this.viewModel, + }) : super(key: key); + + final AppDrawerVM viewModel; + + @override + Widget build(BuildContext context) { + return Drawer( + child: SafeArea( + child: Column( + mainAxisSize: MainAxisSize.max, + children: [ + Text('testk') + ], + ), + ), + ); + } +} diff --git a/lib/ui/app/history_drawer_vm.dart b/lib/ui/app/history_drawer_vm.dart new file mode 100644 index 000000000..ab7082665 --- /dev/null +++ b/lib/ui/app/history_drawer_vm.dart @@ -0,0 +1,49 @@ +import 'package:flutter/foundation.dart'; +import 'package:flutter/widgets.dart'; +import 'package:flutter_redux/flutter_redux.dart'; +import 'package:invoiceninja_flutter/redux/dashboard/dashboard_actions.dart'; +import 'package:invoiceninja_flutter/ui/app/app_builder.dart'; +import 'package:redux/redux.dart'; +import 'package:invoiceninja_flutter/ui/app/history_drawer.dart'; +import 'package:invoiceninja_flutter/redux/app/app_state.dart'; +import 'package:invoiceninja_flutter/redux/company/company_selectors.dart'; +import 'package:invoiceninja_flutter/data/models/models.dart'; + +class HistoryDrawerBuilder extends StatelessWidget { + const HistoryDrawerBuilder({Key key}) : super(key: key); + + @override + Widget build(BuildContext context) { + return StoreConnector( + converter: AppDrawerVM.fromStore, + builder: (context, viewModel) { + return HistoryDrawer(viewModel: viewModel); + }, + ); + } +} + +class AppDrawerVM { + AppDrawerVM({ + @required this.companies, + @required this.selectedCompany, + @required this.user, + @required this.isLoading, + }); + + final List companies; + final CompanyEntity selectedCompany; + final UserEntity user; + final bool isLoading; + + static AppDrawerVM fromStore(Store store) { + final AppState state = store.state; + + return AppDrawerVM( + isLoading: state.isLoading, + companies: companiesSelector(state), + user: state.user, + selectedCompany: state.selectedCompany, + ); + } +} diff --git a/lib/ui/app/list_scaffold.dart b/lib/ui/app/list_scaffold.dart index b8e78b489..1601a2d80 100644 --- a/lib/ui/app/list_scaffold.dart +++ b/lib/ui/app/list_scaffold.dart @@ -7,7 +7,7 @@ import 'package:invoiceninja_flutter/redux/ui/ui_state.dart'; import 'package:invoiceninja_flutter/ui/app/app_bottom_bar.dart'; import 'package:invoiceninja_flutter/utils/platforms.dart'; -import 'app_drawer_vm.dart'; +import 'menu_drawer_vm.dart'; class ListScaffold extends StatelessWidget { const ListScaffold({ @@ -44,7 +44,7 @@ class ListScaffold extends StatelessWidget { return false; }, child: Scaffold( - drawer: isMobile(context) ? AppDrawerBuilder() : null, + drawer: isMobile(context) ? MenuDrawerBuilder() : null, //endDrawer: isMobile(context), appBar: AppBar( automaticallyImplyLeading: false, diff --git a/lib/ui/app/main_screen.dart b/lib/ui/app/main_screen.dart index 7babddabd..6d6ae5332 100644 --- a/lib/ui/app/main_screen.dart +++ b/lib/ui/app/main_screen.dart @@ -4,7 +4,8 @@ import 'package:flutter_redux/flutter_redux.dart'; import 'package:invoiceninja_flutter/data/models/entities.dart'; import 'package:invoiceninja_flutter/redux/app/app_state.dart'; import 'package:invoiceninja_flutter/redux/dashboard/dashboard_actions.dart'; -import 'package:invoiceninja_flutter/ui/app/app_drawer_vm.dart'; +import 'package:invoiceninja_flutter/ui/app/history_drawer_vm.dart'; +import 'package:invoiceninja_flutter/ui/app/menu_drawer_vm.dart'; import 'package:invoiceninja_flutter/ui/app/help_text.dart'; import 'package:invoiceninja_flutter/ui/app/screen_imports.dart'; import 'package:invoiceninja_flutter/ui/settings/settings_screen_vm.dart'; @@ -75,10 +76,14 @@ class MainScreen extends StatelessWidget { return Row(children: [ if (uiState.isMenuVisible) ...[ - AppDrawerBuilder(), + MenuDrawerBuilder(), VerticalDivider(width: isDarkMode(context) ? 1 : .5), ], - Expanded(child: screen) + Expanded(child: screen), + if (uiState.isHistoryVisible) ...[ + VerticalDivider(width: isDarkMode(context) ? 1 : .5), + HistoryDrawerBuilder(), + ], ]); /* diff --git a/lib/ui/app/app_drawer.dart b/lib/ui/app/menu_drawer.dart similarity index 99% rename from lib/ui/app/app_drawer.dart rename to lib/ui/app/menu_drawer.dart index 00edb47df..eefa4cf68 100644 --- a/lib/ui/app/app_drawer.dart +++ b/lib/ui/app/menu_drawer.dart @@ -16,7 +16,7 @@ import 'package:invoiceninja_flutter/redux/dashboard/dashboard_actions.dart'; import 'package:invoiceninja_flutter/redux/invoice/invoice_actions.dart'; import 'package:invoiceninja_flutter/redux/product/product_actions.dart'; import 'package:invoiceninja_flutter/redux/settings/settings_actions.dart'; -import 'package:invoiceninja_flutter/ui/app/app_drawer_vm.dart'; +import 'package:invoiceninja_flutter/ui/app/menu_drawer_vm.dart'; import 'package:invoiceninja_flutter/ui/app/lists/selected_indicator.dart'; import 'package:invoiceninja_flutter/utils/icons.dart'; import 'package:invoiceninja_flutter/utils/localization.dart'; @@ -28,8 +28,8 @@ import 'package:url_launcher/url_launcher.dart'; // STARTER: import - do not remove comment -class AppDrawer extends StatelessWidget { - const AppDrawer({ +class MenuDrawer extends StatelessWidget { + const MenuDrawer({ Key key, @required this.viewModel, }) : super(key: key); diff --git a/lib/ui/app/app_drawer_vm.dart b/lib/ui/app/menu_drawer_vm.dart similarity index 89% rename from lib/ui/app/app_drawer_vm.dart rename to lib/ui/app/menu_drawer_vm.dart index 143ddcbe5..1639d8114 100644 --- a/lib/ui/app/app_drawer_vm.dart +++ b/lib/ui/app/menu_drawer_vm.dart @@ -4,20 +4,20 @@ import 'package:flutter_redux/flutter_redux.dart'; import 'package:invoiceninja_flutter/redux/dashboard/dashboard_actions.dart'; import 'package:invoiceninja_flutter/ui/app/app_builder.dart'; import 'package:redux/redux.dart'; -import 'package:invoiceninja_flutter/ui/app/app_drawer.dart'; +import 'package:invoiceninja_flutter/ui/app/menu_drawer.dart'; import 'package:invoiceninja_flutter/redux/app/app_state.dart'; import 'package:invoiceninja_flutter/redux/company/company_selectors.dart'; import 'package:invoiceninja_flutter/data/models/models.dart'; -class AppDrawerBuilder extends StatelessWidget { - const AppDrawerBuilder({Key key}) : super(key: key); +class MenuDrawerBuilder extends StatelessWidget { + const MenuDrawerBuilder({Key key}) : super(key: key); @override Widget build(BuildContext context) { return StoreConnector( converter: AppDrawerVM.fromStore, builder: (context, viewModel) { - return AppDrawer(viewModel: viewModel); + return MenuDrawer(viewModel: viewModel); }, ); } diff --git a/lib/ui/dashboard/dashboard_view.dart b/lib/ui/dashboard/dashboard_view.dart index deaa151ab..aef353ba7 100644 --- a/lib/ui/dashboard/dashboard_view.dart +++ b/lib/ui/dashboard/dashboard_view.dart @@ -11,7 +11,7 @@ import 'package:invoiceninja_flutter/redux/project/project_actions.dart'; import 'package:invoiceninja_flutter/redux/quote/quote_actions.dart'; import 'package:invoiceninja_flutter/redux/task/task_actions.dart'; import 'package:invoiceninja_flutter/redux/ui/ui_state.dart'; -import 'package:invoiceninja_flutter/ui/app/app_drawer_vm.dart'; +import 'package:invoiceninja_flutter/ui/app/menu_drawer_vm.dart'; import 'package:invoiceninja_flutter/ui/app/list_filter.dart'; import 'package:invoiceninja_flutter/ui/app/list_filter_button.dart'; import 'package:invoiceninja_flutter/ui/dashboard/dashboard_activity.dart'; @@ -57,7 +57,7 @@ class _DashboardViewState extends State return WillPopScope( onWillPop: () async => true, child: Scaffold( - drawer: isMobile(context) ? AppDrawerBuilder() : null, + drawer: isMobile(context) ? MenuDrawerBuilder() : null, appBar: AppBar( leading: !isMobile(context) ? IconButton( diff --git a/starter.sh b/starter.sh index cfabf65da..f50d53d3b 100644 --- a/starter.sh +++ b/starter.sh @@ -85,9 +85,9 @@ if [ ${action} = "init" ]; then './lib/redux/ui/ui_state.dart' './lib/ui/auth/login.dart' './lib/ui/auth/login_vm.dart' - './lib/ui/app/app_drawer.dart' + './lib/ui/app/menu_drawer.dart' './lib/ui/app/init.dart' - './lib/ui/app/app_drawer_vm.dart' + './lib/ui/app/menu_drawer_vm.dart' './lib/ui/app/actions_menu_button.dart' './lib/ui/app/app_bottom_bar.dart' './lib/ui/app/app_search.dart' @@ -336,7 +336,7 @@ else comment="STARTER: import - do not remove comment" code="import 'package:${package}\/redux\/${module_snake}\/${module_snake}_actions.dart';${lineBreak}" - sed -i -e "s/$comment/$comment${lineBreak}$code/g" ./lib/ui/app/app_drawer.dart + sed -i -e "s/$comment/$comment${lineBreak}$code/g" ./lib/ui/app/menu_drawer.dart comment="STARTER: menu - do not remove comment" code="DrawerTile(${lineBreak}" @@ -351,7 +351,7 @@ else code="${code}${module_camel}: ${Module}Entity(), context: context));${lineBreak}" code="${code}},${lineBreak}" code="${code}),${lineBreak}" - sed -i -e "s/$comment/$comment${lineBreak}$code/g" ./lib/ui/app/app_drawer.dart + sed -i -e "s/$comment/$comment${lineBreak}$code/g" ./lib/ui/app/menu_drawer.dart comment="STARTER: import - do not remove comment" code="import 'package:${package}\/redux\/${module_snake}\/${module_snake}_state.dart';${lineBreak}"