2020-10-07 14:42:07 +06:30
|
|
|
import 'package:fcs/domain/entities/fcs_shipment.dart';
|
2020-10-07 02:33:06 +06:30
|
|
|
import 'package:fcs/helpers/theme.dart';
|
|
|
|
|
import 'package:fcs/localization/app_translations.dart';
|
|
|
|
|
import 'package:fcs/pages/fcs_shipment/model/fcs_shipment_model.dart';
|
2020-10-07 18:19:12 +06:30
|
|
|
import 'package:fcs/pages/main/model/language_model.dart';
|
2020-10-07 02:33:06 +06:30
|
|
|
import 'package:fcs/pages/main/model/main_model.dart';
|
2020-10-07 18:19:12 +06:30
|
|
|
import 'package:fcs/pages/widgets/display_text.dart';
|
|
|
|
|
import 'package:fcs/pages/widgets/input_text.dart';
|
2020-10-07 02:33:06 +06:30
|
|
|
import 'package:fcs/pages/widgets/label_widgets.dart';
|
2020-10-07 18:19:12 +06:30
|
|
|
import 'package:fcs/pages/widgets/local_text.dart';
|
|
|
|
|
import 'package:fcs/pages/widgets/popupmenu.dart';
|
2020-10-07 02:33:06 +06:30
|
|
|
import 'package:fcs/pages/widgets/progress.dart';
|
2020-06-01 14:24:45 +06:30
|
|
|
import 'package:flutter_icons/flutter_icons.dart';
|
|
|
|
|
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
|
|
|
|
|
import 'package:intl/intl.dart';
|
|
|
|
|
import 'package:provider/provider.dart';
|
|
|
|
|
|
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
|
2020-10-07 02:33:06 +06:30
|
|
|
import '../main/util.dart';
|
2020-06-01 14:24:45 +06:30
|
|
|
|
2020-10-07 02:33:06 +06:30
|
|
|
class FcsShipmentEditor extends StatefulWidget {
|
2020-10-07 14:42:07 +06:30
|
|
|
final FcsShipment shipment;
|
2020-10-07 02:33:06 +06:30
|
|
|
FcsShipmentEditor({this.shipment});
|
2020-06-01 14:24:45 +06:30
|
|
|
|
|
|
|
|
@override
|
2020-10-07 02:33:06 +06:30
|
|
|
_FcsShipmentEditorState createState() => _FcsShipmentEditorState();
|
2020-06-01 14:24:45 +06:30
|
|
|
}
|
|
|
|
|
|
2020-10-07 02:33:06 +06:30
|
|
|
class _FcsShipmentEditorState extends State<FcsShipmentEditor> {
|
2020-06-01 14:24:45 +06:30
|
|
|
var dateFormatter = new DateFormat('dd MMM yyyy');
|
|
|
|
|
TextEditingController _shipmentNumberController = new TextEditingController();
|
|
|
|
|
TextEditingController _cutoffDateController = new TextEditingController();
|
|
|
|
|
TextEditingController _arrivalDateController = new TextEditingController();
|
|
|
|
|
TextEditingController _departureDateControler = new TextEditingController();
|
|
|
|
|
TextEditingController _consigneeController = new TextEditingController();
|
|
|
|
|
TextEditingController _portController = new TextEditingController();
|
|
|
|
|
TextEditingController _destinationController = new TextEditingController();
|
|
|
|
|
TextEditingController _statusController = new TextEditingController();
|
|
|
|
|
TextEditingController _remarkController = new TextEditingController();
|
|
|
|
|
|
2020-10-07 14:42:07 +06:30
|
|
|
FcsShipment _shipment = new FcsShipment();
|
2020-06-01 14:24:45 +06:30
|
|
|
bool _isLoading = false;
|
|
|
|
|
String _currentShipment;
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
void initState() {
|
|
|
|
|
super.initState();
|
|
|
|
|
if (widget.shipment != null) {
|
|
|
|
|
_shipment = widget.shipment;
|
|
|
|
|
_shipmentNumberController.text = _shipment.shipmentNumber;
|
|
|
|
|
_arrivalDateController.text = dateFormatter.format(_shipment.arrivalDate);
|
|
|
|
|
_departureDateControler.text =
|
|
|
|
|
dateFormatter.format(_shipment.departureDate);
|
|
|
|
|
_statusController.text = _shipment.status;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
void dispose() {
|
|
|
|
|
super.dispose();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Widget showShipmentNumber(BuildContext context) {
|
|
|
|
|
return Container(
|
|
|
|
|
padding: EdgeInsets.only(top: 10),
|
|
|
|
|
child: Row(
|
|
|
|
|
children: <Widget>[
|
|
|
|
|
Icon(Icons.text_rotation_none),
|
|
|
|
|
Padding(
|
|
|
|
|
padding: const EdgeInsets.only(right: 8.0),
|
|
|
|
|
child: labeledText(
|
|
|
|
|
context, _shipmentNumberController.text, "shipment.number"),
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
2020-10-07 02:33:06 +06:30
|
|
|
Widget showShipmentTypes(
|
|
|
|
|
BuildContext context, FcsShipmentModel shipmentModel) {
|
2020-06-01 14:24:45 +06:30
|
|
|
return Row(
|
|
|
|
|
mainAxisSize: MainAxisSize.max,
|
|
|
|
|
children: <Widget>[
|
|
|
|
|
Icon(MaterialCommunityIcons.box_shadow),
|
|
|
|
|
SizedBox(
|
|
|
|
|
width: 10,
|
|
|
|
|
),
|
|
|
|
|
new Flexible(
|
|
|
|
|
child: Container(
|
|
|
|
|
width: 200.0,
|
|
|
|
|
child: DropdownButton<String>(
|
|
|
|
|
value: _currentShipment,
|
|
|
|
|
isExpanded: true,
|
|
|
|
|
hint: Text(
|
|
|
|
|
'Select shipment type',
|
|
|
|
|
),
|
|
|
|
|
onChanged: changedDropDown,
|
|
|
|
|
items: shipmentModel.shipmentType
|
|
|
|
|
.map<DropdownMenuItem<String>>((String shipment) {
|
|
|
|
|
return new DropdownMenuItem<String>(
|
|
|
|
|
value: shipment,
|
|
|
|
|
child: new Text(shipment,
|
|
|
|
|
style:
|
|
|
|
|
new TextStyle(color: Colors.black87, fontSize: 17)),
|
|
|
|
|
);
|
|
|
|
|
}).toList(),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void changedDropDown(selected) {
|
|
|
|
|
setState(() {
|
|
|
|
|
_currentShipment = selected;
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
Widget build(BuildContext context) {
|
2020-10-07 02:33:06 +06:30
|
|
|
var shipmentModel = Provider.of<FcsShipmentModel>(context);
|
2020-10-07 18:19:12 +06:30
|
|
|
var languageModel = Provider.of<LanguageModel>(context);
|
2020-06-01 14:24:45 +06:30
|
|
|
|
2020-10-07 18:19:12 +06:30
|
|
|
final createBtn = fcsButton(
|
|
|
|
|
context,
|
|
|
|
|
getLocalString(context, "FCSshipment.create"),
|
2020-06-01 14:24:45 +06:30
|
|
|
);
|
|
|
|
|
|
2020-10-07 18:19:12 +06:30
|
|
|
final updateBtn = fcsButton(
|
|
|
|
|
context,
|
|
|
|
|
getLocalString(context, "FCSshipment.update"),
|
2020-06-01 14:24:45 +06:30
|
|
|
);
|
|
|
|
|
|
|
|
|
|
return LocalProgress(
|
|
|
|
|
inAsyncCall: _isLoading,
|
|
|
|
|
child: Scaffold(
|
|
|
|
|
appBar: AppBar(
|
|
|
|
|
centerTitle: true,
|
2020-10-07 18:19:12 +06:30
|
|
|
shadowColor: Colors.transparent,
|
2020-06-01 14:24:45 +06:30
|
|
|
leading: new IconButton(
|
2020-10-07 18:19:12 +06:30
|
|
|
icon: new Icon(Icons.close, color: primaryColor),
|
2020-06-01 14:24:45 +06:30
|
|
|
onPressed: () => Navigator.of(context).pop(),
|
|
|
|
|
),
|
2020-10-07 18:19:12 +06:30
|
|
|
backgroundColor: Colors.white,
|
|
|
|
|
title: LocalText(
|
|
|
|
|
context,
|
|
|
|
|
"FCSshipment.form.title",
|
|
|
|
|
color: primaryColor,
|
|
|
|
|
fontSize: 18,
|
|
|
|
|
),
|
|
|
|
|
actions: [menuPopWidget(context)],
|
2020-06-01 14:24:45 +06:30
|
|
|
),
|
|
|
|
|
body: Card(
|
|
|
|
|
child: Column(
|
|
|
|
|
children: <Widget>[
|
|
|
|
|
Expanded(
|
|
|
|
|
child: Padding(
|
|
|
|
|
padding: const EdgeInsets.all(10.0),
|
|
|
|
|
child: ListView(children: <Widget>[
|
2020-06-02 14:56:51 +06:30
|
|
|
// _showCustomerData(mainModel.customer),
|
2020-06-01 14:24:45 +06:30
|
|
|
widget.shipment == null
|
2020-10-07 18:19:12 +06:30
|
|
|
? InputText(
|
|
|
|
|
labelTextKey: "FCSshipment.number",
|
|
|
|
|
iconData: Ionicons.ios_airplane,
|
|
|
|
|
controller: _shipmentNumberController,
|
|
|
|
|
)
|
|
|
|
|
: DisplayText(
|
|
|
|
|
iconData: Ionicons.ios_airplane,
|
|
|
|
|
labelText: "FCSshipment.number",
|
|
|
|
|
text: _shipmentNumberController.text),
|
|
|
|
|
|
2020-06-01 14:24:45 +06:30
|
|
|
widget.shipment == null
|
2020-10-07 18:19:12 +06:30
|
|
|
? InputText(
|
|
|
|
|
labelTextKey: "FCSshipment.cutoff_date",
|
|
|
|
|
iconData: Icons.date_range,
|
|
|
|
|
controller: _cutoffDateController,
|
2020-06-01 14:24:45 +06:30
|
|
|
)
|
|
|
|
|
: Container(),
|
2020-10-07 18:19:12 +06:30
|
|
|
|
|
|
|
|
InputText(
|
|
|
|
|
labelTextKey: "FCSshipment.ETA",
|
|
|
|
|
iconData: Icons.date_range,
|
|
|
|
|
controller: _arrivalDateController,
|
2020-06-03 00:42:31 +06:30
|
|
|
),
|
2020-10-07 18:19:12 +06:30
|
|
|
|
|
|
|
|
InputText(
|
|
|
|
|
labelTextKey: "FCSshipment.departure_date",
|
|
|
|
|
iconData: Icons.date_range,
|
|
|
|
|
controller: _departureDateControler,
|
2020-06-03 00:42:31 +06:30
|
|
|
),
|
2020-06-01 14:24:45 +06:30
|
|
|
widget.shipment == null
|
2020-10-07 18:19:12 +06:30
|
|
|
? 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;
|
|
|
|
|
})
|
|
|
|
|
},
|
2020-06-02 14:56:51 +06:30
|
|
|
)
|
2020-06-01 14:24:45 +06:30
|
|
|
: Container(),
|
2020-06-03 00:42:31 +06:30
|
|
|
|
2020-06-01 14:24:45 +06:30
|
|
|
widget.shipment == null
|
2020-10-07 18:19:12 +06:30
|
|
|
? InputText(
|
|
|
|
|
labelTextKey: 'FCSshipment.consignee',
|
|
|
|
|
iconData: Icons.work,
|
|
|
|
|
controller: _consigneeController)
|
2020-06-01 14:24:45 +06:30
|
|
|
: Container(),
|
|
|
|
|
widget.shipment == null
|
2020-10-07 18:19:12 +06:30
|
|
|
? InputText(
|
|
|
|
|
labelTextKey: 'FCSshipment.port_of_loading',
|
|
|
|
|
iconData: FontAwesomeIcons.ship,
|
|
|
|
|
controller: _portController)
|
2020-06-01 14:24:45 +06:30
|
|
|
: Container(),
|
|
|
|
|
widget.shipment == null
|
2020-10-07 18:19:12 +06:30
|
|
|
? InputText(
|
|
|
|
|
labelTextKey: 'FCSshipment.final_destination',
|
|
|
|
|
iconData: MaterialCommunityIcons.location_enter,
|
|
|
|
|
controller: _destinationController)
|
2020-06-01 14:24:45 +06:30
|
|
|
: Container(),
|
|
|
|
|
widget.shipment == null
|
|
|
|
|
? Container()
|
2020-06-02 14:56:51 +06:30
|
|
|
: Container(
|
|
|
|
|
padding: EdgeInsets.only(top: 5),
|
2020-10-07 18:19:12 +06:30
|
|
|
child: DisplayText(
|
|
|
|
|
text: _statusController.text,
|
|
|
|
|
iconData: Icons.av_timer,
|
|
|
|
|
labelText: 'FCSshipment.status',
|
|
|
|
|
)),
|
|
|
|
|
|
2020-06-01 14:24:45 +06:30
|
|
|
widget.shipment == null
|
|
|
|
|
? Container()
|
2020-10-07 18:19:12 +06:30
|
|
|
: InputText(
|
|
|
|
|
labelTextKey: 'FCSshipment.remark',
|
|
|
|
|
iconData: MaterialCommunityIcons.note,
|
|
|
|
|
controller: _remarkController),
|
2020-06-01 14:24:45 +06:30
|
|
|
]),
|
|
|
|
|
)),
|
2020-10-07 18:19:12 +06:30
|
|
|
widget.shipment == null ? createBtn : updateBtn,
|
|
|
|
|
SizedBox(height: 15)
|
2020-06-01 14:24:45 +06:30
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
}
|
2020-10-07 18:19:12 +06:30
|
|
|
|
|
|
|
|
Widget menuPopWidget(BuildContext context) {
|
|
|
|
|
return PopupMenuButton<PopupMenu>(
|
|
|
|
|
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<PopupMenu> menuPopup = <PopupMenu>[
|
|
|
|
|
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<PopupMenu>(
|
|
|
|
|
value: choice,
|
|
|
|
|
child: Row(
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
|
children: <Widget>[
|
|
|
|
|
Container(
|
|
|
|
|
padding: EdgeInsets.only(left: 15),
|
|
|
|
|
child: LocalText(
|
|
|
|
|
context,
|
|
|
|
|
choice.status,
|
|
|
|
|
color: primaryColor,
|
|
|
|
|
)),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
}).toList();
|
|
|
|
|
});
|
|
|
|
|
}
|
2020-06-01 14:24:45 +06:30
|
|
|
}
|