From 6e3c5bba288968668035b2851ce1faea6108b5b9 Mon Sep 17 00:00:00 2001 From: PhyoThandar Date: Wed, 7 Oct 2020 18:19:12 +0630 Subject: [PATCH] modify FCS shipment --- assets/local/localization_en.json | 25 +- assets/local/localization_mu.json | 25 +- .../fcs_shipment/fcs_shipment_editor.dart | 343 ++++++++---------- lib/pages/fcs_shipment/fcs_shipment_list.dart | 109 ++---- lib/pages/main/home_page.dart | 2 +- lib/pages/widgets/display_text.dart | 6 +- lib/pages/widgets/popupmenu.dart | 14 + 7 files changed, 226 insertions(+), 298 deletions(-) create mode 100644 lib/pages/widgets/popupmenu.dart diff --git a/assets/local/localization_en.json b/assets/local/localization_en.json index 09d45e8..3282320 100644 --- a/assets/local/localization_en.json +++ b/assets/local/localization_en.json @@ -610,11 +610,26 @@ "notifications.title":"Notification", - "shipment.title":"FCS Shipments", - "shipment.list.title":"FCS SHIPMENTS", - "shipment.add":"New FCS shipment", - "shipment.form.title":"FCS SHIPMENT", - "shipment.number":"FCS Shipment Number", + "FCSshipment.title":"FCS Shipments", + "FCSshipment.list.title":"FCS SHIPMENTS", + "FCSshipment.add":"New FCS shipment", + "FCSshipment.form.title":"FCS SHIPMENT", + "FCSshipment.number":"FCS Shipment Number", + "FCSshipment.cutoff_date":"Cutoff Date", + "FCSshipment.ETA":"ETA", + "FCSshipment.departure_date":"Departure Date", + "FCSshipment.shipment_type":"Shipment Type", + "FCSshipment.consignee":"Consignee", + "FCSshipment.port_of_loading":"Port of Loading", + "FCSshipment.final_destination":"Final Destination", + "FCSshipment.status":"Status", + "FCSshipment.remark":"Remark", + "FCSshipment.commercial_invoice":"Download Commercial Invoice", + "FCSshipment.packing_list":"Download Packing List", + "FCSshipment.dms":"Download DMS", + "FCSshipment.cargo_manifest":"Download Cargo Manifest", + "FCSshipment.create":"Create FCS Shipment", + "FCSshipment.update":"Update FCS Shipment", "pickup": "Shipments", "pickup.title": "SHIPMENTS", diff --git a/assets/local/localization_mu.json b/assets/local/localization_mu.json index 56abfdd..8a7bf28 100644 --- a/assets/local/localization_mu.json +++ b/assets/local/localization_mu.json @@ -648,11 +648,26 @@ "notifications.title":"Notifications", - "shipment.title":"FCS တင်ပို့ခြင်းများ", - "shipment.list.title":"FCS တင်ပို့ခြင်းများ", - "shipment.add":"New FCS shipment", - "shipment.form.title":"FCS SHIPMENT", - "shipment.number":"FCS Shipment Number", + "FCSshipment.title":"FCS တင်ပို့ခြင်းများ", + "FCSshipment.list.title":"FCS တင်ပို့ခြင်းများ", + "FCSshipment.add":"FCS တင်ပို့ခြင်းအသစ်", + "FCSshipment.form.title":"FCS တင်ပို့ခြင်း", + "FCSshipment.number":"FCS တင်ပို့နံပါတ်", + "FCSshipment.cutoff_date":"သတ်မှတ်ရက်", + "FCSshipment.ETA":"ခန့်မှန်းရောက်ချိန်", + "FCSshipment.departure_date":"ထွက်ခွာသည့်ရက်", + "FCSshipment.shipment_type":"တင်ပို့မှုအမျိုးအစား", + "FCSshipment.consignee":"ပစ္စည်းလက်ခံသူ", + "FCSshipment.port_of_loading":"ဆိပ်ကမ်း", + "FCSshipment.final_destination":"ဆိုက်ရောက်နေရာ", + "FCSshipment.status":"အခြေအနေ", + "FCSshipment.remark":"မှတ်ချက်", + "FCSshipment.commercial_invoice":"Download Commercial Invoice", + "FCSshipment.packing_list":"Download Packing List", + "FCSshipment.dms":"Download DMS", + "FCSshipment.cargo_manifest":"Download Cargo Manifest", + "FCSshipment.create":"FCS တင်ပို့ခြင်းပြုလုပ်ရန်", + "FCSshipment.update":"FCS တင်ပို့ခြင်းပြင်ရန်", "pickup": "Shipments", "pickup.title": "SHIPMENTS", diff --git a/lib/pages/fcs_shipment/fcs_shipment_editor.dart b/lib/pages/fcs_shipment/fcs_shipment_editor.dart index b339bf4..1430dba 100644 --- a/lib/pages/fcs_shipment/fcs_shipment_editor.dart +++ b/lib/pages/fcs_shipment/fcs_shipment_editor.dart @@ -2,8 +2,13 @@ import 'package:fcs/domain/entities/fcs_shipment.dart'; import 'package:fcs/helpers/theme.dart'; import 'package:fcs/localization/app_translations.dart'; import 'package:fcs/pages/fcs_shipment/model/fcs_shipment_model.dart'; +import 'package:fcs/pages/main/model/language_model.dart'; import 'package:fcs/pages/main/model/main_model.dart'; +import 'package:fcs/pages/widgets/display_text.dart'; +import 'package:fcs/pages/widgets/input_text.dart'; import 'package:fcs/pages/widgets/label_widgets.dart'; +import 'package:fcs/pages/widgets/local_text.dart'; +import 'package:fcs/pages/widgets/popupmenu.dart'; import 'package:fcs/pages/widgets/progress.dart'; import 'package:flutter_icons/flutter_icons.dart'; import 'package:font_awesome_flutter/font_awesome_flutter.dart'; @@ -116,124 +121,36 @@ class _FcsShipmentEditorState extends State { @override Widget build(BuildContext context) { var shipmentModel = Provider.of(context); + var languageModel = 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 createBtn = fcsButton( + context, + getLocalString(context, "FCSshipment.create"), ); - final commercialBtn = Container( - padding: EdgeInsets.only(top: 20), - child: Align( - alignment: Alignment.bottomCenter, - child: Center( - child: Container( - width: 250, - child: FlatButton( - child: Text('Download Commercial Invoice'), - color: primaryColor, - textColor: Colors.white, - onPressed: () { - Navigator.pop(context); - }, - ), - ))), + final updateBtn = fcsButton( + context, + getLocalString(context, "FCSshipment.update"), ); - final packingBtn = Container( - padding: EdgeInsets.only(top: 5), - child: Align( - alignment: Alignment.bottomCenter, - child: Center( - child: Container( - width: 250, - child: FlatButton( - child: Text('Download Packing List'), - color: primaryColor, - textColor: Colors.white, - onPressed: () { - Navigator.pop(context); - }, - ), - ))), - ); - - final dmsBtn = Container( - padding: EdgeInsets.only(top: 5), - child: Align( - alignment: Alignment.bottomCenter, - child: Center( - child: Container( - width: 250, - child: FlatButton( - child: Text('Download DMS'), - color: primaryColor, - textColor: Colors.white, - onPressed: () { - Navigator.pop(context); - }, - ), - ))), - ); - - final createBtn = Container( - padding: EdgeInsets.only(top: 20), - child: Align( - alignment: Alignment.bottomCenter, - child: Center( - child: Container( - width: 250, - child: FlatButton( - child: Text('Create FCS Shipment'), - color: primaryColor, - textColor: Colors.white, - onPressed: () { - Navigator.pop(context); - }, - ), - ))), - ); - final updateBtn = Container( - padding: EdgeInsets.only(top: 5), - child: Align( - alignment: Alignment.bottomCenter, - child: Center( - child: Container( - width: 250, - child: FlatButton( - child: Text('Update FCS Shipment'), - color: primaryColor, - textColor: Colors.white, - onPressed: () { - Navigator.pop(context); - }, - ), - ))), - ); return LocalProgress( inAsyncCall: _isLoading, child: Scaffold( appBar: AppBar( centerTitle: true, + shadowColor: Colors.transparent, leading: new IconButton( - icon: new Icon(Icons.close), + icon: new Icon(Icons.close, color: primaryColor), onPressed: () => Navigator.of(context).pop(), ), - backgroundColor: primaryColor, - title: Text(AppTranslations.of(context).text("shipment.form.title")), + backgroundColor: Colors.white, + title: LocalText( + context, + "FCSshipment.form.title", + color: primaryColor, + fontSize: 18, + ), + actions: [menuPopWidget(context)], ), body: Card( child: Column( @@ -244,127 +161,155 @@ class _FcsShipmentEditorState extends State { child: ListView(children: [ // _showCustomerData(mainModel.customer), widget.shipment == null - ? fcsInput('FCS Shipment Number', Ionicons.ios_airplane, - controller: _shipmentNumberController) - : Container( - child: TextFormField( - controller: _shipmentNumberController, - readOnly: true, - decoration: InputDecoration( - fillColor: Colors.white, - labelText: 'FCS Shipment Number', - labelStyle: - TextStyle(fontSize: 16, color: Colors.grey), - filled: true, - enabledBorder: InputBorder.none, - focusedBorder: InputBorder.none, - icon: Icon( - Ionicons.ios_airplane, - color: primaryColor, - ), - )), - ), + ? InputText( + labelTextKey: "FCSshipment.number", + iconData: Ionicons.ios_airplane, + controller: _shipmentNumberController, + ) + : DisplayText( + iconData: Ionicons.ios_airplane, + labelText: "FCSshipment.number", + text: _shipmentNumberController.text), + widget.shipment == null - ? Container( - padding: EdgeInsets.only(top: 5), - child: fcsInput('Cutoff Date', Icons.date_range, - controller: _cutoffDateController), + ? InputText( + labelTextKey: "FCSshipment.cutoff_date", + iconData: Icons.date_range, + controller: _cutoffDateController, ) : Container(), - Container( - padding: - EdgeInsets.only(top: widget.shipment == null ? 5 : 0), - child: fcsInput('ETA', Icons.date_range, - controller: _arrivalDateController), + + InputText( + labelTextKey: "FCSshipment.ETA", + iconData: Icons.date_range, + controller: _arrivalDateController, ), - Container( - padding: EdgeInsets.only(top: 5), - child: fcsInput('Departure Date', Icons.date_range, - controller: _departureDateControler), + + InputText( + labelTextKey: "FCSshipment.departure_date", + iconData: Icons.date_range, + controller: _departureDateControler, ), widget.shipment == null - ? Container( - padding: EdgeInsets.only(top: 5), - child: DropdownButtonFormField( - decoration: InputDecoration( - fillColor: Colors.white, - labelText: 'FCS Shipment Type', - icon: Icon(Ionicons.ios_airplane, - color: primaryColor)), - items: shipmentModel.shipmentType - .map((e) => - DropdownMenuItem(child: Text(e), value: e)) - .toList(), - onChanged: (selected) => { - setState(() { - _currentShipment = selected; - }) - }, - ), + ? DropdownButtonFormField( + decoration: InputDecoration( + enabledBorder: UnderlineInputBorder( + borderSide: BorderSide(color: primaryColor)), + fillColor: Colors.white, + labelStyle: languageModel.isEng + ? labelStyle + : labelStyleMM, + labelText: AppTranslations.of(context) + .text('FCSshipment.shipment_type'), + icon: Icon(Ionicons.ios_airplane, + color: primaryColor)), + items: shipmentModel.shipmentType + .map((e) => + DropdownMenuItem(child: Text(e), value: e)) + .toList(), + onChanged: (selected) => { + setState(() { + _currentShipment = selected; + }) + }, ) : Container(), widget.shipment == null - ? Container( - padding: EdgeInsets.only(top: 5), - child: fcsInput('Consignee', Icons.work, - controller: _consigneeController), - ) + ? InputText( + labelTextKey: 'FCSshipment.consignee', + iconData: Icons.work, + controller: _consigneeController) : Container(), widget.shipment == null - ? Container( - padding: EdgeInsets.only(top: 5), - child: fcsInput( - 'Port of Loading', FontAwesomeIcons.ship, - controller: _portController), - ) + ? InputText( + labelTextKey: 'FCSshipment.port_of_loading', + iconData: FontAwesomeIcons.ship, + controller: _portController) : Container(), widget.shipment == null - ? Container( - padding: EdgeInsets.only(top: 5), - child: fcsInput('Final Destination', - MaterialCommunityIcons.location_enter, - controller: _destinationController), - ) + ? InputText( + labelTextKey: 'FCSshipment.final_destination', + iconData: MaterialCommunityIcons.location_enter, + controller: _destinationController) : Container(), widget.shipment == null ? Container() : Container( padding: EdgeInsets.only(top: 5), - child: TextFormField( - controller: _statusController, - cursorColor: primaryColor, - decoration: InputDecoration( - fillColor: Colors.white, - labelText: 'Status', - filled: true, - labelStyle: TextStyle( - fontSize: 16, color: Colors.grey), - focusedBorder: UnderlineInputBorder( - borderSide: BorderSide( - color: Colors.grey, width: 1.0)), - icon: Icon(Icons.av_timer, - color: primaryColor))), - ), + child: DisplayText( + text: _statusController.text, + iconData: Icons.av_timer, + labelText: 'FCSshipment.status', + )), + widget.shipment == null ? Container() - : Container( - padding: EdgeInsets.only(top: 5), - child: fcsInput('Remark', MaterialCommunityIcons.note, - controller: _remarkController), - ), - 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) + : InputText( + labelTextKey: 'FCSshipment.remark', + iconData: MaterialCommunityIcons.note, + controller: _remarkController), ]), )), + widget.shipment == null ? createBtn : updateBtn, + SizedBox(height: 15) ], ), ), ), ); } + + Widget menuPopWidget(BuildContext context) { + return PopupMenuButton( + elevation: 3.2, + icon: Icon(Icons.more_vert, color: primaryColor), + tooltip: 'This is tooltip', + onSelected: (choice) { + if (choice.id == 1) { + Navigator.pop(context); + } else if (choice.id == 2) { + Navigator.pop(context); + } else if (choice.id == 3) { + Navigator.pop(context); + } else if (choice.id == 4) { + Navigator.pop(context); + } + }, + itemBuilder: (BuildContext context) { + List menuPopup = [ + PopupMenu( + id: 3, + status: "FCSshipment.commercial_invoice", + ), + PopupMenu(id: 2, status: "FCSshipment.packing_list"), + PopupMenu( + id: 5, + status: "FCSshipment.dms", + ), + PopupMenu( + id: 4, + status: "FCSshipment.cargo_manifest", + ), + ]; + + return menuPopup.map((PopupMenu choice) { + return PopupMenuItem( + value: choice, + child: Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Container( + padding: EdgeInsets.only(left: 15), + child: LocalText( + context, + choice.status, + color: primaryColor, + )), + ], + ), + ); + }).toList(); + }); + } } diff --git a/lib/pages/fcs_shipment/fcs_shipment_list.dart b/lib/pages/fcs_shipment/fcs_shipment_list.dart index b84b3a3..735c7bf 100644 --- a/lib/pages/fcs_shipment/fcs_shipment_list.dart +++ b/lib/pages/fcs_shipment/fcs_shipment_list.dart @@ -31,10 +31,10 @@ class _FcsShipmentListState extends State { @override Widget build(BuildContext context) { + var shipmentModel = Provider.of(context); + return LocalProgress( - inAsyncCall: _isLoading, - child: DefaultTabController( - length: 3, + inAsyncCall: _isLoading, child: Scaffold( appBar: AppBar( centerTitle: true, @@ -43,7 +43,7 @@ class _FcsShipmentListState extends State { onPressed: () => Navigator.of(context).pop(), ), backgroundColor: primaryColor, - title: LocalText(context, 'shipment.list.title', + title: LocalText(context, 'FCSshipment.list.title', color: Colors.white, fontSize: 20), actions: [ IconButton( @@ -55,99 +55,36 @@ class _FcsShipmentListState extends State { // onPressed: () => showPlacesSearch(context), ), ], - bottom: TabBar( - unselectedLabelColor: Colors.grey, - tabs: [ - Tab( - text: "Upcoming", - ), - Tab(text: "Completed"), - Tab(text: "Canceled"), - ], - ), ), floatingActionButton: FloatingActionButton.extended( onPressed: () { _newShipment(); }, icon: Icon(Icons.add), - label: Text(AppTranslations.of(context).text("shipment.add")), + label: LocalText(context, "FCSshipment.add", color: Colors.white), backgroundColor: primaryColor, ), - body: TabBarView( - children: [_upComing(), _completed(), _canceled()], - )), - ), - ); + body: Column( + children: [ + Expanded( + child: new ListView.separated( + separatorBuilder: (context, index) => Divider( + color: Colors.black, + ), + scrollDirection: Axis.vertical, + padding: EdgeInsets.only(top: 15), + shrinkWrap: true, + itemCount: shipmentModel.shipments.length, + itemBuilder: (BuildContext context, int index) { + return FcsShipmentListRow( + shipment: shipmentModel.shipments[index]); + }), + ), + ], + ))); } _newShipment() { Navigator.of(context).push(BottomUpPageRoute(FcsShipmentEditor())); } - - Widget _upComing() { - var shipmentModel = Provider.of(context); - return Column( - children: [ - Expanded( - child: new ListView.separated( - separatorBuilder: (context, index) => Divider( - color: Colors.black, - ), - scrollDirection: Axis.vertical, - padding: EdgeInsets.only(top: 15), - shrinkWrap: true, - itemCount: shipmentModel.upcoming.length, - itemBuilder: (BuildContext context, int index) { - return FcsShipmentListRow( - shipment: shipmentModel.upcoming[index]); - }), - ), - ], - ); - } - - Widget _completed() { - var shipmentModel = Provider.of(context); - return Column( - children: [ - Expanded( - child: new ListView.separated( - separatorBuilder: (context, index) => Divider( - color: Colors.black, - ), - scrollDirection: Axis.vertical, - padding: EdgeInsets.only(top: 15), - shrinkWrap: true, - itemCount: shipmentModel.completed.length, - itemBuilder: (BuildContext context, int index) { - return FcsShipmentListRow( - shipment: shipmentModel.completed[index]); - }), - ), - ], - ); - } - - Widget _canceled() { - var shipmentModel = Provider.of(context); - return Column( - children: [ - Expanded( - child: new ListView.separated( - separatorBuilder: (context, index) => Divider( - color: Colors.black, - ), - scrollDirection: Axis.vertical, - padding: EdgeInsets.only(top: 15), - shrinkWrap: true, - itemCount: shipmentModel.canceled.length, - itemBuilder: (BuildContext context, int index) { - return FcsShipmentListRow( - shipment: shipmentModel.canceled[index]); - }), - ), - ], - ); - } } diff --git a/lib/pages/main/home_page.dart b/lib/pages/main/home_page.dart index b89d13f..0999260 100644 --- a/lib/pages/main/home_page.dart +++ b/lib/pages/main/home_page.dart @@ -218,7 +218,7 @@ class _HomePageState extends State { btnCallback: () => Navigator.of(context).push(BottomUpPageRoute(ShipmentRates()))); - final fcsShipmentBtn = TaskButton("shipment.title", + final fcsShipmentBtn = TaskButton("FCSshipment.title", icon: Ionicons.ios_airplane, btnCallback: () => Navigator.of(context).push(BottomUpPageRoute(FcsShipmentList()))); diff --git a/lib/pages/widgets/display_text.dart b/lib/pages/widgets/display_text.dart index 9d074d8..456213c 100644 --- a/lib/pages/widgets/display_text.dart +++ b/lib/pages/widgets/display_text.dart @@ -1,4 +1,5 @@ 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'; @@ -45,7 +46,8 @@ class DisplayText extends StatelessWidget { iconData == null ? icon == null ? Container() : icon : Padding( - padding: const EdgeInsets.all(8.0), + padding: const EdgeInsets.only( + left: .0, right: 15.0, top: 8.0, bottom: 8.0), child: Icon( iconData, color: primaryColor, @@ -58,7 +60,7 @@ class DisplayText extends StatelessWidget { labelText == null ? Container() : Text( - labelText, + AppTranslations.of(context).text(labelText), style: labelStyle, ), Text( diff --git a/lib/pages/widgets/popupmenu.dart b/lib/pages/widgets/popupmenu.dart new file mode 100644 index 0000000..7cc6380 --- /dev/null +++ b/lib/pages/widgets/popupmenu.dart @@ -0,0 +1,14 @@ +import 'package:flutter/material.dart'; + +class PopupMenu { + int id; + String status; + PopupMenu({this.id, this.status}); +} + +List menuPopup = [ + PopupMenu(id: 1, status: "Download Commercial Invoice"), + PopupMenu(id: 2, status: "Download Packing List"), + PopupMenu(id: 3, status: "Download DMS"), + PopupMenu(id: 5, status: "Download Cargo Manifest"), +];