add shipments

This commit is contained in:
Sai Naw Wun
2020-10-13 07:50:25 +06:30
parent dc79f424a5
commit e032cee922
31 changed files with 1108 additions and 1035 deletions

View File

@@ -0,0 +1,132 @@
import 'package:fcs/domain/entities/box.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
class BoxRow extends StatelessWidget {
final Box box;
const BoxRow({Key key, this.box}) : super(key: key);
@override
Widget build(BuildContext context) {
return Container(
padding: EdgeInsets.only(left: 10),
child: Column(
children: <Widget>[
Row(
children: <Widget>[
Expanded(
child: new Padding(
padding: const EdgeInsets.symmetric(vertical: 10.0),
child: new Row(
children: <Widget>[
new Expanded(
child: new Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Padding(
padding: const EdgeInsets.only(left: 8.0),
child: new Text(
box.shippingAddress.fullName == null
? ''
: box.shippingAddress.fullName,
style: new TextStyle(
fontSize: 15.0,
color: Colors.black,
fontWeight: FontWeight.bold),
),
),
Padding(
padding: const EdgeInsets.only(left: 8.0),
child: new Text(
box.shippingAddress.addressLine1 == null
? ''
: box.shippingAddress.addressLine1,
style: new TextStyle(
fontSize: 14.0, color: Colors.grey),
),
),
Padding(
padding: const EdgeInsets.only(left: 8.0),
child: new Text(
box.shippingAddress.addressLine2 == null
? ''
: box.shippingAddress.addressLine2,
style: new TextStyle(
fontSize: 14.0, color: Colors.grey),
),
),
Padding(
padding: const EdgeInsets.only(left: 8.0),
child: new Text(
box.shippingAddress.city == null
? ''
: box.shippingAddress.city,
style: new TextStyle(
fontSize: 14.0, color: Colors.grey),
),
),
Padding(
padding: const EdgeInsets.only(left: 8.0),
child: new Text(
box.shippingAddress.state == null
? ''
: box.shippingAddress.state,
style: new TextStyle(
fontSize: 14.0, color: Colors.grey),
),
),
Padding(
padding: const EdgeInsets.only(left: 8.0),
child: new Text(
box.shippingAddress.phoneNumber == null
? ''
: "Phone:${box.shippingAddress.phoneNumber}",
style: new TextStyle(
fontSize: 14.0, color: Colors.grey),
),
),
],
),
),
],
),
),
),
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Padding(
padding: const EdgeInsets.only(left: 8.0),
child: new Text(
"L${box.length}xW${box.weight}xH${box.height}",
style: new TextStyle(fontSize: 15.0, color: Colors.black),
),
),
Padding(
padding: const EdgeInsets.only(left: 8.0),
child: new Text(
box.weight == null
? ''
: "Actual Weight:${box.weight.toString()}lb",
style: new TextStyle(fontSize: 14.0, color: Colors.grey),
),
),
Padding(
padding: const EdgeInsets.only(left: 8.0),
child: new Text(
box.shipmentWeight == null
? ''
: "Shipment Weight:${box.shipmentWeight.toString()}lb",
style: new TextStyle(fontSize: 14.0, color: Colors.grey),
),
),
],
)
],
),
],
),
);
}
}

View File

