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