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,