@@ -1,328 +0,0 @@
import 'package:fcs/domain/entities/box.dart';
import 'package:fcs/domain/entities/cargo.dart';
import 'package:fcs/domain/entities/package.dart';
import 'package:fcs/domain/vo/delivery_address.dart';
import 'package:fcs/helpers/theme.dart';
import 'package:fcs/localization/app_translations.dart';
import 'package:fcs/pages/delivery_address/delivery_address_list.dart';
import 'package:fcs/pages/delivery_address/delivery_address_row.dart';
import 'package:fcs/pages/delivery_address/model/delivery_address_model.dart';
import 'package:fcs/pages/widgets/bottom_up_page_route.dart';
import 'package:fcs/pages/widgets/display_text.dart';
import 'package:fcs/pages/widgets/local_text.dart';
import 'package:fcs/pages/widgets/my_data_table.dart';
import 'package:fcs/pages/widgets/progress.dart';
import 'package:flutter/material.dart';
import 'package:flutter_icons/flutter_icons.dart';
import 'package:provider/provider.dart';
import '../main/util.dart';
class PickupBoxEditor extends StatefulWidget {
final Box box;
PickupBoxEditor({this.box});
@override
_PickupBoxEditorState createState() => _PickupBoxEditorState();
}
class _PickupBoxEditorState extends State<PickupBoxEditor> {
Box _box;
bool _isLoading = false;
bool isNew;
bool isMixBox = false;
DeliveryAddress _deliveryAddress = new DeliveryAddress();
@override
void initState() {
super.initState();
if (widget.box != null) {
_box = widget.box;
_deliveryAddress = _box.shippingAddress;
isNew = false;
} else {
List<Package> packages = [
// PackageModel.packages[0],
// PackageModel.packages[1],
// PackageModel.packages[2]
];
List<Cargo> _cargoTypes = [
Cargo(type: 'General Cargo', weight: 25),
Cargo(type: 'Medicine', weight: 20),
Cargo(type: 'Dangerous Cargo', weight: 30)
];
var shipmentModel =
Provider.of<DeliveryAddressModel>(context, listen: false);
_deliveryAddress = shipmentModel.deliveryAddresses[1];
isNew = true;
_box = Box(
rate: 0,
weight: 75,
width: 0,
height: 0,
length: 0,
packages: packages,
cargoTypes: _cargoTypes,
shipmentWeight: 0);
}
}
@override
void dispose() {
super.dispose();
}
@override
Widget build(BuildContext context) {
return LocalProgress(
inAsyncCall: _isLoading,
child: Scaffold(
appBar: AppBar(
centerTitle: true,
leading: new IconButton(
icon: new Icon(Icons.close),
onPressed: () => Navigator.of(context).pop(),
),
backgroundColor: primaryColor,
title: Text(AppTranslations.of(context).text("package.edit.title")),
),
body: Card(
child: Column(
children: <Widget>[
Expanded(
child: ListView(
children: [
ExpansionTile(
title: Text(
'Cargo Types',
style: TextStyle(
color: primaryColor, fontWeight: FontWeight.bold),
),
children: [
Padding(
padding: const EdgeInsets.only(left: 20.0, right: 20),
child: TextFormField(
initialValue: _box.weight.toString(),
textAlign: TextAlign.end,
decoration: InputDecoration(
fillColor: Colors.white,
labelText: 'Actual Weight',
filled: true,
icon: Icon(MaterialCommunityIcons.weight,
color: primaryColor),
)),
),
Container(
padding: EdgeInsets.only(top: 10),
child: SingleChildScrollView(
scrollDirection: Axis.horizontal,
child: MyDataTable(
headingRowHeight: 40,
columnSpacing: 120,
columns: [
MyDataColumn(
label: LocalText(
context,
"cargo.type",
color: Colors.grey,
),
),
MyDataColumn(
label: LocalText(
context,
"cargo.weight",
color: Colors.grey,
),
),
],
rows: getCargoRows(context),
),
),
),
Container(
padding: EdgeInsets.only(top: 20),
child: Align(
alignment: Alignment.bottomRight,
child: FloatingActionButton.extended(
icon: Icon(Icons.add),
label: Text("Add Cargo"),
backgroundColor: primaryColor,
onPressed: () {
// Navigator.of(context).push(
// BottomUpPageRoute(PackageAddition()));
},
),
),
),
SizedBox(height: 25),
],
),
ExpansionTile(
title: Text(
'Box Dimension',
style: TextStyle(
color: primaryColor, fontWeight: FontWeight.bold),
),
children: [
Padding(
padding: const EdgeInsets.only(left: 20.0, right: 20),
child: fcsInputReadOnly(
"Shipment Weight", MaterialCommunityIcons.weight,
value: _box.shipmentWeight.toString()),
),
Padding(
padding: const EdgeInsets.only(left: 20.0, right: 20),
child: TextFormField(
initialValue: _box.width.toString(),
textAlign: TextAlign.end,
decoration: InputDecoration(
fillColor: Colors.white,
labelText: 'Width',
filled: true,
icon: Icon(FontAwesome.arrow_circle_right,
color: primaryColor),
)),
),
Padding(
padding: const EdgeInsets.only(left: 20.0, right: 20),
child: TextFormField(
initialValue: _box.height.toString(),
textAlign: TextAlign.end,
decoration: InputDecoration(
fillColor: Colors.white,
labelText: 'Height',
filled: true,
icon: Icon(FontAwesome.arrow_circle_up,
color: primaryColor),
)),
),
Padding(
padding: const EdgeInsets.only(left: 20.0, right: 20),
child: TextFormField(
initialValue: _box.length.toString(),
textAlign: TextAlign.end,
decoration: InputDecoration(
fillColor: Colors.white,
labelText: 'Length',
filled: true,
icon: Icon(FontAwesome.arrow_circle_left,
color: primaryColor),
)),
),
SizedBox(height: 25),
],
),
makeLocation(context, _deliveryAddress),
],
),
),
widget.box == null
? Align(
alignment: Alignment.bottomCenter,
child: Center(
child: Container(
width: 250,
child: FlatButton(
child: Text('Create New Package'),
color: primaryColor,
textColor: Colors.white,
onPressed: () {
Navigator.pop(context);
},
),
)))
: Container(
child: Column(
children: <Widget>[
Align(
alignment: Alignment.bottomCenter,
child: Center(
child: Container(
width: 250,
child: FlatButton(
child: Text('Update Package'),
color: primaryColor,
textColor: Colors.white,
onPressed: () {
Navigator.pop(context);
},
),
))),
],
))
],
),
),
),
);
}
Widget makeLocation(BuildContext context, DeliveryAddress deliveryAddress) {
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
children: [
Expanded(
child: DisplayText(
labelTextKey: "shipment.box.delivery",
iconData: MaterialCommunityIcons.truck_fast,
),
),
Chip(
label: InkWell(
onTap: () async {
DeliveryAddress d = await Navigator.push<DeliveryAddress>(
context,
BottomUpPageRoute(DeliveryAddressList(
forSelection: true,
)),
);
setState(() {
this._deliveryAddress = d;
});
},
child: LocalText(context, "delivery_address.change_address",
color: primaryColor),
))
],
),
Padding(
padding: const EdgeInsets.only(left: 28.0),
child: deliveryAddress == null
? Container()
: DeliveryAddressRow(
key: ValueKey(deliveryAddress.id),
deliveryAddress: deliveryAddress),
),
],
);
}
List<MyDataRow> getCargoRows(BuildContext context) {
if (_box == null || _box.cargoTypes == null) {
return [];
}
return _box.cargoTypes.map((c) {
return MyDataRow(
onSelectChanged: (bool selected) {},
cells: [
MyDataCell(new Text(
c.type == null ? "" : c.type,
style: textStyle,
)),
MyDataCell(
new Text(c.weight == null ? "0" : c.weight.toString(),
style: textStyle),
),
],
);
}).toList();
}
}

