From a94435749037283f96277b5733e45ab338e18b8e Mon Sep 17 00:00:00 2001 From: tzw Date: Tue, 30 Jan 2024 17:24:28 +0630 Subject: [PATCH] update shipment list and editor --- assets/local/localization_en.json | 19 ++- assets/local/localization_mu.json | 19 ++- .../fcs_shipment/fcs_shipment_editor.dart | 154 ++++++++---------- lib/pages/fcs_shipment/fcs_shipment_list.dart | 4 + .../fcs_shipment/fcs_shipment_list_row.dart | 32 ++-- .../model/fcs_shipment_model.dart | 2 +- lib/pages/widgets/input_date.dart | 17 +- lib/pages/widgets/local_button.dart | 61 +++---- 8 files changed, 152 insertions(+), 156 deletions(-) diff --git a/assets/local/localization_en.json b/assets/local/localization_en.json index c259096..d737581 100644 --- a/assets/local/localization_en.json +++ b/assets/local/localization_en.json @@ -319,11 +319,11 @@ "Delivery End ================================================================":"", "FCS Shipment Start ================================================================":"", - "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.title":"Shipments", + "FCSshipment.list.title":"Shipments", + "FCSshipment.add":"New shipment", + "FCSshipment.form.title":"Shipment", + "FCSshipment.number":"Shipment number", "FCSshipment.cutoff_date":"Cutoff date", "FCSshipment.ETA":"ETA", "FCSshipment.departure_date":"Departure date", @@ -337,12 +337,13 @@ "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", + "FCSshipment.create":"Create new shipment", + "FCSshipment.update":"Update shipment", "FCSshipment.ship.btn":"Ship", "FCSshipment.ship.confirm":"Confirm ship?", - "FCSshipment.popupmenu.active":"Active FCS shipments", - "FCSshipment.popupmenu.shipped":"Shipped FCS shipments", + "FCSshipment.popupmenu.all":"All shipments", + "FCSshipment.popupmenu.active":"Active shipments", + "FCSshipment.popupmenu.shipped":"Shipped shipments", "FCS Shipment End ================================================================":"", "Shipment Start ================================================================":"", diff --git a/assets/local/localization_mu.json b/assets/local/localization_mu.json index ba64207..e39520f 100644 --- a/assets/local/localization_mu.json +++ b/assets/local/localization_mu.json @@ -318,11 +318,11 @@ "Delivery End ================================================================":"", "FCS Shipment Start ================================================================":"", - "FCSshipment.title":"FCS တင်ပို့ခြင်းများ", - "FCSshipment.list.title":"FCS တင်ပို့ခြင်းများ", - "FCSshipment.add":"FCS တင်ပို့ခြင်းအသစ်", - "FCSshipment.form.title":"FCS တင်ပို့ခြင်း", - "FCSshipment.number":"FCS တင်ပို့နံပါတ်", + "FCSshipment.title":"တင်ပို့ခြင်းများ", + "FCSshipment.list.title":"တင်ပို့ခြင်းများ", + "FCSshipment.add":"တင်ပို့ခြင်းအသစ်", + "FCSshipment.form.title":"တင်ပို့ခြင်း", + "FCSshipment.number":"တင်ပို့နံပါတ်", "FCSshipment.cutoff_date":"သတ်မှတ်ရက်", "FCSshipment.ETA":"ခန့်မှန်းရောက်ချိန်", "FCSshipment.departure_date":"ထွက်ခွာသည့်ရက်", @@ -336,12 +336,13 @@ "FCSshipment.packing_list":"ထုပ်ပိုးစာရင်းကိုဒေါင်းမည်", "FCSshipment.dms":"DMS ကိုဒေါင်းမည်", "FCSshipment.cargo_manifest":"ကုန်ပစ္စည်းကိုဒေါင်းမည်", - "FCSshipment.create":"FCS တင်ပို့ခြင်းပြုလုပ်မည်", - "FCSshipment.update":"FCS တင်ပို့ခြင်းပြုပြင်မည်", + "FCSshipment.create":"တင်ပို့ခြင်းအသစ်ပြုလုပ်မည်", + "FCSshipment.update":"တင်ပို့ခြင်းပြုပြင်မည်", "FCSshipment.ship.btn":"Ship", "FCSshipment.ship.confirm":"Confirm ship?", - "FCSshipment.popupmenu.active":"Active FCS shipments", - "FCSshipment.popupmenu.shipped":"Shipped FCS shipments", + "FCSshipment.popupmenu.all":"All shipments", + "FCSshipment.popupmenu.active":"Active shipments", + "FCSshipment.popupmenu.shipped":"Shipped shipments", "FCS Shipment End ================================================================":"", "Shipment Start ================================================================":"", diff --git a/lib/pages/fcs_shipment/fcs_shipment_editor.dart b/lib/pages/fcs_shipment/fcs_shipment_editor.dart index 2e24371..5af5576 100644 --- a/lib/pages/fcs_shipment/fcs_shipment_editor.dart +++ b/lib/pages/fcs_shipment/fcs_shipment_editor.dart @@ -4,7 +4,6 @@ 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_date.dart'; import 'package:fcs/pages/widgets/input_text.dart'; import 'package:fcs/pages/widgets/local_app_bar.dart'; @@ -79,21 +78,27 @@ class _FcsShipmentEditorState extends State { var languageModel = Provider.of(context); var mainModel = Provider.of(context); - final createBtn = LocalButton( - textKey: "FCSshipment.create", - callBack: _create, + final createBtn = Padding( + padding: const EdgeInsets.symmetric(horizontal: 30), + child: LocalButton( + textKey: "FCSshipment.create", + callBack: _create, + ), ); - final updateBtn = LocalButton( - textKey: "FCSshipment.update", - callBack: _update, + final updateBtn = Padding( + padding: const EdgeInsets.symmetric(horizontal: 30), + child: LocalButton( + textKey: "FCSshipment.update", + callBack: _update, + ), ); return LocalProgress( inAsyncCall: _isLoading, child: Scaffold( appBar: LocalAppBar( - labelKey: "FCSshipment.form.title", + labelKey: _isNew ? "FCSshipment.add" : "FCSshipment.form.title", backgroundColor: Colors.white, labelColor: primaryColor, arrowColor: primaryColor, @@ -106,75 +111,63 @@ class _FcsShipmentEditorState extends State { Navigator.of(context).pop(); } }), - body: Padding( - padding: const EdgeInsets.all(10.0), - child: ListView(children: [ - InputText( - labelTextKey: "FCSshipment.number", - iconData: Ionicons.ios_airplane, - controller: _shipmentNumberController, - ), - InputDate( - labelTextKey: "FCSshipment.cutoff_date", - iconData: Icons.date_range, - controller: _cutoffDateController, - ), - // InputDate( - // labelTextKey: "FCSshipment.departure_date", - // iconData: Icons.date_range, - // controller: _departureDateControler, - // ), - InputDate( - labelTextKey: "FCSshipment.ETA", - iconData: Icons.date_range, - controller: _arrivalDateController, - ), - DropdownButtonFormField( - value: _currentShipmentType == "" ? null : _currentShipmentType, - decoration: InputDecoration( - enabledBorder: UnderlineInputBorder( - borderSide: BorderSide(color: primaryColor)), - fillColor: Colors.white, - 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)), - items: mainModel.setting!.shipmentTypes - .map((e) => DropdownMenuItem(child: Text(e), value: e)) - .toList(), - onChanged: (String? selected) => { - setState(() { - _currentShipmentType = selected; - }) - }, - ), - InputText( - labelTextKey: 'FCSshipment.consignee', - iconData: Icons.work, - controller: _consigneeController), - InputText( - labelTextKey: 'FCSshipment.port_of_loading', - iconData: FontAwesomeIcons.ship, - controller: _portController), - InputText( - labelTextKey: 'FCSshipment.final_destination', - iconData: MaterialCommunityIcons.location_enter, - controller: _destinationController), - _isNew - ? Container() - : Container( - padding: EdgeInsets.only(top: 5), - child: DisplayText( - text: _statusController.text, - iconData: Icons.av_timer, - labelTextKey: 'FCSshipment.status', - )), - _isNew ? createBtn : updateBtn, - SizedBox(height: 15) - ]), - ), + body: ListView( + padding: const EdgeInsets.only(left: 10, right: 10), + children: [ + InputText( + labelTextKey: "FCSshipment.number", + iconData: Ionicons.ios_airplane, + controller: _shipmentNumberController, + ), + InputDate( + labelTextKey: "FCSshipment.cutoff_date", + iconData: Icons.date_range, + controller: _cutoffDateController, + ), + InputDate( + labelTextKey: "FCSshipment.ETA", + iconData: Icons.date_range, + controller: _arrivalDateController, + ), + DropdownButtonFormField( + value: _currentShipmentType == "" ? null : _currentShipmentType, + decoration: InputDecoration( + enabledBorder: UnderlineInputBorder( + borderSide: BorderSide(color: primaryColor)), + focusedBorder: UnderlineInputBorder( + borderSide: BorderSide(color: primaryColor)), + fillColor: Colors.white, + 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)), + items: mainModel.setting!.shipmentTypes + .map((e) => DropdownMenuItem(child: Text(e), value: e)) + .toList(), + onChanged: (String? selected) => { + setState(() { + _currentShipmentType = selected; + }) + }, + ), + InputText( + labelTextKey: 'FCSshipment.consignee', + iconData: Icons.work, + controller: _consigneeController), + InputText( + labelTextKey: 'FCSshipment.port_of_loading', + iconData: FontAwesomeIcons.ship, + controller: _portController), + InputText( + labelTextKey: 'FCSshipment.final_destination', + iconData: MaterialCommunityIcons.location_enter, + controller: _destinationController), + SizedBox(height: 20), + _isNew ? createBtn : updateBtn, + SizedBox(height: 15) + ]), ), ); } @@ -190,13 +183,10 @@ class _FcsShipmentEditorState extends State { try { var cutoffDate = _cutoffDateController.text; var arrivalDate = _arrivalDateController.text; - // var depDate = _departureDateControler.text; fcsShipment.cutoffDate = (cutoffDate == "" ? null : dateFormatter.parse(cutoffDate))!; fcsShipment.arrivalDate = (arrivalDate == "" ? null : dateFormatter.parse(arrivalDate))!; - // fcsShipment.departureDate = - // depDate == "" ? null : dateFormatter.parse(depDate); } catch (e) { // showMsgDialog(context, "Error", e.toString()); // shold never happen } @@ -220,10 +210,6 @@ class _FcsShipmentEditorState extends State { await showMsgDialog(context, "Error", "Invalid ETA date!"); return false; } - // if (fcsShipment.departureDate == null) { - // await showMsgDialog(context, "Error", "Invalid departure date!"); - // return false; - // } return true; } diff --git a/lib/pages/fcs_shipment/fcs_shipment_list.dart b/lib/pages/fcs_shipment/fcs_shipment_list.dart index bfa3ac3..920553b 100644 --- a/lib/pages/fcs_shipment/fcs_shipment_list.dart +++ b/lib/pages/fcs_shipment/fcs_shipment_list.dart @@ -44,6 +44,10 @@ class _FcsShipmentListState extends State { final popupMenu = LocalPopupMenuButton( popmenus: [ + LocalPopupMenu( + id: 0, + textKey: "FCSshipment.popupmenu.all", + selected: shipmentModel.selectedIndex == 0), LocalPopupMenu( id: 1, textKey: "FCSshipment.popupmenu.active", diff --git a/lib/pages/fcs_shipment/fcs_shipment_list_row.dart b/lib/pages/fcs_shipment/fcs_shipment_list_row.dart index b16e410..c867fd7 100644 --- a/lib/pages/fcs_shipment/fcs_shipment_list_row.dart +++ b/lib/pages/fcs_shipment/fcs_shipment_list_row.dart @@ -37,26 +37,26 @@ class FcsShipmentListRow extends StatelessWidget { ), ), new Expanded( - child: new Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Padding( - padding: const EdgeInsets.only(left: 8.0), - child: new Text( + child: Padding( + padding: const EdgeInsets.only(left: 8.0), + child: new Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + new Text( shipment?.shipmentNumber ?? '', style: new TextStyle( fontSize: 15.0, color: Colors.black), ), - ), - Padding( - padding: const EdgeInsets.only(left: 10.0, top: 10), - child: new Text( - dateFormatter.format(shipment!.cutoffDate!), - style: new TextStyle( - fontSize: 15.0, color: Colors.grey), - ), - ) - ], + Padding( + padding: const EdgeInsets.only(top: 5), + child: new Text( + dateFormatter.format(shipment!.cutoffDate!), + style: new TextStyle( + fontSize: 15.0, color: Colors.grey), + ), + ) + ], + ), ), ), ], diff --git a/lib/pages/fcs_shipment/model/fcs_shipment_model.dart b/lib/pages/fcs_shipment/model/fcs_shipment_model.dart index 18b92a8..26f501e 100644 --- a/lib/pages/fcs_shipment/model/fcs_shipment_model.dart +++ b/lib/pages/fcs_shipment/model/fcs_shipment_model.dart @@ -13,7 +13,7 @@ class FcsShipmentModel extends BaseModel { final log = Logger('FcsShipmentModel'); PaginatorListener? fcsShipments; bool isLoading = false; - int selectedIndex = 1; + int selectedIndex = 0; onChanged(int index) { selectedIndex = index; diff --git a/lib/pages/widgets/input_date.dart b/lib/pages/widgets/input_date.dart index ad88be5..095f822 100644 --- a/lib/pages/widgets/input_date.dart +++ b/lib/pages/widgets/input_date.dart @@ -53,8 +53,23 @@ class InputDate extends StatelessWidget { firstDate: DateTime(0), lastDate: DateTime(2025), initialDate: initialDate, + builder: (context, child) { + return Theme( + data: Theme.of(context).copyWith( + colorScheme: ColorScheme.light( + background: primaryColor, + surfaceTint: Colors.white, + primary: primaryColor), + textButtonTheme: TextButtonThemeData( + style: + TextButton.styleFrom(foregroundColor: primaryColor), + ), + ), + child: child!, + ); + }, ); - if (d != null && controller.text != "") { + if (d != null) { controller.text = dateFormatter.format(d); } }, diff --git a/lib/pages/widgets/local_button.dart b/lib/pages/widgets/local_button.dart index 00ca51f..9787734 100644 --- a/lib/pages/widgets/local_button.dart +++ b/lib/pages/widgets/local_button.dart @@ -20,42 +20,31 @@ class LocalButton extends StatelessWidget { @override Widget build(BuildContext context) { - return Container( - padding: EdgeInsets.only(left: 10, right: 10, top: 10), - child: Container( - height: 45.0, - decoration: BoxDecoration( - color: color, - shape: BoxShape.rectangle, - ), - child: ButtonTheme( - minWidth: 900.0, - height: 100.0, - child: TextButton( - onPressed: callBack == null ? null : () => callBack!(), - child: Row( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - iconData == null - ? Container() - : Icon( - iconData, - color: Colors.white, - ), - SizedBox( - width: 15, - ), - LocalText( - context, - textKey!, - color: Colors.white, - fontSize: 16, - ), - ], + return ElevatedButton( + style: ElevatedButton.styleFrom( + backgroundColor: color, + shape: + RoundedRectangleBorder(borderRadius: BorderRadius.circular(5))), + onPressed: callBack, + child: Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + iconData == null + ? Container() + : Icon( + iconData, + color: Colors.white, + ), + SizedBox( + width: 15, ), - ), - ), - ), - ); + LocalText( + context, + textKey!, + color: Colors.white, + fontSize: 16, + ), + ], + )); } }