update shipment list and editor

This commit is contained in:
tzw
2024-01-30 17:24:28 +06:30
parent c9680ca3ca
commit a944357490
8 changed files with 152 additions and 156 deletions

View File

@@ -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<FcsShipmentEditor> {
var languageModel = Provider.of<LanguageModel>(context);
var mainModel = Provider.of<MainModel>(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<FcsShipmentEditor> {
Navigator.of(context).pop();
}
}),
body: Padding(
padding: const EdgeInsets.all(10.0),
child: ListView(children: <Widget>[
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: <Widget>[
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<FcsShipmentEditor> {
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<FcsShipmentEditor> {
await showMsgDialog(context, "Error", "Invalid ETA date!");
return false;
}
// if (fcsShipment.departureDate == null) {
// await showMsgDialog(context, "Error", "Invalid departure date!");
// return false;
// }
return true;
}

View File

@@ -44,6 +44,10 @@ class _FcsShipmentListState extends State<FcsShipmentList> {
final popupMenu = LocalPopupMenuButton(
popmenus: [
LocalPopupMenu(
id: 0,
textKey: "FCSshipment.popupmenu.all",
selected: shipmentModel.selectedIndex == 0),
LocalPopupMenu(
id: 1,
textKey: "FCSshipment.popupmenu.active",

View File

@@ -37,26 +37,26 @@ class FcsShipmentListRow extends StatelessWidget {
),
),
new Expanded(
child: new Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
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: <Widget>[
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),
),
)
],
),
),
),
],

View File

@@ -13,7 +13,7 @@ class FcsShipmentModel extends BaseModel {
final log = Logger('FcsShipmentModel');
PaginatorListener<FcsShipment>? fcsShipments;
bool isLoading = false;
int selectedIndex = 1;
int selectedIndex = 0;
onChanged(int index) {
selectedIndex = index;