2020-06-01 14:24:45 +06:30
|
|
|
import 'package:fcs/model/main_model.dart';
|
|
|
|
|
import 'package:fcs/model/shipment_model.dart';
|
|
|
|
|
import 'package:fcs/pages/util.dart';
|
|
|
|
|
import 'package:fcs/vo/shipment.dart';
|
|
|
|
|
import 'package:fcs/vo/user.dart';
|
|
|
|
|
import 'package:fcs/widget/label_widgets.dart';
|
|
|
|
|
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:fcs/widget/localization/app_translations.dart';
|
|
|
|
|
|
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
import 'package:fcs/widget/progress.dart';
|
|
|
|
|
|
|
|
|
|
import '../theme/theme.dart';
|
|
|
|
|
|
|
|
|
|
class ShipmentEditor extends StatefulWidget {
|
|
|
|
|
final Shipment shipment;
|
|
|
|
|
ShipmentEditor({this.shipment});
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
_ShipmentEditorState createState() => _ShipmentEditorState();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class _ShipmentEditorState extends State<ShipmentEditor> {
|
|
|
|
|
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();
|
|
|
|
|
|
|
|
|
|
Shipment _shipment = new Shipment();
|
|
|
|
|
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 _showCustomerData(User customer) {
|
|
|
|
|
return Column(
|
|
|
|
|
children: <Widget>[
|
|
|
|
|
Padding(
|
|
|
|
|
padding: const EdgeInsets.only(left: 10.0, top: 8),
|
|
|
|
|
child: Text(
|
|
|
|
|
customer.name,
|
|
|
|
|
style: TextStyle(
|
|
|
|
|
color: Colors.black87,
|
|
|
|
|
fontSize: 18,
|
|
|
|
|
fontWeight: FontWeight.bold),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
Padding(
|
|
|
|
|
padding: const EdgeInsets.only(left: 10.0, top: 8),
|
|
|
|
|
child: Text(
|
|
|
|
|
customer.phoneNumber,
|
|
|
|
|
style: TextStyle(
|
|
|
|
|
color: Colors.black87,
|
|
|
|
|
fontSize: 18,
|
|
|
|
|
fontWeight: FontWeight.bold),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
widget.shipment == null
|
|
|
|
|
? Container()
|
|
|
|
|
: Padding(
|
|
|
|
|
padding: const EdgeInsets.only(left: 10.0, top: 8),
|
|
|
|
|
child: Text(
|
|
|
|
|
_shipmentNumberController.text,
|
|
|
|
|
style: TextStyle(
|
|
|
|
|
color: Colors.black87,
|
2020-06-02 14:56:51 +06:30
|
|
|
fontSize: 15,
|
2020-06-01 14:24:45 +06:30
|
|
|
fontWeight: FontWeight.bold),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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"),
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Widget showShipmentTypes(BuildContext context, ShipmentModel shipmentModel) {
|
|
|
|
|
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) {
|
|
|
|
|
var shipmentModel = Provider.of<ShipmentModel>(context);
|
|
|
|
|
MainModel mainModel = Provider.of<MainModel>(context);
|
|
|
|
|
|
|
|
|
|
final commercialBtn = Container(
|
|
|
|
|
padding: EdgeInsets.only(top: 20),
|
|
|
|
|
child: Align(
|
|
|
|
|
alignment: Alignment.bottomCenter,
|
|
|
|
|
child: Center(
|
|
|
|
|
child: Container(
|
|
|
|
|
width: 250,
|
|
|
|
|
child: FlatButton(
|
2020-06-02 14:56:51 +06:30
|
|
|
child: Text('Download Commercial Invoice'),
|
2020-06-01 14:24:45 +06:30
|
|
|
color: primaryColor,
|
|
|
|
|
textColor: Colors.white,
|
|
|
|
|
onPressed: () {
|
|
|
|
|
Navigator.pop(context);
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
))),
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
final packingBtn = Container(
|
|
|
|
|
padding: EdgeInsets.only(top: 5),
|
|
|
|
|
child: Align(
|
|
|
|
|
alignment: Alignment.bottomCenter,
|
|
|
|
|
child: Center(
|
|
|
|
|
child: Container(
|
|
|
|
|
width: 250,
|
|
|
|
|
child: FlatButton(
|
2020-06-02 14:56:51 +06:30
|
|
|
child: Text('Download Packing List'),
|
2020-06-01 14:24:45 +06:30
|
|
|
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(
|
2020-06-02 14:56:51 +06:30
|
|
|
child: Text('Create Shipment'),
|
2020-06-01 14:24:45 +06:30
|
|
|
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(
|
2020-06-02 14:56:51 +06:30
|
|
|
child: Text('Update Shipment'),
|
2020-06-01 14:24:45 +06:30
|
|
|
color: primaryColor,
|
|
|
|
|
textColor: Colors.white,
|
|
|
|
|
onPressed: () {
|
|
|
|
|
Navigator.pop(context);
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
))),
|
|
|
|
|
);
|
|
|
|
|
return LocalProgress(
|
|
|
|
|
inAsyncCall: _isLoading,
|
|
|
|
|
child: Scaffold(
|
|
|
|
|
appBar: AppBar(
|
|
|
|
|
centerTitle: true,
|
|
|
|
|
leading: new IconButton(
|
|
|
|
|
icon: new Icon(Icons.close),
|
|
|
|
|
onPressed: () => Navigator.of(context).pop(),
|
|
|
|
|
),
|
|
|
|
|
backgroundColor: primaryColor,
|
|
|
|
|
title: Text(AppTranslations.of(context).text("shipment.form.title")),
|
|
|
|
|
),
|
|
|
|
|
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-06-02 14:56:51 +06:30
|
|
|
? fcsInput('Shipment Number', Icons.text_rotation_none,
|
2020-06-01 14:24:45 +06:30
|
|
|
controller: _shipmentNumberController)
|
2020-06-02 14:56:51 +06:30
|
|
|
: Container(
|
|
|
|
|
child: TextFormField(
|
|
|
|
|
controller: _shipmentNumberController,
|
|
|
|
|
readOnly: true,
|
|
|
|
|
decoration: InputDecoration(
|
|
|
|
|
fillColor: Colors.white,
|
|
|
|
|
labelText: 'Shipment Number',
|
|
|
|
|
labelStyle:
|
|
|
|
|
TextStyle(fontSize: 16, color: Colors.grey),
|
|
|
|
|
filled: true,
|
|
|
|
|
enabledBorder: InputBorder.none,
|
|
|
|
|
focusedBorder: InputBorder.none,
|
|
|
|
|
icon: Icon(
|
|
|
|
|
Icons.text_rotation_none,
|
|
|
|
|
color: Colors.grey,
|
|
|
|
|
),
|
|
|
|
|
)),
|
|
|
|
|
),
|
2020-06-01 14:24:45 +06:30
|
|
|
widget.shipment == null
|
|
|
|
|
? Container(
|
2020-06-02 14:56:51 +06:30
|
|
|
padding: EdgeInsets.only(top: 5),
|
|
|
|
|
child: fcsInput('Cutoff Date', Icons.date_range,
|
2020-06-01 14:24:45 +06:30
|
|
|
controller: _cutoffDateController),
|
|
|
|
|
)
|
|
|
|
|
: Container(),
|
|
|
|
|
widget.shipment == null
|
|
|
|
|
? Container(
|
2020-06-02 14:56:51 +06:30
|
|
|
padding: EdgeInsets.only(top: 5),
|
|
|
|
|
child: DropdownButtonFormField(
|
|
|
|
|
decoration: InputDecoration(
|
|
|
|
|
fillColor: Colors.white,
|
|
|
|
|
labelText: 'Shipment Type',
|
|
|
|
|
icon: Icon(Icons.pages)),
|
|
|
|
|
items: shipmentModel.shipmentType
|
|
|
|
|
.map((e) =>
|
|
|
|
|
DropdownMenuItem(child: Text(e), value: e))
|
|
|
|
|
.toList(),
|
|
|
|
|
onChanged: (selected) => {
|
|
|
|
|
setState(() {
|
|
|
|
|
_currentShipment = selected;
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
)
|
2020-06-01 14:24:45 +06:30
|
|
|
: Container(),
|
|
|
|
|
Container(
|
2020-06-02 14:56:51 +06:30
|
|
|
padding:
|
|
|
|
|
EdgeInsets.only(top: widget.shipment == null ? 5 : 0),
|
|
|
|
|
child: fcsInput('Arrival Date', Icons.date_range,
|
2020-06-01 14:24:45 +06:30
|
|
|
controller: _arrivalDateController),
|
|
|
|
|
),
|
|
|
|
|
Container(
|
2020-06-02 14:56:51 +06:30
|
|
|
padding: EdgeInsets.only(top: 5),
|
|
|
|
|
child: fcsInput('Departure Date', Icons.date_range,
|
2020-06-01 14:24:45 +06:30
|
|
|
controller: _departureDateControler),
|
|
|
|
|
),
|
|
|
|
|
widget.shipment == null
|
|
|
|
|
? Container(
|
2020-06-02 14:56:51 +06:30
|
|
|
padding: EdgeInsets.only(top: 5),
|
2020-06-01 14:24:45 +06:30
|
|
|
child: fcsInput('Consignee', Icons.work,
|
|
|
|
|
controller: _consigneeController),
|
|
|
|
|
)
|
|
|
|
|
: Container(),
|
|
|
|
|
widget.shipment == null
|
|
|
|
|
? Container(
|
2020-06-02 14:56:51 +06:30
|
|
|
padding: EdgeInsets.only(top: 5),
|
2020-06-01 14:24:45 +06:30
|
|
|
child: fcsInput(
|
2020-06-02 14:56:51 +06:30
|
|
|
'Port of Loading', FontAwesomeIcons.ship,
|
2020-06-01 14:24:45 +06:30
|
|
|
controller: _portController),
|
|
|
|
|
)
|
|
|
|
|
: Container(),
|
|
|
|
|
widget.shipment == null
|
|
|
|
|
? Container(
|
2020-06-02 14:56:51 +06:30
|
|
|
padding: EdgeInsets.only(top: 5),
|
|
|
|
|
child: fcsInput('Final Destination',
|
2020-06-01 14:24:45 +06:30
|
|
|
MaterialCommunityIcons.location_enter,
|
|
|
|
|
controller: _destinationController),
|
|
|
|
|
)
|
|
|
|
|
: Container(),
|
|
|
|
|
widget.shipment == null
|
|
|
|
|
? Container()
|
2020-06-02 14:56:51 +06:30
|
|
|
: 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: Image.asset(
|
|
|
|
|
'assets/status.png',
|
|
|
|
|
width: 24,
|
|
|
|
|
height: 24,
|
|
|
|
|
color: Colors.grey[700],
|
|
|
|
|
),
|
|
|
|
|
)),
|
2020-06-01 14:24:45 +06:30
|
|
|
),
|
|
|
|
|
widget.shipment == null
|
|
|
|
|
? Container()
|
|
|
|
|
: Container(
|
2020-06-02 14:56:51 +06:30
|
|
|
padding: EdgeInsets.only(top: 5),
|
2020-06-01 14:24:45 +06:30
|
|
|
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 ? createBtn : updateBtn,
|
|
|
|
|
SizedBox(height: 15)
|
|
|
|
|
]),
|
|
|
|
|
)),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|