From 2b02806715be42009197a263f6f605b255d4bd9c Mon Sep 17 00:00:00 2001 From: Sai Naw Wun Date: Mon, 12 Oct 2020 08:26:27 +0630 Subject: [PATCH] add shipment --- assets/local/localization_en.json | 9 +- assets/local/localization_mu.json | 7 +- lib/data/services/auth_imp.dart | 2 +- lib/data/services/auth_service.dart | 2 +- lib/domain/constants.dart | 6 + .../delivery_address_list.dart | 35 +- .../fcs_shipment/fcs_shipment_editor.dart | 4 +- lib/pages/package/model/package_model.dart | 2 + lib/pages/processing/processing_editor.dart | 87 ++- lib/pages/processing/processing_info.dart | 3 - lib/pages/shipment/model/shipment_model.dart | 8 + lib/pages/shipment/pickup_box_editor.dart | 97 ++- lib/pages/shipment/shipment_editor.dart | 731 +++++++----------- lib/pages/shipment/shipment_list_row.dart | 2 +- lib/pages/widgets/input_date.dart | 4 +- lib/pages/widgets/input_text.dart | 4 +- lib/pages/widgets/input_time.dart | 98 +++ pubspec.yaml | 2 +- 18 files changed, 549 insertions(+), 554 deletions(-) create mode 100644 lib/pages/widgets/input_time.dart diff --git a/assets/local/localization_en.json b/assets/local/localization_en.json index 08d0ae9..1a809ba 100644 --- a/assets/local/localization_en.json +++ b/assets/local/localization_en.json @@ -291,15 +291,20 @@ "Shipment Start ================================================================":"", "shipment": "Shipments", - "shipment.title": "SHIPMENTS", + "shipment.title": "Shipments", "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.time": "Pickup Time", + "shipment.location": "Pickup Location", "shipment.location_time": "Pickup Location / Time", "shipment.information": "Pickup Informations", "shipment.recipient_information": "Recipient Informations", "shipment.from":"From", "shipment.to":"To", + "shipment.box.delivery":"Delivery Address", "Shipment End ================================================================":"", "Rate Start ================================================================":"", diff --git a/assets/local/localization_mu.json b/assets/local/localization_mu.json index 6219dbb..79c720f 100644 --- a/assets/local/localization_mu.json +++ b/assets/local/localization_mu.json @@ -293,13 +293,18 @@ "shipment": "ပို့ဆောင်ခြင်းများ", "shipment.title": "ပို့ဆောင်ခြင်းများ", "shipment.new": "ပို့ဆောင်ခြင်း အသစ်", - "shipment.edit.title": "PICKUP", + "shipment.new.title": "ပို့ဆောင်ခြင်း အသစ်", + "shipment.edit.title": "ပို့ဆောင်ခြင်း ပြင်ဆင်ခြင်း", + "shipment.type": "Pickup/Drop-off", "shipment.date": "Pickup Date", + "shipment.time": "Pickup Time", "shipment.location_time": "Pickup Location / Time", + "shipment.location": "Pickup Location", "shipment.information": "Pickup Informations", "shipment.recipient_information": "Recipient Informations", "shipment.from":"From", "shipment.to":"To", + "shipment.box.delivery":"Delivery Address", "Shipment End ================================================================":"", "Rate Start ================================================================":"", diff --git a/lib/data/services/auth_imp.dart b/lib/data/services/auth_imp.dart index 27d0376..bcf6f06 100644 --- a/lib/data/services/auth_imp.dart +++ b/lib/data/services/auth_imp.dart @@ -47,7 +47,7 @@ class AuthServiceImp implements AuthService { } @override - Future joinInvite(String userName) { + Future joinInvite(String userName) { return authFb.joinInvite(userName); } diff --git a/lib/data/services/auth_service.dart b/lib/data/services/auth_service.dart index 412c498..f97d63e 100644 --- a/lib/data/services/auth_service.dart +++ b/lib/data/services/auth_service.dart @@ -7,7 +7,7 @@ abstract class AuthService { Future signInWithSmsCode(String smsCode); Future signout(); Future signup(String userName); - Future joinInvite(String userName); + Future joinInvite(String userName); Future updateProfileName(String newUserName); Future updatePreferredCurrency(String currency); Future hasInvite(); diff --git a/lib/domain/constants.dart b/lib/domain/constants.dart index 10f6be1..a8d83ca 100644 --- a/lib/domain/constants.dart +++ b/lib/domain/constants.dart @@ -48,3 +48,9 @@ const privilege_delivery = "deli"; const privilege_invoice = "inv"; const privilege_processing = "pr"; 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"; diff --git a/lib/pages/delivery_address/delivery_address_list.dart b/lib/pages/delivery_address/delivery_address_list.dart index b2c967d..2d932b9 100644 --- a/lib/pages/delivery_address/delivery_address_list.dart +++ b/lib/pages/delivery_address/delivery_address_list.dart @@ -13,8 +13,11 @@ import 'delivery_address_row.dart'; class DeliveryAddressList extends StatefulWidget { 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 _DeliveryAddressListState createState() => _DeliveryAddressListState(); } @@ -80,15 +83,18 @@ class _DeliveryAddressListState extends State { _row(BuildContext context, DeliveryAddress deliveryAddress) { return Row( children: [ - InkWell( - onTap: () => _select(deliveryAddress), - child: Padding( - padding: const EdgeInsets.all(10.0), - child: Icon(Icons.check, - color: - deliveryAddress.isDefault ? primaryColor : Colors.black26), - ), - ), + widget.forSelection + ? Container() + : InkWell( + onTap: () => _select(deliveryAddress), + child: Padding( + padding: const EdgeInsets.all(10.0), + child: Icon(Icons.check, + color: deliveryAddress.isDefault + ? primaryColor + : Colors.black26), + ), + ), Expanded( child: DeliveryAddressRow( key: ValueKey(deliveryAddress.id), @@ -100,6 +106,11 @@ class _DeliveryAddressListState extends State { } _edit(BuildContext context, DeliveryAddress deliveryAddress) { + if (widget.forSelection) { + Navigator.pop(context, deliveryAddress); + return; + } + Navigator.push( context, BottomUpPageRoute( @@ -108,6 +119,10 @@ class _DeliveryAddressListState extends State { } Future _select(DeliveryAddress deliveryAddress) async { + if (widget.forSelection) { + return; + } + if (deliveryAddress.isDefault) { Navigator.pop(context); return; diff --git a/lib/pages/fcs_shipment/fcs_shipment_editor.dart b/lib/pages/fcs_shipment/fcs_shipment_editor.dart index 83083d9..b2d9e8a 100644 --- a/lib/pages/fcs_shipment/fcs_shipment_editor.dart +++ b/lib/pages/fcs_shipment/fcs_shipment_editor.dart @@ -131,7 +131,9 @@ class _FcsShipmentEditorState extends State { enabledBorder: UnderlineInputBorder( borderSide: BorderSide(color: primaryColor)), 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) .text('FCSshipment.shipment_type'), icon: Icon(Ionicons.ios_airplane, color: primaryColor)), diff --git a/lib/pages/package/model/package_model.dart b/lib/pages/package/model/package_model.dart index 5411e5c..8d71d4d 100644 --- a/lib/pages/package/model/package_model.dart +++ b/lib/pages/package/model/package_model.dart @@ -173,6 +173,7 @@ class PackageModel extends BaseModel { .collection("$path") .where("tracking_id", isEqualTo: trackingID) .where("has_user_id", isEqualTo: false) + .where("is_deleted", isEqualTo: false) .getDocuments(source: Source.server); if (qsnap.documents.length > 0) { var snap = qsnap.documents[0]; @@ -186,6 +187,7 @@ class PackageModel extends BaseModel { .collection("$path") .where("tracking_id", isEqualTo: trackingID) .where("user_id", isEqualTo: user.id) + .where("is_deleted", isEqualTo: false) .getDocuments(source: Source.server); if (qsnap.documents.length > 0) { var snap = qsnap.documents[0]; diff --git a/lib/pages/processing/processing_editor.dart b/lib/pages/processing/processing_editor.dart index 70f38a4..cdcb374 100644 --- a/lib/pages/processing/processing_editor.dart +++ b/lib/pages/processing/processing_editor.dart @@ -161,49 +161,58 @@ class _ProcessingEditorState extends State { } return Padding( - padding: const EdgeInsets.only(left: 8.0), + padding: const EdgeInsets.only(left: 5.0, right: 0), child: Row( children: [ Padding( - padding: const EdgeInsets.only(right: 18.0), - child: LocalText( - context, - "processing.market", - color: primaryColor, - fontSize: 16, - ), + padding: const EdgeInsets.only(left: 0, right: 10), + child: Icon(Icons.store, color: primaryColor), ), - Container( - width: 150, - child: DropdownButton( - value: selectedMarket, - style: TextStyle(color: Colors.black, fontSize: 14), - underline: Container( - height: 1, - color: Colors.grey, - ), - onChanged: (String newValue) { - setState(() { - if (newValue == MANAGE_MARKET) { - selectedMarket = null; - _manageMarket(); - return; - } - selectedMarket = newValue; - }); - }, - isExpanded: true, - items: markets.map>((String value) { - return DropdownMenuItem( - value: value, - child: Text(value ?? "", - overflow: TextOverflow.ellipsis, - style: TextStyle( - color: value == MANAGE_MARKET - ? secondaryColor - : primaryColor)), - ); - }).toList(), + Expanded( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Padding( + padding: const EdgeInsets.only(right: 18.0), + child: LocalText( + context, + "processing.market", + color: Colors.black54, + fontSize: 16, + ), + ), + DropdownButton( + isDense: true, + value: selectedMarket, + style: TextStyle(color: Colors.black, fontSize: 14), + underline: Container( + height: 1, + color: Colors.grey, + ), + onChanged: (String newValue) { + setState(() { + if (newValue == MANAGE_MARKET) { + selectedMarket = null; + _manageMarket(); + return; + } + selectedMarket = newValue; + }); + }, + isExpanded: true, + items: markets.map>((String value) { + return DropdownMenuItem( + value: value, + child: Text(value ?? "", + overflow: TextOverflow.ellipsis, + style: TextStyle( + color: value == MANAGE_MARKET + ? secondaryColor + : primaryColor)), + ); + }).toList(), + ), + ], ), ), ], diff --git a/lib/pages/processing/processing_info.dart b/lib/pages/processing/processing_info.dart index b3783b7..f250adb 100644 --- a/lib/pages/processing/processing_info.dart +++ b/lib/pages/processing/processing_info.dart @@ -1,6 +1,5 @@ import 'package:fcs/domain/entities/package.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/package/model/package_model.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:intl/intl.dart'; import 'package:provider/provider.dart'; -import 'package:timeline_list/timeline.dart'; -import 'package:timeline_list/timeline_model.dart'; import 'processing_editor.dart'; diff --git a/lib/pages/shipment/model/shipment_model.dart b/lib/pages/shipment/model/shipment_model.dart index a49a453..a20558f 100644 --- a/lib/pages/shipment/model/shipment_model.dart +++ b/lib/pages/shipment/model/shipment_model.dart @@ -1,6 +1,7 @@ import 'dart:async'; 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/pickup.dart'; import 'package:fcs/domain/vo/radio.dart'; @@ -31,6 +32,13 @@ class ShipmentModel extends BaseModel { ), ]; + List pickupTypes = [ + shipment_local_pickup, + shipment_courier_pickup, + shipment_local_dropoff, + shipment_courier_dropoff + ]; + List get radioGroups { List radioGroups = [ RadioGroup( diff --git a/lib/pages/shipment/pickup_box_editor.dart b/lib/pages/shipment/pickup_box_editor.dart index 0d53b96..5ed3b7c 100644 --- a/lib/pages/shipment/pickup_box_editor.dart +++ b/lib/pages/shipment/pickup_box_editor.dart @@ -4,13 +4,16 @@ 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:font_awesome_flutter/font_awesome_flutter.dart'; +import 'package:flutter_icons/flutter_icons.dart'; import 'package:provider/provider.dart'; import '../main/util.dart'; @@ -30,14 +33,14 @@ class _PickupBoxEditorState extends State { bool isNew; bool isMixBox = false; - DeliveryAddress _shippingAddress = new DeliveryAddress(); + DeliveryAddress _deliveryAddress = new DeliveryAddress(); @override void initState() { super.initState(); if (widget.box != null) { _box = widget.box; - _shippingAddress = _box.shippingAddress; + _deliveryAddress = _box.shippingAddress; isNew = false; } else { @@ -55,7 +58,7 @@ class _PickupBoxEditorState extends State { var shipmentModel = Provider.of(context, listen: false); - _shippingAddress = shipmentModel.deliveryAddresses[1]; + _deliveryAddress = shipmentModel.deliveryAddresses[1]; isNew = true; _box = Box( @@ -111,7 +114,7 @@ class _PickupBoxEditorState extends State { fillColor: Colors.white, labelText: 'Actual Weight', filled: true, - icon: Icon(FontAwesomeIcons.weightHanging, + icon: Icon(MaterialCommunityIcons.weight, color: primaryColor), )), ), @@ -170,7 +173,7 @@ class _PickupBoxEditorState extends State { Padding( padding: const EdgeInsets.only(left: 20.0, right: 20), child: fcsInputReadOnly( - "Shipment Weight", FontAwesomeIcons.weightHanging, + "Shipment Weight", MaterialCommunityIcons.weight, value: _box.shipmentWeight.toString()), ), Padding( @@ -182,7 +185,7 @@ class _PickupBoxEditorState extends State { fillColor: Colors.white, labelText: 'Width', filled: true, - icon: Icon(FontAwesomeIcons.arrowCircleRight, + icon: Icon(FontAwesome.arrow_circle_right, color: primaryColor), )), ), @@ -195,7 +198,7 @@ class _PickupBoxEditorState extends State { fillColor: Colors.white, labelText: 'Height', filled: true, - icon: Icon(FontAwesomeIcons.arrowAltCircleUp, + icon: Icon(FontAwesome.arrow_circle_up, color: primaryColor), )), ), @@ -208,46 +211,14 @@ class _PickupBoxEditorState extends State { fillColor: Colors.white, labelText: 'Length', filled: true, - icon: Icon(FontAwesomeIcons.arrowCircleUp, + icon: Icon(FontAwesome.arrow_circle_left, color: primaryColor), )), ), SizedBox(height: 25), ], ), - ExpansionTile( - 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), - ], - ), + makeLocation(context, _deliveryAddress), ], ), ), @@ -292,6 +263,48 @@ class _PickupBoxEditorState extends State { ); } + 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( + 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 getCargoRows(BuildContext context) { if (_box == null || _box.cargoTypes == null) { return []; diff --git a/lib/pages/shipment/shipment_editor.dart b/lib/pages/shipment/shipment_editor.dart index bc412b9..36c94f3 100644 --- a/lib/pages/shipment/shipment_editor.dart +++ b/lib/pages/shipment/shipment_editor.dart @@ -1,3 +1,4 @@ +import 'package:fcs/domain/constants.dart'; import 'package:fcs/domain/entities/box.dart'; import 'package:fcs/domain/entities/cargo.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/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/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_text.dart'; import 'package:fcs/pages/widgets/multi_img_controller.dart'; import 'package:fcs/pages/widgets/multi_img_file.dart'; @@ -27,8 +32,8 @@ import 'package:flutter/material.dart'; import 'pickup_box_editor.dart'; class ShipmentEditor extends StatefulWidget { - final Shipment pickUp; - ShipmentEditor({this.pickUp}); + final Shipment shipment; + ShipmentEditor({this.shipment}); @override _ShipmentEditorState createState() => _ShipmentEditorState(); @@ -58,17 +63,20 @@ class _ShipmentEditorState extends State { Shipment _pickUp; bool _isLoading = false; var now = new DateTime.now(); - bool isNew; - DeliveryAddress _shippingAddress = new DeliveryAddress(); + bool _isNew; + DeliveryAddress _pickupAddress = new DeliveryAddress(); int _currVal = 1; + String selectedPickupType; @override void initState() { super.initState(); - if (widget.pickUp != null) { - isNew = false; - _pickUp = widget.pickUp; + selectedPickupType = shipment_local_pickup; + + if (widget.shipment != null) { + _isNew = false; + _pickUp = widget.shipment; _addressEditingController.text = _pickUp.address; _fromTimeEditingController.text = _pickUp.fromTime; _toTimeEditingController.text = _pickUp.toTime; @@ -84,7 +92,7 @@ class _ShipmentEditorState extends State { // _recipientAddressEditingController.text = // mainModel.recipient.shippingAddress; } else { - isNew = true; + _isNew = true; List _cargoTypes = [ Cargo(type: 'General Cargo', weight: 25), Cargo(type: 'Medicine', weight: 20), @@ -94,7 +102,7 @@ class _ShipmentEditorState extends State { } var shipmentModel = Provider.of(context, listen: false); - _shippingAddress = shipmentModel.deliveryAddresses[1]; + _pickupAddress = shipmentModel.defalutAddress; } @override @@ -104,17 +112,13 @@ class _ShipmentEditorState extends State { @override Widget build(BuildContext context) { - var pickupModel = Provider.of(context); - - final fromTimeBox = InputText( + final fromTimeBox = InputTime( labelTextKey: 'shipment.from', iconData: Icons.timer, controller: _fromTimeEditingController); - final toTimeBox = InputText( - labelTextKey: 'shipment.to', - iconData: null, - controller: _toTimeEditingController); + final toTimeBox = InputTime( + labelTextKey: 'shipment.to', controller: _toTimeEditingController); final fromTimeBoxReadOnly = fcsInputReadOnly( 'From', @@ -128,25 +132,23 @@ class _ShipmentEditorState extends State { controller: _toTimeEditingController, ); - final pickupTime = Padding( - padding: const EdgeInsets.only(left: 20.0), - child: Row( - children: [ - Container( - child: fromTimeBox, - width: 120, - ), - Padding( - padding: const EdgeInsets.only(left: 8.0), - child: Text('-'), - ), - Container( - padding: EdgeInsets.only(left: 20), - child: toTimeBox, - width: 120, - ), - ], - ), + final pickupTimeBox = Row( + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Container( + child: fromTimeBox, + width: 120, + ), + Padding( + padding: const EdgeInsets.only(left: 8.0), + child: Text('-'), + ), + Container( + padding: EdgeInsets.only(left: 20), + child: toTimeBox, + width: 120, + ), + ], ); final pickupTimeReadOnly = Padding( @@ -170,54 +172,6 @@ class _ShipmentEditorState extends State { ), ); - 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(context); var boxModel = Provider.of(context); @@ -230,386 +184,165 @@ class _ShipmentEditorState extends State { icon: new Icon(Icons.close), onPressed: () => Navigator.of(context).pop(), ), - backgroundColor: primaryColor, - title: LocalText(context, "shipment.edit.title", - fontSize: 18, color: Colors.white), + shadowColor: Colors.transparent, + backgroundColor: Colors.white, + title: LocalText( + context, + _isNew ? "shipment.new.title" : "shipment.edit.title", + fontSize: 20, + color: primaryColor, + ), ), - body: Card( - child: Column( + body: Padding( + padding: const EdgeInsets.all(10.0), + child: ListView( children: [ - Expanded( - child: Padding( - padding: const EdgeInsets.all(10.0), - child: ListView(children: [ - Center(child: nameWidget("mainModel.customer.name")), - Center(child: nameWidget("mainModel.customer.phoneNumber")), - 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.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: [ - 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(), + _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), ), ), - ], - ), - _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'), - ), + ), + 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), ) - : _currVal == 4 - ? Container( - child: Column( - children: [ - 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, - ), + : 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, + ), + 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: [ + 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( - title: Text( - 'Package Information', + ), + ), + ], + )) + : Container(), + Padding( + padding: const EdgeInsets.all(8.0), + child: Row( + children: [ + Text( + 'Boxes', style: TextStyle( color: primaryColor, fontWeight: FontWeight.bold), ), - children: [ - 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 Package', - style: TextStyle(fontSize: 12), + Spacer(), + IconButton( + onPressed: () { + Navigator.push( + context, + BottomUpPageRoute(PickupBoxEditor()), + ); + }, + icon: Icon( + Icons.add, + color: primaryColor, + )) + ], + ), + ), + Column( + children: getBoxList(context, boxModel.boxes), + ), + mainModel.isCustomer() || _isNew + ? Container() + : ExpansionTile( + title: Text('For FCS'), + children: [ + 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: [ + 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), - ], - ), - _currVal == 3 || _currVal == 4 - ? Container() - : ExpansionTile( - title: Text( - 'Pickup Location / Time', - style: TextStyle( - color: primaryColor, - fontWeight: FontWeight.bold), - ), - children: [ - Padding( - padding: const EdgeInsets.only(left: 20.0), - child: Column( - children: [ - Row( - children: [ - 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: [ - 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: [ - // 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.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: [ - 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 + ], + ), + widget.shipment == null ? Align( alignment: Alignment.bottomCenter, child: Center( @@ -627,7 +360,7 @@ class _ShipmentEditorState extends State { : Container( child: Column( children: [ - widget.pickUp.status == 'Confirmed' + widget.shipment.status == 'Confirmed' ? Align( alignment: Alignment.bottomCenter, child: Center( @@ -679,6 +412,104 @@ class _ShipmentEditorState extends State { ); } + Widget makeDropdown() { + ShipmentModel pickupModel = Provider.of(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( + 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>((String value) { + return DropdownMenuItem( + 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( + 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 getBoxList(BuildContext context, List boxes) { List _boxes = [boxes[0], boxes[1]]; diff --git a/lib/pages/shipment/shipment_list_row.dart b/lib/pages/shipment/shipment_list_row.dart index d8c08f0..0a0046c 100644 --- a/lib/pages/shipment/shipment_list_row.dart +++ b/lib/pages/shipment/shipment_list_row.dart @@ -41,7 +41,7 @@ class _ShipmentListRowState extends State { child: InkWell( onTap: () { Navigator.of(context) - .push(BottomUpPageRoute(ShipmentEditor(pickUp: _pickUp))); + .push(BottomUpPageRoute(ShipmentEditor(shipment: _pickUp))); }, child: Row( children: [ diff --git a/lib/pages/widgets/input_date.dart b/lib/pages/widgets/input_date.dart index f9ac184..c490584 100644 --- a/lib/pages/widgets/input_date.dart +++ b/lib/pages/widgets/input_date.dart @@ -73,7 +73,9 @@ class InputDate extends StatelessWidget { labelText: labelTextKey == null ? null : 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 ? null : Icon( diff --git a/lib/pages/widgets/input_text.dart b/lib/pages/widgets/input_text.dart index ac5e81c..b0bd81a 100644 --- a/lib/pages/widgets/input_text.dart +++ b/lib/pages/widgets/input_text.dart @@ -49,7 +49,9 @@ class InputText extends StatelessWidget { labelText: labelTextKey == null ? null : 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 ? null : Icon( diff --git a/lib/pages/widgets/input_time.dart b/lib/pages/widgets/input_time.dart new file mode 100644 index 0000000..06f65ae --- /dev/null +++ b/lib/pages/widgets/input_time.dart @@ -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 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(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), + ); + } +} diff --git a/pubspec.yaml b/pubspec.yaml index 02707c8..350d597 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -2,7 +2,7 @@ name: fcs description: FCS Logistics 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: sdk: ">=2.7.0 <3.0.0"