View File

@@ -0,0 +1,336 @@
import 'package:fcs/domain/entities/box.dart';
import 'package:fcs/domain/entities/cargo.dart';
import 'package:fcs/domain/entities/package.dart';
import 'package:fcs/domain/vo/delivery_address.dart';
import 'package:fcs/helpers/theme.dart';
import 'package:fcs/pages/box/cargo_type_editor.dart';
import 'package:fcs/pages/delivery_address/delivery_address_list.dart';
import 'package:fcs/pages/delivery_address/delivery_address_row.dart';
import 'package:fcs/pages/delivery_address/model/delivery_address_model.dart';
import 'package:fcs/pages/main/model/main_model.dart';
import 'package:fcs/pages/widgets/bottom_up_page_route.dart';
import 'package:fcs/pages/widgets/defalut_delivery_address.dart';
import 'package:fcs/pages/widgets/delivery_address_selection.dart';
import 'package:fcs/pages/widgets/display_text.dart';
import 'package:fcs/pages/widgets/input_text.dart';
import 'package:fcs/pages/widgets/local_button.dart';
import 'package:fcs/pages/widgets/local_text.dart';
import 'package:fcs/pages/widgets/my_data_table.dart';
import 'package:fcs/pages/widgets/progress.dart';
import 'package:fcs/pages/widgets/title_with_add_button.dart';
import 'package:flutter/material.dart';
import 'package:flutter_icons/flutter_icons.dart';
import 'package:provider/provider.dart';
class ShipmentBoxEditor extends StatefulWidget {
final Box box;
ShipmentBoxEditor({this.box});
@override
_ShipmentBoxEditorState createState() => _ShipmentBoxEditorState();
}
class _ShipmentBoxEditorState extends State<ShipmentBoxEditor> {
TextEditingController _lengthCtl = new TextEditingController();
TextEditingController _widthCtl = new TextEditingController();
TextEditingController _heightCtl = new TextEditingController();
Box _box;
bool _isLoading = false;
bool _isNew;
bool isMixBox = false;
DeliveryAddress _deliveryAddress = new DeliveryAddress();
double volumetricRatio;
double shipmentWeight;
List<Cargo> cargos;
@override
void initState() {
super.initState();
volumetricRatio =
Provider.of<MainModel>(context, listen: false).setting.volumetricRatio;
shipmentWeight = 0;
cargos = [];
if (widget.box != null) {
_box = widget.box;
_deliveryAddress = _box.shippingAddress;
_isNew = false;
} else {
var shipmentModel =
Provider.of<DeliveryAddressModel>(context, listen: false);
_deliveryAddress = shipmentModel.defalutAddress;
_isNew = true;
_box = Box();
}
_lengthCtl.addListener(_calShipmentWeight);
_widthCtl.addListener(_calShipmentWeight);
_heightCtl.addListener(_calShipmentWeight);
}
_calShipmentWeight() {
double l = double.parse(_lengthCtl.text, (s) => 0);
double w = double.parse(_widthCtl.text, (s) => 0);
double h = double.parse(_heightCtl.text, (s) => 0);
setState(() {
shipmentWeight = l * w * h / volumetricRatio;
});
}
@override
Widget build(BuildContext context) {
double iconSize = 32;
final shipmentWeightBox = DisplayText(
labelTextKey: "shipment.box.shipment.weight",
text: shipmentWeight == null ? "" : shipmentWeight.toStringAsFixed(0),
iconData: MaterialCommunityIcons.weight,
);
final lengthBox = InputText(
labelTextKey: "shipment.box.length",
controller: _lengthCtl,
textInputType: TextInputType.number,
iconData: FontAwesome.arrow_circle_right,
);
final widthBox = InputText(
labelTextKey: "shipment.box.width",
controller: _widthCtl,
textInputType: TextInputType.number,
iconData: FontAwesome.arrow_circle_left,
);
final heightBox = InputText(
labelTextKey: "shipment.box.height",
controller: _heightCtl,
textInputType: TextInputType.number,
iconData: FontAwesome.arrow_circle_up,
);
final createBtn = LocalButton(
textKey: "shipment.box.add",
);
return LocalProgress(
inAsyncCall: _isLoading,
child: Scaffold(
appBar: AppBar(
centerTitle: true,
leading: new IconButton(
icon: new Icon(
Icons.close,
color: primaryColor,
),
onPressed: () => Navigator.of(context).pop(),
),
shadowColor: Colors.transparent,
backgroundColor: Colors.white,
title: LocalText(
context,
_isNew ? "boxes.new" : "box.edit.title",
fontSize: 20,
color: primaryColor,
),
),
body: Padding(
padding: const EdgeInsets.all(8.0),
child: ListView(
children: [
TitleWithAddButton(
iconData: MaterialCommunityIcons.briefcase_check,
titleKey: "shipment.box.cargo.type",
onTap: () async {
Cargo cargo = await Navigator.push<Cargo>(
context, BottomUpPageRoute(CargoTypeEditor()));
if (cargo != null) {
setState(() {
cargos.add(cargo);
});
}
}),
MyDataTable(
headingRowHeight: 40,
columns: [
MyDataColumn(
label: LocalText(
context,
"cargo.type",
color: Colors.grey,
),
),
MyDataColumn(
label: LocalText(
context,
"cargo.weight",
color: Colors.grey,
),
),
],
rows: getCargoRows(context),
),
SizedBox(
height: 30,
),
TitleWithAddButton(
titleKey: "shipment.box.dimemsion",
),
shipmentWeightBox,
lengthBox,
widthBox,
heightBox,
DefaultDeliveryAddress(
deliveryAddress: _deliveryAddress,
onTap: () async {
DeliveryAddress d = await Navigator.push<DeliveryAddress>(
context,
BottomUpPageRoute(DeliveryAddressSelection(
deliveryAddress: _deliveryAddress,
)),
);
if (d == null) return;
setState(() {
this._deliveryAddress = d;
});
}),
createBtn
],
),
),
),
);
}
List<TableRow> getRows(BuildContext context) {
if (cargos == null || cargos == null) {
return [];
}
int total = 0;
var rows = cargos.map((c) {
total += c.weight;
return TableRow(
children: [
Text(
c.type == null ? "" : c.type,
style: textStyle,
),
Align(
alignment: Alignment.centerRight,
child: Text(c.weight == null ? "0" : c.weight.toString(),
style: textStyle)),
IconButton(icon: Icon(Icons.remove), onPressed: () => {})
],
);
}).toList();
var totalRow = TableRow(
children: [
Align(
alignment: Alignment.centerRight,
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Text("Total Weight",
style: TextStyle(
fontWeight: FontWeight.bold,
)),
),
),
Align(
alignment: Alignment.centerRight,
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Text(total.toString(),
style: TextStyle(fontWeight: FontWeight.bold)),
)),
Container(
width: 50,
child:
new Text(" ", style: TextStyle(fontWeight: FontWeight.bold))),
],
);
rows.add(totalRow);
rows.insert(
0,
TableRow(children: [
Center(
child: Padding(
padding: const EdgeInsets.all(8.0),
child: LocalText(
context,
"cargo.type",
color: Colors.grey,
),
),
),
Center(
child: Padding(
padding: const EdgeInsets.all(8.0),
child: LocalText(
context,
"cargo.weight",
color: Colors.grey,
),
),
),
Text("")
]));
return rows;
}
List<MyDataRow> getCargoRows(BuildContext context) {
if (cargos == null || cargos == null) {
return [];
}
int total = 0;
var rows = cargos.map((c) {
total += c.weight;
return MyDataRow(
onSelectChanged: (bool selected) {},
cells: [
MyDataCell(new Text(
c.type == null ? "" : c.type,
style: textStyle,
)),
MyDataCell(
Row(
mainAxisAlignment: MainAxisAlignment.end,
children: [
Text(c.weight == null ? "0" : c.weight.toString(),
style: textStyle),
IconButton(
icon: Icon(
Icons.remove_circle,
color: primaryColor,
),
onPressed: () => {},
)
],
),
),
],
);
}).toList();
var totalRow = MyDataRow(
onSelectChanged: (bool selected) {},
cells: [
MyDataCell(Align(
alignment: Alignment.centerRight,
child: Text("Total Weight",
style: TextStyle(
fontWeight: FontWeight.bold,
)),
)),
MyDataCell(
Padding(
padding: const EdgeInsets.only(right: 45.0),
child: Align(
alignment: Alignment.centerRight,
child: Text(total.toString(),
style: TextStyle(fontWeight: FontWeight.bold))),
),
),
],
);
rows.add(totalRow);
return rows;
}
}

