Added snackbar
This commit is contained in:
parent
11a83b48c0
commit
1da0ec57a2
|
|
@ -16,7 +16,7 @@ class UserLoginRequest {
|
|||
final String password;
|
||||
final String url;
|
||||
|
||||
UserLoginRequest(this.context, this.email, this.password, [this.url]);
|
||||
UserLoginRequest(this.email, this.password, this.url, this.context);
|
||||
}
|
||||
|
||||
class UserLoginSuccess {}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
import 'package:invoiceninja/data/models/models.dart';
|
||||
import 'package:built_collection/built_collection.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class LoadProductsAction {}
|
||||
|
||||
|
|
@ -32,9 +33,10 @@ class SelectProductAction {
|
|||
}
|
||||
|
||||
class SaveProductRequest {
|
||||
final BuildContext context;
|
||||
final ProductEntity product;
|
||||
|
||||
SaveProductRequest(this.product);
|
||||
SaveProductRequest(this.product, this.context);
|
||||
}
|
||||
|
||||
class SaveProductSuccess {
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:path_provider/path_provider.dart';
|
||||
import 'package:redux/redux.dart';
|
||||
import 'package:invoiceninja/redux/product/product_actions.dart';
|
||||
|
|
@ -26,10 +27,22 @@ Middleware<AppState> _createSaveProduct(ProductsRepository repository) {
|
|||
return (Store<AppState> store, action, NextDispatcher next) {
|
||||
|
||||
repository.saveData(store.state.selectedCompany(), store.state.authState, action.product).then(
|
||||
(product) => store.dispatch(SaveProductSuccess(product))
|
||||
).catchError((error) {
|
||||
(product) {
|
||||
store.dispatch(SaveProductSuccess(product));
|
||||
Scaffold.of(action.context).showSnackBar(
|
||||
SnackBar(
|
||||
content: new Text('Successfully updated product'),
|
||||
duration: Duration(seconds: 3)
|
||||
)
|
||||
);
|
||||
}
|
||||
);
|
||||
/*
|
||||
.catchError((error) {
|
||||
store.dispatch(SaveProductFailure(error));
|
||||
});
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
repository.login(action.email, action.password, action.url).then(
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@ class _ViewModel {
|
|||
if (store.state.isLoading) {
|
||||
return;
|
||||
}
|
||||
store.dispatch(UserLoginRequest(context, email.trim(), password.trim(), url.trim()));
|
||||
store.dispatch(UserLoginRequest(email.trim(), password.trim(), url.trim(), context));
|
||||
}
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,13 +1,12 @@
|
|||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
//import 'package:invoiceninja/containers/edit_product.dart';
|
||||
import 'package:invoiceninja/data/models/models.dart';
|
||||
import 'package:invoiceninja/ui/app/progress_button.dart';
|
||||
|
||||
class DetailsScreen extends StatelessWidget {
|
||||
final ProductEntity product;
|
||||
final Function onDelete;
|
||||
final Function(ProductEntity) onSaveClicked;
|
||||
final Function(ProductEntity, BuildContext) onSaveClicked;
|
||||
final bool isLoading;
|
||||
|
||||
static final GlobalKey<FormState> _formKey = GlobalKey<FormState>();
|
||||
|
|
@ -87,19 +86,23 @@ class DetailsScreen extends StatelessWidget {
|
|||
),
|
||||
),
|
||||
),
|
||||
ProgressButton(
|
||||
label: 'SAVE',
|
||||
isLoading: this.isLoading,
|
||||
onPressed: () {
|
||||
_formKey.currentState.save();
|
||||
this.onSaveClicked(product.rebuild((b) => b
|
||||
..productKey = _productKey.trim()
|
||||
..notes = _notes.trim()
|
||||
..cost = _cost
|
||||
));
|
||||
},
|
||||
new Builder(
|
||||
builder: (BuildContext context) {
|
||||
return ProgressButton(
|
||||
label: 'SAVE',
|
||||
isLoading: this.isLoading,
|
||||
onPressed: () {
|
||||
_formKey.currentState.save();
|
||||
this.onSaveClicked(product.rebuild((b) => b
|
||||
..productKey = _productKey.trim()
|
||||
..notes = _notes.trim()
|
||||
..cost = _cost
|
||||
), context);
|
||||
},
|
||||
);
|
||||
}
|
||||
),
|
||||
],
|
||||
]
|
||||
),
|
||||
),
|
||||
/*
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ class ProductDetails extends StatelessWidget {
|
|||
class _ViewModel {
|
||||
final ProductEntity product;
|
||||
final Function onDelete;
|
||||
final Function(ProductEntity) onSaveClicked;
|
||||
final Function(ProductEntity, BuildContext) onSaveClicked;
|
||||
final bool isLoading;
|
||||
|
||||
_ViewModel({
|
||||
|
|
@ -57,8 +57,8 @@ class _ViewModel {
|
|||
isLoading: store.state.isLoading,
|
||||
product: product,
|
||||
onDelete: () => false, //store.dispatch(DeleteProductAction(product.id)),
|
||||
onSaveClicked: (ProductEntity product) {
|
||||
store.dispatch(SaveProductRequest(product));
|
||||
onSaveClicked: (ProductEntity product, BuildContext context) {
|
||||
store.dispatch(SaveProductRequest(product, context));
|
||||
},
|
||||
);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue