2020-10-14 16:53:16 +06:30
|
|
|
import 'package:fcs/domain/constants.dart';
|
2020-10-07 02:33:06 +06:30
|
|
|
import 'package:fcs/domain/entities/box.dart';
|
2020-10-15 03:06:13 +06:30
|
|
|
import 'package:fcs/domain/entities/cargo_type.dart';
|
2020-10-07 02:33:06 +06:30
|
|
|
import 'package:fcs/domain/entities/package.dart';
|
2020-10-09 17:28:42 +06:30
|
|
|
import 'package:fcs/domain/entities/user.dart';
|
2020-10-08 11:38:05 +06:30
|
|
|
import 'package:fcs/domain/vo/delivery_address.dart';
|
2020-10-07 02:33:06 +06:30
|
|
|
import 'package:fcs/helpers/theme.dart';
|
|
|
|
|
import 'package:fcs/localization/app_translations.dart';
|
2020-10-08 15:54:43 +06:30
|
|
|
import 'package:fcs/pages/delivery_address/delivery_address_row.dart';
|
2020-10-13 15:45:01 +06:30
|
|
|
import 'package:fcs/pages/delivery_address/model/delivery_address_model.dart';
|
2020-10-09 17:28:42 +06:30
|
|
|
import 'package:fcs/pages/main/model/language_model.dart';
|
2020-10-13 15:45:01 +06:30
|
|
|
import 'package:fcs/pages/main/model/main_model.dart';
|
2020-10-07 02:33:06 +06:30
|
|
|
import 'package:fcs/pages/main/util.dart';
|
2020-10-09 17:28:42 +06:30
|
|
|
import 'package:fcs/pages/package/model/package_model.dart';
|
2020-10-15 03:06:13 +06:30
|
|
|
import 'package:fcs/pages/rates/model/shipment_rate_model.dart';
|
2020-10-09 17:28:42 +06:30
|
|
|
import 'package:fcs/pages/user_search/user_serach.dart';
|
|
|
|
|
import 'package:fcs/pages/widgets/bottom_up_page_route.dart';
|
2020-10-13 15:45:01 +06:30
|
|
|
import 'package:fcs/pages/widgets/defalut_delivery_address.dart';
|
|
|
|
|
import 'package:fcs/pages/widgets/delivery_address_selection.dart';
|
2020-10-09 17:28:42 +06:30
|
|
|
import 'package:fcs/pages/widgets/display_text.dart';
|
|
|
|
|
import 'package:fcs/pages/widgets/fcs_id_icon.dart';
|
2020-10-14 16:53:16 +06:30
|
|
|
import 'package:fcs/pages/widgets/length_picker.dart';
|
|
|
|
|
import 'package:fcs/pages/widgets/local_button.dart';
|
2020-10-14 13:17:12 +06:30
|
|
|
import 'package:fcs/pages/widgets/local_radio_buttons.dart';
|
2020-10-07 02:33:06 +06:30
|
|
|
import 'package:fcs/pages/widgets/local_text.dart';
|
2020-10-14 13:17:12 +06:30
|
|
|
import 'package:fcs/pages/widgets/local_title.dart';
|
2020-10-07 02:33:06 +06:30
|
|
|
import 'package:fcs/pages/widgets/progress.dart';
|
2020-10-14 16:53:16 +06:30
|
|
|
import 'package:flutter/cupertino.dart';
|
2020-06-04 01:36:49 +06:30
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
import 'package:flutter_icons/flutter_icons.dart';
|
|
|
|
|
import 'package:provider/provider.dart';
|
2020-10-09 17:28:42 +06:30
|
|
|
import 'cargo_type_editor.dart';
|
2020-10-14 13:17:12 +06:30
|
|
|
import 'model/box_model.dart';
|
2020-10-09 17:28:42 +06:30
|
|
|
|
2020-06-04 01:36:49 +06:30
|
|
|
class BoxEditor extends StatefulWidget {
|
|
|
|
|
final Box box;
|
|
|
|
|
BoxEditor({this.box});
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
_BoxEditorState createState() => _BoxEditorState();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class _BoxEditorState extends State<BoxEditor> {
|
2020-10-09 17:28:42 +06:30
|
|
|
TextEditingController _widthController = new TextEditingController();
|
|
|
|
|
TextEditingController _heightController = new TextEditingController();
|
|
|
|
|
TextEditingController _lengthController = new TextEditingController();
|
2020-06-04 01:36:49 +06:30
|
|
|
|
|
|
|
|
Box _box;
|
|
|
|
|
bool _isLoading = false;
|
|
|
|
|
bool isNew;
|
2020-10-09 17:28:42 +06:30
|
|
|
DeliveryAddress _deliveryAddress = new DeliveryAddress();
|
|
|
|
|
User user;
|
2020-10-14 13:17:12 +06:30
|
|
|
String _selectShipmentNumber;
|
|
|
|
|
String _selectedCartonType;
|
2020-10-09 17:28:42 +06:30
|
|
|
List<Package> _packages = [];
|
2020-10-14 16:53:16 +06:30
|
|
|
List<Box> _shipmentBoxes = [];
|
|
|
|
|
List<Box> _mixBoxes = [];
|
2020-10-15 03:06:13 +06:30
|
|
|
List<CargoType> _cargoTypes = [];
|
2020-10-13 15:45:01 +06:30
|
|
|
double volumetricRatio = 0;
|
|
|
|
|
double shipmentWeight = 0;
|
2020-10-14 16:53:16 +06:30
|
|
|
Box _selectedShipmentBox;
|
2020-06-25 16:19:23 +06:30
|
|
|
|
2020-06-04 01:36:49 +06:30
|
|
|
@override
|
|
|
|
|
void initState() {
|
|
|
|
|
super.initState();
|
2020-10-14 16:53:16 +06:30
|
|
|
// for packages
|
2020-10-09 17:28:42 +06:30
|
|
|
var packageModel = Provider.of<PackageModel>(context, listen: false);
|
|
|
|
|
_packages = [
|
|
|
|
|
packageModel.packages[0],
|
|
|
|
|
packageModel.packages[1],
|
|
|
|
|
];
|
|
|
|
|
_packages.forEach((p) {
|
|
|
|
|
p.isChecked = false;
|
|
|
|
|
});
|
2020-10-14 16:53:16 +06:30
|
|
|
|
|
|
|
|
//for shipment boxes
|
|
|
|
|
var boxModel = Provider.of<BoxModel>(context, listen: false);
|
|
|
|
|
_shipmentBoxes = [boxModel.boxes[0], boxModel.boxes[1], boxModel.boxes[2]];
|
|
|
|
|
|
|
|
|
|
//for mix boxes
|
|
|
|
|
_mixBoxes = [boxModel.boxes[0], boxModel.boxes[1], boxModel.boxes[2]];
|
|
|
|
|
_mixBoxes.forEach((b) {
|
|
|
|
|
b.isChecked = false;
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
//for shipment weight
|
2020-10-15 03:06:13 +06:30
|
|
|
volumetricRatio = Provider.of<ShipmentRateModel>(context, listen: false)
|
|
|
|
|
.rate
|
|
|
|
|
.volumetricRatio;
|
2020-10-13 15:45:01 +06:30
|
|
|
_lengthController.addListener(_calShipmentWeight);
|
|
|
|
|
_widthController.addListener(_calShipmentWeight);
|
|
|
|
|
_heightController.addListener(_calShipmentWeight);
|
|
|
|
|
|
2020-06-04 01:36:49 +06:30
|
|
|
if (widget.box != null) {
|
|
|
|
|
_box = widget.box;
|
2020-10-09 17:28:42 +06:30
|
|
|
_deliveryAddress = _box.shippingAddress;
|
2020-10-13 15:45:01 +06:30
|
|
|
_cargoTypes = _box.cargoTypes;
|
2020-10-14 13:17:12 +06:30
|
|
|
_selectShipmentNumber = _box.shipmentNumber;
|
2020-10-09 17:28:42 +06:30
|
|
|
_widthController.text = _box.width.toString();
|
|
|
|
|
_heightController.text = _box.height.toString();
|
|
|
|
|
_lengthController.text = _box.length.toString();
|
2020-10-14 16:53:16 +06:30
|
|
|
_selectedCartonType = _box.cartonType;
|
2020-10-13 15:45:01 +06:30
|
|
|
isNew = false;
|
2020-06-04 01:36:49 +06:30
|
|
|
} else {
|
2020-10-13 15:45:01 +06:30
|
|
|
_cargoTypes = [
|
2020-10-15 03:06:13 +06:30
|
|
|
CargoType(id: "1", name: 'General', weight: 25),
|
|
|
|
|
CargoType(id: "2", name: 'Medicine', weight: 20),
|
|
|
|
|
CargoType(id: "3", name: 'Dangerous', weight: 30)
|
2020-06-25 16:19:23 +06:30
|
|
|
];
|
|
|
|
|
|
2020-10-13 15:45:01 +06:30
|
|
|
var shipmentModel =
|
|
|
|
|
Provider.of<DeliveryAddressModel>(context, listen: false);
|
|
|
|
|
_deliveryAddress = shipmentModel.defalutAddress;
|
2020-06-04 01:36:49 +06:30
|
|
|
isNew = true;
|
2020-10-14 16:53:16 +06:30
|
|
|
_selectedCartonType = carton_from_packages;
|
2020-06-04 01:36:49 +06:30
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-10-13 15:45:01 +06:30
|
|
|
_calShipmentWeight() {
|
|
|
|
|
double l = double.parse(_lengthController.text, (s) => 0);
|
|
|
|
|
double w = double.parse(_widthController.text, (s) => 0);
|
|
|
|
|
double h = double.parse(_heightController.text, (s) => 0);
|
|
|
|
|
setState(() {
|
|
|
|
|
shipmentWeight = l * w * h / volumetricRatio;
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2020-06-04 01:36:49 +06:30
|
|
|
@override
|
|
|
|
|
void dispose() {
|
|
|
|
|
super.dispose();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
Widget build(BuildContext context) {
|
2020-10-09 17:28:42 +06:30
|
|
|
var languageModel = Provider.of<LanguageModel>(context);
|
2020-10-14 13:17:12 +06:30
|
|
|
var boxModel = Provider.of<BoxModel>(context);
|
2020-10-09 17:28:42 +06:30
|
|
|
|
|
|
|
|
var shipmentBox = Container(
|
2020-10-14 13:17:12 +06:30
|
|
|
child: DropdownButtonFormField(
|
|
|
|
|
value: _selectShipmentNumber,
|
|
|
|
|
decoration: InputDecoration(
|
|
|
|
|
fillColor: Colors.white,
|
|
|
|
|
labelText: AppTranslations.of(context).text("box.fcs_shipment_num"),
|
|
|
|
|
labelStyle: languageModel.isEng
|
|
|
|
|
? TextStyle(fontWeight: FontWeight.w500)
|
|
|
|
|
: TextStyle(fontWeight: FontWeight.w500, fontFamily: "Myanmar3"),
|
|
|
|
|
icon: Icon(
|
|
|
|
|
Ionicons.ios_airplane,
|
|
|
|
|
color: primaryColor,
|
|
|
|
|
)),
|
2020-10-14 16:53:16 +06:30
|
|
|
items: ["A204", "A203", "A201", "A202"]
|
2020-10-14 13:17:12 +06:30
|
|
|
.map((e) => DropdownMenuItem(
|
|
|
|
|
child: Text(
|
|
|
|
|
e,
|
|
|
|
|
style: TextStyle(color: primaryColor),
|
|
|
|
|
),
|
|
|
|
|
value: e))
|
|
|
|
|
.toList(),
|
|
|
|
|
onChanged: (value) {
|
|
|
|
|
setState(() {
|
|
|
|
|
_selectShipmentNumber = value;
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
));
|
2020-10-09 17:28:42 +06:30
|
|
|
|
2020-10-14 13:17:12 +06:30
|
|
|
final fcsIDBox = Row(
|
|
|
|
|
children: <Widget>[
|
|
|
|
|
Expanded(
|
|
|
|
|
child: DisplayText(
|
|
|
|
|
text: user != null ? user.fcsID : "",
|
|
|
|
|
labelTextKey: "box.fcs.id",
|
|
|
|
|
icon: FcsIDIcon(),
|
|
|
|
|
)),
|
|
|
|
|
IconButton(
|
|
|
|
|
icon: Icon(Icons.search, color: primaryColor),
|
|
|
|
|
onPressed: () => searchUser(context, callbackUserSelect: (u) {
|
|
|
|
|
setState(() {
|
|
|
|
|
this.user = u;
|
|
|
|
|
});
|
|
|
|
|
})),
|
|
|
|
|
],
|
|
|
|
|
);
|
2020-10-09 17:28:42 +06:30
|
|
|
|
2020-10-14 13:17:12 +06:30
|
|
|
final phoneNumberBox = DisplayText(
|
|
|
|
|
text: user != null ? user.phoneNumber : "",
|
|
|
|
|
labelTextKey: "box.phone",
|
|
|
|
|
iconData: Icons.phone,
|
|
|
|
|
);
|
2020-10-09 17:28:42 +06:30
|
|
|
|
2020-10-14 13:17:12 +06:30
|
|
|
final namebox = DisplayText(
|
|
|
|
|
text: user != null ? user.name : "",
|
|
|
|
|
labelTextKey: "box.name",
|
|
|
|
|
iconData: Icons.person,
|
|
|
|
|
);
|
2020-10-09 17:28:42 +06:30
|
|
|
|
|
|
|
|
final packageTitle = Container(
|
|
|
|
|
padding: EdgeInsets.only(right: 10.0, top: 20),
|
|
|
|
|
child: Row(
|
|
|
|
|
children: <Widget>[
|
|
|
|
|
Container(
|
2020-10-14 16:53:16 +06:30
|
|
|
width: 30,
|
2020-10-09 17:28:42 +06:30
|
|
|
),
|
|
|
|
|
Expanded(
|
|
|
|
|
child: LocalText(context, 'box.tracking.id', color: Colors.grey),
|
|
|
|
|
),
|
2020-10-14 16:53:16 +06:30
|
|
|
LocalText(context, 'box.package.desc', color: Colors.grey),
|
2020-10-09 17:28:42 +06:30
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
List<Widget> getPackageRowList() {
|
|
|
|
|
return _packages.asMap().entries.map((p) {
|
|
|
|
|
return Container(
|
|
|
|
|
color: p.value.isChecked
|
|
|
|
|
? Colors.grey.withOpacity(0.2)
|
|
|
|
|
: Colors.grey[50].withOpacity(0.2),
|
|
|
|
|
child: Container(
|
|
|
|
|
padding:
|
|
|
|
|
EdgeInsets.only(left: 0.0, right: 10.0, top: 3.0, bottom: 3.0),
|
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
|
border: Border(
|
|
|
|
|
bottom: BorderSide(
|
|
|
|
|
color: p.key == _packages.length - 1
|
|
|
|
|
? Colors.white
|
|
|
|
|
: Colors.grey[350],
|
|
|
|
|
width: 1),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
child: Row(
|
|
|
|
|
children: <Widget>[
|
|
|
|
|
Checkbox(
|
|
|
|
|
value: p.value.isChecked,
|
|
|
|
|
activeColor: primaryColor,
|
|
|
|
|
onChanged: (bool check) {
|
|
|
|
|
setState(() {
|
|
|
|
|
p.value.isChecked = check;
|
|
|
|
|
});
|
|
|
|
|
}),
|
|
|
|
|
Expanded(
|
|
|
|
|
child: new Text(
|
|
|
|
|
p.value.trackingID,
|
|
|
|
|
style: textStyle,
|
|
|
|
|
)),
|
2020-10-14 16:53:16 +06:30
|
|
|
new Column(
|
|
|
|
|
children: [
|
|
|
|
|
new Text(
|
|
|
|
|
p.value.desc == null ? "" : p.value.desc,
|
|
|
|
|
style: textStyle,
|
|
|
|
|
),
|
|
|
|
|
new Text(
|
|
|
|
|
"(${p.value.market == null ? "" : p.value.market})",
|
|
|
|
|
style: textStyle,
|
|
|
|
|
)
|
|
|
|
|
],
|
|
|
|
|
)
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
}).toList();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
final shipmentBoxTitle = Container(
|
|
|
|
|
padding: EdgeInsets.only(right: 10.0, top: 20),
|
|
|
|
|
child: Row(
|
|
|
|
|
children: <Widget>[
|
|
|
|
|
Container(
|
|
|
|
|
width: 30,
|
|
|
|
|
),
|
|
|
|
|
Expanded(
|
|
|
|
|
child:
|
|
|
|
|
LocalText(context, 'box.shipment_number', color: Colors.grey),
|
|
|
|
|
),
|
|
|
|
|
LocalText(context, 'box.shipment.desc', color: Colors.grey),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
List<Widget> getshipmentBoxRowList() {
|
|
|
|
|
return _shipmentBoxes.asMap().entries.map((s) {
|
|
|
|
|
return Container(
|
|
|
|
|
color: Colors.grey[50].withOpacity(0.2),
|
|
|
|
|
child: Container(
|
|
|
|
|
padding:
|
|
|
|
|
EdgeInsets.only(left: 0.0, right: 10.0, top: 3.0, bottom: 3.0),
|
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
|
border: Border(
|
|
|
|
|
bottom: BorderSide(
|
|
|
|
|
color: s.key == _shipmentBoxes.length - 1
|
|
|
|
|
? Colors.white
|
|
|
|
|
: Colors.grey[350],
|
|
|
|
|
width: 1),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
child: Row(
|
|
|
|
|
children: <Widget>[
|
|
|
|
|
Radio(
|
|
|
|
|
activeColor: primaryColor,
|
|
|
|
|
groupValue: _selectedShipmentBox,
|
|
|
|
|
value: s.value,
|
|
|
|
|
onChanged: (value) {
|
|
|
|
|
setState(() {
|
|
|
|
|
_selectedShipmentBox = value;
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
Expanded(
|
|
|
|
|
child: new Text(
|
|
|
|
|
s.value.shipmentNumber,
|
|
|
|
|
style: textStyle,
|
|
|
|
|
)),
|
2020-10-09 17:28:42 +06:30
|
|
|
new Text(
|
2020-10-14 16:53:16 +06:30
|
|
|
s.value.desc == null ? "" : s.value.desc,
|
2020-10-09 17:28:42 +06:30
|
|
|
style: textStyle,
|
2020-10-14 16:53:16 +06:30
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
}).toList();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
final mixBoxTitle = Container(
|
|
|
|
|
padding: EdgeInsets.only(right: 10.0, top: 20),
|
|
|
|
|
child: Row(
|
|
|
|
|
children: <Widget>[
|
|
|
|
|
Container(
|
|
|
|
|
width: 30,
|
|
|
|
|
),
|
|
|
|
|
Expanded(
|
|
|
|
|
child: LocalText(context, 'box.mix.number', color: Colors.grey),
|
|
|
|
|
),
|
|
|
|
|
LocalText(context, 'box.mix.desc', color: Colors.grey),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
List<Widget> getMixBoxRowList() {
|
|
|
|
|
return _mixBoxes.asMap().entries.map((b) {
|
|
|
|
|
return Container(
|
|
|
|
|
color: b.value.isChecked
|
|
|
|
|
? Colors.grey.withOpacity(0.2)
|
|
|
|
|
: Colors.grey[50].withOpacity(0.2),
|
|
|
|
|
child: Container(
|
|
|
|
|
padding:
|
|
|
|
|
EdgeInsets.only(left: 0.0, right: 10.0, top: 3.0, bottom: 3.0),
|
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
|
border: Border(
|
|
|
|
|
bottom: BorderSide(
|
|
|
|
|
color: b.key == _mixBoxes.length - 1
|
|
|
|
|
? Colors.white
|
|
|
|
|
: Colors.grey[350],
|
|
|
|
|
width: 1),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
child: Row(
|
|
|
|
|
children: <Widget>[
|
|
|
|
|
Checkbox(
|
|
|
|
|
value: b.value.isChecked,
|
|
|
|
|
activeColor: primaryColor,
|
|
|
|
|
onChanged: (bool check) {
|
|
|
|
|
setState(() {
|
|
|
|
|
b.value.isChecked = check;
|
|
|
|
|
});
|
|
|
|
|
}),
|
|
|
|
|
Expanded(
|
|
|
|
|
child: new Text(
|
|
|
|
|
b.value.packageNumber,
|
|
|
|
|
style: textStyle,
|
|
|
|
|
)),
|
|
|
|
|
new Text(
|
|
|
|
|
b.value.desc == null ? "" : b.value.desc,
|
|
|
|
|
style: textStyle,
|
|
|
|
|
),
|
2020-10-09 17:28:42 +06:30
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
}).toList();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
final cargoTitle = Container(
|
|
|
|
|
padding: EdgeInsets.only(left: 15, right: 0.0, top: 20),
|
|
|
|
|
child: Row(
|
|
|
|
|
children: <Widget>[
|
|
|
|
|
Expanded(
|
|
|
|
|
child: LocalText(context, 'cargo.type', color: Colors.grey),
|
|
|
|
|
),
|
2020-10-13 15:45:01 +06:30
|
|
|
Container(
|
|
|
|
|
padding: EdgeInsets.only(right: 20),
|
|
|
|
|
child: LocalText(context, 'cargo.weight', color: Colors.grey)),
|
2020-10-09 17:28:42 +06:30
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
List<Widget> getCargoRowList() {
|
2020-10-13 15:45:01 +06:30
|
|
|
if (_cargoTypes == null) {
|
|
|
|
|
return [];
|
|
|
|
|
}
|
|
|
|
|
int total = 0;
|
|
|
|
|
|
|
|
|
|
var rows = _cargoTypes.asMap().entries.map((c) {
|
|
|
|
|
total += c.value.weight;
|
2020-10-09 17:28:42 +06:30
|
|
|
return InkWell(
|
2020-10-14 16:53:16 +06:30
|
|
|
onTap: () async {
|
2020-10-15 03:06:13 +06:30
|
|
|
CargoType cargo = await Navigator.push<CargoType>(
|
2020-10-09 17:28:42 +06:30
|
|
|
context,
|
2020-10-14 13:54:42 +06:30
|
|
|
CupertinoPageRoute(
|
|
|
|
|
builder: (context) => CargoTypeEditor(cargo: c.value)),
|
2020-10-09 17:28:42 +06:30
|
|
|
);
|
2020-10-14 16:53:16 +06:30
|
|
|
_addCargo(cargo);
|
2020-10-09 17:28:42 +06:30
|
|
|
},
|
|
|
|
|
child: Container(
|
|
|
|
|
color: Colors.grey[50].withOpacity(0.2),
|
|
|
|
|
child: Container(
|
|
|
|
|
padding: EdgeInsets.only(
|
2020-10-13 15:45:01 +06:30
|
|
|
left: 15.0, right: 0.0, top: 0.0, bottom: 0.0),
|
2020-10-09 17:28:42 +06:30
|
|
|
decoration: BoxDecoration(
|
|
|
|
|
border: Border(
|
|
|
|
|
bottom: BorderSide(color: Colors.grey[350], width: 1),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
child: Row(
|
|
|
|
|
children: <Widget>[
|
|
|
|
|
Expanded(
|
|
|
|
|
child: new Text(
|
2020-10-15 03:06:13 +06:30
|
|
|
c.value.name,
|
2020-10-09 17:28:42 +06:30
|
|
|
style: textStyle,
|
|
|
|
|
)),
|
2020-10-13 15:45:01 +06:30
|
|
|
Row(
|
|
|
|
|
children: [
|
|
|
|
|
new Text(
|
|
|
|
|
c.value.weight == null
|
|
|
|
|
? "0"
|
|
|
|
|
: c.value.weight.toString(),
|
|
|
|
|
style: textStyle,
|
|
|
|
|
),
|
|
|
|
|
IconButton(
|
|
|
|
|
icon: Icon(
|
|
|
|
|
Icons.remove_circle,
|
|
|
|
|
color: primaryColor,
|
|
|
|
|
),
|
|
|
|
|
onPressed: () {
|
|
|
|
|
setState(() {
|
|
|
|
|
_cargoTypes.remove(c.value);
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
)
|
|
|
|
|
],
|
2020-10-09 17:28:42 +06:30
|
|
|
)
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
}).toList();
|
2020-10-13 15:45:01 +06:30
|
|
|
|
|
|
|
|
var totalRow = InkWell(
|
|
|
|
|
child: Container(
|
|
|
|
|
color: Colors.grey[50].withOpacity(0.2),
|
|
|
|
|
child: Container(
|
|
|
|
|
padding:
|
|
|
|
|
EdgeInsets.only(left: 15.0, right: 10.0, top: 15.0, bottom: 15.0),
|
|
|
|
|
child: Row(
|
|
|
|
|
children: <Widget>[
|
|
|
|
|
Expanded(
|
2020-10-15 17:33:43 +06:30
|
|
|
child: LocalText(context, "box.cargo.total",
|
|
|
|
|
color: Colors.black87, fontWeight: FontWeight.bold),
|
|
|
|
|
),
|
2020-10-13 15:45:01 +06:30
|
|
|
Padding(
|
|
|
|
|
padding: const EdgeInsets.only(right: 40.0),
|
|
|
|
|
child: Align(
|
|
|
|
|
alignment: Alignment.centerRight,
|
|
|
|
|
child: new Text(
|
|
|
|
|
total.toString(),
|
|
|
|
|
style: TextStyle(fontWeight: FontWeight.bold),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
)
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
));
|
|
|
|
|
|
|
|
|
|
rows.add(totalRow);
|
|
|
|
|
return rows;
|
2020-10-09 17:28:42 +06:30
|
|
|
}
|
|
|
|
|
|
2020-10-14 16:53:16 +06:30
|
|
|
final lengthBox = LengthPicker(
|
|
|
|
|
controller: _lengthController,
|
|
|
|
|
lableKey: "box.length",
|
|
|
|
|
);
|
|
|
|
|
final widthBox = LengthPicker(
|
|
|
|
|
controller: _widthController,
|
|
|
|
|
lableKey: "box.width",
|
|
|
|
|
);
|
|
|
|
|
final heightBox = LengthPicker(
|
|
|
|
|
controller: _heightController,
|
|
|
|
|
lableKey: "box.height",
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
final dimBox = Row(
|
|
|
|
|
mainAxisAlignment: MainAxisAlignment.start,
|
|
|
|
|
children: [
|
|
|
|
|
Padding(
|
|
|
|
|
padding: const EdgeInsets.only(right: 8.0),
|
|
|
|
|
child: Icon(FontAwesome.arrow_circle_right, color: primaryColor),
|
|
|
|
|
),
|
|
|
|
|
SizedBox(child: lengthBox, width: 80),
|
|
|
|
|
SizedBox(child: widthBox, width: 80),
|
|
|
|
|
SizedBox(child: heightBox, width: 80),
|
|
|
|
|
],
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
final shipmentWeightBox = DisplayText(
|
|
|
|
|
text: shipmentWeight != null ? shipmentWeight.toStringAsFixed(0) : "",
|
|
|
|
|
labelTextKey: "box.shipment_weight",
|
|
|
|
|
iconData: MaterialCommunityIcons.weight,
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
final createBtn = LocalButton(
|
|
|
|
|
textKey: "box.create.btn",
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
final completeBtn = LocalButton(
|
|
|
|
|
textKey: "box.complete.btn",
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
final deliveryBtn = LocalButton(
|
|
|
|
|
textKey: "box.deliver.btn",
|
|
|
|
|
);
|
2020-10-09 17:28:42 +06:30
|
|
|
|
2020-06-04 01:36:49 +06:30
|
|
|
return LocalProgress(
|
|
|
|
|
inAsyncCall: _isLoading,
|
|
|
|
|
child: Scaffold(
|
|
|
|
|
appBar: AppBar(
|
|
|
|
|
centerTitle: true,
|
|
|
|
|
leading: new IconButton(
|
2020-10-14 16:53:16 +06:30
|
|
|
icon: new Icon(CupertinoIcons.back, color: primaryColor, size: 30),
|
2020-06-04 01:36:49 +06:30
|
|
|
onPressed: () => Navigator.of(context).pop(),
|
|
|
|
|
),
|
2020-10-09 17:28:42 +06:30
|
|
|
shadowColor: Colors.transparent,
|
|
|
|
|
backgroundColor: Colors.white,
|
|
|
|
|
title: widget.box == null
|
|
|
|
|
? LocalText(
|
|
|
|
|
context,
|
2020-10-14 13:17:12 +06:30
|
|
|
"boxes.create.title",
|
2020-10-09 17:28:42 +06:30
|
|
|
fontSize: 20,
|
|
|
|
|
color: primaryColor,
|
|
|
|
|
)
|
|
|
|
|
: LocalText(
|
|
|
|
|
context,
|
|
|
|
|
"box.edit.title",
|
|
|
|
|
fontSize: 20,
|
|
|
|
|
color: primaryColor,
|
|
|
|
|
),
|
2020-06-04 01:36:49 +06:30
|
|
|
),
|
2020-10-14 13:17:12 +06:30
|
|
|
body: Padding(
|
|
|
|
|
padding: const EdgeInsets.all(10.0),
|
|
|
|
|
child: ListView(
|
|
|
|
|
shrinkWrap: true,
|
|
|
|
|
children: [
|
|
|
|
|
widget.box == null
|
|
|
|
|
? Container()
|
|
|
|
|
: Center(child: nameWidget(_box.packageNumber)),
|
|
|
|
|
SizedBox(
|
|
|
|
|
height: 10,
|
2020-10-09 17:28:42 +06:30
|
|
|
),
|
2020-10-14 13:17:12 +06:30
|
|
|
LocalTitle(textKey: "box.type.title"),
|
|
|
|
|
LocalRadioButtons(
|
|
|
|
|
values: boxModel.cartonTypes,
|
|
|
|
|
selectedValue: _selectedCartonType,
|
|
|
|
|
callback: (v) {
|
|
|
|
|
print(v);
|
|
|
|
|
setState(() {
|
|
|
|
|
_selectedCartonType = v;
|
|
|
|
|
});
|
|
|
|
|
}),
|
|
|
|
|
LocalTitle(textKey: "box.shipment_info"),
|
|
|
|
|
shipmentBox,
|
|
|
|
|
SizedBox(
|
|
|
|
|
height: 10,
|
|
|
|
|
),
|
|
|
|
|
fcsIDBox,
|
|
|
|
|
namebox,
|
2020-10-14 16:53:16 +06:30
|
|
|
_selectedCartonType == "From packages"
|
|
|
|
|
? Column(
|
|
|
|
|
children: [
|
|
|
|
|
LocalTitle(textKey: "box.packages"),
|
|
|
|
|
packageTitle,
|
|
|
|
|
Divider(
|
|
|
|
|
color: Colors.grey[400],
|
|
|
|
|
),
|
|
|
|
|
Column(
|
|
|
|
|
children: getPackageRowList(),
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
)
|
|
|
|
|
: _selectedCartonType == "From shipments"
|
|
|
|
|
? Column(
|
|
|
|
|
children: [
|
|
|
|
|
LocalTitle(textKey: "box.shipment.boxes"),
|
|
|
|
|
shipmentBoxTitle,
|
|
|
|
|
Divider(
|
|
|
|
|
color: Colors.grey[400],
|
|
|
|
|
),
|
|
|
|
|
Column(
|
|
|
|
|
children: getshipmentBoxRowList(),
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
)
|
|
|
|
|
: _selectedCartonType == "Mix carton"
|
|
|
|
|
? Column(
|
|
|
|
|
children: [
|
|
|
|
|
LocalTitle(textKey: "box.shipment.boxes"),
|
|
|
|
|
mixBoxTitle,
|
|
|
|
|
Divider(
|
|
|
|
|
color: Colors.grey[400],
|
|
|
|
|
),
|
|
|
|
|
Column(
|
|
|
|
|
children: getMixBoxRowList(),
|
|
|
|
|
)
|
|
|
|
|
],
|
|
|
|
|
)
|
|
|
|
|
: Container(),
|
|
|
|
|
LocalTitle(
|
|
|
|
|
textKey: "box.cargo_type",
|
|
|
|
|
trailing: IconButton(
|
|
|
|
|
icon: Icon(
|
|
|
|
|
Icons.add_circle,
|
|
|
|
|
color: primaryColor,
|
|
|
|
|
),
|
|
|
|
|
onPressed: () async {
|
2020-10-15 03:06:13 +06:30
|
|
|
CargoType cargo = await Navigator.push<CargoType>(
|
2020-10-14 13:54:42 +06:30
|
|
|
context,
|
2020-10-14 13:57:27 +06:30
|
|
|
CupertinoPageRoute(
|
2020-10-14 21:46:35 +06:30
|
|
|
builder: (context) => CargoTypeEditor()),
|
2020-10-14 13:17:12 +06:30
|
|
|
);
|
2020-10-14 21:46:35 +06:30
|
|
|
|
2020-10-14 16:53:16 +06:30
|
|
|
_addCargo(cargo);
|
2020-10-14 13:17:12 +06:30
|
|
|
}),
|
|
|
|
|
),
|
2020-10-14 16:53:16 +06:30
|
|
|
cargoTitle,
|
|
|
|
|
Divider(
|
|
|
|
|
color: Colors.grey[400],
|
2020-10-14 13:17:12 +06:30
|
|
|
),
|
2020-10-14 16:53:16 +06:30
|
|
|
Column(
|
|
|
|
|
children: getCargoRowList(),
|
2020-10-14 13:17:12 +06:30
|
|
|
),
|
2020-10-14 16:53:16 +06:30
|
|
|
LocalTitle(textKey: "box.dimension"),
|
|
|
|
|
dimBox,
|
2020-10-14 13:17:12 +06:30
|
|
|
shipmentWeightBox,
|
2020-10-14 16:53:16 +06:30
|
|
|
LocalTitle(textKey: "box.delivery_address"),
|
|
|
|
|
DefaultDeliveryAddress(
|
|
|
|
|
deliveryAddress: _deliveryAddress,
|
|
|
|
|
labelKey: "box.delivery_address",
|
|
|
|
|
onTap: () async {
|
|
|
|
|
DeliveryAddress d = await Navigator.push<DeliveryAddress>(
|
|
|
|
|
context,
|
2020-10-14 21:46:35 +06:30
|
|
|
CupertinoPageRoute(
|
|
|
|
|
builder: (context) => DeliveryAddressSelection(
|
|
|
|
|
deliveryAddress: _deliveryAddress,
|
|
|
|
|
)),
|
2020-10-14 16:53:16 +06:30
|
|
|
);
|
|
|
|
|
if (d == null) return;
|
|
|
|
|
setState(() {
|
|
|
|
|
this._deliveryAddress = d;
|
|
|
|
|
});
|
|
|
|
|
}),
|
2020-10-14 13:17:12 +06:30
|
|
|
SizedBox(
|
|
|
|
|
height: 10,
|
|
|
|
|
),
|
|
|
|
|
widget.box == null
|
|
|
|
|
? createBtn
|
|
|
|
|
: Container(
|
|
|
|
|
child: Column(
|
|
|
|
|
children: <Widget>[
|
|
|
|
|
completeBtn,
|
|
|
|
|
widget.box.status == 'Arrived'
|
|
|
|
|
? deliveryBtn
|
|
|
|
|
: Container(),
|
|
|
|
|
],
|
|
|
|
|
)),
|
|
|
|
|
SizedBox(
|
|
|
|
|
height: 20,
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
2020-06-04 01:36:49 +06:30
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
2020-06-26 16:17:40 +06:30
|
|
|
List<Widget> getAddressList(
|
2020-10-08 11:38:05 +06:30
|
|
|
BuildContext context, List<DeliveryAddress> addresses) {
|
2020-06-26 16:17:40 +06:30
|
|
|
return addresses.asMap().entries.map((s) {
|
|
|
|
|
return InkWell(
|
|
|
|
|
onTap: () {},
|
2020-10-11 02:17:23 +06:30
|
|
|
child: DeliveryAddressRow(deliveryAddress: s.value),
|
2020-06-26 16:17:40 +06:30
|
|
|
);
|
|
|
|
|
}).toList();
|
|
|
|
|
}
|
2020-10-14 16:53:16 +06:30
|
|
|
|
2020-10-15 03:06:13 +06:30
|
|
|
_addCargo(CargoType cargo) {
|
2020-10-14 16:53:16 +06:30
|
|
|
if (cargo == null) return;
|
|
|
|
|
setState(() {
|
|
|
|
|
_cargoTypes.remove(cargo);
|
|
|
|
|
_cargoTypes.add(cargo);
|
|
|
|
|
});
|
|
|
|
|
}
|
2020-06-04 01:36:49 +06:30
|
|
|
}
|