update pickup and box list
This commit is contained in:
@@ -1,8 +1,14 @@
|
||||
import 'package:fcs/model/main_model.dart';
|
||||
import 'package:fcs/model/pickup_model.dart';
|
||||
import 'package:fcs/model/shipment_model.dart';
|
||||
import 'package:fcs/model_fcs/box_model.dart';
|
||||
import 'package:fcs/pages/util.dart';
|
||||
import 'package:fcs/pages_fcs/shipping_address_row.dart';
|
||||
import 'package:fcs/vo/box.dart';
|
||||
import 'package:fcs/vo/cargo.dart';
|
||||
import 'package:fcs/vo/pickup.dart';
|
||||
import 'package:fcs/vo/shipping_address.dart';
|
||||
import 'package:fcs/widget/bottom_up_page_route.dart';
|
||||
import 'package:fcs/widget/fcs_text_field.dart';
|
||||
import 'package:fcs/widget/fcs_text_field_readonly.dart';
|
||||
import 'package:flutter_datetime_picker/flutter_datetime_picker.dart';
|
||||
@@ -16,6 +22,7 @@ import 'package:flutter/material.dart';
|
||||
import 'package:fcs/widget/progress.dart';
|
||||
|
||||
import '../theme/theme.dart';
|
||||
import 'pickup_box_editor.dart';
|
||||
|
||||
class PickUpEditor extends StatefulWidget {
|
||||
final PickUp pickUp;
|
||||
@@ -49,6 +56,7 @@ class _PickUpEditorState extends State<PickUpEditor> {
|
||||
bool _isLoading = false;
|
||||
var now = new DateTime.now();
|
||||
bool isNew;
|
||||
ShippingAddress _shippingAddress = new ShippingAddress();
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
@@ -78,6 +86,8 @@ class _PickUpEditorState extends State<PickUpEditor> {
|
||||
];
|
||||
_pickUp = PickUp(cargoTypes: _cargoTypes);
|
||||
}
|
||||
var shipmentModel = Provider.of<ShipmentModel>(context, listen: false);
|
||||
_shippingAddress = shipmentModel.shippingAddresses[1];
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -216,6 +226,7 @@ class _PickUpEditorState extends State<PickUpEditor> {
|
||||
));
|
||||
|
||||
MainModel mainModel = Provider.of<MainModel>(context);
|
||||
var boxModel = Provider.of<BoxModel>(context);
|
||||
|
||||
return LocalProgress(
|
||||
inAsyncCall: _isLoading,
|
||||
@@ -253,7 +264,11 @@ class _PickUpEditorState extends State<PickUpEditor> {
|
||||
),
|
||||
),
|
||||
ExpansionTile(
|
||||
title: Text('Pickup Location / Time'),
|
||||
title: Text(
|
||||
'Pickup Location / Time',
|
||||
style: TextStyle(
|
||||
color: primaryColor, fontWeight: FontWeight.bold),
|
||||
),
|
||||
children: <Widget>[
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(left: 20.0),
|
||||
@@ -280,7 +295,11 @@ class _PickUpEditorState extends State<PickUpEditor> {
|
||||
],
|
||||
),
|
||||
ExpansionTile(
|
||||
title: Text('Package Information'),
|
||||
title: Text(
|
||||
'Package Information',
|
||||
style: TextStyle(
|
||||
color: primaryColor, fontWeight: FontWeight.bold),
|
||||
),
|
||||
children: <Widget>[
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(left: 20.0),
|
||||
@@ -322,60 +341,136 @@ class _PickUpEditorState extends State<PickUpEditor> {
|
||||
padding: const EdgeInsets.only(left: 20.0),
|
||||
child: fcsInput("Remark", MaterialCommunityIcons.note),
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(left: 3.0),
|
||||
child: ExpansionTile(
|
||||
leading: Icon(
|
||||
SimpleLineIcons.location_pin,
|
||||
color: primaryColor,
|
||||
),
|
||||
title: Text(
|
||||
'Shipping Address',
|
||||
),
|
||||
children: [
|
||||
ShippingAddressRow(
|
||||
shippingAddress: _shippingAddress),
|
||||
Container(
|
||||
padding: EdgeInsets.only(
|
||||
top: 20, bottom: 15, right: 15),
|
||||
child: Align(
|
||||
alignment: Alignment.bottomRight,
|
||||
child: Container(
|
||||
width: 130,
|
||||
height: 40,
|
||||
child: FloatingActionButton.extended(
|
||||
materialTapTargetSize:
|
||||
MaterialTapTargetSize.shrinkWrap,
|
||||
onPressed: () {},
|
||||
icon: Icon(Icons.add),
|
||||
label: Text(
|
||||
'Add Shipping\nAddress',
|
||||
style: TextStyle(fontSize: 12),
|
||||
),
|
||||
backgroundColor: primaryColor,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
SizedBox(height: 10.0),
|
||||
],
|
||||
),
|
||||
ExpansionTile(
|
||||
title: Text(
|
||||
'Box Information',
|
||||
style: TextStyle(
|
||||
color: primaryColor, fontWeight: FontWeight.bold),
|
||||
),
|
||||
children: <Widget>[
|
||||
Column(
|
||||
children: getBoxList(context, boxModel.boxes),
|
||||
),
|
||||
Container(
|
||||
padding:
|
||||
EdgeInsets.only(top: 20, bottom: 15, right: 15),
|
||||
child: Align(
|
||||
alignment: Alignment.bottomRight,
|
||||
child: Container(
|
||||
width: 120,
|
||||
height: 40,
|
||||
child: FloatingActionButton.extended(
|
||||
materialTapTargetSize:
|
||||
MaterialTapTargetSize.shrinkWrap,
|
||||
icon: Icon(Icons.add),
|
||||
onPressed: () {
|
||||
Navigator.push(
|
||||
context,
|
||||
BottomUpPageRoute(PickupBoxEditor()),
|
||||
);
|
||||
},
|
||||
label: Text(
|
||||
'Add Box',
|
||||
style: TextStyle(fontSize: 12),
|
||||
),
|
||||
backgroundColor: primaryColor,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
SizedBox(height: 10.0),
|
||||
],
|
||||
),
|
||||
// ExpansionTile(
|
||||
// title: Text('Box Information'),
|
||||
// title: Text(
|
||||
// 'Shipping Address',
|
||||
// style: TextStyle(
|
||||
// color: primaryColor, fontWeight: FontWeight.bold),
|
||||
// ),
|
||||
// children: <Widget>[
|
||||
// SizedBox(height: 10.0),
|
||||
// Padding(
|
||||
// padding: const EdgeInsets.only(left: 20.0),
|
||||
// child: widget.pickUp == null
|
||||
// ? fcsInput("Name", FontAwesomeIcons.user,
|
||||
// controller: _recipientNameEditingController)
|
||||
// : widget.pickUp.status == 'Pending'
|
||||
// ? fcsInput("Name", FontAwesomeIcons.user,
|
||||
// controller:
|
||||
// _recipientNameEditingController)
|
||||
// : fcsInputReadOnly(
|
||||
// "Name", FontAwesomeIcons.user,
|
||||
// controller:
|
||||
// _recipientNameEditingController)),
|
||||
// Padding(
|
||||
// padding: const EdgeInsets.only(left: 20.0),
|
||||
// child: widget.pickUp == null
|
||||
// ? fcsInput("Phone Number", Icons.phone,
|
||||
// controller: _recipientPhoneEditingController)
|
||||
// : widget.pickUp.status == 'Pending'
|
||||
// ? fcsInput("Phone Number", Icons.phone,
|
||||
// controller:
|
||||
// _recipientPhoneEditingController)
|
||||
// : fcsInputReadOnly(
|
||||
// "Phone Number", Icons.phone,
|
||||
// controller:
|
||||
// _recipientPhoneEditingController)),
|
||||
// Padding(
|
||||
// padding: const EdgeInsets.only(left: 20.0),
|
||||
// child: widget.pickUp == null
|
||||
// ? fcsInput("Address", Icons.location_on,
|
||||
// controller:
|
||||
// _recipientAddressEditingController)
|
||||
// : widget.pickUp.status == 'Pending'
|
||||
// ? fcsInput("Address", Icons.location_on,
|
||||
// controller:
|
||||
// _recipientAddressEditingController)
|
||||
// : fcsInputReadOnly(
|
||||
// "Address", Icons.location_on,
|
||||
// controller:
|
||||
// _recipientAddressEditingController)),
|
||||
// ],
|
||||
// ),
|
||||
ExpansionTile(
|
||||
title: Text('Shipping Address'),
|
||||
children: <Widget>[
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(left: 20.0),
|
||||
child: widget.pickUp == null
|
||||
? fcsInput("Name", FontAwesomeIcons.user,
|
||||
controller: _recipientNameEditingController)
|
||||
: widget.pickUp.status == 'Pending'
|
||||
? fcsInput("Name", FontAwesomeIcons.user,
|
||||
controller:
|
||||
_recipientNameEditingController)
|
||||
: fcsInputReadOnly(
|
||||
"Name", FontAwesomeIcons.user,
|
||||
controller:
|
||||
_recipientNameEditingController)),
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(left: 20.0),
|
||||
child: widget.pickUp == null
|
||||
? fcsInput("Phone Number", Icons.phone,
|
||||
controller: _recipientPhoneEditingController)
|
||||
: widget.pickUp.status == 'Pending'
|
||||
? fcsInput("Phone Number", Icons.phone,
|
||||
controller:
|
||||
_recipientPhoneEditingController)
|
||||
: fcsInputReadOnly(
|
||||
"Phone Number", Icons.phone,
|
||||
controller:
|
||||
_recipientPhoneEditingController)),
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(left: 20.0),
|
||||
child: widget.pickUp == null
|
||||
? fcsInput("Address", Icons.location_on,
|
||||
controller:
|
||||
_recipientAddressEditingController)
|
||||
: widget.pickUp.status == 'Pending'
|
||||
? fcsInput("Address", Icons.location_on,
|
||||
controller:
|
||||
_recipientAddressEditingController)
|
||||
: fcsInputReadOnly(
|
||||
"Address", Icons.location_on,
|
||||
controller:
|
||||
_recipientAddressEditingController)),
|
||||
],
|
||||
),
|
||||
mainModel.isCustomer()
|
||||
? Container()
|
||||
: ExpansionTile(
|
||||
@@ -413,14 +508,14 @@ class _PickUpEditorState extends State<PickUpEditor> {
|
||||
: Container(
|
||||
child: Column(
|
||||
children: <Widget>[
|
||||
widget.pickUp.status == 'Assigned'
|
||||
widget.pickUp.status == 'Confirmed'
|
||||
? Align(
|
||||
alignment: Alignment.bottomCenter,
|
||||
child: Center(
|
||||
child: Container(
|
||||
width: 250,
|
||||
child: FlatButton(
|
||||
child: Text('Complete'),
|
||||
child: Text('Complete Pickup'),
|
||||
color: primaryColor,
|
||||
textColor: Colors.white,
|
||||
onPressed: () {
|
||||
@@ -434,7 +529,7 @@ class _PickUpEditorState extends State<PickUpEditor> {
|
||||
child: Container(
|
||||
width: 250,
|
||||
child: FlatButton(
|
||||
child: Text('Assign'),
|
||||
child: Text('Assign Pickup'),
|
||||
color: primaryColor,
|
||||
textColor: Colors.white,
|
||||
onPressed: () {
|
||||
@@ -442,20 +537,6 @@ class _PickUpEditorState extends State<PickUpEditor> {
|
||||
},
|
||||
),
|
||||
))),
|
||||
Align(
|
||||
alignment: Alignment.bottomCenter,
|
||||
child: Center(
|
||||
child: Container(
|
||||
width: 250,
|
||||
child: FlatButton(
|
||||
child: Text('Complete Pickup '),
|
||||
color: primaryColor,
|
||||
textColor: Colors.white,
|
||||
onPressed: () {
|
||||
Navigator.pop(context);
|
||||
},
|
||||
),
|
||||
))),
|
||||
Align(
|
||||
alignment: Alignment.bottomCenter,
|
||||
child: Center(
|
||||
@@ -478,4 +559,136 @@ class _PickUpEditorState extends State<PickUpEditor> {
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
List<Widget> getBoxList(BuildContext context, List<Box> boxes) {
|
||||
List<Box> _boxes = [boxes[0], boxes[1]];
|
||||
|
||||
return _boxes.asMap().entries.map((_box) {
|
||||
ShippingAddress shippingAddress = _box.value.shippingAddress;
|
||||
|
||||
return InkWell(
|
||||
onTap: () {
|
||||
Navigator.of(context)
|
||||
.push(BottomUpPageRoute(PickupBoxEditor(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
|
||||
? ''
|
||||
: "Total Weight:${_box.value.weight.toString()}lb",
|
||||
style:
|
||||
new TextStyle(fontSize: 14.0, color: Colors.grey),
|
||||
),
|
||||
),
|
||||
],
|
||||
)
|
||||
],
|
||||
),
|
||||
_box.key == _boxes.length - 1
|
||||
? Container()
|
||||
: Divider(
|
||||
color: Colors.black,
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}).toList();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user