merge
This commit is contained in:
@@ -59,13 +59,12 @@ class _DiscountByWeightListState extends State<DiscountByWeightList> {
|
||||
),
|
||||
floatingActionButton: FloatingActionButton.extended(
|
||||
onPressed: () {
|
||||
Navigator.of(context).push(
|
||||
CupertinoPageRoute(builder: (context) => DiscountByWeightEditor()));
|
||||
Navigator.of(context).push(CupertinoPageRoute(
|
||||
builder: (context) => DiscountByWeightEditor()));
|
||||
},
|
||||
icon: Icon(Icons.add, color: Colors.white),
|
||||
backgroundColor: primaryColor,
|
||||
label: LocalText(context, 'discount.new',
|
||||
color: Colors.white)),
|
||||
label: LocalText(context, 'discount.new', color: Colors.white)),
|
||||
body: Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: ListView.separated(
|
||||
@@ -80,7 +79,7 @@ class _DiscountByWeightListState extends State<DiscountByWeightList> {
|
||||
onTap: () {
|
||||
Navigator.of(context).push(CupertinoPageRoute(
|
||||
builder: (context) => DiscountByWeightEditor(
|
||||
discount: discountByWeight)));
|
||||
discountByWeight: discountByWeight)));
|
||||
},
|
||||
child: Container(
|
||||
child: _row("${discountByWeight.weight.toString()} lb",
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import 'package:fcs/domain/entities/discount.dart';
|
||||
import 'package:fcs/domain/entities/discount_by_weight.dart';
|
||||
import 'package:fcs/helpers/theme.dart';
|
||||
import 'package:fcs/localization/app_translations.dart';
|
||||
@@ -12,8 +11,8 @@ import 'package:font_awesome_flutter/font_awesome_flutter.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
class DiscountByWeightEditor extends StatefulWidget {
|
||||
final DiscountByWeight discount;
|
||||
DiscountByWeightEditor({this.discount});
|
||||
final DiscountByWeight discountByWeight;
|
||||
DiscountByWeightEditor({this.discountByWeight});
|
||||
|
||||
@override
|
||||
_DiscountByWeightEditorState createState() => _DiscountByWeightEditorState();
|
||||
@@ -24,18 +23,16 @@ class _DiscountByWeightEditorState extends State<DiscountByWeightEditor> {
|
||||
TextEditingController _discountController = new TextEditingController();
|
||||
|
||||
bool _isLoading = false;
|
||||
DiscountByWeight _discount = new DiscountByWeight();
|
||||
bool _isNew = false;
|
||||
DiscountByWeight _discountByWeight = new DiscountByWeight();
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
if (widget.discount != null) {
|
||||
_discount = widget.discount;
|
||||
_weightController.text = _discount.weight.toString();
|
||||
_discountController.text = _discount.discount.toString();
|
||||
} else {
|
||||
_isNew = true;
|
||||
if (widget.discountByWeight != null) {
|
||||
_discountByWeight = widget.discountByWeight;
|
||||
_weightController.text = _discountByWeight.weight.toString();
|
||||
_discountController.text = _discountByWeight.discount.toString();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -109,7 +106,7 @@ class _DiscountByWeightEditorState extends State<DiscountByWeightEditor> {
|
||||
if (_isNew) {
|
||||
await shipmentRateModel.addDiscountByWeight(_discount);
|
||||
} else {
|
||||
_discount.id = widget.discount.id;
|
||||
_discount.id = widget.discountByWeight.id;
|
||||
await shipmentRateModel.updateDiscountByWeight(_discount);
|
||||
}
|
||||
Navigator.pop(context);
|
||||
@@ -134,7 +131,7 @@ class _DiscountByWeightEditorState extends State<DiscountByWeightEditor> {
|
||||
try {
|
||||
var shipmentRateModel =
|
||||
Provider.of<ShipmentRateModel>(context, listen: false);
|
||||
await shipmentRateModel.deleteDiscountByWeight(widget.discount.id);
|
||||
await shipmentRateModel.deleteDiscountByWeight(widget.discountByWeight.id);
|
||||
Navigator.pop(context);
|
||||
} catch (e) {
|
||||
showMsgDialog(context, "Error", e.toString());
|
||||
|
||||
Reference in New Issue
Block a user