add two decimal and add confirm dialog if press back button

This commit is contained in:
Thinzar Win
2020-12-04 17:28:21 +06:30
parent d5a3c4410e
commit 0b339e9dc1
32 changed files with 169 additions and 54 deletions

View File

@@ -1,5 +1,6 @@
import 'package:fcs/domain/entities/cargo_type.dart';
import 'package:fcs/helpers/theme.dart';
import 'package:fcs/pages/main/util.dart';
import 'package:fcs/pages/widgets/local_text.dart';
import 'package:fcs/pages/widgets/my_data_table.dart';
import 'package:flutter/cupertino.dart';
@@ -25,6 +26,8 @@ class CargoTable extends StatefulWidget {
class _CargoTableState extends State<CargoTable> {
double totalWeight = 0;
List<CargoType> _cargos = [];
double remainingWeight = 0;
@override
Widget build(BuildContext context) {
return MyDataTable(
@@ -54,12 +57,13 @@ class _CargoTableState extends State<CargoTable> {
return [];
}
double _total = 0;
var rows = widget.cargoTypes.map((c) {
_total += c.weight;
return MyDataRow(
onSelectChanged: (bool selected) async {
if (this.totalWeight <= 0) {
showMsgDialog(context, "Error", "Please insert total weight");
return;
}
CargoType cargo = await Navigator.push<CargoType>(
context,
CupertinoPageRoute(
@@ -67,6 +71,12 @@ class _CargoTableState extends State<CargoTable> {
cargo: c,
)));
if (widget.onAdd != null) widget.onAdd(cargo);
if (cargo == null) return;
this._cargos.add(cargo);
if (this.remainingWeight <= 0) return;
this.remainingWeight -= cargo.weight;
print("this.remainingWeight>>>${this.remainingWeight}");
},
cells: [
MyDataCell(new Text(
@@ -104,6 +114,7 @@ class _CargoTableState extends State<CargoTable> {
if (_t == null) return;
setState(() {
totalWeight = _t;
remainingWeight = _t;
});
},
cells: [

View File

@@ -351,7 +351,11 @@ class _CartonEditorState extends State<CartonEditor> {
centerTitle: true,
leading: new IconButton(
icon: new Icon(CupertinoIcons.back, color: primaryColor, size: 30),
onPressed: () => Navigator.of(context).pop(),
onPressed: () {
showConfirmDialog(context, "back.button_confirm", () {
Navigator.of(context).pop();
});
},
),
shadowColor: Colors.transparent,
backgroundColor: Colors.white,

View File

@@ -139,7 +139,11 @@ class _CartonSizeEditorState extends State<CartonSizeEditor> {
leading: new IconButton(
icon:
new Icon(CupertinoIcons.back, color: primaryColor, size: 30),
onPressed: () => Navigator.of(context).pop(),
onPressed: () {
showConfirmDialog(context, "back.button_confirm", () {
Navigator.of(context).pop();
});
},
),
shadowColor: Colors.transparent,
backgroundColor: Colors.white,

View File

@@ -81,9 +81,12 @@ class _ContactEditorState extends State<ContactEditor> {
appBar: AppBar(
centerTitle: true,
leading: new IconButton(
icon: new Icon(CupertinoIcons.back, color: primaryColor),
onPressed: () => Navigator.of(context).pop(),
),
icon: new Icon(CupertinoIcons.back, color: primaryColor),
onPressed: () {
showConfirmDialog(context, "back.button_confirm", () {
Navigator.of(context).pop();
});
}),
shadowColor: Colors.transparent,
backgroundColor: Colors.white,
title: LocalText(

View File

@@ -51,7 +51,11 @@ class _InvitationCreateState extends State<InvitationCreate> {
CupertinoIcons.back,
color: primaryColor,
),
onPressed: () => Navigator.of(context).pop(),
onPressed: () {
showConfirmDialog(context, "back.button_confirm", () {
Navigator.of(context).pop();
});
},
),
title: LocalText(
context,

View File

@@ -237,7 +237,11 @@ class _DeliveryInfoState extends State<DeliveryInfo> {
centerTitle: true,
leading: new IconButton(
icon: new Icon(CupertinoIcons.back, color: primaryColor, size: 30),
onPressed: () => Navigator.of(context).pop(),
onPressed: () {
showConfirmDialog(context, "back.button_confirm", () {
Navigator.of(context).pop();
});
},
),
shadowColor: Colors.transparent,
backgroundColor: Colors.white,

View File

@@ -106,7 +106,11 @@ class _DeliveryAddressEditorState extends State<DeliveryAddressEditor> {
centerTitle: true,
leading: new IconButton(
icon: new Icon(CupertinoIcons.back, color: primaryColor),
onPressed: () => Navigator.of(context).pop(),
onPressed: () {
showConfirmDialog(context, "back.button_confirm", () {
Navigator.of(context).pop();
});
},
),
backgroundColor: Colors.white,
shadowColor: Colors.transparent,

View File

@@ -40,7 +40,7 @@ class _DiscountEditorState extends State<DiscountEditor> {
if (widget.discount != null) {
_discount = widget.discount;
_codeController.text = _discount.code;
_amountController.text = _discount.amount.toString();
_amountController.text = _discount.amount.toStringAsFixed(2);
_statusController.text = _discount.status;
customerName = widget.discount.customerName;
customerId = widget.discount.customerId;
@@ -97,7 +97,11 @@ class _DiscountEditorState extends State<DiscountEditor> {
),
leading: new IconButton(
icon: new Icon(CupertinoIcons.back),
onPressed: () => Navigator.of(context).pop(),
onPressed: () {
showConfirmDialog(context, "back.button_confirm", () {
Navigator.of(context).pop();
});
},
),
backgroundColor: primaryColor,
actions: [

View File

@@ -80,7 +80,7 @@ class DiscountListRow extends StatelessWidget {
child: Row(
children: <Widget>[
new Text(
"${discount.amount ?? ''}",
"${discount.amount.toStringAsFixed(2) ?? ''}",
style:
new TextStyle(fontSize: 15.0, color: Colors.grey),
),

View File

@@ -126,7 +126,11 @@ class _FAQEditorState extends State<FAQEditor> {
centerTitle: true,
leading: new IconButton(
icon: new Icon(CupertinoIcons.back, color: primaryColor),
onPressed: () => Navigator.of(context).pop(),
onPressed: () {
showConfirmDialog(context, "back.button_confirm", () {
Navigator.of(context).pop();
});
},
),
backgroundColor: Colors.white,
shadowColor: Colors.transparent,

View File

@@ -59,9 +59,9 @@ class _FcsShipmentEditorState extends State<FcsShipmentEditor> {
_consigneeController.text = _shipment.consignee;
_portController.text = _shipment.port;
_destinationController.text = _shipment.destination;
}else{
var mainModel = Provider.of<MainModel>(context,listen: false);
_currentShipmentType =mainModel.setting.shipmentTypes[0];
} else {
var mainModel = Provider.of<MainModel>(context, listen: false);
_currentShipmentType = mainModel.setting.shipmentTypes[0];
}
}
@@ -93,7 +93,11 @@ class _FcsShipmentEditorState extends State<FcsShipmentEditor> {
shadowColor: Colors.transparent,
leading: new IconButton(
icon: new Icon(CupertinoIcons.back, color: primaryColor),
onPressed: () => Navigator.of(context).pop(),
onPressed: () {
showConfirmDialog(context, "back.button_confirm", () {
Navigator.of(context).pop();
});
},
),
backgroundColor: Colors.white,
title: LocalText(

View File

@@ -315,7 +315,11 @@ class _InvoiceEditorState extends State<InvoiceEditor> {
centerTitle: true,
leading: new IconButton(
icon: new Icon(CupertinoIcons.back, color: primaryColor),
onPressed: () => Navigator.of(context).pop(),
onPressed: () {
showConfirmDialog(context, "back.button_confirm", () {
Navigator.of(context).pop();
});
},
),
backgroundColor: Colors.white,
shadowColor: Colors.transparent,

View File

@@ -91,7 +91,11 @@ class _PackageEditorPageState extends State<PackageEditorPage> {
centerTitle: true,
leading: new IconButton(
icon: new Icon(CupertinoIcons.back, color: primaryColor, size: 30),
onPressed: () => Navigator.of(context).pop(),
onPressed: () {
showConfirmDialog(context, "back.button_confirm", () {
Navigator.of(context).pop();
});
},
),
shadowColor: Colors.transparent,
backgroundColor: Colors.white,

View File

@@ -60,7 +60,11 @@ class _PaymentMethodEditorState extends State<PaymentMethodEditor> {
centerTitle: true,
leading: new IconButton(
icon: new Icon(CupertinoIcons.back, color: primaryColor),
onPressed: () => Navigator.of(context).pop(),
onPressed: () {
showConfirmDialog(context, "back.button_confirm", () {
Navigator.of(context).pop();
});
},
),
title: LocalText(
context,

View File

@@ -117,7 +117,11 @@ class _ProcessingEditEditorState extends State<ProcessingEditEditor> {
centerTitle: true,
leading: new IconButton(
icon: new Icon(CupertinoIcons.back, color: primaryColor, size: 30),
onPressed: () => Navigator.of(context).pop(),
onPressed: () {
showConfirmDialog(context, "back.button_confirm", () {
Navigator.of(context).pop();
});
},
),
shadowColor: Colors.transparent,
backgroundColor: Colors.white,

View File

@@ -171,7 +171,11 @@ class _ProcesingEditorState extends State<ProcesingEditor> {
leading: new IconButton(
icon:
new Icon(CupertinoIcons.back, color: primaryColor, size: 30),
onPressed: () => Navigator.of(context).pop(),
onPressed: () {
showConfirmDialog(context, "back.button_confirm", () {
Navigator.of(context).pop();
});
},
),
shadowColor: Colors.transparent,
backgroundColor: Colors.white,

View File

@@ -59,7 +59,11 @@ class _ProfileCurrencyEditState extends State<ProfileCurrencyEdit> {
size: 35,
color: primaryColor,
),
onPressed: () => Navigator.of(context).pop(),
onPressed: () {
showConfirmDialog(context, "back.button_confirm", () {
Navigator.of(context).pop();
});
},
),
),
body: Column(

View File

@@ -74,7 +74,11 @@ class _ProfileEditState extends State<ProfileEdit> {
size: 35,
color: primaryColor,
),
onPressed: () => Navigator.of(context).pop(),
onPressed: () {
showConfirmDialog(context, "back.button_confirm", () {
Navigator.of(context).pop();
});
},
),
),
body: Column(

View File

@@ -32,7 +32,7 @@ class _CargoEditorState extends State<CargoEditor> {
if (widget.cargo != null) {
_cargo = widget.cargo;
_descController.text = _cargo.name;
_rateController.text = _cargo.rate.toString();
_rateController.text = _cargo.rate.toStringAsFixed(2);
} else {
_isNew = true;
}
@@ -60,7 +60,11 @@ class _CargoEditorState extends State<CargoEditor> {
centerTitle: true,
leading: new IconButton(
icon: new Icon(CupertinoIcons.back),
onPressed: () => Navigator.of(context).pop(),
onPressed: () {
showConfirmDialog(context, "back.button_confirm", () {
Navigator.of(context).pop();
});
},
),
backgroundColor: primaryColor,
title: Text(AppTranslations.of(context).text("cargo.form.title")),

View File

@@ -75,8 +75,8 @@ class _CargoTypeListState extends State<CargoTypeList> {
)));
},
child: Container(
child: _row(cargo.name, "\$ " + cargo.rate.toString(),
'per pound'),
child: _row(cargo.name,
"\$ " + cargo.rate.toStringAsFixed(2), 'per pound'),
),
);
}),

View File

@@ -33,7 +33,7 @@ class _CustomEditorState extends State<CustomEditor> {
if (widget.custom != null) {
_custom = widget.custom;
_productController.text = _custom.productType;
_feeController.text = _custom.fee.toString();
_feeController.text = _custom.fee.toStringAsFixed(2);
} else {
_isNew = true;
}
@@ -63,7 +63,11 @@ class _CustomEditorState extends State<CustomEditor> {
icon: new Icon(
CupertinoIcons.back,
),
onPressed: () => Navigator.of(context).pop(),
onPressed: () {
showConfirmDialog(context, "back.button_confirm", () {
Navigator.of(context).pop();
});
},
),
backgroundColor: primaryColor,
title:

View File

@@ -88,7 +88,7 @@ class _CustomListState extends State<CustomList> {
},
child: Container(
child: _row(
custom.productType, "\$ " + custom.fee.toString()),
custom.productType, "\$ " + custom.fee.toStringAsFixed(2)),
),
);
}),

View File

@@ -62,7 +62,11 @@ class _DiscountByWeightEditorState extends State<DiscountByWeightEditor> {
centerTitle: true,
leading: new IconButton(
icon: new Icon(CupertinoIcons.back),
onPressed: () => Navigator.of(context).pop(),
onPressed: () {
showConfirmDialog(context, "back.button_confirm", () {
Navigator.of(context).pop();
});
},
),
backgroundColor: primaryColor,
title: Text(AppTranslations.of(context).text("discount.new")),

View File

@@ -138,10 +138,12 @@ class _ShipmentRatesState extends State<ShipmentRates> {
color: Colors.grey,
),
_row("Free delivery within Yangon \nfor shipments over",
"${rate.freeDeliveryWeight}", "pounds"),
_row("Delivery fees", "\$ ${rate.deliveryFee}",
"below ${rate.freeDeliveryWeight} pounds"),
_row("Volumetric Ratio", "${rate.volumetricRatio}",
"${rate.freeDeliveryWeight.toStringAsFixed(2)}", "pounds"),
_row("Delivery fees", "\$ ${rate.deliveryFee.toStringAsFixed(2)}",
"below ${rate.freeDeliveryWeight.toStringAsFixed(2)} pounds"),
_row(
"Volumetric Ratio",
"${rate.volumetricRatio.toStringAsFixed(2)}",
"in3 per pound"),
Divider(
color: Colors.grey,
@@ -179,7 +181,8 @@ class _ShipmentRatesState extends State<ShipmentRates> {
List<Widget> getCargoWidget(List<CargoType> cargos) {
return cargos.map((cargo) {
return Container(
child: _row(cargo.name, "\$ " + cargo.rate.toString(), 'per pound'),
child: _row(
cargo.name, "\$ " + cargo.rate.toStringAsFixed(2), 'per pound'),
);
}).toList();
}
@@ -187,7 +190,7 @@ class _ShipmentRatesState extends State<ShipmentRates> {
List<Widget> getCustonWidget(List<CustomDuty> customs) {
return customs.map((c) {
return Container(
child: _row(c.productType, "\$ " + c.fee.toString(), ''),
child: _row(c.productType, "\$ " + c.fee.toStringAsFixed(2), ''),
);
}).toList();
}
@@ -197,7 +200,7 @@ class _ShipmentRatesState extends State<ShipmentRates> {
return discounts.map((d) {
return Container(
child: _row("${d.weight.toStringAsFixed(2)} lb",
"\$ " + d.discount.toString(), ''),
"\$ " + d.discount.toStringAsFixed(2), ''),
);
}).toList();
}

View File

@@ -2,6 +2,7 @@ import 'package:fcs/domain/entities/carton.dart';
import 'package:fcs/domain/entities/cargo_type.dart';
import 'package:fcs/domain/entities/rate.dart';
import 'package:fcs/helpers/theme.dart';
import 'package:fcs/pages/main/util.dart';
import 'package:fcs/pages/rates/model/shipment_rate_model.dart';
import 'package:fcs/pages/widgets/display_text.dart';
import 'package:fcs/pages/widgets/input_text.dart';
@@ -46,7 +47,7 @@ class _ShipmentRatesCalState extends State<ShipmentRatesCal> {
_lengthController.text = '12';
_widthController.text = '12';
_heightController.text = '12';
_actualWeightCtl.text = "10";
_actualWeightCtl.text = "10.00";
_calShipmentWeight();
}
@@ -141,7 +142,11 @@ class _ShipmentRatesCalState extends State<ShipmentRatesCal> {
centerTitle: true,
leading: new IconButton(
icon: new Icon(CupertinoIcons.back, color: primaryColor),
onPressed: () => Navigator.of(context).pop(),
onPressed: () {
showConfirmDialog(context, "back.button_confirm", () {
Navigator.of(context).pop();
});
},
),
backgroundColor: Colors.white,
shadowColor: Colors.transparent,
@@ -163,7 +168,7 @@ class _ShipmentRatesCalState extends State<ShipmentRatesCal> {
LocalText(context, "rate.delivery_fee",
color: primaryColor, fontSize: 16),
Text(
':\$ $_deliveryFee',
':\$ ${_deliveryFee.toStringAsFixed(2)}',
style: TextStyle(
color: primaryColor,
fontSize: 16,

View File

@@ -38,8 +38,8 @@ class _ShipmentRatesEditState extends State<ShipmentRatesEdit> {
Rate rate = shipmentRateModel.rate;
_minWeight.text = rate.freeDeliveryWeight?.toStringAsFixed(2) ?? "";
_deliveryFee.text = rate.deliveryFee?.toString() ?? "";
_volumetricRatio.text = rate.volumetricRatio?.toString() ?? "";
_deliveryFee.text = rate.deliveryFee?.toStringAsFixed(2) ?? "";
_volumetricRatio.text = rate.volumetricRatio?.toStringAsFixed(2) ?? "";
}
@override
@@ -73,7 +73,11 @@ class _ShipmentRatesEditState extends State<ShipmentRatesEdit> {
icon: new Icon(
CupertinoIcons.back,
),
onPressed: () => Navigator.of(context).pop(),
onPressed: () {
showConfirmDialog(context, "back.button_confirm", () {
Navigator.of(context).pop();
});
},
),
backgroundColor: primaryColor,
title: Text(AppTranslations.of(context).text("rate.edit.title")),

View File

@@ -149,7 +149,11 @@ class _ReceivingEditorState extends State<ReceivingEditor> {
leading: new IconButton(
icon:
new Icon(CupertinoIcons.back, color: primaryColor, size: 30),
onPressed: () => Navigator.of(context).pop(),
onPressed: () {
showConfirmDialog(context, "back.button_confirm", () {
Navigator.of(context).pop();
});
},
),
shadowColor: Colors.transparent,
backgroundColor: Colors.white,

View File

@@ -165,7 +165,11 @@ class _ShipmentEditorState extends State<ShipmentEditor> {
CupertinoIcons.back,
color: primaryColor,
),
onPressed: () => Navigator.of(context).pop(),
onPressed: () {
showConfirmDialog(context, "back.button_confirm", () {
Navigator.of(context).pop();
});
},
),
shadowColor: Colors.transparent,
backgroundColor: Colors.white,

View File

@@ -171,10 +171,13 @@ class _StaffEditorState extends State<StaffEditor> {
appBar: AppBar(
centerTitle: true,
leading: new IconButton(
icon:
new Icon(CupertinoIcons.back, color: primaryColor, size: 30),
onPressed: () => Navigator.of(context).pop(),
),
icon: new Icon(CupertinoIcons.back,
color: primaryColor, size: 30),
onPressed: () {
showConfirmDialog(context, "back.button_confirm", () {
Navigator.of(context).pop();
});
}),
shadowColor: Colors.transparent,
backgroundColor: Colors.white,
title: LocalText(

View File

@@ -76,7 +76,11 @@ class _TermEditState extends State<TermEdit> {
color: primaryColor,
size: 30,
),
onPressed: () => Navigator.of(context).pop(),
onPressed: () {
showConfirmDialog(context, "back.button_confirm", () {
Navigator.of(context).pop();
});
},
),
shadowColor: Colors.transparent,
backgroundColor: Colors.white,