add shipment

This commit is contained in:
Sai Naw Wun
2020-10-12 08:26:27 +06:30
parent b13dc69161
commit 2b02806715
18 changed files with 549 additions and 554 deletions

View File

@@ -291,15 +291,20 @@
"Shipment Start ================================================================":"", "Shipment Start ================================================================":"",
"shipment": "Shipments", "shipment": "Shipments",
"shipment.title": "SHIPMENTS", "shipment.title": "Shipments",
"shipment.new": "New Shipment", "shipment.new": "New Shipment",
"shipment.edit.title": "SHIPMENT", "shipment.new.title": "New Shipment",
"shipment.edit.title": "Edit Shipment",
"shipment.type": "Pickup/Drop-off",
"shipment.date": "Pickup Date", "shipment.date": "Pickup Date",
"shipment.time": "Pickup Time",
"shipment.location": "Pickup Location",
"shipment.location_time": "Pickup Location / Time", "shipment.location_time": "Pickup Location / Time",
"shipment.information": "Pickup Informations", "shipment.information": "Pickup Informations",
"shipment.recipient_information": "Recipient Informations", "shipment.recipient_information": "Recipient Informations",
"shipment.from":"From", "shipment.from":"From",
"shipment.to":"To", "shipment.to":"To",
"shipment.box.delivery":"Delivery Address",
"Shipment End ================================================================":"", "Shipment End ================================================================":"",
"Rate Start ================================================================":"", "Rate Start ================================================================":"",

View File

@@ -293,13 +293,18 @@
"shipment": "ပို့ဆောင်ခြင်းများ", "shipment": "ပို့ဆောင်ခြင်းများ",
"shipment.title": "ပို့ဆောင်ခြင်းများ", "shipment.title": "ပို့ဆောင်ခြင်းများ",
"shipment.new": "ပို့ဆောင်ခြင်း အသစ်", "shipment.new": "ပို့ဆောင်ခြင်း အသစ်",
"shipment.edit.title": "PICKUP", "shipment.new.title": "ပို့ဆောင်ခြင်း အသစ်",
"shipment.edit.title": "ပို့ဆောင်ခြင်း ပြင်ဆင်ခြင်း",
"shipment.type": "Pickup/Drop-off",
"shipment.date": "Pickup Date", "shipment.date": "Pickup Date",
"shipment.time": "Pickup Time",
"shipment.location_time": "Pickup Location / Time", "shipment.location_time": "Pickup Location / Time",
"shipment.location": "Pickup Location",
"shipment.information": "Pickup Informations", "shipment.information": "Pickup Informations",
"shipment.recipient_information": "Recipient Informations", "shipment.recipient_information": "Recipient Informations",
"shipment.from":"From", "shipment.from":"From",
"shipment.to":"To", "shipment.to":"To",
"shipment.box.delivery":"Delivery Address",
"Shipment End ================================================================":"", "Shipment End ================================================================":"",
"Rate Start ================================================================":"", "Rate Start ================================================================":"",

View File

@@ -47,7 +47,7 @@ class AuthServiceImp implements AuthService {
} }
@override @override
Future<User> joinInvite(String userName) { Future<void> joinInvite(String userName) {
return authFb.joinInvite(userName); return authFb.joinInvite(userName);
} }

View File

@@ -7,7 +7,7 @@ abstract class AuthService {
Future<AuthResult> signInWithSmsCode(String smsCode); Future<AuthResult> signInWithSmsCode(String smsCode);
Future<void> signout(); Future<void> signout();
Future<void> signup(String userName); Future<void> signup(String userName);
Future<User> joinInvite(String userName); Future<void> joinInvite(String userName);
Future<void> updateProfileName(String newUserName); Future<void> updateProfileName(String newUserName);
Future<void> updatePreferredCurrency(String currency); Future<void> updatePreferredCurrency(String currency);
Future<bool> hasInvite(); Future<bool> hasInvite();

View File

@@ -48,3 +48,9 @@ const privilege_delivery = "deli";
const privilege_invoice = "inv"; const privilege_invoice = "inv";
const privilege_processing = "pr"; const privilege_processing = "pr";
const privilege_receiving = "rc"; const privilege_receiving = "rc";
// Pickup types
const shipment_local_pickup = "Local Pickup";
const shipment_courier_pickup = "Courier Pickup";
const shipment_local_dropoff = "Local Drop-off";
const shipment_courier_dropoff = "Courier Drop-off";

View File

@@ -13,8 +13,11 @@ import 'delivery_address_row.dart';
class DeliveryAddressList extends StatefulWidget { class DeliveryAddressList extends StatefulWidget {
final DeliveryAddress deliveryAddress; final DeliveryAddress deliveryAddress;
final bool forSelection;
const DeliveryAddressList({Key key, this.deliveryAddress}) : super(key: key); const DeliveryAddressList(
{Key key, this.deliveryAddress, this.forSelection = false})
: super(key: key);
@override @override
_DeliveryAddressListState createState() => _DeliveryAddressListState(); _DeliveryAddressListState createState() => _DeliveryAddressListState();
} }
@@ -80,15 +83,18 @@ class _DeliveryAddressListState extends State<DeliveryAddressList> {
_row(BuildContext context, DeliveryAddress deliveryAddress) { _row(BuildContext context, DeliveryAddress deliveryAddress) {
return Row( return Row(
children: [ children: [
InkWell( widget.forSelection
onTap: () => _select(deliveryAddress), ? Container()
child: Padding( : InkWell(
padding: const EdgeInsets.all(10.0), onTap: () => _select(deliveryAddress),
child: Icon(Icons.check, child: Padding(
color: padding: const EdgeInsets.all(10.0),
deliveryAddress.isDefault ? primaryColor : Colors.black26), child: Icon(Icons.check,
), color: deliveryAddress.isDefault
), ? primaryColor
: Colors.black26),
),
),
Expanded( Expanded(
child: DeliveryAddressRow( child: DeliveryAddressRow(
key: ValueKey(deliveryAddress.id), key: ValueKey(deliveryAddress.id),
@@ -100,6 +106,11 @@ class _DeliveryAddressListState extends State<DeliveryAddressList> {
} }
_edit(BuildContext context, DeliveryAddress deliveryAddress) { _edit(BuildContext context, DeliveryAddress deliveryAddress) {
if (widget.forSelection) {
Navigator.pop(context, deliveryAddress);
return;
}
Navigator.push( Navigator.push(
context, context,
BottomUpPageRoute( BottomUpPageRoute(
@@ -108,6 +119,10 @@ class _DeliveryAddressListState extends State<DeliveryAddressList> {
} }
Future<void> _select(DeliveryAddress deliveryAddress) async { Future<void> _select(DeliveryAddress deliveryAddress) async {
if (widget.forSelection) {
return;
}
if (deliveryAddress.isDefault) { if (deliveryAddress.isDefault) {
Navigator.pop(context); Navigator.pop(context);
return; return;

View File

@@ -131,7 +131,9 @@ class _FcsShipmentEditorState extends State<FcsShipmentEditor> {
enabledBorder: UnderlineInputBorder( enabledBorder: UnderlineInputBorder(
borderSide: BorderSide(color: primaryColor)), borderSide: BorderSide(color: primaryColor)),
fillColor: Colors.white, fillColor: Colors.white,
labelStyle: languageModel.isEng ? labelStyle : labelStyleMM, labelStyle: languageModel.isEng
? newLabelStyle(color: Colors.black54, fontSize: 20)
: newLabelStyleMM(color: Colors.black54, fontSize: 20),
labelText: AppTranslations.of(context) labelText: AppTranslations.of(context)
.text('FCSshipment.shipment_type'), .text('FCSshipment.shipment_type'),
icon: Icon(Ionicons.ios_airplane, color: primaryColor)), icon: Icon(Ionicons.ios_airplane, color: primaryColor)),

View File

@@ -173,6 +173,7 @@ class PackageModel extends BaseModel {
.collection("$path") .collection("$path")
.where("tracking_id", isEqualTo: trackingID) .where("tracking_id", isEqualTo: trackingID)
.where("has_user_id", isEqualTo: false) .where("has_user_id", isEqualTo: false)
.where("is_deleted", isEqualTo: false)
.getDocuments(source: Source.server); .getDocuments(source: Source.server);
if (qsnap.documents.length > 0) { if (qsnap.documents.length > 0) {
var snap = qsnap.documents[0]; var snap = qsnap.documents[0];
@@ -186,6 +187,7 @@ class PackageModel extends BaseModel {
.collection("$path") .collection("$path")
.where("tracking_id", isEqualTo: trackingID) .where("tracking_id", isEqualTo: trackingID)
.where("user_id", isEqualTo: user.id) .where("user_id", isEqualTo: user.id)
.where("is_deleted", isEqualTo: false)
.getDocuments(source: Source.server); .getDocuments(source: Source.server);
if (qsnap.documents.length > 0) { if (qsnap.documents.length > 0) {
var snap = qsnap.documents[0]; var snap = qsnap.documents[0];

View File

@@ -161,49 +161,58 @@ class _ProcessingEditorState extends State<ProcessingEditor> {
} }
return Padding( return Padding(
padding: const EdgeInsets.only(left: 8.0), padding: const EdgeInsets.only(left: 5.0, right: 0),
child: Row( child: Row(
children: [ children: [
Padding( Padding(
padding: const EdgeInsets.only(right: 18.0), padding: const EdgeInsets.only(left: 0, right: 10),
child: LocalText( child: Icon(Icons.store, color: primaryColor),
context,
"processing.market",
color: primaryColor,
fontSize: 16,
),
), ),
Container( Expanded(
width: 150, child: Column(
child: DropdownButton<String>( crossAxisAlignment: CrossAxisAlignment.start,
value: selectedMarket, children: [
style: TextStyle(color: Colors.black, fontSize: 14), Padding(
underline: Container( padding: const EdgeInsets.only(right: 18.0),
height: 1, child: LocalText(
color: Colors.grey, context,
), "processing.market",
onChanged: (String newValue) { color: Colors.black54,
setState(() { fontSize: 16,
if (newValue == MANAGE_MARKET) { ),
selectedMarket = null; ),
_manageMarket(); DropdownButton<String>(
return; isDense: true,
} value: selectedMarket,
selectedMarket = newValue; style: TextStyle(color: Colors.black, fontSize: 14),
}); underline: Container(
}, height: 1,
isExpanded: true, color: Colors.grey,
items: markets.map<DropdownMenuItem<String>>((String value) { ),
return DropdownMenuItem<String>( onChanged: (String newValue) {
value: value, setState(() {
child: Text(value ?? "", if (newValue == MANAGE_MARKET) {
overflow: TextOverflow.ellipsis, selectedMarket = null;
style: TextStyle( _manageMarket();
color: value == MANAGE_MARKET return;
? secondaryColor }
: primaryColor)), selectedMarket = newValue;
); });
}).toList(), },
isExpanded: true,
items: markets.map<DropdownMenuItem<String>>((String value) {
return DropdownMenuItem<String>(
value: value,
child: Text(value ?? "",
overflow: TextOverflow.ellipsis,
style: TextStyle(
color: value == MANAGE_MARKET
? secondaryColor
: primaryColor)),
);
}).toList(),
),
],
), ),
), ),
], ],

View File

@@ -1,6 +1,5 @@
import 'package:fcs/domain/entities/package.dart'; import 'package:fcs/domain/entities/package.dart';
import 'package:fcs/helpers/theme.dart'; import 'package:fcs/helpers/theme.dart';
import 'package:fcs/pages/main/model/main_model.dart';
import 'package:fcs/pages/main/util.dart'; import 'package:fcs/pages/main/util.dart';
import 'package:fcs/pages/package/model/package_model.dart'; import 'package:fcs/pages/package/model/package_model.dart';
import 'package:fcs/pages/widgets/bottom_up_page_route.dart'; import 'package:fcs/pages/widgets/bottom_up_page_route.dart';
@@ -14,8 +13,6 @@ import 'package:flutter/material.dart';
import 'package:flutter_icons/flutter_icons.dart'; import 'package:flutter_icons/flutter_icons.dart';
import 'package:intl/intl.dart'; import 'package:intl/intl.dart';
import 'package:provider/provider.dart'; import 'package:provider/provider.dart';
import 'package:timeline_list/timeline.dart';
import 'package:timeline_list/timeline_model.dart';
import 'processing_editor.dart'; import 'processing_editor.dart';

View File

@@ -1,6 +1,7 @@
import 'dart:async'; import 'dart:async';
import 'package:cloud_firestore/cloud_firestore.dart'; import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:fcs/domain/constants.dart';
import 'package:fcs/domain/entities/cargo.dart'; import 'package:fcs/domain/entities/cargo.dart';
import 'package:fcs/domain/entities/pickup.dart'; import 'package:fcs/domain/entities/pickup.dart';
import 'package:fcs/domain/vo/radio.dart'; import 'package:fcs/domain/vo/radio.dart';
@@ -31,6 +32,13 @@ class ShipmentModel extends BaseModel {
), ),
]; ];
List<String> pickupTypes = [
shipment_local_pickup,
shipment_courier_pickup,
shipment_local_dropoff,
shipment_courier_dropoff
];
List<RadioGroup> get radioGroups { List<RadioGroup> get radioGroups {
List<RadioGroup> radioGroups = [ List<RadioGroup> radioGroups = [
RadioGroup( RadioGroup(

View File

@@ -4,13 +4,16 @@ import 'package:fcs/domain/entities/package.dart';
import 'package:fcs/domain/vo/delivery_address.dart'; import 'package:fcs/domain/vo/delivery_address.dart';
import 'package:fcs/helpers/theme.dart'; import 'package:fcs/helpers/theme.dart';
import 'package:fcs/localization/app_translations.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/delivery_address_row.dart';
import 'package:fcs/pages/delivery_address/model/delivery_address_model.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/local_text.dart';
import 'package:fcs/pages/widgets/my_data_table.dart'; import 'package:fcs/pages/widgets/my_data_table.dart';
import 'package:fcs/pages/widgets/progress.dart'; import 'package:fcs/pages/widgets/progress.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart'; import 'package:flutter_icons/flutter_icons.dart';
import 'package:provider/provider.dart'; import 'package:provider/provider.dart';
import '../main/util.dart'; import '../main/util.dart';
@@ -30,14 +33,14 @@ class _PickupBoxEditorState extends State<PickupBoxEditor> {
bool isNew; bool isNew;
bool isMixBox = false; bool isMixBox = false;
DeliveryAddress _shippingAddress = new DeliveryAddress(); DeliveryAddress _deliveryAddress = new DeliveryAddress();
@override @override
void initState() { void initState() {
super.initState(); super.initState();
if (widget.box != null) { if (widget.box != null) {
_box = widget.box; _box = widget.box;
_shippingAddress = _box.shippingAddress; _deliveryAddress = _box.shippingAddress;
isNew = false; isNew = false;
} else { } else {
@@ -55,7 +58,7 @@ class _PickupBoxEditorState extends State<PickupBoxEditor> {
var shipmentModel = var shipmentModel =
Provider.of<DeliveryAddressModel>(context, listen: false); Provider.of<DeliveryAddressModel>(context, listen: false);
_shippingAddress = shipmentModel.deliveryAddresses[1]; _deliveryAddress = shipmentModel.deliveryAddresses[1];
isNew = true; isNew = true;
_box = Box( _box = Box(
@@ -111,7 +114,7 @@ class _PickupBoxEditorState extends State<PickupBoxEditor> {
fillColor: Colors.white, fillColor: Colors.white,
labelText: 'Actual Weight', labelText: 'Actual Weight',
filled: true, filled: true,
icon: Icon(FontAwesomeIcons.weightHanging, icon: Icon(MaterialCommunityIcons.weight,
color: primaryColor), color: primaryColor),
)), )),
), ),
@@ -170,7 +173,7 @@ class _PickupBoxEditorState extends State<PickupBoxEditor> {
Padding( Padding(
padding: const EdgeInsets.only(left: 20.0, right: 20), padding: const EdgeInsets.only(left: 20.0, right: 20),
child: fcsInputReadOnly( child: fcsInputReadOnly(
"Shipment Weight", FontAwesomeIcons.weightHanging, "Shipment Weight", MaterialCommunityIcons.weight,
value: _box.shipmentWeight.toString()), value: _box.shipmentWeight.toString()),
), ),
Padding( Padding(
@@ -182,7 +185,7 @@ class _PickupBoxEditorState extends State<PickupBoxEditor> {
fillColor: Colors.white, fillColor: Colors.white,
labelText: 'Width', labelText: 'Width',
filled: true, filled: true,
icon: Icon(FontAwesomeIcons.arrowCircleRight, icon: Icon(FontAwesome.arrow_circle_right,
color: primaryColor), color: primaryColor),
)), )),
), ),
@@ -195,7 +198,7 @@ class _PickupBoxEditorState extends State<PickupBoxEditor> {
fillColor: Colors.white, fillColor: Colors.white,
labelText: 'Height', labelText: 'Height',
filled: true, filled: true,
icon: Icon(FontAwesomeIcons.arrowAltCircleUp, icon: Icon(FontAwesome.arrow_circle_up,
color: primaryColor), color: primaryColor),
)), )),
), ),
@@ -208,46 +211,14 @@ class _PickupBoxEditorState extends State<PickupBoxEditor> {
fillColor: Colors.white, fillColor: Colors.white,
labelText: 'Length', labelText: 'Length',
filled: true, filled: true,
icon: Icon(FontAwesomeIcons.arrowCircleUp, icon: Icon(FontAwesome.arrow_circle_left,
color: primaryColor), color: primaryColor),
)), )),
), ),
SizedBox(height: 25), SizedBox(height: 25),
], ],
), ),
ExpansionTile( makeLocation(context, _deliveryAddress),
title: Text(
'Shipment Address',
style: TextStyle(
color: primaryColor, fontWeight: FontWeight.bold),
),
children: [
DeliveryAddressRow(deliveryAddress: _shippingAddress),
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,
onPressed: () {},
icon: Icon(Icons.add),
label: Text(
'Select\nAddress',
style: TextStyle(fontSize: 12),
),
backgroundColor: primaryColor,
),
),
),
),
SizedBox(height: 25),
],
),
], ],
), ),
), ),
@@ -292,6 +263,48 @@ class _PickupBoxEditorState extends State<PickupBoxEditor> {
); );
} }
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) { List<MyDataRow> getCargoRows(BuildContext context) {
if (_box == null || _box.cargoTypes == null) { if (_box == null || _box.cargoTypes == null) {
return []; return [];

View File

@@ -1,3 +1,4 @@
import 'package:fcs/domain/constants.dart';
import 'package:fcs/domain/entities/box.dart'; import 'package:fcs/domain/entities/box.dart';
import 'package:fcs/domain/entities/cargo.dart'; import 'package:fcs/domain/entities/cargo.dart';
import 'package:fcs/domain/entities/pickup.dart'; import 'package:fcs/domain/entities/pickup.dart';
@@ -5,13 +6,17 @@ import 'package:fcs/domain/vo/delivery_address.dart';
import 'package:fcs/helpers/theme.dart'; import 'package:fcs/helpers/theme.dart';
import 'package:fcs/localization/app_translations.dart'; import 'package:fcs/localization/app_translations.dart';
import 'package:fcs/pages/box/model/box_model.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/delivery_address_row.dart';
import 'package:fcs/pages/delivery_address/model/delivery_address_model.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/main/model/main_model.dart';
import 'package:fcs/pages/shipment/model/shipment_model.dart'; import 'package:fcs/pages/shipment/model/shipment_model.dart';
import 'package:fcs/pages/main/util.dart'; import 'package:fcs/pages/main/util.dart';
import 'package:fcs/pages/widgets/bottom_up_page_route.dart'; import 'package:fcs/pages/widgets/bottom_up_page_route.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_text.dart';
import 'package:fcs/pages/widgets/input_time.dart';
import 'package:fcs/pages/widgets/local_text.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_controller.dart';
import 'package:fcs/pages/widgets/multi_img_file.dart'; import 'package:fcs/pages/widgets/multi_img_file.dart';
@@ -27,8 +32,8 @@ import 'package:flutter/material.dart';
import 'pickup_box_editor.dart'; import 'pickup_box_editor.dart';
class ShipmentEditor extends StatefulWidget { class ShipmentEditor extends StatefulWidget {
final Shipment pickUp; final Shipment shipment;
ShipmentEditor({this.pickUp}); ShipmentEditor({this.shipment});
@override @override
_ShipmentEditorState createState() => _ShipmentEditorState(); _ShipmentEditorState createState() => _ShipmentEditorState();
@@ -58,17 +63,20 @@ class _ShipmentEditorState extends State<ShipmentEditor> {
Shipment _pickUp; Shipment _pickUp;
bool _isLoading = false; bool _isLoading = false;
var now = new DateTime.now(); var now = new DateTime.now();
bool isNew; bool _isNew;
DeliveryAddress _shippingAddress = new DeliveryAddress(); DeliveryAddress _pickupAddress = new DeliveryAddress();
int _currVal = 1; int _currVal = 1;
String selectedPickupType;
@override @override
void initState() { void initState() {
super.initState(); super.initState();
if (widget.pickUp != null) { selectedPickupType = shipment_local_pickup;
isNew = false;
_pickUp = widget.pickUp; if (widget.shipment != null) {
_isNew = false;
_pickUp = widget.shipment;
_addressEditingController.text = _pickUp.address; _addressEditingController.text = _pickUp.address;
_fromTimeEditingController.text = _pickUp.fromTime; _fromTimeEditingController.text = _pickUp.fromTime;
_toTimeEditingController.text = _pickUp.toTime; _toTimeEditingController.text = _pickUp.toTime;
@@ -84,7 +92,7 @@ class _ShipmentEditorState extends State<ShipmentEditor> {
// _recipientAddressEditingController.text = // _recipientAddressEditingController.text =
// mainModel.recipient.shippingAddress; // mainModel.recipient.shippingAddress;
} else { } else {
isNew = true; _isNew = true;
List<Cargo> _cargoTypes = [ List<Cargo> _cargoTypes = [
Cargo(type: 'General Cargo', weight: 25), Cargo(type: 'General Cargo', weight: 25),
Cargo(type: 'Medicine', weight: 20), Cargo(type: 'Medicine', weight: 20),
@@ -94,7 +102,7 @@ class _ShipmentEditorState extends State<ShipmentEditor> {
} }
var shipmentModel = var shipmentModel =
Provider.of<DeliveryAddressModel>(context, listen: false); Provider.of<DeliveryAddressModel>(context, listen: false);
_shippingAddress = shipmentModel.deliveryAddresses[1]; _pickupAddress = shipmentModel.defalutAddress;
} }
@override @override
@@ -104,17 +112,13 @@ class _ShipmentEditorState extends State<ShipmentEditor> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
var pickupModel = Provider.of<ShipmentModel>(context); final fromTimeBox = InputTime(
final fromTimeBox = InputText(
labelTextKey: 'shipment.from', labelTextKey: 'shipment.from',
iconData: Icons.timer, iconData: Icons.timer,
controller: _fromTimeEditingController); controller: _fromTimeEditingController);
final toTimeBox = InputText( final toTimeBox = InputTime(
labelTextKey: 'shipment.to', labelTextKey: 'shipment.to', controller: _toTimeEditingController);
iconData: null,
controller: _toTimeEditingController);
final fromTimeBoxReadOnly = fcsInputReadOnly( final fromTimeBoxReadOnly = fcsInputReadOnly(
'From', 'From',
@@ -128,25 +132,23 @@ class _ShipmentEditorState extends State<ShipmentEditor> {
controller: _toTimeEditingController, controller: _toTimeEditingController,
); );
final pickupTime = Padding( final pickupTimeBox = Row(
padding: const EdgeInsets.only(left: 20.0), crossAxisAlignment: CrossAxisAlignment.center,
child: Row( children: <Widget>[
children: <Widget>[ Container(
Container( child: fromTimeBox,
child: fromTimeBox, width: 120,
width: 120, ),
), Padding(
Padding( padding: const EdgeInsets.only(left: 8.0),
padding: const EdgeInsets.only(left: 8.0), child: Text('-'),
child: Text('-'), ),
), Container(
Container( padding: EdgeInsets.only(left: 20),
padding: EdgeInsets.only(left: 20), child: toTimeBox,
child: toTimeBox, width: 120,
width: 120, ),
), ],
],
),
); );
final pickupTimeReadOnly = Padding( final pickupTimeReadOnly = Padding(
@@ -170,54 +172,6 @@ class _ShipmentEditorState extends State<ShipmentEditor> {
), ),
); );
final noOfPackageBoxReadonly = fcsInputReadOnly(
'Number of Packages',
Octicons.package,
controller: _noOfPackageEditingController,
);
final requestDateBox = Container(
child: InkWell(
onTap: () {
DatePicker.showDatePicker(
context,
showTitleActions: true,
currentTime: _pickupDate.text == ""
? null
: dateFormatter.parse(_pickupDate.text),
minTime: DateTime.now(),
maxTime: DateTime(2030, 12, 31),
onConfirm: (date) {},
locale: LocaleType.en,
);
},
child: TextFormField(
controller: _pickupDate,
autofocus: false,
cursorColor: primaryColor,
style: textStyle,
enabled: false,
keyboardType: TextInputType.datetime,
decoration: new InputDecoration(
border: InputBorder.none,
focusedBorder: InputBorder.none,
labelText: AppTranslations.of(context).text("shipment.date"),
// labelStyle: languageModel.isEng ? labelStyle : labelStyleMM,
contentPadding:
EdgeInsets.symmetric(vertical: 10.0, horizontal: 0.0),
icon: Icon(
Icons.date_range,
color: primaryColor,
)),
validator: (value) {
if (value.isEmpty) {
return AppTranslations.of(context).text("do.form.date");
}
return null;
},
),
));
MainModel mainModel = Provider.of<MainModel>(context); MainModel mainModel = Provider.of<MainModel>(context);
var boxModel = Provider.of<BoxModel>(context); var boxModel = Provider.of<BoxModel>(context);
@@ -230,386 +184,165 @@ class _ShipmentEditorState extends State<ShipmentEditor> {
icon: new Icon(Icons.close), icon: new Icon(Icons.close),
onPressed: () => Navigator.of(context).pop(), onPressed: () => Navigator.of(context).pop(),
), ),
backgroundColor: primaryColor, shadowColor: Colors.transparent,
title: LocalText(context, "shipment.edit.title", backgroundColor: Colors.white,
fontSize: 18, color: Colors.white), title: LocalText(
context,
_isNew ? "shipment.new.title" : "shipment.edit.title",
fontSize: 20,
color: primaryColor,
),
), ),
body: Card( body: Padding(
child: Column( padding: const EdgeInsets.all(10.0),
child: ListView(
children: <Widget>[ children: <Widget>[
Expanded( _isNew
child: Padding( ? Container()
padding: const EdgeInsets.all(10.0), : Center(
child: ListView(children: <Widget>[ child: Padding(
Center(child: nameWidget("mainModel.customer.name")), padding: const EdgeInsets.only(left: 10.0, top: 8),
Center(child: nameWidget("mainModel.customer.phoneNumber")), child: Text(
isNew '#P200304',
? Container() style: TextStyle(
: Center( color: Colors.black87,
child: Padding( fontSize: 14,
padding: const EdgeInsets.only(left: 10.0, top: 8), fontWeight: FontWeight.bold),
child: Text(
'#P200304',
style: TextStyle(
color: Colors.black87,
fontSize: 14,
fontWeight: FontWeight.bold),
),
),
),
widget.pickUp == null
? Container()
: widget.pickUp.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),
),
ExpansionTile(
title: Text(
'Pickup/Drop-off',
style: TextStyle(
color: primaryColor, fontWeight: FontWeight.bold),
),
children: <Widget>[
Container(
child: Wrap(
children: pickupModel.radioGroups
.map((t) => RadioListTile(
title: Text("${t.text}"),
groupValue: _currVal,
activeColor: primaryColor,
value: t.index,
onChanged: (val) {
setState(() {
_currVal = val;
});
},
))
.toList(),
), ),
), ),
], ),
), widget.shipment == null
_currVal == 3 ? Container()
? Container( : widget.shipment.isCourier
child: DeliveryAddressRow( ? Padding(
deliveryAddress: DeliveryAddress( padding: const EdgeInsets.only(left: 15.0),
fullName: 'FCS Office', child: fcsInputReadOnly("Handling Fee/Courier Fee",
addressLine1: '154-19 64th Ave.', FontAwesomeIcons.moneyBill,
addressLine2: 'Flushing', controller: _handlingFeeController),
city: 'NY',
state: 'NY',
phoneNumber: '+1 (292)215-2247'),
),
) )
: _currVal == 4 : Padding(
? Container( padding: const EdgeInsets.only(left: 15.0),
child: Column( child: fcsInputReadOnly("Handling Fee/Courier Fee",
children: <Widget>[ FontAwesomeIcons.moneyBill,
Container( controller: _handlingFeeController),
padding: EdgeInsets.only( ),
top: 20, bottom: 15, right: 15), makeDropdown(),
child: Align( makeLocation(context, _pickupAddress),
alignment: Alignment.center, InputDate(
child: Container( labelTextKey: "shipment.date",
width: 350, iconData: Icons.date_range,
height: 40, controller: _pickupDate,
child: FloatingActionButton.extended( ),
materialTapTargetSize: pickupTimeBox,
MaterialTapTargetSize.shrinkWrap, _currVal == 3
onPressed: () {}, ? Container(
icon: Icon(Icons.arrow_right), child: DeliveryAddressRow(
label: Text( deliveryAddress: DeliveryAddress(
'Visit courier websie for nearest drop-off', fullName: 'FCS Office',
style: TextStyle(fontSize: 12), addressLine1: '154-19 64th Ave.',
), addressLine2: 'Flushing',
backgroundColor: primaryColor, 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(), ],
))
ExpansionTile( : Container(),
title: Text( Padding(
'Package Information', padding: const EdgeInsets.all(8.0),
child: Row(
children: [
Text(
'Boxes',
style: TextStyle( style: TextStyle(
color: primaryColor, fontWeight: FontWeight.bold), color: primaryColor, fontWeight: FontWeight.bold),
), ),
children: <Widget>[ Spacer(),
Column( IconButton(
children: getBoxList(context, boxModel.boxes), onPressed: () {
), Navigator.push(
Container( context,
padding: BottomUpPageRoute(PickupBoxEditor()),
EdgeInsets.only(top: 20, bottom: 15, right: 15), );
child: Align( },
alignment: Alignment.bottomRight, icon: Icon(
child: Container( Icons.add,
width: 120, color: primaryColor,
height: 40, ))
child: FloatingActionButton.extended( ],
materialTapTargetSize: ),
MaterialTapTargetSize.shrinkWrap, ),
icon: Icon(Icons.add), Column(
onPressed: () { children: getBoxList(context, boxModel.boxes),
Navigator.push( ),
context, mainModel.isCustomer() || _isNew
BottomUpPageRoute(PickupBoxEditor()), ? Container()
); : ExpansionTile(
}, title: Text('For FCS'),
label: Text( children: <Widget>[
'Add Package', widget.shipment != null
style: TextStyle(fontSize: 12), ? 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),
),
), ),
backgroundColor: primaryColor, Container(
), padding: EdgeInsets.only(left: 10),
child: MultiImageFile(
enabled: true,
controller: multiImgController,
title: "Receipt File",
)),
],
), ),
), ),
), ],
SizedBox(height: 10.0), ),
], widget.shipment == null
),
_currVal == 3 || _currVal == 4
? Container()
: ExpansionTile(
title: Text(
'Pickup Location / Time',
style: TextStyle(
color: primaryColor,
fontWeight: FontWeight.bold),
),
children: <Widget>[
Padding(
padding: const EdgeInsets.only(left: 20.0),
child: Column(
children: <Widget>[
Row(
children: <Widget>[
Icon(
Icons.location_on,
color: primaryColor,
),
Padding(
padding: const EdgeInsets.all(8.0),
child: Text('Pickup Address'),
),
],
),
Padding(
padding: const EdgeInsets.only(left: 10.0),
child: DeliveryAddressRow(
deliveryAddress: _shippingAddress),
),
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,
onPressed: () {},
icon: Icon(Icons.add),
label: Text(
'Select\nAddress',
style: TextStyle(fontSize: 12),
),
backgroundColor: primaryColor,
),
),
),
),
],
),
// child: ExpansionTile(
// leading: Icon(
// Icons.location_on,
// color: primaryColor,
// ),
// title: Text('My Address'),
// children: [
// Padding(
// padding: const EdgeInsets.only(left: 10.0),
// child: ShippingAddressRow(
// shippingAddress: _shippingAddress),
// ),
// 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,
// onPressed: () {},
// icon: Icon(Icons.add),
// label: Text(
// 'Select\nAddress',
// style: TextStyle(fontSize: 12),
// ),
// backgroundColor: primaryColor,
// ),
// ),
// ),
// ),
// ],
// ),
),
widget.pickUp == null
? pickupTime
: widget.pickUp.status == 'Pending'
? pickupTime
: pickupTimeReadOnly,
Padding(
padding: const EdgeInsets.only(left: 20.0),
child: Column(
children: <Widget>[
SizedBox(height: 5),
Container(height: 50.0, child: requestDateBox)
],
),
),
SizedBox(height: 15.0),
],
),
// ExpansionTile(
// title: Text(
// 'Package Information',
// style: TextStyle(
// color: primaryColor, fontWeight: FontWeight.bold),
// ),
// children: <Widget>[
// Padding(
// padding: const EdgeInsets.only(left: 20.0),
// child: widget.pickUp == null
// ? noOfPackageBox
// : widget.pickUp.status == 'Pending'
// ? noOfPackageBox
// : noOfPackageBoxReadonly,
// ),
// Padding(
// padding: const EdgeInsets.only(left: 20.0),
// child: widget.pickUp == null
// ? fcsInput("Total Weight (lb)",
// FontAwesomeIcons.weightHanging,
// controller: _weightEditingController)
// : widget.pickUp.status == 'Pending'
// ? fcsInput("Total Weight (lb)",
// FontAwesomeIcons.weightHanging,
// controller: _weightEditingController)
// : fcsInputReadOnly("Total Weight (lb)",
// FontAwesomeIcons.weightHanging,
// controller: _weightEditingController),
// ),
// Padding(
// 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),
// ],
// ),
mainModel.isCustomer()
? Container()
: ExpansionTile(
title: Text('For FCS'),
children: <Widget>[
widget.pickUp != null
? widget.pickUp.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",
)),
],
),
),
],
),
]),
)),
widget.pickUp == null
? Align( ? Align(
alignment: Alignment.bottomCenter, alignment: Alignment.bottomCenter,
child: Center( child: Center(
@@ -627,7 +360,7 @@ class _ShipmentEditorState extends State<ShipmentEditor> {
: Container( : Container(
child: Column( child: Column(
children: <Widget>[ children: <Widget>[
widget.pickUp.status == 'Confirmed' widget.shipment.status == 'Confirmed'
? Align( ? Align(
alignment: Alignment.bottomCenter, alignment: Alignment.bottomCenter,
child: Center( child: Center(
@@ -679,6 +412,104 @@ 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<Widget> getBoxList(BuildContext context, List<Box> boxes) {
List<Box> _boxes = [boxes[0], boxes[1]]; List<Box> _boxes = [boxes[0], boxes[1]];

View File

@@ -41,7 +41,7 @@ class _ShipmentListRowState extends State<ShipmentListRow> {
child: InkWell( child: InkWell(
onTap: () { onTap: () {
Navigator.of(context) Navigator.of(context)
.push(BottomUpPageRoute(ShipmentEditor(pickUp: _pickUp))); .push(BottomUpPageRoute(ShipmentEditor(shipment: _pickUp)));
}, },
child: Row( child: Row(
children: <Widget>[ children: <Widget>[

View File

@@ -73,7 +73,9 @@ class InputDate extends StatelessWidget {
labelText: labelTextKey == null labelText: labelTextKey == null
? null ? null
: AppTranslations.of(context).text(labelTextKey), : AppTranslations.of(context).text(labelTextKey),
labelStyle: languageModel.isEng ? labelStyle : labelStyleMM, labelStyle: languageModel.isEng
? newLabelStyle(color: Colors.black54, fontSize: 20)
: newLabelStyleMM(color: Colors.black54, fontSize: 20),
icon: iconData == null icon: iconData == null
? null ? null
: Icon( : Icon(

View File

@@ -49,7 +49,9 @@ class InputText extends StatelessWidget {
labelText: labelTextKey == null labelText: labelTextKey == null
? null ? null
: AppTranslations.of(context).text(labelTextKey), : AppTranslations.of(context).text(labelTextKey),
labelStyle: languageModel.isEng ? labelStyle : labelStyleMM, labelStyle: languageModel.isEng
? newLabelStyle(color: Colors.black54, fontSize: 20)
: newLabelStyleMM(color: Colors.black54, fontSize: 20),
icon: iconData == null icon: iconData == null
? null ? null
: Icon( : Icon(

View File

@@ -0,0 +1,98 @@
import 'package:fcs/helpers/theme.dart';
import 'package:fcs/localization/app_translations.dart';
import 'package:fcs/pages/main/model/language_model.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
class InputTime extends StatelessWidget {
final String labelTextKey;
final IconData iconData;
final TextEditingController controller;
final FormFieldValidator<String> validator;
final int maxLines;
final bool withBorder;
final Color borderColor;
final TextInputType textInputType;
final bool autoFocus;
const InputTime(
{Key key,
this.labelTextKey,
this.iconData,
this.controller,
this.validator,
this.maxLines = 1,
this.withBorder = false,
this.borderColor,
this.autoFocus = false,
this.textInputType})
: super(key: key);
@override
Widget build(BuildContext context) {
var languageModel = Provider.of<LanguageModel>(context);
return Padding(
padding: const EdgeInsets.only(top: 15.0, bottom: 5),
child: TextFormField(
readOnly: true,
onTap: () async {
FocusScope.of(context).unfocus();
var initialDate = TimeOfDay.now();
if (controller != null) {
try {
var values = controller.text.split(":");
initialDate = TimeOfDay(
hour: int.parse(values[0]), minute: int.parse(values[1]));
} catch (e) {} // ignore error
}
var t = await showTimePicker(
initialTime: initialDate,
context: context,
);
if (t != null && controller != null) {
controller.text = "${t.hour} : ${t.minute}";
}
},
controller: controller,
autofocus: autoFocus,
cursorColor: primaryColor,
style: textStyle,
maxLines: maxLines,
keyboardType: textInputType,
decoration: new InputDecoration(
// hintText: '',
hintStyle: TextStyle(
height: 1.5,
),
labelText: labelTextKey == null
? null
: AppTranslations.of(context).text(labelTextKey),
labelStyle: languageModel.isEng
? newLabelStyle(color: Colors.black54, fontSize: 20)
: newLabelStyleMM(color: Colors.black54, fontSize: 20),
icon: iconData == null
? null
: Icon(
iconData,
color: primaryColor,
),
enabledBorder: withBorder
? OutlineInputBorder(
borderSide: BorderSide(color: primaryColor, width: 1.0),
)
: UnderlineInputBorder(
borderSide: BorderSide(color: primaryColor, width: 1.0)),
focusedBorder: withBorder
? OutlineInputBorder(
borderSide: BorderSide(color: primaryColor, width: 1.0),
)
: UnderlineInputBorder(
borderSide: BorderSide(color: primaryColor, width: 1.0)),
),
validator: validator),
);
}
}

View File

@@ -2,7 +2,7 @@ name: fcs
description: FCS Logistics description: FCS Logistics
publish_to: 'none' # Remove this line if you wish to publish to pub.dev publish_to: 'none' # Remove this line if you wish to publish to pub.dev
version: 1.0.0+1 version: 1.0.0+2
environment: environment:
sdk: ">=2.7.0 <3.0.0" sdk: ">=2.7.0 <3.0.0"