update shipment list and editor
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user