Snack bar fixes
This commit is contained in:
parent
8971b4d1d7
commit
935f53eafc
|
|
@ -45,6 +45,7 @@ linter:
|
||||||
# - prefer_const_literals_to_create_immutables
|
# - prefer_const_literals_to_create_immutables
|
||||||
# - avoid_classes_with_only_static_members
|
# - avoid_classes_with_only_static_members
|
||||||
# - avoid_function_literals_in_foreach_calls
|
# - avoid_function_literals_in_foreach_calls
|
||||||
|
# - avoid_field_initializers_in_const_classes
|
||||||
# these rules are documented on and in the same order as
|
# these rules are documented on and in the same order as
|
||||||
# the Dart Lint rules page to make maintenance easier
|
# the Dart Lint rules page to make maintenance easier
|
||||||
# https://github.com/dart-lang/linter/blob/master/example/all.yaml
|
# https://github.com/dart-lang/linter/blob/master/example/all.yaml
|
||||||
|
|
@ -61,7 +62,6 @@ linter:
|
||||||
# - avoid_catching_errors # we do this commonly
|
# - avoid_catching_errors # we do this commonly
|
||||||
# - avoid_double_and_int_checks # only useful when targeting JS runtime
|
# - avoid_double_and_int_checks # only useful when targeting JS runtime
|
||||||
- avoid_empty_else
|
- avoid_empty_else
|
||||||
- avoid_field_initializers_in_const_classes
|
|
||||||
- avoid_init_to_null
|
- avoid_init_to_null
|
||||||
# - avoid_js_rounded_ints # only useful when targeting JS runtime
|
# - avoid_js_rounded_ints # only useful when targeting JS runtime
|
||||||
- avoid_null_checks_in_equality_operators
|
- avoid_null_checks_in_equality_operators
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,6 @@ import 'package:flutter/widgets.dart';
|
||||||
import 'package:invoiceninja_flutter/data/models/models.dart';
|
import 'package:invoiceninja_flutter/data/models/models.dart';
|
||||||
import 'package:invoiceninja_flutter/redux/product/product_actions.dart';
|
import 'package:invoiceninja_flutter/redux/product/product_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/app/snackbar_row.dart';
|
|
||||||
import 'package:invoiceninja_flutter/ui/client/client_screen.dart';
|
import 'package:invoiceninja_flutter/ui/client/client_screen.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/client/view/client_view_vm.dart';
|
import 'package:invoiceninja_flutter/ui/client/view/client_view_vm.dart';
|
||||||
|
|
@ -63,14 +62,7 @@ Middleware<AppState> _viewClient() {
|
||||||
next(action);
|
next(action);
|
||||||
|
|
||||||
store.dispatch(UpdateCurrentRoute(ClientViewScreen.route));
|
store.dispatch(UpdateCurrentRoute(ClientViewScreen.route));
|
||||||
final message = await Navigator.of(action.context).pushNamed(ClientViewScreen.route);
|
Navigator.of(action.context).pushNamed(ClientViewScreen.route);
|
||||||
|
|
||||||
/*
|
|
||||||
Scaffold.of(action.context).showSnackBar(SnackBar(
|
|
||||||
content: SnackBarRow(
|
|
||||||
message: message,
|
|
||||||
)));
|
|
||||||
*/
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:invoiceninja_flutter/data/models/models.dart';
|
import 'package:invoiceninja_flutter/data/models/models.dart';
|
||||||
import 'package:invoiceninja_flutter/redux/ui/ui_actions.dart';
|
import 'package:invoiceninja_flutter/redux/ui/ui_actions.dart';
|
||||||
import 'package:invoiceninja_flutter/ui/app/snackbar_row.dart';
|
|
||||||
import 'package:invoiceninja_flutter/ui/invoice/edit/invoice_edit_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/invoice/invoice_screen.dart';
|
||||||
import 'package:invoiceninja_flutter/ui/invoice/view/invoice_view_vm.dart';
|
import 'package:invoiceninja_flutter/ui/invoice/view/invoice_view_vm.dart';
|
||||||
|
|
@ -44,14 +43,7 @@ Middleware<AppState> _viewInvoice() {
|
||||||
next(action);
|
next(action);
|
||||||
|
|
||||||
store.dispatch(UpdateCurrentRoute(InvoiceViewScreen.route));
|
store.dispatch(UpdateCurrentRoute(InvoiceViewScreen.route));
|
||||||
final message = await Navigator.of(action.context).pushNamed(InvoiceViewScreen.route);
|
await Navigator.of(action.context).pushNamed(InvoiceViewScreen.route);
|
||||||
|
|
||||||
/*
|
|
||||||
Scaffold.of(action.context).showSnackBar(SnackBar(
|
|
||||||
content: SnackBarRow(
|
|
||||||
message: message,
|
|
||||||
)));
|
|
||||||
*/
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -69,14 +61,12 @@ Middleware<AppState> _editInvoice() {
|
||||||
next(action);
|
next(action);
|
||||||
|
|
||||||
store.dispatch(UpdateCurrentRoute(InvoiceEditScreen.route));
|
store.dispatch(UpdateCurrentRoute(InvoiceEditScreen.route));
|
||||||
final message = await Navigator.of(action.context).pushNamed(InvoiceEditScreen.route);
|
final invoice = await Navigator.of(action.context).pushNamed(InvoiceEditScreen.route);
|
||||||
|
|
||||||
|
if (action.completer != null) {
|
||||||
|
action.completer.complete(invoice);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
Scaffold.of(action.context).showSnackBar(SnackBar(
|
|
||||||
content: SnackBarRow(
|
|
||||||
message: message,
|
|
||||||
)));
|
|
||||||
*/
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:invoiceninja_flutter/data/models/models.dart';
|
import 'package:invoiceninja_flutter/data/models/models.dart';
|
||||||
import 'package:invoiceninja_flutter/redux/ui/ui_actions.dart';
|
import 'package:invoiceninja_flutter/redux/ui/ui_actions.dart';
|
||||||
import 'package:invoiceninja_flutter/ui/app/snackbar_row.dart';
|
|
||||||
import 'package:invoiceninja_flutter/ui/product/edit/product_edit_vm.dart';
|
import 'package:invoiceninja_flutter/ui/product/edit/product_edit_vm.dart';
|
||||||
import 'package:invoiceninja_flutter/ui/product/product_screen.dart';
|
import 'package:invoiceninja_flutter/ui/product/product_screen.dart';
|
||||||
import 'package:redux/redux.dart';
|
import 'package:redux/redux.dart';
|
||||||
|
|
@ -36,14 +35,7 @@ Middleware<AppState> _editProduct() {
|
||||||
next(action);
|
next(action);
|
||||||
|
|
||||||
store.dispatch(UpdateCurrentRoute(ProductEditScreen.route));
|
store.dispatch(UpdateCurrentRoute(ProductEditScreen.route));
|
||||||
final message = await Navigator.of(action.context).pushNamed(ProductEditScreen.route);
|
Navigator.of(action.context).pushNamed(ProductEditScreen.route);
|
||||||
|
|
||||||
/*
|
|
||||||
Scaffold.of(action.context).showSnackBar(SnackBar(
|
|
||||||
content: SnackBarRow(
|
|
||||||
message: message,
|
|
||||||
)));
|
|
||||||
*/
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,6 @@ import 'package:flutter_redux/flutter_redux.dart';
|
||||||
import 'package:invoiceninja_flutter/data/models/models.dart';
|
import 'package:invoiceninja_flutter/data/models/models.dart';
|
||||||
import 'package:invoiceninja_flutter/redux/app/app_state.dart';
|
import 'package:invoiceninja_flutter/redux/app/app_state.dart';
|
||||||
import 'package:invoiceninja_flutter/redux/client/client_actions.dart';
|
import 'package:invoiceninja_flutter/redux/client/client_actions.dart';
|
||||||
import 'package:invoiceninja_flutter/redux/invoice/invoice_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/app/dialogs/error_dialog.dart';
|
import 'package:invoiceninja_flutter/ui/app/dialogs/error_dialog.dart';
|
||||||
import 'package:invoiceninja_flutter/ui/client/client_screen.dart';
|
import 'package:invoiceninja_flutter/ui/client/client_screen.dart';
|
||||||
|
|
@ -102,28 +101,16 @@ class ClientEditVM {
|
||||||
store.dispatch(
|
store.dispatch(
|
||||||
SaveClientRequest(completer: completer, client: client));
|
SaveClientRequest(completer: completer, client: client));
|
||||||
return completer.future.then((savedClient) {
|
return completer.future.then((savedClient) {
|
||||||
final localization = AppLocalization.of(context);
|
//final localization = AppLocalization.of(context);
|
||||||
if (client.isNew) {
|
if (client.isNew) {
|
||||||
if (store.state.uiState.currentRoute == InvoiceEditScreen.route) {
|
if (store.state.uiState.currentRoute == InvoiceEditScreen.route) {
|
||||||
/*
|
|
||||||
final invoice = store.state.invoiceUIState.editing;
|
|
||||||
invoice.rebuild((b) => b
|
|
||||||
..clientId = client.id
|
|
||||||
);
|
|
||||||
store.dispatch(UpdateInvoice(invoice));
|
|
||||||
*/
|
|
||||||
Navigator.of(context).pop(savedClient);
|
Navigator.of(context).pop(savedClient);
|
||||||
} else {
|
} else {
|
||||||
Navigator.of(context).pushReplacementNamed(
|
Navigator.of(context).pushReplacementNamed(
|
||||||
ClientViewScreen.route);
|
ClientViewScreen.route);
|
||||||
}
|
}
|
||||||
/*
|
|
||||||
Navigator.of(context).pop(localization.successfullyCreatedClient);
|
|
||||||
Navigator.of(context).push<ClientViewScreen>(
|
|
||||||
MaterialPageRoute(builder: (_) => ClientViewScreen()));
|
|
||||||
*/
|
|
||||||
} else {
|
} else {
|
||||||
Navigator.of(context).pop(localization.successfullyUpdatedClient);
|
Navigator.of(context).pop(savedClient);
|
||||||
}
|
}
|
||||||
}).catchError((Object error) {
|
}).catchError((Object error) {
|
||||||
showDialog<ErrorDialog>(
|
showDialog<ErrorDialog>(
|
||||||
|
|
|
||||||
|
|
@ -53,34 +53,10 @@ class _ClientViewState extends State<ClientView>
|
||||||
},
|
},
|
||||||
child: Scaffold(
|
child: Scaffold(
|
||||||
backgroundColor: Theme.of(context).backgroundColor,
|
backgroundColor: Theme.of(context).backgroundColor,
|
||||||
appBar: AppBar(
|
appBar: CustomAppBar(
|
||||||
title: Text(
|
viewModel: viewModel,
|
||||||
client.displayName ?? ''), // Text(localizations.clientDetails),
|
client: client,
|
||||||
bottom: TabBar(
|
controller: _controller,
|
||||||
controller: _controller,
|
|
||||||
//isScrollable: true,
|
|
||||||
tabs: [
|
|
||||||
Tab(
|
|
||||||
text: localization.overview,
|
|
||||||
),
|
|
||||||
Tab(
|
|
||||||
text: localization.details,
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
actions: client.isNew
|
|
||||||
? []
|
|
||||||
: [
|
|
||||||
EditIconButton(
|
|
||||||
isVisible: !client.isDeleted,
|
|
||||||
onPressed: () => viewModel.onEditPressed(context),
|
|
||||||
),
|
|
||||||
ActionMenuButton(
|
|
||||||
isSaving: viewModel.isSaving,
|
|
||||||
entity: client,
|
|
||||||
onSelected: viewModel.onActionSelected,
|
|
||||||
)
|
|
||||||
],
|
|
||||||
),
|
),
|
||||||
body: TabBarView(
|
body: TabBarView(
|
||||||
controller: _controller,
|
controller: _controller,
|
||||||
|
|
@ -145,3 +121,53 @@ class _ClientViewState extends State<ClientView>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class CustomAppBar extends StatelessWidget implements PreferredSizeWidget {
|
||||||
|
const CustomAppBar({
|
||||||
|
@required this.client,
|
||||||
|
@required this.viewModel,
|
||||||
|
@required this.controller,
|
||||||
|
});
|
||||||
|
|
||||||
|
final ClientViewVM viewModel;
|
||||||
|
final ClientEntity client;
|
||||||
|
final TabController controller;
|
||||||
|
|
||||||
|
@override
|
||||||
|
final Size preferredSize = const Size(double.infinity, 100.0);
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
final localization = AppLocalization.of(context);
|
||||||
|
|
||||||
|
return AppBar(
|
||||||
|
title: Text(
|
||||||
|
client.displayName ?? ''), // Text(localizations.clientDetails),
|
||||||
|
bottom: TabBar(
|
||||||
|
controller: controller,
|
||||||
|
//isScrollable: true,
|
||||||
|
tabs: [
|
||||||
|
Tab(
|
||||||
|
text: localization.overview,
|
||||||
|
),
|
||||||
|
Tab(
|
||||||
|
text: localization.details,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
actions: client.isNew
|
||||||
|
? []
|
||||||
|
: [
|
||||||
|
EditIconButton(
|
||||||
|
isVisible: !client.isDeleted,
|
||||||
|
onPressed: () => viewModel.onEditPressed(context),
|
||||||
|
),
|
||||||
|
ActionMenuButton(
|
||||||
|
isSaving: viewModel.isSaving,
|
||||||
|
entity: client,
|
||||||
|
onSelected: viewModel.onActionSelected,
|
||||||
|
)
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -64,7 +64,15 @@ class ClientViewVM {
|
||||||
client: client,
|
client: client,
|
||||||
company: state.selectedCompany,
|
company: state.selectedCompany,
|
||||||
onEditPressed: (BuildContext context) {
|
onEditPressed: (BuildContext context) {
|
||||||
store.dispatch(EditClient(client: client, context: context));
|
final Completer<ClientEntity> completer = new Completer<ClientEntity>();
|
||||||
|
store.dispatch(EditClient(client: client, context: context, completer: completer));
|
||||||
|
completer.future.then((client) {
|
||||||
|
Scaffold.of(context).showSnackBar(SnackBar(
|
||||||
|
content: SnackBarRow(
|
||||||
|
message: AppLocalization.of(context).successfullyUpdatedClient,
|
||||||
|
)
|
||||||
|
));
|
||||||
|
});
|
||||||
},
|
},
|
||||||
onInvoicesPressed: (BuildContext context) {
|
onInvoicesPressed: (BuildContext context) {
|
||||||
store.dispatch(FilterInvoicesByClient(client.id));
|
store.dispatch(FilterInvoicesByClient(client.id));
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue