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