Tablet layout
This commit is contained in:
parent
c6096efb2f
commit
1a610d1ec6
|
|
@ -215,7 +215,7 @@ Middleware<AppState> _createLoadState(
|
|||
final Completer<Null> completer = Completer<Null>();
|
||||
completer.future.then((_) {
|
||||
if (uiState.layout == AppLayout.mobile) {
|
||||
store.dispatch(ViewDashboard(action.context));
|
||||
store.dispatch(ViewDashboard(context: action.context));
|
||||
} else {
|
||||
store.dispatch(ViewMainScreen(action.context));
|
||||
}
|
||||
|
|
@ -426,6 +426,14 @@ void _setLastLoadWasSuccesfull() async {
|
|||
*/
|
||||
|
||||
bool hasChanges(Store<AppState> store, dynamic action) {
|
||||
if (action.context == null) {
|
||||
print('WARNING: context is null in hasChanges');
|
||||
return false;
|
||||
} else if (action.force == null) {
|
||||
print('WARNING: force is null in hasChanges');
|
||||
return false;
|
||||
}
|
||||
|
||||
if (store.state.hasChanges() && !isMobile(action.context) && !action.force) {
|
||||
showDialog<MessageDialog>(
|
||||
context: action.context,
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@ import 'package:invoiceninja_flutter/redux/project/project_state.dart';
|
|||
import 'package:invoiceninja_flutter/redux/payment/payment_state.dart';
|
||||
import 'package:invoiceninja_flutter/redux/quote/quote_state.dart';
|
||||
import 'package:invoiceninja_flutter/ui/client/edit/client_edit_vm.dart';
|
||||
import 'package:invoiceninja_flutter/ui/product/edit/product_edit_vm.dart';
|
||||
|
||||
part 'app_state.g.dart';
|
||||
|
||||
|
|
@ -209,6 +210,10 @@ abstract class AppState implements Built<AppState, AppStateBuilder> {
|
|||
case ClientEditScreen.route:
|
||||
return clientUIState.editing.isNew ||
|
||||
clientState.map[clientUIState.editing.id] != clientUIState.editing;
|
||||
case ProductEditScreen.route:
|
||||
return productUIState.editing.isNew ||
|
||||
productState.map[productUIState.editing.id] !=
|
||||
productUIState.editing;
|
||||
}
|
||||
|
||||
if (uiState.currentRoute.endsWith('/edit')) {
|
||||
|
|
|
|||
|
|
@ -36,12 +36,14 @@ class EditClient implements PersistUI {
|
|||
@required this.context,
|
||||
this.contact,
|
||||
this.completer,
|
||||
this.force = false,
|
||||
this.trackRoute = true});
|
||||
|
||||
final ClientEntity client;
|
||||
final ContactEntity contact;
|
||||
final BuildContext context;
|
||||
final Completer completer;
|
||||
final bool force;
|
||||
final bool trackRoute;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -6,9 +6,10 @@ import 'package:invoiceninja_flutter/data/models/models.dart';
|
|||
import 'package:invoiceninja_flutter/redux/app/app_actions.dart';
|
||||
|
||||
class ViewDashboard implements PersistUI {
|
||||
ViewDashboard([this.context]);
|
||||
ViewDashboard({@required this.context, this.force = false});
|
||||
|
||||
final BuildContext context;
|
||||
final bool force;
|
||||
}
|
||||
|
||||
class UpdateDashboardSettings implements PersistUI {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
import 'package:flutter/widgets.dart';
|
||||
import 'package:invoiceninja_flutter/redux/app/app_middleware.dart';
|
||||
import 'package:invoiceninja_flutter/redux/client/client_actions.dart';
|
||||
import 'package:invoiceninja_flutter/redux/ui/ui_actions.dart';
|
||||
import 'package:invoiceninja_flutter/ui/dashboard/dashboard_screen.dart';
|
||||
|
|
@ -22,10 +23,15 @@ List<Middleware<AppState>> createStoreDashboardMiddleware([
|
|||
|
||||
Middleware<AppState> _createViewDashboard() {
|
||||
return (Store<AppState> store, dynamic action, NextDispatcher next) {
|
||||
|
||||
if (hasChanges(store, action)) {
|
||||
return;
|
||||
}
|
||||
|
||||
store.dispatch(LoadDashboard());
|
||||
store.dispatch(UpdateCurrentRoute(DashboardScreen.route));
|
||||
|
||||
if (action.context != null && isMobile(action.context)) {
|
||||
if (isMobile(action.context)) {
|
||||
Navigator.of(action.context).pushNamedAndRemoveUntil(
|
||||
DashboardScreen.route, (Route<dynamic> route) => false);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -170,7 +170,7 @@ class AppDrawer extends StatelessWidget {
|
|||
company: company,
|
||||
icon: FontAwesomeIcons.tachometerAlt,
|
||||
title: localization.dashboard,
|
||||
onTap: () => store.dispatch(ViewDashboard(context)),
|
||||
onTap: () => store.dispatch(ViewDashboard(context: context)),
|
||||
),
|
||||
DrawerTile(
|
||||
key: Key(ClientKeys.drawer),
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ import 'package:invoiceninja_flutter/utils/localization.dart';
|
|||
|
||||
class MessageDialog extends StatelessWidget {
|
||||
const MessageDialog(this.message);
|
||||
|
||||
final String message;
|
||||
|
||||
@override
|
||||
|
|
@ -25,7 +26,10 @@ class MessageDialog extends StatelessWidget {
|
|||
style: Theme.of(context).textTheme.title),
|
||||
*/
|
||||
SizedBox(height: 20.0),
|
||||
Text(message),
|
||||
Text(
|
||||
message,
|
||||
style: Theme.of(context).textTheme.title,
|
||||
),
|
||||
SizedBox(height: 40.0),
|
||||
ElevatedButton(
|
||||
onPressed: () => Navigator.of(context).pop(),
|
||||
|
|
|
|||
|
|
@ -68,7 +68,7 @@ class LoginVM {
|
|||
AppBuilder.of(context).rebuild();
|
||||
|
||||
if (isMobile(context)) {
|
||||
store.dispatch(ViewDashboard(context));
|
||||
store.dispatch(ViewDashboard(context: context));
|
||||
} else {
|
||||
store.dispatch(ViewMainScreen(context));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ class ClientScreen extends StatelessWidget {
|
|||
|
||||
return WillPopScope(
|
||||
onWillPop: () async {
|
||||
store.dispatch(ViewDashboard(context));
|
||||
store.dispatch(ViewDashboard(context: context));
|
||||
return false;
|
||||
},
|
||||
child: Scaffold(
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ class DocumentScreen extends StatelessWidget {
|
|||
|
||||
return WillPopScope(
|
||||
onWillPop: () async {
|
||||
store.dispatch(ViewDashboard(context));
|
||||
store.dispatch(ViewDashboard(context: context));
|
||||
return false;
|
||||
},
|
||||
child: Scaffold(
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ class ExpenseScreen extends StatelessWidget {
|
|||
|
||||
return WillPopScope(
|
||||
onWillPop: () async {
|
||||
store.dispatch(ViewDashboard(context));
|
||||
store.dispatch(ViewDashboard(context: context));
|
||||
return false;
|
||||
},
|
||||
child: Scaffold(
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ class InvoiceScreen extends StatelessWidget {
|
|||
|
||||
return WillPopScope(
|
||||
onWillPop: () async {
|
||||
store.dispatch(ViewDashboard(context));
|
||||
store.dispatch(ViewDashboard(context: context));
|
||||
return false;
|
||||
},
|
||||
child: Scaffold(
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ class PaymentScreen extends StatelessWidget {
|
|||
|
||||
return WillPopScope(
|
||||
onWillPop: () async {
|
||||
store.dispatch(ViewDashboard(context));
|
||||
store.dispatch(ViewDashboard(context: context));
|
||||
return false;
|
||||
},
|
||||
child: Scaffold(
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ class ProductScreen extends StatelessWidget {
|
|||
|
||||
return WillPopScope(
|
||||
onWillPop: () async {
|
||||
store.dispatch(ViewDashboard(context));
|
||||
store.dispatch(ViewDashboard(context: context));
|
||||
return false;
|
||||
},
|
||||
child: Scaffold(
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ class ProjectScreen extends StatelessWidget {
|
|||
|
||||
return WillPopScope(
|
||||
onWillPop: () async {
|
||||
store.dispatch(ViewDashboard(context));
|
||||
store.dispatch(ViewDashboard(context: context));
|
||||
return false;
|
||||
},
|
||||
child: Scaffold(
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ class QuoteScreen extends StatelessWidget {
|
|||
|
||||
return WillPopScope(
|
||||
onWillPop: () async {
|
||||
store.dispatch(ViewDashboard(context));
|
||||
store.dispatch(ViewDashboard(context: context));
|
||||
return false;
|
||||
},
|
||||
child: Scaffold(
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ class TaskScreen extends StatelessWidget {
|
|||
|
||||
return WillPopScope(
|
||||
onWillPop: () async {
|
||||
store.dispatch(ViewDashboard(context));
|
||||
store.dispatch(ViewDashboard(context: context));
|
||||
return false;
|
||||
},
|
||||
child: Scaffold(
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ class VendorScreen extends StatelessWidget {
|
|||
|
||||
return WillPopScope(
|
||||
onWillPop: () async {
|
||||
store.dispatch(ViewDashboard(context));
|
||||
store.dispatch(ViewDashboard(context: context));
|
||||
return false;
|
||||
},
|
||||
child: Scaffold(
|
||||
|
|
|
|||
Loading…
Reference in New Issue