add packages
This commit is contained in:
@@ -1,12 +1,13 @@
|
||||
import 'package:fcs/model/main_model.dart';
|
||||
import 'package:fcs/model/pickup_model.dart';
|
||||
import 'package:fcs/pages/util.dart';
|
||||
import 'package:fcs/vo/package.dart';
|
||||
import 'package:fcs/widget/localization/app_translations.dart';
|
||||
import 'package:fcs/widget/progress.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_icons/flutter_icons.dart';
|
||||
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
import 'package:timeline_list/timeline.dart';
|
||||
import 'package:timeline_list/timeline_model.dart';
|
||||
|
||||
import '../theme/theme.dart';
|
||||
|
||||
@@ -29,18 +30,26 @@ class _PackageEditorState extends State<PackageEditor> {
|
||||
|
||||
Package _package;
|
||||
bool _isLoading = false;
|
||||
List<String> _images = [
|
||||
"assets/photos/1.jpg",
|
||||
"assets/photos/2.jpg",
|
||||
"assets/photos/3.jpg"
|
||||
];
|
||||
bool isNew;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
if (widget.package != null) {
|
||||
_package = widget.package;
|
||||
isNew = false;
|
||||
// _addressEditingController.text = _pickUp.address;
|
||||
// _fromTimeEditingController.text = _pickUp.fromTime;
|
||||
// _toTimeEditingController.text = _pickUp.toTime;
|
||||
// _noOfPackageEditingController.text = _pickUp.numberOfPackage.toString();
|
||||
// _weightEditingController.text = _pickUp.weight.toString();
|
||||
} else {
|
||||
isNew = true;
|
||||
_package = Package(rate: 0, weight: 0);
|
||||
}
|
||||
}
|
||||
@@ -50,8 +59,48 @@ class _PackageEditorState extends State<PackageEditor> {
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
final DateFormat dateFormat = DateFormat("d MMM yyyy");
|
||||
List<TimelineModel> _models() {
|
||||
return _package.statusHistory
|
||||
.map((e) => TimelineModel(
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(18.0),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: <Widget>[
|
||||
Text(e.status,
|
||||
style: TextStyle(
|
||||
color: e.done ? primaryColor : Colors.grey,
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.bold)),
|
||||
e.status == "Processed"
|
||||
? Text("(Waiting for payment)",
|
||||
style: TextStyle(
|
||||
color: e.done ? primaryColor : Colors.grey,
|
||||
fontSize: 14,
|
||||
fontWeight: FontWeight.bold))
|
||||
: Container(),
|
||||
Text(dateFormat.format(e.date)),
|
||||
],
|
||||
),
|
||||
),
|
||||
iconBackground: e.done ? primaryColor : Colors.grey,
|
||||
icon: Icon(
|
||||
e.status == "Shipped"
|
||||
? Ionicons.ios_airplane
|
||||
: e.status == "Delivered"
|
||||
? MaterialCommunityIcons.truck_fast
|
||||
: e.status == "Processed"
|
||||
? MaterialIcons.check
|
||||
: Octicons.package,
|
||||
color: Colors.white,
|
||||
)))
|
||||
.toList();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
var images = isNew ? [] : _images;
|
||||
return LocalProgress(
|
||||
inAsyncCall: _isLoading,
|
||||
child: Scaffold(
|
||||
@@ -67,26 +116,31 @@ class _PackageEditorState extends State<PackageEditor> {
|
||||
body: Card(
|
||||
child: Column(
|
||||
children: <Widget>[
|
||||
widget.package == null
|
||||
? Center(
|
||||
child: Container(
|
||||
padding: EdgeInsets.all(8),
|
||||
child: Text("New Package")))
|
||||
: Center(child: nameWidget(_package.packageNumber)),
|
||||
Expanded(
|
||||
child: ListView(
|
||||
children: [
|
||||
widget.package == null
|
||||
? Center(
|
||||
child: Container(
|
||||
padding: EdgeInsets.all(8),
|
||||
child: Text("New Package")))
|
||||
: Center(child: nameWidget(_package.packageNumber)),
|
||||
ExpansionTile(
|
||||
title: Text('Package Information'),
|
||||
title: Text(
|
||||
'Receiving',
|
||||
style: TextStyle(
|
||||
color: primaryColor, fontWeight: FontWeight.bold),
|
||||
),
|
||||
children: [
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(left: 20.0),
|
||||
padding: const EdgeInsets.only(left: 20.0, right: 20),
|
||||
child: DropdownButtonFormField(
|
||||
value: _package.shipmentNumber,
|
||||
decoration: InputDecoration(
|
||||
fillColor: Colors.white,
|
||||
labelText: 'Shipment Number',
|
||||
icon: Icon(Icons.pages)
|
||||
icon: Icon(Ionicons.ios_airplane,
|
||||
color: primaryColor)
|
||||
// prefixIcon: Icon(Icons.play_arrow)
|
||||
),
|
||||
items: ["A102", "A103", "A201", "A202"]
|
||||
@@ -97,92 +151,44 @@ class _PackageEditorState extends State<PackageEditor> {
|
||||
),
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(left: 20.0),
|
||||
padding: const EdgeInsets.only(left: 20.0, right: 20),
|
||||
child: TextFormField(
|
||||
initialValue: "FCS383-283-1",
|
||||
initialValue: isNew ? "" : "FCS383-283-1",
|
||||
decoration: InputDecoration(
|
||||
fillColor: Colors.white,
|
||||
labelText: 'FCS_ID',
|
||||
hintText: 'FCS_ID',
|
||||
filled: true,
|
||||
icon: Icon(
|
||||
Icons.account_box,
|
||||
),
|
||||
icon: Icon(Feather.user, color: primaryColor),
|
||||
suffixIcon: IconButton(
|
||||
icon: Icon(Icons.search),
|
||||
onPressed: () {})),
|
||||
),
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(left: 20.0),
|
||||
child: DropdownButtonFormField(
|
||||
value: _package.packageType,
|
||||
padding: const EdgeInsets.only(left: 20.0, right: 20),
|
||||
child: TextFormField(
|
||||
initialValue: _package.receiverName,
|
||||
decoration: InputDecoration(
|
||||
fillColor: Colors.white,
|
||||
labelText: 'Cargo Type',
|
||||
icon: Icon(Icons.pages)
|
||||
// prefixIcon: Icon(Icons.play_arrow)
|
||||
),
|
||||
items: ["General", "Medicine", "Dangerous"]
|
||||
.map((e) =>
|
||||
DropdownMenuItem(child: Text(e), value: e))
|
||||
.toList(),
|
||||
onChanged: (map) => {},
|
||||
labelText: 'Customer Name',
|
||||
filled: true,
|
||||
icon: Icon(Feather.user, color: Colors.white),
|
||||
suffixIcon: IconButton(
|
||||
icon: Icon(Icons.search),
|
||||
onPressed: () {})),
|
||||
),
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(left: 20.0),
|
||||
padding: const EdgeInsets.only(left: 20.0, right: 20),
|
||||
child: TextFormField(
|
||||
initialValue: _package.weight.toString(),
|
||||
textAlign: TextAlign.end,
|
||||
decoration: InputDecoration(
|
||||
fillColor: Colors.white,
|
||||
labelText: 'Weight',
|
||||
filled: true,
|
||||
icon: Icon(
|
||||
FontAwesomeIcons.weightHanging,
|
||||
),
|
||||
)),
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(left: 20.0),
|
||||
child: TextFormField(
|
||||
initialValue: _package.rate.toString(),
|
||||
textAlign: TextAlign.end,
|
||||
decoration: InputDecoration(
|
||||
fillColor: Colors.white,
|
||||
labelText: 'Rate',
|
||||
filled: true,
|
||||
icon: Icon(
|
||||
FontAwesomeIcons.tag,
|
||||
),
|
||||
)),
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(left: 20.0),
|
||||
child: TextFormField(
|
||||
initialValue: _package.amount.toString(),
|
||||
textAlign: TextAlign.end,
|
||||
decoration: InputDecoration(
|
||||
fillColor: Colors.white,
|
||||
labelText: 'Amount',
|
||||
filled: true,
|
||||
icon: Icon(
|
||||
FontAwesomeIcons.moneyBill,
|
||||
),
|
||||
)),
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(left: 20.0),
|
||||
child: TextFormField(
|
||||
initialValue: "P0203",
|
||||
initialValue: isNew ? "" : "P0203",
|
||||
decoration: InputDecoration(
|
||||
fillColor: Colors.white,
|
||||
labelText: 'Pickup ID',
|
||||
filled: true,
|
||||
icon: Icon(
|
||||
Icons.account_box,
|
||||
),
|
||||
icon: Icon(MaterialCommunityIcons.directions,
|
||||
color: primaryColor),
|
||||
suffixIcon: IconButton(
|
||||
icon: Icon(Icons.search),
|
||||
onPressed: () {})),
|
||||
@@ -191,35 +197,152 @@ class _PackageEditorState extends State<PackageEditor> {
|
||||
],
|
||||
),
|
||||
ExpansionTile(
|
||||
title: Text('Photos'),
|
||||
title: Text(
|
||||
'Processing',
|
||||
style: TextStyle(
|
||||
color: primaryColor, fontWeight: FontWeight.bold),
|
||||
),
|
||||
children: [
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(left: 20.0, right: 20),
|
||||
child: DropdownButtonFormField(
|
||||
value: _package.packageType,
|
||||
decoration: InputDecoration(
|
||||
fillColor: Colors.white,
|
||||
labelText: 'Cargo Type',
|
||||
icon: Icon(Entypo.box, color: primaryColor)),
|
||||
items: ["General", "Medicine", "Dangerous"]
|
||||
.map((e) =>
|
||||
DropdownMenuItem(child: Text(e), value: e))
|
||||
.toList(),
|
||||
onChanged: (map) => {},
|
||||
),
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(left: 20.0, right: 20),
|
||||
child: TextFormField(
|
||||
initialValue:
|
||||
isNew ? "" : _package.cargoDesc.toString(),
|
||||
decoration: InputDecoration(
|
||||
fillColor: Colors.white,
|
||||
labelText: 'Description',
|
||||
filled: true,
|
||||
icon: Icon(MaterialIcons.description,
|
||||
color: primaryColor),
|
||||
)),
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(left: 20.0, right: 20),
|
||||
child: TextFormField(
|
||||
initialValue: _package.weight.toString(),
|
||||
textAlign: TextAlign.end,
|
||||
decoration: InputDecoration(
|
||||
fillColor: Colors.white,
|
||||
labelText: 'Weight',
|
||||
filled: true,
|
||||
icon: Icon(FontAwesomeIcons.weightHanging,
|
||||
color: primaryColor),
|
||||
)),
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(left: 20.0, right: 20),
|
||||
child: TextFormField(
|
||||
initialValue: _package.rate.toString(),
|
||||
textAlign: TextAlign.end,
|
||||
decoration: InputDecoration(
|
||||
fillColor: Colors.white,
|
||||
labelText: 'Rate',
|
||||
filled: true,
|
||||
icon: Icon(FontAwesomeIcons.tag,
|
||||
color: primaryColor),
|
||||
)),
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(left: 20.0, right: 20),
|
||||
child: TextFormField(
|
||||
initialValue: _package.amount.toString(),
|
||||
textAlign: TextAlign.end,
|
||||
decoration: InputDecoration(
|
||||
fillColor: Colors.white,
|
||||
labelText: 'Amount',
|
||||
filled: true,
|
||||
icon: Icon(FontAwesomeIcons.moneyBill,
|
||||
color: primaryColor),
|
||||
)),
|
||||
),
|
||||
],
|
||||
),
|
||||
ExpansionTile(
|
||||
title: Text(
|
||||
'Photos',
|
||||
style: TextStyle(
|
||||
color: primaryColor, fontWeight: FontWeight.bold),
|
||||
),
|
||||
children: <Widget>[
|
||||
Container(
|
||||
height: 130,
|
||||
width: 500,
|
||||
child: ListView(
|
||||
// scrollDirection: Axis.horizontal,
|
||||
children: <Widget>[
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(left: 20.0),
|
||||
child: DropdownButtonFormField(
|
||||
value: _package.shipmentNumber,
|
||||
decoration: InputDecoration(
|
||||
fillColor: Colors.white,
|
||||
labelText: 'Shipment Number',
|
||||
icon: Icon(Icons.pages)
|
||||
// prefixIcon: Icon(Icons.play_arrow)
|
||||
child: ListView.separated(
|
||||
separatorBuilder: (context, index) => Divider(
|
||||
color: Colors.black,
|
||||
),
|
||||
itemCount: images.length + 1,
|
||||
scrollDirection: Axis.horizontal,
|
||||
itemBuilder: (context, index) {
|
||||
if (index == images.length) {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: Container(
|
||||
width: 200,
|
||||
height: 70,
|
||||
decoration: BoxDecoration(
|
||||
border: Border.all(
|
||||
color: primaryColor,
|
||||
width: 2.0,
|
||||
),
|
||||
items: ["A102", "A103", "A201", "A202"]
|
||||
.map((e) => DropdownMenuItem(
|
||||
child: Text(e), value: e))
|
||||
.toList(),
|
||||
onChanged: (map) => {},
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
child: Icon(SimpleLineIcons.plus),
|
||||
),
|
||||
);
|
||||
} else {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: Container(
|
||||
width: 200,
|
||||
height: 70,
|
||||
decoration: BoxDecoration(
|
||||
border: Border.all(
|
||||
color: primaryColor,
|
||||
width: 2.0,
|
||||
),
|
||||
),
|
||||
child: Image.asset(images[index],
|
||||
width: 50, height: 50),
|
||||
),
|
||||
);
|
||||
}
|
||||
},
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
ExpansionTile(
|
||||
title: Text(
|
||||
'Status',
|
||||
style: TextStyle(
|
||||
color: primaryColor, fontWeight: FontWeight.bold),
|
||||
),
|
||||
children: <Widget>[
|
||||
Container(
|
||||
height: 500,
|
||||
padding: EdgeInsets.only(left: 20),
|
||||
child: isNew
|
||||
? Container()
|
||||
: Timeline(
|
||||
children: _models(),
|
||||
position: TimelinePosition.Left),
|
||||
),
|
||||
],
|
||||
)
|
||||
],
|
||||
),
|
||||
@@ -231,7 +354,7 @@ class _PackageEditorState extends State<PackageEditor> {
|
||||
child: Container(
|
||||
width: 250,
|
||||
child: FlatButton(
|
||||
child: Text('Create package'),
|
||||
child: Text('Complete receiving'),
|
||||
color: primaryColor,
|
||||
textColor: Colors.white,
|
||||
onPressed: () {
|
||||
@@ -248,7 +371,7 @@ class _PackageEditorState extends State<PackageEditor> {
|
||||
child: Container(
|
||||
width: 250,
|
||||
child: FlatButton(
|
||||
child: Text('Save package'),
|
||||
child: Text('Complete processing'),
|
||||
color: primaryColor,
|
||||
textColor: Colors.white,
|
||||
onPressed: () {
|
||||
|
||||
Reference in New Issue
Block a user