diff --git a/lib/redux/client/client_middleware.dart b/lib/redux/client/client_middleware.dart index d5ecc0b64..6e2be5336 100644 --- a/lib/redux/client/client_middleware.dart +++ b/lib/redux/client/client_middleware.dart @@ -62,7 +62,10 @@ Middleware _viewClient() { next(action); store.dispatch(UpdateCurrentRoute(ClientViewScreen.route)); - Navigator.of(action.context).pushNamed(ClientViewScreen.route); + + if (action.context != null && isMobile(action.context)) { + Navigator.of(action.context).pushNamed(ClientViewScreen.route); + } }; } @@ -72,8 +75,10 @@ Middleware _viewClientList() { store.dispatch(UpdateCurrentRoute(ClientScreen.route)); - Navigator.of(action.context).pushNamedAndRemoveUntil( - ClientScreen.route, (Route route) => false); + if (action.context != null && isMobile(action.context)) { + Navigator.of(action.context).pushNamedAndRemoveUntil( + ClientScreen.route, (Route route) => false); + } }; } diff --git a/lib/ui/app/main_screen.dart b/lib/ui/app/main_screen.dart index 3ef0d65f1..0a911f02e 100644 --- a/lib/ui/app/main_screen.dart +++ b/lib/ui/app/main_screen.dart @@ -1,26 +1,61 @@ import 'package:flutter/material.dart'; +import 'package:flutter_redux/flutter_redux.dart'; +import 'package:invoiceninja_flutter/ui/client/edit/client_edit_vm.dart'; +import 'package:invoiceninja_flutter/ui/client/view/client_view_vm.dart'; +import 'package:redux/redux.dart'; +import 'package:invoiceninja_flutter/data/models/entities.dart'; +import 'package:invoiceninja_flutter/redux/app/app_state.dart'; import 'package:invoiceninja_flutter/ui/app/app_drawer_vm.dart'; -import 'package:invoiceninja_flutter/ui/invoice/edit/invoice_edit_vm.dart'; -import 'package:invoiceninja_flutter/ui/invoice/invoice_screen.dart'; +import 'package:invoiceninja_flutter/ui/client/client_screen.dart'; +import 'package:invoiceninja_flutter/ui/dashboard/dashboard_screen.dart'; class MainScreen extends StatelessWidget { static const String route = '/main'; @override Widget build(BuildContext context) { - return Row( - children: [ - AppDrawerBuilder(), - //Expanded(child: DashboardScreen()), - Expanded( - flex: 3, - child: InvoiceScreen(), - ), - Expanded( - flex: 5, - child: InvoiceEditScreen(), - ), - ], - ); + return StoreBuilder(builder: (BuildContext context, Store store) { + final route = store.state.uiState.currentRoute; + final parts = route.split('/').where((part) => part.isNotEmpty).toList(); + final mainRoute = parts[0]; + + int index = 0; + if (mainRoute == EntityType.client.name) { + index = 1; + } + + return Row( + children: [ + AppDrawerBuilder(), + Expanded( + child: IndexedStack( + index: index, + key: ValueKey(index), + children: [ + DashboardScreen(), + Row( + children: [ + Expanded( + child: ClientScreen(), + flex: 3, + ), + Expanded( + flex: 5, + child: IndexedStack( + index: 0, + children: [ + ClientViewScreen(), + ClientEditScreen(), + ], + ), + ) + ], + ) + ], + ), + ), + ], + ); + }); } }