diff --git a/assets/local/localization_en.json b/assets/local/localization_en.json index dcf1c95..0b9310c 100644 --- a/assets/local/localization_en.json +++ b/assets/local/localization_en.json @@ -516,6 +516,10 @@ "rate.cal.title":"ESTIMATE SHIPPING COST", + "cargo.form.title":"CARGO", + "cargo.type":"Cargo Type", + "cargo.weight":"Weight", + "boxes.name":"Boxes", "boxes.title":"BOXES", "boxes.new":"New Box", diff --git a/assets/local/localization_mu.json b/assets/local/localization_mu.json index 748bea1..ab4ea0f 100644 --- a/assets/local/localization_mu.json +++ b/assets/local/localization_mu.json @@ -563,6 +563,10 @@ "rate.cal.title":"အဆင့်သတ်မှတ်ချက်များတွက်ချက်ရန်", + "cargo.form.title":"ကုန်ပစ္စည်းအမျိုးအစား", + "cargo.type":"ကုန်ပစ္စည်းအမျိုးအစား", + "cargo.weight":"အလေးချိန်", + "message.btn":"အသိပေးချက်များ", "message.title":"အသိပေးချက်များ", diff --git a/lib/model/pickup_model.dart b/lib/model/pickup_model.dart index 6f1c5fc..72aec01 100644 --- a/lib/model/pickup_model.dart +++ b/lib/model/pickup_model.dart @@ -1,6 +1,7 @@ import 'dart:async'; import 'package:cloud_firestore/cloud_firestore.dart'; +import 'package:fcs/vo/cargo.dart'; import 'package:fcs/vo/fcs_profile.dart'; import 'package:fcs/vo/pickup.dart'; import 'package:logging/logging.dart'; @@ -33,7 +34,12 @@ class PickUpModel extends BaseModel { status: 'Pending', date: DateTime(2020, 5, 1), address: '154-19 64th Ave.\nFlushing, NY 11367', - handlingFee: 5000), + handlingFee: 5000, + cargoTypes: [ + Cargo(type: 'General Cargo', weight: 25), + Cargo(type: 'Medicine', weight: 20), + Cargo(type: 'Dangerous Cargo', weight: 30) + ]), PickUp( id: "P200125 - 12 May 2020", userName: "Ko Kyaw Nyi", @@ -45,7 +51,12 @@ class PickUpModel extends BaseModel { status: 'Assigned', date: DateTime(2020, 5, 6), address: '154-19 64th Ave.\nFlushing, NY 11367', - handlingFee: 5000), + handlingFee: 5000, + cargoTypes: [ + Cargo(type: 'General Cargo', weight: 25), + Cargo(type: 'Medicine', weight: 20), + Cargo(type: 'Dangerous Cargo', weight: 30) + ]), PickUp( id: "P200441 - 13 Apr 2020", userName: "Ko Kyaw Nyi", @@ -57,7 +68,12 @@ class PickUpModel extends BaseModel { status: "Pickuped", date: DateTime(2020, 5, 9), address: '154-19 64th Ave.\nFlushing, NY 11367', - handlingFee: 5000), + handlingFee: 5000, + cargoTypes: [ + Cargo(type: 'General Cargo', weight: 25), + Cargo(type: 'Medicine', weight: 20), + Cargo(type: 'Dangerous Cargo', weight: 30) + ]), PickUp( id: "P200412 - 12 Apr 2020", userName: "Ko Kyaw Nyi", @@ -69,7 +85,12 @@ class PickUpModel extends BaseModel { status: 'Pickuped', date: DateTime(2020, 5, 15), address: '154-19 64th Ave.\nFlushing, NY 11367', - handlingFee: 5000), + handlingFee: 5000, + cargoTypes: [ + Cargo(type: 'General Cargo', weight: 25), + Cargo(type: 'Medicine', weight: 20), + Cargo(type: 'Dangerous Cargo', weight: 30) + ]), PickUp( id: "P200125 - 12 May 2020", userName: "Ko Kyaw Nyi", @@ -81,7 +102,12 @@ class PickUpModel extends BaseModel { status: 'Pickuped', date: DateTime(2020, 5, 20), address: '154-19 64th Ave.\nFlushing, NY 11367', - handlingFee: 5000), + handlingFee: 5000, + cargoTypes: [ + Cargo(type: 'General Cargo', weight: 25), + Cargo(type: 'Medicine', weight: 20), + Cargo(type: 'Dangerous Cargo', weight: 30) + ]), PickUp( id: "P200441 - 13 Apr 2020", userName: "Ko Kyaw Nyi", @@ -93,7 +119,12 @@ class PickUpModel extends BaseModel { status: "Pickuped", date: DateTime(2020, 5, 21), address: '154-19 64th Ave.\nFlushing, NY 11367', - handlingFee: 5000), + handlingFee: 5000, + cargoTypes: [ + Cargo(type: 'General Cargo', weight: 25), + Cargo(type: 'Medicine', weight: 20), + Cargo(type: 'Dangerous Cargo', weight: 30) + ]), PickUp( id: "P200441 - 10 Apr 2020", userName: "Ko Kyaw Nyi", @@ -105,7 +136,12 @@ class PickUpModel extends BaseModel { status: "Canceled", date: DateTime(2020, 5, 25), address: '154-19 64th Ave.\nFlushing, NY 11367', - handlingFee: 5000), + handlingFee: 5000, + cargoTypes: [ + Cargo(type: 'General Cargo', weight: 25), + Cargo(type: 'Medicine', weight: 20), + Cargo(type: 'Dangerous Cargo', weight: 30) + ]), PickUp( id: "P200441 - 6 Apr 2020", userName: "Ko Kyaw Nyi", @@ -117,7 +153,12 @@ class PickUpModel extends BaseModel { status: "Canceled", date: DateTime(2020, 5, 27), address: '154-19 64th Ave.\nFlushing, NY 11367', - handlingFee: 5000), + handlingFee: 5000, + cargoTypes: [ + Cargo(type: 'General Cargo', weight: 25), + Cargo(type: 'Medicine', weight: 20), + Cargo(type: 'Dangerous Cargo', weight: 30) + ]), ]; List get canceled { diff --git a/lib/model/shipment_model.dart b/lib/model/shipment_model.dart index 088ce3e..313a4c4 100644 --- a/lib/model/shipment_model.dart +++ b/lib/model/shipment_model.dart @@ -77,14 +77,14 @@ class ShipmentModel extends BaseModel { List shippingAddresses = [ ShippingAddress( - fullName: 'FCS-0203-390-2', + fullName: 'U Nyi Nyi', addressLine1: '154-19 64th Ave.', addressLine2: 'Flushing', city: 'NY', state: 'NY', phoneNumber: '+1 (292)215-2247'), ShippingAddress( - fullName: 'FCS-0204-390-2', + fullName: 'Mg Myo', addressLine1: '153-154 5th Thitsar.', addressLine2: 'Flushing', city: 'Yangon', diff --git a/lib/model_fcs/box_model.dart b/lib/model_fcs/box_model.dart index 96d3b91..47b6c1b 100644 --- a/lib/model_fcs/box_model.dart +++ b/lib/model_fcs/box_model.dart @@ -4,6 +4,7 @@ import 'package:cloud_firestore/cloud_firestore.dart'; import 'package:fcs/model/base_model.dart'; import 'package:fcs/model_fcs/package_model.dart'; import 'package:fcs/vo/box.dart'; +import 'package:fcs/vo/cargo.dart'; import 'package:fcs/vo/package.dart'; import 'package:logging/logging.dart'; @@ -21,6 +22,7 @@ class BoxModel extends BaseModel { PackageModel.packages[1], PackageModel.packages[2] ]; + List boxes = [ Box( shipmentNumber: "A202", @@ -29,13 +31,21 @@ class BoxModel extends BaseModel { boxNumber: "1", rate: 7, packageType: "General", - weight: 25, + weight: 75, status: "Packed", receiverAddress: '1 Bo Yar Nyunt St.\nDagon Tsp, Yangon', cargoDesc: "Clothes", arrivedDate: DateTime(2020, 6, 1), + width: 10, + height: 10, + length: 10, packages: packages, - statusHistory: statusHistory), + statusHistory: statusHistory, + cargoTypes: [ + Cargo(type: 'General Cargo', weight: 25), + Cargo(type: 'Medicine', weight: 20), + Cargo(type: 'Dangerous Cargo', weight: 30) + ]), Box( shipmentNumber: "A202", receiverNumber: "3", @@ -43,13 +53,21 @@ class BoxModel extends BaseModel { boxNumber: "2", rate: 7, packageType: "General", - weight: 20, + weight: 75, status: "Packed", cargoDesc: "Clothes", arrivedDate: DateTime(2020, 6, 1), + width: 10, + height: 10, + length: 10, statusHistory: statusHistory, packages: packages, - receiverAddress: '1 Bo Yar Nyunt St.\nDagon Tsp, Yangon'), + receiverAddress: '1 Bo Yar Nyunt St.\nDagon Tsp, Yangon', + cargoTypes: [ + Cargo(type: 'General Cargo', weight: 25), + Cargo(type: 'Medicine', weight: 20), + Cargo(type: 'Dangerous Cargo', weight: 30) + ]), Box( shipmentNumber: "A202", receiverNumber: "3", @@ -57,13 +75,21 @@ class BoxModel extends BaseModel { boxNumber: "3", rate: 7, packageType: "General", - weight: 15, + weight: 75, cargoDesc: "Shoes", status: "Packed", arrivedDate: DateTime(2020, 6, 1), + width: 10, + height: 10, + length: 10, statusHistory: statusHistory, packages: packages, - receiverAddress: '1 Bo Yar Nyunt St.\nDagon Tsp, Yangon'), + receiverAddress: '1 Bo Yar Nyunt St.\nDagon Tsp, Yangon', + cargoTypes: [ + Cargo(type: 'General Cargo', weight: 25), + Cargo(type: 'Medicine', weight: 20), + Cargo(type: 'Dangerous Cargo', weight: 30) + ]), Box( shipmentNumber: "A202", receiverNumber: "2", @@ -71,13 +97,21 @@ class BoxModel extends BaseModel { boxNumber: "1", rate: 8, packageType: "Medicine", - weight: 15, + weight: 75, status: "Packed", cargoDesc: "Dietary supplement", arrivedDate: DateTime(2020, 6, 1), + width: 10, + height: 10, + length: 10, statusHistory: statusHistory, packages: packages, - receiverAddress: '2 Shwe Taung Kyar St, Bahan Tsp, Yangon'), + receiverAddress: '2 Shwe Taung Kyar St, Bahan Tsp, Yangon', + cargoTypes: [ + Cargo(type: 'General Cargo', weight: 25), + Cargo(type: 'Medicine', weight: 20), + Cargo(type: 'Dangerous Cargo', weight: 30) + ]), Box( shipmentNumber: "A202", receiverNumber: "2", @@ -86,12 +120,20 @@ class BoxModel extends BaseModel { rate: 7, packageType: "General", cargoDesc: "Handbags", - weight: 55, + weight: 75, status: "Shipped", arrivedDate: DateTime(2020, 6, 1), + width: 10, + height: 10, + length: 10, statusHistory: statusHistory, packages: packages, - receiverAddress: '2 Shwe Taung Kyar St, Bahan Tsp, Yangon'), + receiverAddress: '2 Shwe Taung Kyar St, Bahan Tsp, Yangon', + cargoTypes: [ + Cargo(type: 'General Cargo', weight: 25), + Cargo(type: 'Medicine', weight: 20), + Cargo(type: 'Dangerous Cargo', weight: 30) + ]), Box( shipmentNumber: "A201", receiverNumber: "1", @@ -100,12 +142,20 @@ class BoxModel extends BaseModel { rate: 9, packageType: "Dangerous", cargoDesc: "Phones and Scooters", - weight: 25, + weight: 75, status: "Delivered", arrivedDate: DateTime(2020, 5, 21), + width: 10, + height: 10, + length: 10, statusHistory: statusHistory, packages: packages, - receiverAddress: '3 Kambzwza St, Bahan Tsp, Yangon'), + receiverAddress: '3 Kambzwza St, Bahan Tsp, Yangon', + cargoTypes: [ + Cargo(type: 'General Cargo', weight: 25), + Cargo(type: 'Medicine', weight: 20), + Cargo(type: 'Dangerous Cargo', weight: 30) + ]), Box( shipmentNumber: "A201", receiverNumber: "1", @@ -114,12 +164,20 @@ class BoxModel extends BaseModel { rate: 7, packageType: "General", cargoDesc: "Construction tools", - weight: 5, + weight: 75, status: "Delivered", arrivedDate: DateTime(2020, 5, 21), + width: 10, + height: 10, + length: 10, statusHistory: statusHistory, packages: packages, - receiverAddress: '3 Kambzwza St, Bahan Tsp, Yangon'), + receiverAddress: '3 Kambzwza St, Bahan Tsp, Yangon', + cargoTypes: [ + Cargo(type: 'General Cargo', weight: 25), + Cargo(type: 'Medicine', weight: 20), + Cargo(type: 'Dangerous Cargo', weight: 30) + ]), ]; List get completed { diff --git a/lib/pages/pickup_editor.dart b/lib/pages/pickup_editor.dart index b26cc9f..4299f8a 100644 --- a/lib/pages/pickup_editor.dart +++ b/lib/pages/pickup_editor.dart @@ -1,6 +1,7 @@ import 'package:fcs/model/main_model.dart'; import 'package:fcs/model/pickup_model.dart'; import 'package:fcs/pages/util.dart'; +import 'package:fcs/vo/cargo.dart'; import 'package:fcs/vo/pickup.dart'; import 'package:fcs/widget/fcs_text_field.dart'; import 'package:fcs/widget/fcs_text_field_readonly.dart'; @@ -70,6 +71,12 @@ class _PickUpEditorState extends State { mainModel.recipient.shippingAddress; } else { isNew = true; + List _cargoTypes = [ + Cargo(type: 'General Cargo', weight: 25), + Cargo(type: 'Medicine', weight: 20), + Cargo(type: 'Dangerous Cargo', weight: 30) + ]; + _pickUp = PickUp(cargoTypes: _cargoTypes); } } @@ -319,50 +326,56 @@ class _PickUpEditorState extends State { ], ), // ExpansionTile( - // title: Text('Recipient Information'), + // title: Text('Box Information'), // children: [ - // 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)), + // SizedBox(height: 10.0), // ], // ), + ExpansionTile( + title: Text('Shipping Address'), + children: [ + 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( @@ -421,7 +434,7 @@ class _PickUpEditorState extends State { child: Container( width: 250, child: FlatButton( - child: Text('Update'), + child: Text('Assign'), color: primaryColor, textColor: Colors.white, onPressed: () { @@ -429,6 +442,20 @@ class _PickUpEditorState extends State { }, ), ))), + 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( diff --git a/lib/pages/profile_page.dart b/lib/pages/profile_page.dart index b3910f1..abe7d85 100644 --- a/lib/pages/profile_page.dart +++ b/lib/pages/profile_page.dart @@ -4,6 +4,7 @@ import 'package:fcs/widget/bottom_up_page_route.dart'; import 'package:fcs/widget/local_text.dart'; import 'package:fcs/widget/my_data_table.dart'; import 'package:flutter/material.dart'; +import 'package:flutter_icons/flutter_icons.dart'; import 'package:package_info/package_info.dart'; import 'package:provider/provider.dart'; import 'package:fcs/model/language_model.dart'; @@ -214,52 +215,55 @@ class _ProfileState extends State { ), )); - final logoutbutton = Padding( - padding: EdgeInsets.symmetric(vertical: 10.0), - child: Card( - elevation: 23, - child: Container( - height: 45.0, - child: ButtonTheme( - minWidth: 900.0, - height: 100.0, - child: FlatButton.icon( - onPressed: () { - showConfirmDialog(context, "profile.logout.confirm", - () async { - setState(() { - _isLoading = true; - }); - await mainModel.logout(); - Navigator.of(context).pushNamedAndRemoveUntil( - "/home", ModalRoute.withName('/home')); - Future.delayed(Duration(seconds: 1), () { - if (mounted) { + final logoutbutton = Container( + padding: EdgeInsets.only( left: 20.0, right: 24.0), + child: Padding( + padding: EdgeInsets.symmetric(vertical: 10.0), + child: Card( + elevation: 23, + child: Container( + height: 45.0, + child: ButtonTheme( + minWidth: 900.0, + height: 100.0, + child: FlatButton.icon( + onPressed: () { + showConfirmDialog(context, "profile.logout.confirm", + () async { setState(() { - _isLoading = false; + _isLoading = true; }); - } - }); - }); - }, - label: Text(AppTranslations.of(context).text("profile.logout"), - style: languageModel.isEng - ? TextStyle( - fontSize: 16.0, - fontWeight: FontWeight.bold, - fontStyle: FontStyle.normal) - : TextStyle( - fontSize: 16.0, - fontWeight: FontWeight.bold, - fontStyle: FontStyle.normal, - fontFamily: "MyanmarUnicode")), - icon: Icon( - Icons.exit_to_app, + await mainModel.logout(); + Navigator.of(context).pushNamedAndRemoveUntil( + "/home", ModalRoute.withName('/home')); + Future.delayed(Duration(seconds: 1), () { + if (mounted) { + setState(() { + _isLoading = false; + }); + } + }); + }); + }, + label: Text( + AppTranslations.of(context).text("profile.logout"), + style: languageModel.isEng + ? TextStyle( + fontSize: 16.0, + fontWeight: FontWeight.bold, + fontStyle: FontStyle.normal) + : TextStyle( + fontSize: 16.0, + fontWeight: FontWeight.bold, + fontStyle: FontStyle.normal, + fontFamily: "MyanmarUnicode")), + icon: Icon( + Icons.exit_to_app, + ), + ), ), ), - ), - ), - )); + ))); return LocalProgress( inAsyncCall: _isLoading, child: Scaffold( @@ -270,32 +274,37 @@ class _ProfileState extends State { backgroundColor: primaryColor, actions: [], ), - body: ListView( - // padding: EdgeInsets.only(left: 25.0, right: 25.0), - shrinkWrap: true, + body: Column( children: [ - Row( - children: [ - namebox, - Padding( - padding: const EdgeInsets.only(left: 18.0), - child: Icon(Icons.edit), - ) - ], - ), - mainModel.isBuyer() ? Container() : getPrivilegeBox(context), - phonenumberbox, - mainModel.user == null - ? Container() - : mainModel.user.email == null || mainModel.user.email == '' - ? Container() - : emailBox, - languageBox, - getShippingAddressList(context), - SizedBox( - height: 50, + Expanded( + child: ListView( + // padding: EdgeInsets.only(left: 25.0, right: 25.0), + shrinkWrap: true, + children: [ + Row( + children: [ + namebox, + Padding( + padding: const EdgeInsets.only(left: 18.0), + child: Icon(Icons.edit), + ) + ], + ), + mainModel.isBuyer() ? Container() : getPrivilegeBox(context), + phonenumberbox, + mainModel.user == null + ? Container() + : mainModel.user.email == null || + mainModel.user.email == '' + ? Container() + : emailBox, + languageBox, + getShippingAddressList(context), + ], + ), ), logoutbutton, + SizedBox(height: 25) ], ), ), @@ -313,41 +322,8 @@ class _ProfileState extends State { fontWeight: FontWeight.bold, fontStyle: FontStyle.normal), ), children: [ - Container( - child: SingleChildScrollView( - scrollDirection: Axis.horizontal, - child: MyDataTable( - headingRowHeight: 40, - columnSpacing: 50, - columns: [ - MyDataColumn( - label: Text( - "Full Name", - style: TextStyle( - fontSize: 15, - color: Colors.grey[600], - ), - )), - MyDataColumn( - label: Text( - "Phone Number", - style: TextStyle( - fontSize: 15, - color: Colors.grey[600], - ), - )), - MyDataColumn( - label: Text( - "Delete", - style: TextStyle( - fontSize: 15, - color: Colors.grey[600], - ), - )), - ], - rows: getAddressRows(shipmentModel.shippingAddresses), - ), - ), + Column( + children: getAddressList(context, shipmentModel.shippingAddresses), ), Container( padding: EdgeInsets.only(top: 20, bottom: 15, right: 15), @@ -378,30 +354,75 @@ class _ProfileState extends State { ); } - List getAddressRows(List addresses) { - return addresses.map((s) { - return MyDataRow( - onSelectChanged: (selected) { - Navigator.push( - context, - BottomUpPageRoute(ShippingAddressEditor(shippingAddress: s)), - ); - }, - cells: [ - MyDataCell( - new Text( - s.fullName, - style: textStyle, - ), + List getAddressList( + BuildContext context, List addresses) { + return addresses.asMap().entries.map((s) { + return Container( + padding: EdgeInsets.only(left: 10, right: 10), + child: InkWell( + onTap: () { + Navigator.push( + context, + BottomUpPageRoute( + ShippingAddressEditor(shippingAddress: s.value)), + ); + }, + child: Column( + children: [ + Row( + children: [ + Expanded( + child: new Padding( + padding: const EdgeInsets.symmetric(vertical: 10.0), + child: Row( + children: [ + Padding( + padding: EdgeInsets.all(5.0), + child: Icon( + SimpleLineIcons.location_pin, + color: primaryColor, + )), + new Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Padding( + padding: const EdgeInsets.only(left: 8.0), + child: new Text( + s.value.fullName == null + ? '' + : s.value.fullName, + style: new TextStyle( + fontSize: 15.0, color: Colors.black), + ), + ), + Padding( + padding: const EdgeInsets.only(left: 8.0), + child: new Text( + s.value.phoneNumber == null + ? '' + : s.value.phoneNumber, + style: new TextStyle( + fontSize: 14.0, color: Colors.grey), + ), + ), + ], + ), + ], + ), + ), + ), + IconButton( + padding: EdgeInsets.only(right: 30), + icon: Icon(Icons.delete, color: Colors.black45), + onPressed: null) + ], + ), + s.key == addresses.length - 1 + ? Container() + : Divider(color: Colors.black) + ], ), - MyDataCell( - new Text( - s.phoneNumber, - style: textStyle, - ), - ), - MyDataCell(IconButton(icon: Icon(Icons.delete), onPressed: null)), - ], + ), ); }).toList(); } diff --git a/lib/pages/shipment_editor.dart b/lib/pages/shipment_editor.dart index 82bee4e..b4143d8 100644 --- a/lib/pages/shipment_editor.dart +++ b/lib/pages/shipment_editor.dart @@ -157,6 +157,24 @@ class _ShipmentEditorState extends State { var shipmentModel = Provider.of(context); MainModel mainModel = Provider.of(context); + final cargoBtn = Container( + padding: EdgeInsets.only(top: 5), + child: Align( + alignment: Alignment.bottomCenter, + child: Center( + child: Container( + width: 250, + child: FlatButton( + child: Text('Download Cargo Manifest'), + color: primaryColor, + textColor: Colors.white, + onPressed: () { + Navigator.pop(context); + }, + ), + ))), + ); + final commercialBtn = Container( padding: EdgeInsets.only(top: 20), child: Align( @@ -296,7 +314,7 @@ class _ShipmentEditorState extends State { Container( padding: EdgeInsets.only(top: widget.shipment == null ? 5 : 0), - child: fcsInput('Arrival Date', Icons.date_range, + child: fcsInput('ETA', Icons.date_range, controller: _arrivalDateController), ), Container( @@ -378,6 +396,7 @@ class _ShipmentEditorState extends State { widget.shipment == null ? Container() : commercialBtn, widget.shipment == null ? Container() : packingBtn, widget.shipment == null ? Container() : dmsBtn, + widget.shipment == null ? Container() : cargoBtn, widget.shipment == null ? createBtn : updateBtn, SizedBox(height: 15) ]), diff --git a/lib/pages/shipment_rates.dart b/lib/pages/shipment_rates.dart index 87b8e7a..b93ad3f 100644 --- a/lib/pages/shipment_rates.dart +++ b/lib/pages/shipment_rates.dart @@ -105,6 +105,7 @@ class _ShipmentRatesState extends State { _row("Free delivery within Yangon \nfor shipments over", "10", "pounds"), _row("Delivery fees", "\$ 5", "below 10 pounds"), + _row("Volumetric Ratio", "\$ 166.36", "per pound"), fcsButton(context, "Terms & Conditions", callack: () { Navigator.of(context) .push(MaterialPageRoute(builder: (_) => Term())); diff --git a/lib/pages/shipment_rates_calculate.dart b/lib/pages/shipment_rates_calculate.dart index 63ab1f0..7d456d0 100644 --- a/lib/pages/shipment_rates_calculate.dart +++ b/lib/pages/shipment_rates_calculate.dart @@ -1,7 +1,4 @@ -import 'package:fcs/model/pickup_model.dart'; import 'package:fcs/model/shipment_rate_model.dart'; -import 'package:fcs/pages/shipment_rates_calculate.dart'; -import 'package:fcs/pages/shipment_rates_edit.dart'; import 'package:fcs/vo/pickup.dart'; import 'package:provider/provider.dart'; import 'package:fcs/widget/localization/app_translations.dart'; @@ -10,7 +7,6 @@ import 'package:flutter/material.dart'; import 'package:fcs/widget/progress.dart'; import '../theme/theme.dart'; -import 'util.dart'; class ShipmentRatesCal extends StatefulWidget { final PickUp pickUp; @@ -31,6 +27,7 @@ class _ShipmentRatesCalState extends State { PickUp _pickUp; bool _isLoading = false; + String cargoType; @override void initState() { @@ -53,6 +50,7 @@ class _ShipmentRatesCalState extends State { @override Widget build(BuildContext context) { var shipmentRateModel = Provider.of(context); + return LocalProgress( inAsyncCall: _isLoading, child: Scaffold( @@ -70,33 +68,74 @@ class _ShipmentRatesCalState extends State { body: Padding( padding: const EdgeInsets.all(8.0), child: ListView( - // crossAxisAlignment: CrossAxisAlignment.center, children: [ Container( - height: 185, - child: ListView.builder( - itemCount: shipmentRateModel.rates.length, - itemBuilder: (context, index) { - return _row( - shipmentRateModel.rates[index].description + - "\n\$ " + - shipmentRateModel.rates[index].price.toString() + - " per pound", - '', - "", - input: true); - }), + padding: EdgeInsets.only(top: 5, left: 25), + child: Row( + children: [ + Expanded( + child: + Text('Cargo Type', style: TextStyle(fontSize: 15))), + Container( + width: 150.0, + child: DropdownButtonFormField( + decoration: InputDecoration( + fillColor: Colors.white, + hintText: shipmentRateModel.rates[0].description, + hintStyle: TextStyle(color: Colors.black87)), + items: shipmentRateModel.rates + .map((e) => DropdownMenuItem( + child: Text(e.description), + value: e.description)) + .toList(), + onChanged: (selected) => { + setState(() { + cargoType = selected; + }) + }, + ), + ), + ], + ), ), + _row('Width (inches)', "", "", "10", input: true), + _row('Height', "", "", "10", input: true), + _row('Length', "", "", "10", input: true), + Container( + padding: EdgeInsets.only(left: 25, top: 15, bottom: 5), + child: Row( + children: [ + Text('Shipment Weight', style: TextStyle(fontSize: 15)), + Spacer(), + Column( + crossAxisAlignment: CrossAxisAlignment.end, + children: [ + Padding( + padding: const EdgeInsets.only(bottom: 3.0), + child: Text( + '6', + style: + TextStyle(color: primaryColor, fontSize: 16), + ), + ), + Text( + 'pounds', + style: TextStyle(color: Colors.grey, fontSize: 16), + ), + ], + ), + ], + )), SizedBox(height: 50), Center( child: Text( - "Delivery fee:\$ 0", + "Delivery fee:\$ 5", style: TextStyle(color: primaryColor, fontSize: 16), )), SizedBox(height: 20), Center( child: Text( - "Total estimated amount:\$ 95", + "Total estimated amount:\$ 41", style: TextStyle(color: primaryColor, fontSize: 20), )) ], @@ -106,7 +145,7 @@ class _ShipmentRatesCalState extends State { ); } - _row(String desc, String price, String unit, {bool input}) { + _row(String desc, String price, String unit, String value, {bool input}) { return Container( padding: EdgeInsets.only(left: 25, top: 5, bottom: 5), child: Row( @@ -134,8 +173,9 @@ class _ShipmentRatesCalState extends State { width: 50, ), Container( - width: 70, - child: TextField( + width: 150, + child: TextFormField( + initialValue: value, textAlign: TextAlign.end, )), ], diff --git a/lib/pages/shipment_rates_edit.dart b/lib/pages/shipment_rates_edit.dart index 50ff469..793f87f 100644 --- a/lib/pages/shipment_rates_edit.dart +++ b/lib/pages/shipment_rates_edit.dart @@ -1,6 +1,11 @@ import 'package:fcs/model/pickup_model.dart'; import 'package:fcs/model/shipment_rate_model.dart'; +import 'package:fcs/pages_fcs/cargo_editor.dart'; import 'package:fcs/vo/pickup.dart'; +import 'package:fcs/vo/rate.dart'; +import 'package:fcs/widget/bottom_up_page_route.dart'; +import 'package:fcs/widget/local_text.dart'; +import 'package:fcs/widget/my_data_table.dart'; import 'package:font_awesome_flutter/font_awesome_flutter.dart'; import 'package:provider/provider.dart'; import 'package:fcs/widget/localization/app_translations.dart'; @@ -69,26 +74,88 @@ class _ShipmentRatesEditState extends State { ), body: Container( padding: EdgeInsets.all(18), - child: ListView( + child: Column( children: [ - Container( - height: 190, - child: ListView.builder( - itemCount: shipmentRateModel.rates.length, - itemBuilder: (context, index) { - return fcsInput( - shipmentRateModel.rates[index].description, - Icons.attach_money, - value: - shipmentRateModel.rates[index].price.toString()); - }), + Expanded( + child: ListView( + children: [ + fcsInput("Min Weight for Free delivery within Yangon", + FontAwesomeIcons.weightHanging, + value: "10"), + fcsInput("Delivery fees", Icons.attach_money, value: "5"), + SizedBox(height: 10), + fcsInput("Volumetric Ratio", Icons.attach_money, + value: "166.36"), + SizedBox(height: 10), + ExpansionTile( + title: Text( + 'Cargo Types', + style: TextStyle( + color: primaryColor, fontWeight: FontWeight.bold), + ), + children: [ + Container( + child: SingleChildScrollView( + scrollDirection: Axis.horizontal, + child: MyDataTable( + headingRowHeight: 40, + columnSpacing: 50, + columns: [ + MyDataColumn( + label: Text("Cargo Type", + style: TextStyle( + fontSize: 15, + color: Colors.grey[600]))), + MyDataColumn( + label: Text("Rate", + style: TextStyle( + fontSize: 15, + color: Colors.grey[600]))), + MyDataColumn( + label: Text("Delete", + style: TextStyle( + fontSize: 15, + color: Colors.grey[600]))), + ], + rows: getCargoRows(shipmentRateModel.rates), + ), + ), + ), + 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(CargoEditor()), + ); + }, + label: Text( + 'Add Cargo', + style: TextStyle(fontSize: 12), + ), + backgroundColor: primaryColor, + ), + ), + ), + ) + ], + ), + ], + ), ), - fcsInput("Min Weight for Free delivery within Yangon", - FontAwesomeIcons.weightHanging, - value: "10"), - fcsInput("Delivery fees", Icons.attach_money, value: "5"), - SizedBox(height: 10), - fcsButton(context, "Save", callack: () {}), + fcsButton(context, "Save", callack: () { + Navigator.pop(context); + }), SizedBox(height: 10) ], ), @@ -97,6 +164,34 @@ class _ShipmentRatesEditState extends State { ); } + List getCargoRows(List rates) { + return rates.map((r) { + return MyDataRow( + onSelectChanged: (selected) { + Navigator.push( + context, + BottomUpPageRoute(CargoEditor(rate: r)), + ); + }, + cells: [ + MyDataCell( + new Text( + r.description, + style: textStyle, + ), + ), + MyDataCell( + new Text( + r.price.toString(), + style: textStyle, + ), + ), + MyDataCell(IconButton(icon: Icon(Icons.delete), onPressed: null)), + ], + ); + }).toList(); + } + _row(String desc, String price, String unit) { return Container( padding: EdgeInsets.only(left: 25, top: 5, bottom: 5), diff --git a/lib/pages/shipping_address_editor.dart b/lib/pages/shipping_address_editor.dart index add284a..b5c9c16 100644 --- a/lib/pages/shipping_address_editor.dart +++ b/lib/pages/shipping_address_editor.dart @@ -85,7 +85,7 @@ class _ShippingAddressEditorState extends State { children: [ Expanded( child: Padding( - padding: const EdgeInsets.only(left: 20.0), + padding: const EdgeInsets.only(left: 10.0,right: 10), child: ListView(children: [ usaAddress, SizedBox(height: 10), diff --git a/lib/pages/splash.dart b/lib/pages/splash.dart index 47a8d7c..492c3ff 100644 --- a/lib/pages/splash.dart +++ b/lib/pages/splash.dart @@ -50,8 +50,12 @@ class _SplashScreenState extends State { if (_loaded) { timer.cancel(); + if (this._isLogin) { + Navigator.of(context).pushReplacementNamed('/homeLogin'); + } else { + Navigator.of(context).pushReplacementNamed('/home'); + } - Navigator.of(context).pushReplacementNamed('/home'); // if (_isSupport) { // if (_isLogin) { // if (!_isAgree) { diff --git a/lib/pages_fcs/box_editor.dart b/lib/pages_fcs/box_editor.dart index 4c3b174..bc08e80 100644 --- a/lib/pages_fcs/box_editor.dart +++ b/lib/pages_fcs/box_editor.dart @@ -3,6 +3,7 @@ import 'package:fcs/model_fcs/package_model.dart'; import 'package:fcs/pages/invoice/package_addition.dart'; import 'package:fcs/pages/util.dart'; import 'package:fcs/vo/box.dart'; +import 'package:fcs/vo/cargo.dart'; import 'package:fcs/vo/package.dart'; import 'package:fcs/widget/bottom_up_page_route.dart'; import 'package:fcs/widget/local_text.dart'; @@ -45,6 +46,8 @@ class _BoxEditorState extends State { ]; bool isNew; + bool isMixBox = false; + @override void initState() { super.initState(); @@ -63,8 +66,22 @@ class _BoxEditorState extends State { PackageModel.packages[2] ]; + List _cargoTypes = [ + Cargo(type: 'General Cargo', weight: 25), + Cargo(type: 'Medicine', weight: 20), + Cargo(type: 'Dangerous Cargo', weight: 30) + ]; + isNew = true; - _box = Box(rate: 0, weight: 0, packages: packages); + _box = Box( + rate: 0, + weight: 75, + width: 0, + height: 0, + length: 0, + packages: packages, + cargoTypes: _cargoTypes, + ); } } @@ -166,6 +183,33 @@ class _BoxEditorState extends State { onChanged: (map) => {}, ), ), + Padding( + padding: const EdgeInsets.only(left: 8.0, right: 20), + child: new Row( + children: [ + new Checkbox( + value: isMixBox, + activeColor: primaryColor, + onChanged: (bool value) { + setState(() { + isMixBox = value; + }); + }), + SizedBox( + width: 5, + ), + Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + new Text( + "Mix Box", + style: TextStyle(fontSize: 15.0), + ), + ], + ), + ], + ), + ), Padding( padding: const EdgeInsets.only(left: 20.0, right: 20), child: TextFormField( @@ -208,21 +252,21 @@ class _BoxEditorState extends State { color: primaryColor, fontWeight: FontWeight.bold), ), children: [ - Padding( - padding: const EdgeInsets.only(left: 20.0, right: 20), - child: DropdownButtonFormField( - value: _box.packageType, - decoration: InputDecoration( - fillColor: Colors.white, - labelText: 'Cargo Type', - icon: Icon(Entypo.box, color: primaryColor)), - items: ["General", "Medicine", "Dangerous"] - .map((e) => - DropdownMenuItem(child: Text(e), value: e)) - .toList(), - onChanged: (map) => {}, - ), - ), + // Padding( + // padding: const EdgeInsets.only(left: 20.0, right: 20), + // child: DropdownButtonFormField( + // value: _box.packageType, + // decoration: InputDecoration( + // fillColor: Colors.white, + // labelText: 'Cargo Type', + // icon: Icon(Entypo.box, color: primaryColor)), + // items: ["General", "Medicine", "Dangerous"] + // .map((e) => + // DropdownMenuItem(child: Text(e), value: e)) + // .toList(), + // onChanged: (map) => {}, + // ), + // ), Padding( padding: const EdgeInsets.only(left: 20.0, right: 20), child: TextFormField( @@ -236,66 +280,60 @@ class _BoxEditorState extends State { color: primaryColor), )), ), - Padding( - padding: const EdgeInsets.only(left: 20.0, right: 20), - child: TextFormField( - initialValue: _box.rate.toString(), - textAlign: TextAlign.end, - decoration: InputDecoration( - fillColor: Colors.white, - labelText: 'Rate', - filled: true, - icon: Icon(FontAwesomeIcons.tag, - color: primaryColor), - )), - ), - Padding( - padding: const EdgeInsets.only(left: 20.0, right: 20), - child: TextFormField( - initialValue: _box.amount.toString(), - textAlign: TextAlign.end, - decoration: InputDecoration( - fillColor: Colors.white, - labelText: 'Total Amount', - filled: true, - icon: Icon(FontAwesomeIcons.moneyBill, - color: primaryColor), - )), - ), + // Padding( + // padding: const EdgeInsets.only(left: 20.0, right: 20), + // child: TextFormField( + // initialValue: _box.rate.toString(), + // textAlign: TextAlign.end, + // decoration: InputDecoration( + // fillColor: Colors.white, + // labelText: 'Rate', + // filled: true, + // icon: Icon(FontAwesomeIcons.tag, + // color: primaryColor), + // )), + // ), + // Padding( + // padding: const EdgeInsets.only(left: 20.0, right: 20), + // child: TextFormField( + // initialValue: _box.amount.toString(), + // textAlign: TextAlign.end, + // decoration: InputDecoration( + // fillColor: Colors.white, + // labelText: 'Total Amount', + // filled: true, + // icon: Icon(FontAwesomeIcons.moneyBill, + // color: primaryColor), + // )), + // ), Container( padding: EdgeInsets.only(top: 10), child: SingleChildScrollView( scrollDirection: Axis.horizontal, child: MyDataTable( headingRowHeight: 40, - columnSpacing: 20, + columnSpacing: 120, columns: [ MyDataColumn( label: LocalText( context, - "box.package.id", + "cargo.type", color: Colors.grey, ), ), MyDataColumn( label: LocalText( context, - "box.package.desc", - color: Colors.grey, - ), - ), - MyDataColumn( - label: LocalText( - context, - "box.package.market", + "cargo.weight", color: Colors.grey, ), ), ], - rows: getPackageRow(context), + rows: getCargoRows(context), ), ), ), + mainModel.isOwner() ? Container( padding: EdgeInsets.only(top: 20), @@ -303,12 +341,11 @@ class _BoxEditorState extends State { alignment: Alignment.bottomRight, child: FloatingActionButton.extended( icon: Icon(Icons.add), - label: Text(AppTranslations.of(context) - .text("box.add_package")), + label: Text("Add Cargo"), backgroundColor: primaryColor, onPressed: () { - Navigator.of(context).push( - BottomUpPageRoute(PackageAddition())); + // Navigator.of(context).push( + // BottomUpPageRoute(PackageAddition())); }, ), ), @@ -317,6 +354,55 @@ class _BoxEditorState extends State { SizedBox(height: 25), ], ), + ExpansionTile( + title: Text( + 'Box Dimension', + style: TextStyle( + color: primaryColor, fontWeight: FontWeight.bold), + ), + children: [ + Padding( + padding: const EdgeInsets.only(left: 20.0, right: 20), + child: TextFormField( + initialValue: _box.width.toString(), + textAlign: TextAlign.end, + decoration: InputDecoration( + fillColor: Colors.white, + labelText: 'Width', + filled: true, + icon: Icon(FontAwesomeIcons.arrowCircleRight, + color: primaryColor), + )), + ), + Padding( + padding: const EdgeInsets.only(left: 20.0, right: 20), + child: TextFormField( + initialValue: _box.height.toString(), + textAlign: TextAlign.end, + decoration: InputDecoration( + fillColor: Colors.white, + labelText: 'Height', + filled: true, + icon: Icon(FontAwesomeIcons.arrowAltCircleUp, + color: primaryColor), + )), + ), + Padding( + padding: const EdgeInsets.only(left: 20.0, right: 20), + child: TextFormField( + initialValue: _box.length.toString(), + textAlign: TextAlign.end, + decoration: InputDecoration( + fillColor: Colors.white, + labelText: 'Length', + filled: true, + icon: Icon(FontAwesomeIcons.arrowCircleUp, + color: primaryColor), + )), + ), + SizedBox(height: 25), + ], + ), isNew ? Container() : ExpansionTile( @@ -382,23 +468,21 @@ class _BoxEditorState extends State { ); } - List getPackageRow(BuildContext context) { - if (_box == null || _box.packages == null) { + List getCargoRows(BuildContext context) { + if (_box == null || _box.cargoTypes == null) { return []; } - return _box.packages.map((p) { + return _box.cargoTypes.map((c) { return MyDataRow( onSelectChanged: (bool selected) {}, cells: [ MyDataCell(new Text( - p.id == null ? "" : p.id, + c.type == null ? "" : c.type, style: textStyle, )), MyDataCell( - new Text(p.cargoDesc, style: textStyle), - ), - MyDataCell( - new Text("${p.market}", style: textStyle), + new Text(c.weight == null ? "0" : c.weight.toString(), + style: textStyle), ), ], ); diff --git a/lib/pages_fcs/cargo_editor.dart b/lib/pages_fcs/cargo_editor.dart new file mode 100644 index 0000000..2101b3e --- /dev/null +++ b/lib/pages_fcs/cargo_editor.dart @@ -0,0 +1,79 @@ +import 'package:fcs/pages/util.dart'; +import 'package:fcs/vo/rate.dart'; +import 'package:fcs/widget/localization/app_translations.dart'; +import 'package:flutter/material.dart'; +import 'package:fcs/widget/progress.dart'; +import '../theme/theme.dart'; + +class CargoEditor extends StatefulWidget { + final Rate rate; + CargoEditor({this.rate}); + + @override + _CargoEditorState createState() => _CargoEditorState(); +} + +class _CargoEditorState extends State { + TextEditingController _descController = new TextEditingController(); + TextEditingController _rateController = new TextEditingController(); + + bool _isLoading = false; + Rate _rate = new Rate(); + + @override + void initState() { + super.initState(); + if (widget.rate != null) { + _rate = widget.rate; + _descController.text = _rate.description; + _rateController.text = _rate.price.toString(); + } + } + + @override + void dispose() { + super.dispose(); + } + + @override + Widget build(BuildContext context) { + return LocalProgress( + inAsyncCall: _isLoading, + child: Scaffold( + appBar: AppBar( + centerTitle: true, + leading: new IconButton( + icon: new Icon( + Icons.close, + ), + onPressed: () => Navigator.of(context).pop(), + ), + backgroundColor: primaryColor, + title: Text(AppTranslations.of(context).text("cargo.form.title")), + ), + body: Container( + padding: EdgeInsets.all(18), + child: Column( + children: [ + Expanded( + child: ListView( + children: [ + fcsInput("Cargo Type", Icons.text_format, + controller: _descController), + fcsInput("Rate", Icons.attach_money, + controller: _rateController), + SizedBox(height: 30), + ], + ), + ), + widget.rate == null + ? fcsButton(context, "Create", callack: () {}) + : fcsButton(context, "Save", callack: () {}), + SizedBox(height: 10) + ], + ), + ), + ), + ); + } +} diff --git a/lib/vo/box.dart b/lib/vo/box.dart index 81f7414..0f2bd84 100644 --- a/lib/vo/box.dart +++ b/lib/vo/box.dart @@ -1,3 +1,4 @@ +import 'package:fcs/vo/cargo.dart'; import 'package.dart'; class Status { @@ -19,6 +20,9 @@ class Box { String boxNumber; String status; String cargoDesc; + int width; + int height; + int length; int rate; int weight; @@ -30,6 +34,8 @@ class Box { List packages; + List cargoTypes; + int get amount => rate != null && weight != null ? rate * weight : 0; String get packageNumber => @@ -48,6 +54,9 @@ class Box { this.receiverNumber, this.receiverAddress, this.boxNumber, + this.width, + this.height, + this.length, this.rate, this.weight, this.packageType, @@ -57,5 +66,6 @@ class Box { this.arrivedDate, this.cargoDesc, this.statusHistory, - this.packages}); + this.packages, + this.cargoTypes}); } diff --git a/lib/vo/cargo.dart b/lib/vo/cargo.dart new file mode 100644 index 0000000..c892aec --- /dev/null +++ b/lib/vo/cargo.dart @@ -0,0 +1,6 @@ +class Cargo { + String type; + int price; + int weight; + Cargo({this.type, this.price, this.weight}); +} diff --git a/lib/vo/pickup.dart b/lib/vo/pickup.dart index 41daa36..d34a123 100644 --- a/lib/vo/pickup.dart +++ b/lib/vo/pickup.dart @@ -1,3 +1,5 @@ +import 'cargo.dart'; + class PickUp { String id; String userName; @@ -10,6 +12,7 @@ class PickUp { String address; String status; DateTime date; + List cargoTypes; PickUp( {this.id, @@ -22,7 +25,8 @@ class PickUp { this.handlingFee, this.address, this.status, - this.date}); + this.date, + this.cargoTypes}); int get last => DateTime.now().difference(date).inDays;