View File

@@ -4,32 +4,29 @@ import 'package:fcs/domain/entities/cargo.dart';
import 'package:fcs/domain/entities/pickup.dart';
import 'package:fcs/domain/vo/delivery_address.dart';
import 'package:fcs/helpers/theme.dart';
import 'package:fcs/localization/app_translations.dart';
import 'package:fcs/pages/box/model/box_model.dart';
import 'package:fcs/pages/delivery_address/delivery_address_list.dart';
import 'package:fcs/pages/delivery_address/delivery_address_row.dart';
import 'package:fcs/pages/delivery_address/model/delivery_address_model.dart';
import 'package:fcs/pages/main/model/main_model.dart';
import 'package:fcs/pages/shipment/model/shipment_model.dart';
import 'package:fcs/pages/main/util.dart';
import 'package:fcs/pages/widgets/bottom_up_page_route.dart';
import 'package:fcs/pages/widgets/defalut_delivery_address.dart';
import 'package:fcs/pages/widgets/delivery_address_selection.dart';
import 'package:fcs/pages/widgets/display_text.dart';
import 'package:fcs/pages/widgets/input_date.dart';
import 'package:fcs/pages/widgets/input_text.dart';
import 'package:fcs/pages/widgets/input_time.dart';
import 'package:fcs/pages/widgets/local_dropdown.dart';
import 'package:fcs/pages/widgets/local_text.dart';
import 'package:fcs/pages/widgets/multi_img_controller.dart';
import 'package:fcs/pages/widgets/multi_img_file.dart';
import 'package:fcs/pages/widgets/progress.dart';
import 'package:flutter_datetime_picker/flutter_datetime_picker.dart';
import 'package:fcs/pages/widgets/title_with_add_button.dart';
import 'package:flutter/material.dart';
import 'package:flutter_icons/flutter_icons.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
import 'package:intl/intl.dart';
import 'package:provider/provider.dart';
import 'package:flutter/material.dart';
import 'pickup_box_editor.dart';
import 'box_row.dart';
import 'shipment_box_editor.dart';
class ShipmentEditor extends StatefulWidget {
final Shipment shipment;
@@ -85,12 +82,6 @@ class _ShipmentEditorState extends State<ShipmentEditor> {
_pickupDate.text = dateFormatter.format(now);
_handlingFeeController.text = numberFormatter.format(_pickUp.handlingFee);
_currVal = _pickUp.radioIndex;
var mainModel = Provider.of<MainModel>(context, listen: false);
// _recipientNameEditingController.text = mainModel.recipient.name;
// _recipientPhoneEditingController.text = mainModel.recipient.phoneNumber;
// _recipientAddressEditingController.text =
// mainModel.recipient.shippingAddress;
} else {
_isNew = true;
List<Cargo> _cargoTypes = [
@@ -112,6 +103,9 @@ class _ShipmentEditorState extends State<ShipmentEditor> {
@override
Widget build(BuildContext context) {
MainModel mainModel = Provider.of<MainModel>(context);
ShipmentModel pickupModel = Provider.of<ShipmentModel>(context);
final fromTimeBox = InputTime(
labelTextKey: 'shipment.from',
iconData: Icons.timer,
@@ -120,18 +114,6 @@ class _ShipmentEditorState extends State<ShipmentEditor> {
final toTimeBox = InputTime(
labelTextKey: 'shipment.to', controller: _toTimeEditingController);
final fromTimeBoxReadOnly = fcsInputReadOnly(
'From',
Icons.timer,
controller: _fromTimeEditingController,
);
final toTimeBoxReadOnly = fcsInputReadOnly(
'To',
null,
controller: _toTimeEditingController,
);
final pickupTimeBox = Row(
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
@@ -151,37 +133,66 @@ class _ShipmentEditorState extends State<ShipmentEditor> {
],
);
final pickupTimeReadOnly = Padding(
padding: const EdgeInsets.only(left: 20.0),
child: Row(
children: <Widget>[
SizedBox(height: 5),
Container(
child: fromTimeBoxReadOnly,
width: 120,
),
Padding(
padding: const EdgeInsets.only(left: 8.0),
child: Text('-'),
),
Container(
child: toTimeBoxReadOnly,
width: 120,
),
],
),
final shipmentDateBox = InputDate(
labelTextKey: "shipment.date",
iconData: Icons.date_range,
controller: _pickupDate,
);
final localDropoffAddress = DisplayText(
iconData: Icons.location_on,
labelTextKey: "Local Dropoff Address",
text: mainModel.setting.usaAddress);
final curierDropoffAddress = FloatingActionButton.extended(
materialTapTargetSize: MaterialTapTargetSize.shrinkWrap,
onPressed: () {},
icon: Icon(Icons.arrow_right),
label: Text(
'Visit courier websie for nearest drop-off',
style: TextStyle(fontSize: 12),
),
backgroundColor: primaryColor,
);
var deliveryAddressBox = DefaultDeliveryAddress(
deliveryAddress: _pickupAddress,
labelKey: "shipment.location",
onTap: () async {
DeliveryAddress d = await Navigator.push<DeliveryAddress>(
context,
BottomUpPageRoute(DeliveryAddressSelection(
deliveryAddress: _pickupAddress,
)),
);
if (d == null) return;
setState(() {
this._pickupAddress = d;
});
},
);
MainModel mainModel = Provider.of<MainModel>(context);
var boxModel = Provider.of<BoxModel>(context);
var handlingFeeBox = DisplayText(
labelTextKey: "shipment.handling.fee",
text: "10",
iconData: FontAwesomeIcons.moneyBill);
var shipmentTypeBox = LocalDropdown<String>(
callback: (v) {
setState(() {
selectedPickupType = v;
});
},
iconData: SimpleLineIcons.direction,
selectedValue: selectedPickupType,
values: pickupModel.pickupTypes,
);
return LocalProgress(
inAsyncCall: _isLoading,
child: Scaffold(
appBar: AppBar(
centerTitle: true,
leading: new IconButton(
icon: new Icon(Icons.close),
icon: new Icon(
Icons.close,
color: primaryColor,
),
onPressed: () => Navigator.of(context).pop(),
),
shadowColor: Colors.transparent,
@@ -197,214 +208,38 @@ class _ShipmentEditorState extends State<ShipmentEditor> {
padding: const EdgeInsets.all(10.0),
child: ListView(
children: <Widget>[
_isNew
? Container()
: Center(
child: Padding(
padding: const EdgeInsets.only(left: 10.0, top: 8),
child: Text(
'#P200304',
style: TextStyle(
color: Colors.black87,
fontSize: 14,
fontWeight: FontWeight.bold),
),
),
),
widget.shipment == null
? Container()
: widget.shipment.isCourier
? Padding(
padding: const EdgeInsets.only(left: 15.0),
child: fcsInputReadOnly("Handling Fee/Courier Fee",
FontAwesomeIcons.moneyBill,
controller: _handlingFeeController),
)
: Padding(
padding: const EdgeInsets.only(left: 15.0),
child: fcsInputReadOnly("Handling Fee/Courier Fee",
FontAwesomeIcons.moneyBill,
controller: _handlingFeeController),
),
makeDropdown(),
makeLocation(context, _pickupAddress),
InputDate(
labelTextKey: "shipment.date",
iconData: Icons.date_range,
controller: _pickupDate,
),
handlingFeeBox,
shipmentTypeBox,
deliveryAddressBox,
shipmentDateBox,
pickupTimeBox,
_currVal == 3
? Container(
child: DeliveryAddressRow(
deliveryAddress: DeliveryAddress(
fullName: 'FCS Office',
addressLine1: '154-19 64th Ave.',
addressLine2: 'Flushing',
city: 'NY',
state: 'NY',
phoneNumber: '+1 (292)215-2247'),
),
)
: _currVal == 4
? Container(
child: Column(
children: <Widget>[
Container(
padding: EdgeInsets.only(
top: 20, bottom: 15, right: 15),
child: Align(
alignment: Alignment.center,
child: Container(
width: 350,
height: 40,
child: FloatingActionButton.extended(
materialTapTargetSize:
MaterialTapTargetSize.shrinkWrap,
onPressed: () {},
icon: Icon(Icons.arrow_right),
label: Text(
'Visit courier websie for nearest drop-off',
style: TextStyle(fontSize: 12),
),
backgroundColor: primaryColor,
),
),
),
),
],
))
: Container(),
Padding(
padding: const EdgeInsets.all(8.0),
child: Row(
children: [
Text(
'Boxes',
style: TextStyle(
color: primaryColor, fontWeight: FontWeight.bold),
),
Spacer(),
IconButton(
onPressed: () {
Navigator.push(
context,
BottomUpPageRoute(PickupBoxEditor()),
);
},
icon: Icon(
Icons.add,
color: primaryColor,
))
],
localDropoffAddress,
curierDropoffAddress,
TitleWithAddButton(
titleKey: "boxes.name",
iconData: MaterialCommunityIcons.package,
onTap: () => Navigator.push(
context,
BottomUpPageRoute(ShipmentBoxEditor()),
),
),
Column(
children: getBoxList(context, boxModel.boxes),
),
mainModel.isCustomer() || _isNew
? Container()
: ExpansionTile(
title: Text('For FCS'),
children: <Widget>[
widget.shipment != null
? widget.shipment.status == 'Pending'
? Padding(
padding: const EdgeInsets.only(left: 20.0),
child: fcsDropDown("Assigned",
MaterialCommunityIcons.worker),
)
: Container()
: Container(),
Padding(
padding: EdgeInsets.only(left: 20),
child: Row(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Container(
padding: EdgeInsets.only(top: 8),
child: Text(
'Attach Courier Shiping Labels',
style: TextStyle(
color: Colors.black, fontSize: 16),
),
),
Container(
padding: EdgeInsets.only(left: 10),
child: MultiImageFile(
enabled: true,
controller: multiImgController,
title: "Receipt File",
)),
],
),
),
],
Align(
alignment: Alignment.bottomCenter,
child: Center(
child: Container(
width: 250,
child: FlatButton(
child: Text('Create shipment'),
color: primaryColor,
textColor: Colors.white,
onPressed: () {
Navigator.pop(context);
},
),
widget.shipment == null
? Align(
alignment: Alignment.bottomCenter,
child: Center(
child: Container(
width: 250,
child: FlatButton(
child: Text('Create shipment'),
color: primaryColor,
textColor: Colors.white,
onPressed: () {
Navigator.pop(context);
},
),
)))
: Container(
child: Column(
children: <Widget>[
widget.shipment.status == 'Confirmed'
? Align(
alignment: Alignment.bottomCenter,
child: Center(
child: Container(
width: 250,
child: FlatButton(
child: Text('Complete Shipment'),
color: primaryColor,
textColor: Colors.white,
onPressed: () {
Navigator.pop(context);
},
),
)))
: Align(
alignment: Alignment.bottomCenter,
child: Center(
child: Container(
width: 250,
child: FlatButton(
child: Text('Confirm Shipment'),
color: primaryColor,
textColor: Colors.white,
onPressed: () {
Navigator.pop(context);
},
),
))),
Align(
alignment: Alignment.bottomCenter,
child: Center(
child: Container(
width: 250,
child: FlatButton(
child: Text('Cancel Shipment'),
color: Colors.grey[600],
textColor: Colors.white,
onPressed: () {
Navigator.pop(context);
},
),
)))
],
))
)))
],
),
),
@@ -412,242 +247,14 @@ class _ShipmentEditorState extends State<ShipmentEditor> {
);
}
Widget makeDropdown() {
ShipmentModel pickupModel = Provider.of<ShipmentModel>(context);
return Padding(
padding: const EdgeInsets.only(left: 5.0, right: 0),
child: Row(
children: [
Padding(
padding: const EdgeInsets.only(left: 0, right: 10),
child: Icon(SimpleLineIcons.direction, color: primaryColor),
),
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Padding(
padding: const EdgeInsets.only(right: 18.0),
child: LocalText(
context,
"shipment.type",
color: Colors.black54,
fontSize: 16,
),
),
DropdownButton<String>(
isDense: true,
value: selectedPickupType,
style: TextStyle(color: Colors.black, fontSize: 14),
underline: Container(
height: 1,
color: Colors.grey,
),
onChanged: (String newValue) {
setState(() {
selectedPickupType = newValue;
});
},
isExpanded: true,
items: pickupModel.pickupTypes
.map<DropdownMenuItem<String>>((String value) {
return DropdownMenuItem<String>(
value: value,
child: Text(value ?? "",
overflow: TextOverflow.ellipsis,
style: TextStyle(color: primaryColor)),
);
}).toList(),
),
],
),
),
],
),
);
}
Widget makeLocation(BuildContext context, DeliveryAddress deliveryAddress) {
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
children: [
Expanded(
child: DisplayText(
labelTextKey: "shipment.location",
iconData: MaterialCommunityIcons.truck_fast,
),
),
Chip(
label: InkWell(
onTap: () async {
DeliveryAddress d = await Navigator.push<DeliveryAddress>(
context,
BottomUpPageRoute(DeliveryAddressList(
forSelection: true,
)),
);
setState(() {
this._pickupAddress = d;
});
},
child: LocalText(context, "delivery_address.change_address",
color: primaryColor),
))
],
),
Padding(
padding: const EdgeInsets.only(left: 28.0),
child: deliveryAddress == null
? Container()
: DeliveryAddressRow(
key: ValueKey(deliveryAddress.id),
deliveryAddress: deliveryAddress),
),
],
);
}
List<Widget> getBoxList(BuildContext context, List<Box> boxes) {
List<Box> _boxes = [boxes[0], boxes[1]];
return _boxes.asMap().entries.map((_box) {
DeliveryAddress shippingAddress = _box.value.shippingAddress;
return boxes.asMap().entries.map((_box) {
return InkWell(
onTap: () {
Navigator.of(context)
.push(BottomUpPageRoute(PickupBoxEditor(box: _box.value)));
.push(BottomUpPageRoute(ShipmentBoxEditor(box: _box.value)));
},
child: Container(
padding: EdgeInsets.only(left: 10),
child: Column(
children: <Widget>[
Row(
children: <Widget>[
Expanded(
child: new Padding(
padding: const EdgeInsets.symmetric(vertical: 10.0),
child: new Row(
children: <Widget>[
new Expanded(
child: new Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Padding(
padding: const EdgeInsets.only(left: 8.0),
child: new Text(
shippingAddress.fullName == null
? ''
: shippingAddress.fullName,
style: new TextStyle(
fontSize: 15.0,
color: Colors.black,
fontWeight: FontWeight.bold),
),
),
Padding(
padding: const EdgeInsets.only(left: 8.0),
child: new Text(
shippingAddress.addressLine1 == null
? ''
: shippingAddress.addressLine1,
style: new TextStyle(
fontSize: 14.0, color: Colors.grey),
),
),
Padding(
padding: const EdgeInsets.only(left: 8.0),
child: new Text(
shippingAddress.addressLine2 == null
? ''
: shippingAddress.addressLine2,
style: new TextStyle(
fontSize: 14.0, color: Colors.grey),
),
),
Padding(
padding: const EdgeInsets.only(left: 8.0),
child: new Text(
shippingAddress.city == null
? ''
: shippingAddress.city,
style: new TextStyle(
fontSize: 14.0, color: Colors.grey),
),
),
Padding(
padding: const EdgeInsets.only(left: 8.0),
child: new Text(
shippingAddress.state == null
? ''
: shippingAddress.state,
style: new TextStyle(
fontSize: 14.0, color: Colors.grey),
),
),
Padding(
padding: const EdgeInsets.only(left: 8.0),
child: new Text(
shippingAddress.phoneNumber == null
? ''
: "Phone:${shippingAddress.phoneNumber}",
style: new TextStyle(
fontSize: 14.0, color: Colors.grey),
),
),
],
),
),
],
),
),
),
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Padding(
padding: const EdgeInsets.only(left: 8.0),
child: new Text(
"L${_box.value.length}xW${_box.value.weight}xH${_box.value.height}",
style: new TextStyle(
fontSize: 15.0, color: Colors.black),
),
),
Padding(
padding: const EdgeInsets.only(left: 8.0),
child: new Text(
_box.value.weight == null
? ''
: "Actual Weight:${_box.value.weight.toString()}lb",
style:
new TextStyle(fontSize: 14.0, color: Colors.grey),
),
),
Padding(
padding: const EdgeInsets.only(left: 8.0),
child: new Text(
_box.value.shipmentWeight == null
? ''
: "Shipment Weight:${_box.value.shipmentWeight.toString()}lb",
style:
new TextStyle(fontSize: 14.0, color: Colors.grey),
),
),
],
)
],
),
_box.key == _boxes.length - 1
? Container()
: Divider(
color: Colors.black,
)
],
),
),
child: BoxRow(box: _box.value),
);
}).toList();
}

View File

@@ -57,16 +57,6 @@ class _ShipmentListState extends State<ShipmentList> {
// onPressed: () => showPlacesSearch(context),
),
],
// bottom: TabBar(
// unselectedLabelColor: Colors.grey,
// tabs: [
// Tab(
// text: "Upcoming",
// ),
// Tab(text: "Completed"),
// Tab(text: "Canceled"),
// ],
// ),
),
floatingActionButton: FloatingActionButton.extended(
onPressed: () {
@@ -87,14 +77,6 @@ class _ShipmentListState extends State<ShipmentList> {
itemBuilder: (BuildContext context, int index) {
return ShipmentListRow(pickUp: pickupModel.pickups[index]);
}),
// body: TabBarView(
// children: [
// //Icon(Icons.directions_car),
// _upComing(),
// _completed(),
// _canceled()
// ],
// )
),
),
);
@@ -103,67 +85,4 @@ class _ShipmentListState extends State<ShipmentList> {
_newPickup() {
Navigator.of(context).push(BottomUpPageRoute(ShipmentEditor()));
}
Widget _upComing() {
var pickupModel = Provider.of<ShipmentModel>(context);
return Column(
children: <Widget>[
Expanded(
child: new ListView.separated(
separatorBuilder: (context, index) => Divider(
color: Colors.black,
),
scrollDirection: Axis.vertical,
padding: EdgeInsets.only(top: 15),
shrinkWrap: true,
itemCount: pickupModel.upcoming.length,
itemBuilder: (BuildContext context, int index) {
return ShipmentListRow(pickUp: pickupModel.upcoming[index]);
}),
),
],
);
}
Widget _completed() {
var pickupModel = Provider.of<ShipmentModel>(context);
return Column(
children: <Widget>[
Expanded(
child: new ListView.separated(
separatorBuilder: (context, index) => Divider(
color: Colors.black,
),
scrollDirection: Axis.vertical,
padding: EdgeInsets.only(top: 15),
shrinkWrap: true,
itemCount: pickupModel.completed.length,
itemBuilder: (BuildContext context, int index) {
return ShipmentListRow(pickUp: pickupModel.completed[index]);
}),
),
],
);
}
Widget _canceled() {
var pickupModel = Provider.of<ShipmentModel>(context);
return Column(
children: <Widget>[
Expanded(
child: new ListView.separated(
separatorBuilder: (context, index) => Divider(
color: Colors.black,
),
scrollDirection: Axis.vertical,
padding: EdgeInsets.only(top: 15),
shrinkWrap: true,
itemCount: pickupModel.canceled.length,
itemBuilder: (BuildContext context, int index) {
return ShipmentListRow(pickUp: pickupModel.canceled[index]);
}),
),
],
);
}
}