v3
This commit is contained in:
407
lib/pages_fcs/box_editor.dart
Normal file
407
lib/pages_fcs/box_editor.dart
Normal file
@@ -0,0 +1,407 @@
|
||||
import 'package:fcs/model/main_model.dart';
|
||||
import 'package:fcs/model_fcs/package_model.dart';
|
||||
import 'package:fcs/pages/invoice/package_addition.dart';
|
||||
import 'package:fcs/pages/util.dart';
|
||||
import 'package:fcs/vo/box.dart';
|
||||
import 'package:fcs/vo/package.dart';
|
||||
import 'package:fcs/widget/bottom_up_page_route.dart';
|
||||
import 'package:fcs/widget/local_text.dart';
|
||||
import 'package:fcs/widget/localization/app_translations.dart';
|
||||
import 'package:fcs/widget/my_data_table.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:intl/intl.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:timeline_list/timeline.dart';
|
||||
import 'package:timeline_list/timeline_model.dart';
|
||||
|
||||
import '../theme/theme.dart';
|
||||
|
||||
class BoxEditor extends StatefulWidget {
|
||||
final Box box;
|
||||
BoxEditor({this.box});
|
||||
|
||||
@override
|
||||
_BoxEditorState createState() => _BoxEditorState();
|
||||
}
|
||||
|
||||
class _BoxEditorState extends State<BoxEditor> {
|
||||
TextEditingController _addressEditingController = new TextEditingController();
|
||||
TextEditingController _fromTimeEditingController =
|
||||
new TextEditingController();
|
||||
TextEditingController _toTimeEditingController = new TextEditingController();
|
||||
TextEditingController _noOfPackageEditingController =
|
||||
new TextEditingController();
|
||||
TextEditingController _weightEditingController = new TextEditingController();
|
||||
|
||||
Box _box;
|
||||
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.box != null) {
|
||||
_box = widget.box;
|
||||
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 {
|
||||
List<Package> packages = [
|
||||
PackageModel.packages[0],
|
||||
PackageModel.packages[1],
|
||||
PackageModel.packages[2]
|
||||
];
|
||||
|
||||
isNew = true;
|
||||
_box = Box(rate: 0, weight: 0, packages: packages);
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
final DateFormat dateFormat = DateFormat("d MMM yyyy");
|
||||
List<TimelineModel> _models() {
|
||||
// return [];
|
||||
return _box.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 mainModel = Provider.of<MainModel>(context);
|
||||
|
||||
var images = isNew ? [] : _images;
|
||||
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("box.edit.title")),
|
||||
),
|
||||
body: Card(
|
||||
child: Column(
|
||||
children: <Widget>[
|
||||
widget.box == null
|
||||
? Center(
|
||||
child: Container(
|
||||
padding: EdgeInsets.all(8), child: Text("New Box")))
|
||||
: Center(child: nameWidget(_box.packageNumber)),
|
||||
Expanded(
|
||||
child: ListView(
|
||||
children: [
|
||||
ExpansionTile(
|
||||
title: Text(
|
||||
'Shipment Information',
|
||||
style: TextStyle(
|
||||
color: primaryColor, fontWeight: FontWeight.bold),
|
||||
),
|
||||
children: [
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(left: 20.0, right: 20),
|
||||
child: DropdownButtonFormField(
|
||||
value: _box.shipmentNumber,
|
||||
decoration: InputDecoration(
|
||||
fillColor: Colors.white,
|
||||
labelText: 'Shipment Number',
|
||||
icon: Icon(Ionicons.ios_airplane,
|
||||
color: primaryColor)
|
||||
// prefixIcon: Icon(Icons.play_arrow)
|
||||
),
|
||||
items: ["A102", "A103", "A201", "A202"]
|
||||
.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 ? "FCS-0203-390-2" : "FCS-0203-390-2",
|
||||
decoration: InputDecoration(
|
||||
fillColor: Colors.white,
|
||||
labelText: 'FCS_ID',
|
||||
hintText: 'FCS_ID',
|
||||
filled: true,
|
||||
icon: Icon(Feather.user, color: primaryColor),
|
||||
suffixIcon: IconButton(
|
||||
icon: Icon(Icons.search),
|
||||
onPressed: () {})),
|
||||
),
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(left: 20.0, right: 20),
|
||||
child: TextFormField(
|
||||
initialValue: _box.receiverName,
|
||||
decoration: InputDecoration(
|
||||
fillColor: Colors.white,
|
||||
labelText: 'Customer Name',
|
||||
filled: true,
|
||||
icon: Icon(Feather.user, color: Colors.white),
|
||||
suffixIcon: IconButton(
|
||||
icon: Icon(Icons.search),
|
||||
onPressed: () {})),
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
height: 30,
|
||||
)
|
||||
],
|
||||
),
|
||||
ExpansionTile(
|
||||
title: Text(
|
||||
'Packages',
|
||||
style: TextStyle(
|
||||
color: primaryColor, fontWeight: FontWeight.bold),
|
||||
),
|
||||
children: [
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(left: 20.0, right: 20),
|
||||
child: DropdownButtonFormField(
|
||||
value: _box.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: _box.weight.toString(),
|
||||
textAlign: TextAlign.end,
|
||||
decoration: InputDecoration(
|
||||
fillColor: Colors.white,
|
||||
labelText: 'Total Weight',
|
||||
filled: true,
|
||||
icon: Icon(FontAwesomeIcons.weightHanging,
|
||||
color: primaryColor),
|
||||
)),
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(left: 20.0, right: 20),
|
||||
child: TextFormField(
|
||||
initialValue: _box.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: _box.amount.toString(),
|
||||
textAlign: TextAlign.end,
|
||||
decoration: InputDecoration(
|
||||
fillColor: Colors.white,
|
||||
labelText: 'Total Amount',
|
||||
filled: true,
|
||||
icon: Icon(FontAwesomeIcons.moneyBill,
|
||||
color: primaryColor),
|
||||
)),
|
||||
),
|
||||
Container(
|
||||
padding: EdgeInsets.only(top: 10),
|
||||
child: SingleChildScrollView(
|
||||
scrollDirection: Axis.horizontal,
|
||||
child: MyDataTable(
|
||||
headingRowHeight: 40,
|
||||
columnSpacing: 20,
|
||||
columns: [
|
||||
MyDataColumn(
|
||||
label: LocalText(
|
||||
context,
|
||||
"box.package.id",
|
||||
color: Colors.grey,
|
||||
),
|
||||
),
|
||||
MyDataColumn(
|
||||
label: LocalText(
|
||||
context,
|
||||
"box.package.desc",
|
||||
color: Colors.grey,
|
||||
),
|
||||
),
|
||||
MyDataColumn(
|
||||
label: LocalText(
|
||||
context,
|
||||
"box.package.market",
|
||||
color: Colors.grey,
|
||||
),
|
||||
),
|
||||
],
|
||||
rows: getPackageRow(context),
|
||||
),
|
||||
),
|
||||
),
|
||||
mainModel.isOwner()
|
||||
? Container(
|
||||
padding: EdgeInsets.only(top: 20),
|
||||
child: Align(
|
||||
alignment: Alignment.bottomRight,
|
||||
child: FloatingActionButton.extended(
|
||||
icon: Icon(Icons.add),
|
||||
label: Text(AppTranslations.of(context)
|
||||
.text("box.add_package")),
|
||||
backgroundColor: primaryColor,
|
||||
onPressed: () {
|
||||
Navigator.of(context).push(
|
||||
BottomUpPageRoute(PackageAddition()));
|
||||
},
|
||||
),
|
||||
),
|
||||
)
|
||||
: Container(),
|
||||
SizedBox(height: 25),
|
||||
],
|
||||
),
|
||||
isNew
|
||||
? Container()
|
||||
: 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),
|
||||
),
|
||||
],
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
widget.box == null
|
||||
? Align(
|
||||
alignment: Alignment.bottomCenter,
|
||||
child: Center(
|
||||
child: Container(
|
||||
width: 250,
|
||||
child: FlatButton(
|
||||
child: Text('Create New Box'),
|
||||
color: primaryColor,
|
||||
textColor: Colors.white,
|
||||
onPressed: () {
|
||||
Navigator.pop(context);
|
||||
},
|
||||
),
|
||||
)))
|
||||
: Container(
|
||||
child: Column(
|
||||
children: <Widget>[
|
||||
Align(
|
||||
alignment: Alignment.bottomCenter,
|
||||
child: Center(
|
||||
child: Container(
|
||||
width: 250,
|
||||
child: FlatButton(
|
||||
child: Text('Complete packing'),
|
||||
color: primaryColor,
|
||||
textColor: Colors.white,
|
||||
onPressed: () {
|
||||
Navigator.pop(context);
|
||||
},
|
||||
),
|
||||
))),
|
||||
],
|
||||
))
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
List<MyDataRow> getPackageRow(BuildContext context) {
|
||||
if (_box == null || _box.packages == null) {
|
||||
return [];
|
||||
}
|
||||
return _box.packages.map((p) {
|
||||
return MyDataRow(
|
||||
onSelectChanged: (bool selected) {},
|
||||
cells: [
|
||||
MyDataCell(new Text(
|
||||
p.id == null ? "" : p.id,
|
||||
style: textStyle,
|
||||
)),
|
||||
MyDataCell(
|
||||
new Text(p.cargoDesc, style: textStyle),
|
||||
),
|
||||
MyDataCell(
|
||||
new Text("${p.market}", style: textStyle),
|
||||
),
|
||||
],
|
||||
);
|
||||
}).toList();
|
||||
}
|
||||
}
|
||||
146
lib/pages_fcs/box_list.dart
Normal file
146
lib/pages_fcs/box_list.dart
Normal file
@@ -0,0 +1,146 @@
|
||||
import 'package:fcs/model/pickup_model.dart';
|
||||
import 'package:fcs/model_fcs/box_model.dart';
|
||||
import 'package:fcs/model_fcs/package_model.dart';
|
||||
import 'package:fcs/pages/pickup_list_row.dart';
|
||||
import 'package:fcs/pages/search_page.dart';
|
||||
import 'package:fcs/pages_fcs/box_editor.dart';
|
||||
import 'package:fcs/pages_fcs/box_list_row.dart';
|
||||
import 'package:fcs/pages_fcs/package_editor.dart';
|
||||
import 'package:fcs/pages_fcs/package_list_row.dart';
|
||||
import 'package:fcs/vo/buyer.dart';
|
||||
import 'package:fcs/widget/bottom_up_page_route.dart';
|
||||
import 'package:fcs/widget/localization/app_translations.dart';
|
||||
import 'package:fcs/widget/progress.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
import '../theme/theme.dart';
|
||||
import 'pickup_editor.dart';
|
||||
|
||||
class BoxList extends StatefulWidget {
|
||||
@override
|
||||
_BoxListState createState() => _BoxListState();
|
||||
}
|
||||
|
||||
class _BoxListState extends State<BoxList> {
|
||||
Buyer buyer;
|
||||
bool _isLoading = false;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return LocalProgress(
|
||||
inAsyncCall: _isLoading,
|
||||
child: DefaultTabController(
|
||||
length: 2,
|
||||
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("boxes.title")),
|
||||
actions: <Widget>[
|
||||
IconButton(
|
||||
icon: Icon(
|
||||
Icons.search,
|
||||
color: Colors.white,
|
||||
),
|
||||
iconSize: 30,
|
||||
onPressed: () => showPlacesSearch(context),
|
||||
),
|
||||
],
|
||||
bottom: TabBar(
|
||||
unselectedLabelColor: Colors.grey,
|
||||
tabs: [
|
||||
Tab(
|
||||
text: "Upcoming",
|
||||
),
|
||||
Tab(text: "Delivered"),
|
||||
],
|
||||
),
|
||||
),
|
||||
floatingActionButton: FloatingActionButton.extended(
|
||||
onPressed: () {
|
||||
_newPickup();
|
||||
},
|
||||
icon: Icon(Icons.add),
|
||||
label: Text(AppTranslations.of(context).text("boxes.new")),
|
||||
backgroundColor: primaryColor,
|
||||
),
|
||||
body: TabBarView(
|
||||
children: [
|
||||
_upComing(),
|
||||
_completed(),
|
||||
],
|
||||
)),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
_newPickup() {
|
||||
Navigator.push(
|
||||
context,
|
||||
BottomUpPageRoute(BoxEditor()),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _upComing() {
|
||||
var boxModel = Provider.of<BoxModel>(context);
|
||||
return Column(
|
||||
children: <Widget>[
|
||||
Expanded(
|
||||
child: new ListView.separated(
|
||||
separatorBuilder: (context, index) => Divider(
|
||||
color: Colors.black,
|
||||
),
|
||||
scrollDirection: Axis.vertical,
|
||||
padding: EdgeInsets.only(top: 15),
|
||||
shrinkWrap: true,
|
||||
itemCount: boxModel.upcoming.length,
|
||||
itemBuilder: (BuildContext context, int index) {
|
||||
return BoxListRow(
|
||||
box: boxModel.upcoming[index],
|
||||
isReadOnly: false,
|
||||
);
|
||||
}),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Widget _completed() {
|
||||
var boxModel = Provider.of<BoxModel>(context);
|
||||
return Column(
|
||||
children: <Widget>[
|
||||
Expanded(
|
||||
child: new ListView.separated(
|
||||
separatorBuilder: (context, index) => Divider(
|
||||
color: Colors.black,
|
||||
),
|
||||
scrollDirection: Axis.vertical,
|
||||
padding: EdgeInsets.only(top: 15),
|
||||
shrinkWrap: true,
|
||||
itemCount: boxModel.completed.length,
|
||||
itemBuilder: (BuildContext context, int index) {
|
||||
return BoxListRow(
|
||||
box: boxModel.completed[index],
|
||||
isReadOnly: false,
|
||||
);
|
||||
}),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
119
lib/pages_fcs/box_list_row.dart
Normal file
119
lib/pages_fcs/box_list_row.dart
Normal file
@@ -0,0 +1,119 @@
|
||||
import 'package:fcs/pages/invoice/package_info.dart';
|
||||
import 'package:fcs/pages/util.dart';
|
||||
import 'package:fcs/pages_fcs/box_editor.dart';
|
||||
import 'package:fcs/pages_fcs/package_editor.dart';
|
||||
import 'package:fcs/vo/box.dart';
|
||||
import 'package:fcs/vo/package.dart';
|
||||
import 'package:fcs/widget/bottom_up_page_route.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
|
||||
class BoxListRow extends StatefulWidget {
|
||||
final bool isReadOnly;
|
||||
final Box box;
|
||||
const BoxListRow({this.box, this.isReadOnly});
|
||||
|
||||
@override
|
||||
_BoxListRowState createState() => _BoxListRowState();
|
||||
}
|
||||
|
||||
class _BoxListRowState extends State<BoxListRow> {
|
||||
final double dotSize = 15.0;
|
||||
Box _box = new Box();
|
||||
final DateFormat dateFormat = new DateFormat("dd MMM yyyy");
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_box = widget.box;
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
padding: EdgeInsets.only(left: 15, right: 15),
|
||||
child: InkWell(
|
||||
onTap: () {
|
||||
if (widget.isReadOnly) {
|
||||
// Navigator.push(
|
||||
// context,
|
||||
// BottomUpPageRoute(PackageInfo(package: _box)),
|
||||
// );
|
||||
} else {
|
||||
Navigator.push(
|
||||
context,
|
||||
BottomUpPageRoute(BoxEditor(box: _box)),
|
||||
);
|
||||
}
|
||||
},
|
||||
child: Row(
|
||||
children: <Widget>[
|
||||
Expanded(
|
||||
child: new Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 16.0),
|
||||
child: new Row(
|
||||
children: <Widget>[
|
||||
new Expanded(
|
||||
child: new Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: <Widget>[
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(left: 8.0),
|
||||
child: new Text(
|
||||
_box.packageNumber == null
|
||||
? ''
|
||||
: _box.packageNumber,
|
||||
style: new TextStyle(
|
||||
fontSize: 15.0, color: Colors.black),
|
||||
),
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(left: 10.0, top: 10),
|
||||
child: new Text(
|
||||
dateFormat.format(_box.arrivedDate),
|
||||
style: new TextStyle(
|
||||
fontSize: 15.0, color: Colors.grey),
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
Column(
|
||||
children: <Widget>[
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(0),
|
||||
child: getStatus(_box.status),
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(left: 8.0, top: 5, bottom: 5),
|
||||
child: Row(
|
||||
children: <Widget>[
|
||||
new Text(
|
||||
_box.weight == null
|
||||
? ''
|
||||
: _box.weight.toString() + 'lb - ',
|
||||
style:
|
||||
new TextStyle(fontSize: 15.0, color: Colors.grey),
|
||||
),
|
||||
new Text(
|
||||
_box.price == null
|
||||
? ""
|
||||
: "\$ " + _box.price.toString(),
|
||||
style:
|
||||
new TextStyle(fontSize: 15.0, color: Colors.grey),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -60,43 +60,6 @@ class _PackageEditorState extends State<PackageEditor> {
|
||||
}
|
||||
|
||||
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) {
|
||||
@@ -116,12 +79,13 @@ class _PackageEditorState extends State<PackageEditor> {
|
||||
body: Card(
|
||||
child: Column(
|
||||
children: <Widget>[
|
||||
widget.package == null
|
||||
isNew ? Container() : Center(child: nameWidget(_package.market)),
|
||||
isNew
|
||||
? Center(
|
||||
child: Container(
|
||||
padding: EdgeInsets.all(8),
|
||||
child: Text("New Package")))
|
||||
: Center(child: nameWidget(_package.packageNumber)),
|
||||
: Center(child: nameWidget(_package.trackingID)),
|
||||
Expanded(
|
||||
child: ListView(
|
||||
children: [
|
||||
@@ -134,26 +98,49 @@ class _PackageEditorState extends State<PackageEditor> {
|
||||
children: [
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(left: 20.0, right: 20),
|
||||
child: DropdownButtonFormField(
|
||||
value: _package.shipmentNumber,
|
||||
child: TextFormField(
|
||||
initialValue: isNew ? "" : "PKG2039",
|
||||
decoration: InputDecoration(
|
||||
fillColor: Colors.white,
|
||||
labelText: 'Shipment Number',
|
||||
icon: Icon(Ionicons.ios_airplane,
|
||||
color: primaryColor)
|
||||
// prefixIcon: Icon(Icons.play_arrow)
|
||||
),
|
||||
items: ["A102", "A103", "A201", "A202"]
|
||||
.map((e) =>
|
||||
DropdownMenuItem(child: Text(e), value: e))
|
||||
.toList(),
|
||||
onChanged: (map) => {},
|
||||
fillColor: Colors.white,
|
||||
labelText: 'Package ID',
|
||||
hintText: 'Package ID',
|
||||
filled: true,
|
||||
icon: Icon(MaterialCommunityIcons.id_card,
|
||||
color: primaryColor),
|
||||
),
|
||||
),
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(left: 20.0, right: 20),
|
||||
child: TextFormField(
|
||||
initialValue: isNew ? "" : "FCS383-283-1",
|
||||
initialValue: isNew ? "" : "Amazon",
|
||||
decoration: InputDecoration(
|
||||
fillColor: Colors.white,
|
||||
labelText: 'Market',
|
||||
hintText: 'FCS_ID',
|
||||
filled: true,
|
||||
icon: Icon(MaterialCommunityIcons.cart_outline,
|
||||
color: primaryColor),
|
||||
),
|
||||
),
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(left: 20.0, right: 20),
|
||||
child: TextFormField(
|
||||
initialValue: isNew ? "" : "zdf-sdfl-37sdfks",
|
||||
decoration: InputDecoration(
|
||||
fillColor: Colors.white,
|
||||
labelText: 'Tracking ID',
|
||||
hintText: 'Tracking ID',
|
||||
filled: true,
|
||||
icon: Icon(Octicons.package, color: primaryColor),
|
||||
),
|
||||
),
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(left: 20.0, right: 20),
|
||||
child: TextFormField(
|
||||
initialValue: isNew ? "" : "FCS-0203-390-2",
|
||||
decoration: InputDecoration(
|
||||
fillColor: Colors.white,
|
||||
labelText: 'FCS_ID',
|
||||
@@ -182,7 +169,7 @@ class _PackageEditorState extends State<PackageEditor> {
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(left: 20.0, right: 20),
|
||||
child: TextFormField(
|
||||
initialValue: isNew ? "" : "P0203",
|
||||
initialValue: isNew ? "" : "",
|
||||
decoration: InputDecoration(
|
||||
fillColor: Colors.white,
|
||||
labelText: 'Pickup ID',
|
||||
@@ -196,154 +183,90 @@ class _PackageEditorState extends State<PackageEditor> {
|
||||
),
|
||||
],
|
||||
),
|
||||
ExpansionTile(
|
||||
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.separated(
|
||||
separatorBuilder: (context, index) => Divider(
|
||||
color: Colors.black,
|
||||
isNew
|
||||
? Container()
|
||||
: ExpansionTile(
|
||||
title: Text(
|
||||
'Processing',
|
||||
style: TextStyle(
|
||||
color: primaryColor,
|
||||
fontWeight: FontWeight.bold),
|
||||
),
|
||||
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,
|
||||
),
|
||||
),
|
||||
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),
|
||||
),
|
||||
);
|
||||
}
|
||||
},
|
||||
children: [
|
||||
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),
|
||||
)),
|
||||
),
|
||||
],
|
||||
),
|
||||
isNew
|
||||
? Container()
|
||||
: ExpansionTile(
|
||||
title: Text(
|
||||
'Photos',
|
||||
style: TextStyle(
|
||||
color: primaryColor,
|
||||
fontWeight: FontWeight.bold),
|
||||
),
|
||||
children: <Widget>[
|
||||
Container(
|
||||
height: 130,
|
||||
width: 500,
|
||||
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,
|
||||
),
|
||||
),
|
||||
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),
|
||||
),
|
||||
],
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
@@ -62,9 +62,9 @@ class _PackageListState extends State<PackageList> {
|
||||
unselectedLabelColor: Colors.grey,
|
||||
tabs: [
|
||||
Tab(
|
||||
text: "Upcoming",
|
||||
text: "Received",
|
||||
),
|
||||
Tab(text: "Completed"),
|
||||
Tab(text: "Processed"),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
@@ -58,21 +58,29 @@ class _PackageListRowtate extends State<PackageListRow> {
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(left: 8.0),
|
||||
child: new Text(
|
||||
_package.packageNumber == null
|
||||
? ''
|
||||
: _package.packageNumber,
|
||||
_package.id == null ? '' : _package.id,
|
||||
style: new TextStyle(
|
||||
fontSize: 15.0, color: Colors.black),
|
||||
),
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(left: 10.0, top: 10),
|
||||
padding: const EdgeInsets.only(left: 8.0),
|
||||
child: new Text(
|
||||
dateFormat.format(_package.arrivedDate),
|
||||
_package.market == null ? '' : _package.market,
|
||||
style: new TextStyle(
|
||||
fontSize: 15.0, color: Colors.black),
|
||||
),
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(left: 8.0),
|
||||
child: new Text(
|
||||
_package.trackingID == null
|
||||
? ''
|
||||
: _package.trackingID,
|
||||
style: new TextStyle(
|
||||
fontSize: 15.0, color: Colors.grey),
|
||||
),
|
||||
)
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
@@ -84,7 +92,10 @@ class _PackageListRowtate extends State<PackageListRow> {
|
||||
children: <Widget>[
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(0),
|
||||
child: getStatus(_package.status),
|
||||
child: new Text(
|
||||
dateFormat.format(_package.arrivedDate),
|
||||
style: new TextStyle(fontSize: 15.0, color: Colors.grey),
|
||||
),
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(left: 8.0, top: 5, bottom: 5),
|
||||
|
||||
Reference in New Issue
Block a user