clean up
This commit is contained in:
370
lib/pages/fcs_shipment/fcs_shipment_editor.dart
Normal file
370
lib/pages/fcs_shipment/fcs_shipment_editor.dart
Normal file
@@ -0,0 +1,370 @@
|
||||
import 'package:fcs/domain/entities/shipment.dart';
|
||||
import 'package:fcs/helpers/theme.dart';
|
||||
import 'package:fcs/localization/app_translations.dart';
|
||||
import 'package:fcs/pages/fcs_shipment/model/fcs_shipment_model.dart';
|
||||
import 'package:fcs/pages/main/model/main_model.dart';
|
||||
import 'package:fcs/pages/widgets/label_widgets.dart';
|
||||
import 'package:fcs/pages/widgets/progress.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:flutter/material.dart';
|
||||
|
||||
import '../main/util.dart';
|
||||
|
||||
class FcsShipmentEditor extends StatefulWidget {
|
||||
final Shipment shipment;
|
||||
FcsShipmentEditor({this.shipment});
|
||||
|
||||
@override
|
||||
_FcsShipmentEditorState createState() => _FcsShipmentEditorState();
|
||||
}
|
||||
|
||||
class _FcsShipmentEditorState extends State<FcsShipmentEditor> {
|
||||
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 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, FcsShipmentModel 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<FcsShipmentModel>(context);
|
||||
|
||||
final cargoBtn = Container(
|
||||
padding: EdgeInsets.only(top: 5),
|
||||
child: Align(
|
||||
alignment: Alignment.bottomCenter,
|
||||
child: Center(
|
||||
child: Container(
|
||||
width: 250,
|
||||
child: FlatButton(
|
||||
child: Text('Download Cargo Manifest'),
|
||||
color: primaryColor,
|
||||
textColor: Colors.white,
|
||||
onPressed: () {
|
||||
Navigator.pop(context);
|
||||
},
|
||||
),
|
||||
))),
|
||||
);
|
||||
|
||||
final commercialBtn = Container(
|
||||
padding: EdgeInsets.only(top: 20),
|
||||
child: Align(
|
||||
alignment: Alignment.bottomCenter,
|
||||
child: Center(
|
||||
child: Container(
|
||||
width: 250,
|
||||
child: FlatButton(
|
||||
child: Text('Download Commercial Invoice'),
|
||||
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(
|
||||
child: Text('Download Packing List'),
|
||||
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(
|
||||
child: Text('Create FCS Shipment'),
|
||||
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(
|
||||
child: Text('Update FCS Shipment'),
|
||||
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>[
|
||||
// _showCustomerData(mainModel.customer),
|
||||
widget.shipment == null
|
||||
? fcsInput('FCS Shipment Number', Ionicons.ios_airplane,
|
||||
controller: _shipmentNumberController)
|
||||
: Container(
|
||||
child: TextFormField(
|
||||
controller: _shipmentNumberController,
|
||||
readOnly: true,
|
||||
decoration: InputDecoration(
|
||||
fillColor: Colors.white,
|
||||
labelText: 'FCS Shipment Number',
|
||||
labelStyle:
|
||||
TextStyle(fontSize: 16, color: Colors.grey),
|
||||
filled: true,
|
||||
enabledBorder: InputBorder.none,
|
||||
focusedBorder: InputBorder.none,
|
||||
icon: Icon(
|
||||
Ionicons.ios_airplane,
|
||||
color: primaryColor,
|
||||
),
|
||||
)),
|
||||
),
|
||||
widget.shipment == null
|
||||
? Container(
|
||||
padding: EdgeInsets.only(top: 5),
|
||||
child: fcsInput('Cutoff Date', Icons.date_range,
|
||||
controller: _cutoffDateController),
|
||||
)
|
||||
: Container(),
|
||||
Container(
|
||||
padding:
|
||||
EdgeInsets.only(top: widget.shipment == null ? 5 : 0),
|
||||
child: fcsInput('ETA', Icons.date_range,
|
||||
controller: _arrivalDateController),
|
||||
),
|
||||
Container(
|
||||
padding: EdgeInsets.only(top: 5),
|
||||
child: fcsInput('Departure Date', Icons.date_range,
|
||||
controller: _departureDateControler),
|
||||
),
|
||||
widget.shipment == null
|
||||
? Container(
|
||||
padding: EdgeInsets.only(top: 5),
|
||||
child: DropdownButtonFormField(
|
||||
decoration: InputDecoration(
|
||||
fillColor: Colors.white,
|
||||
labelText: 'FCS 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;
|
||||
})
|
||||
},
|
||||
),
|
||||
)
|
||||
: Container(),
|
||||
|
||||
widget.shipment == null
|
||||
? Container(
|
||||
padding: EdgeInsets.only(top: 5),
|
||||
child: fcsInput('Consignee', Icons.work,
|
||||
controller: _consigneeController),
|
||||
)
|
||||
: Container(),
|
||||
widget.shipment == null
|
||||
? Container(
|
||||
padding: EdgeInsets.only(top: 5),
|
||||
child: fcsInput(
|
||||
'Port of Loading', FontAwesomeIcons.ship,
|
||||
controller: _portController),
|
||||
)
|
||||
: Container(),
|
||||
widget.shipment == null
|
||||
? Container(
|
||||
padding: EdgeInsets.only(top: 5),
|
||||
child: fcsInput('Final Destination',
|
||||
MaterialCommunityIcons.location_enter,
|
||||
controller: _destinationController),
|
||||
)
|
||||
: Container(),
|
||||
widget.shipment == null
|
||||
? Container()
|
||||
: 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: Icon(Icons.av_timer,
|
||||
color: primaryColor))),
|
||||
),
|
||||
widget.shipment == null
|
||||
? Container()
|
||||
: Container(
|
||||
padding: EdgeInsets.only(top: 5),
|
||||
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 ? Container() : cargoBtn,
|
||||
widget.shipment == null ? createBtn : updateBtn,
|
||||
SizedBox(height: 15)
|
||||
]),
|
||||
)),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user