314 lines
13 KiB
Dart
314 lines
13 KiB
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:intl/intl.dart';
|
|
import 'package:timeline_list/timeline.dart';
|
|
import 'package:timeline_list/timeline_model.dart';
|
|
|
|
import '../theme/theme.dart';
|
|
|
|
class PackageEditor extends StatefulWidget {
|
|
final Package package;
|
|
PackageEditor({this.package});
|
|
|
|
@override
|
|
_PackageEditorState createState() => _PackageEditorState();
|
|
}
|
|
|
|
class _PackageEditorState extends State<PackageEditor> {
|
|
TextEditingController _addressEditingController = new TextEditingController();
|
|
TextEditingController _fromTimeEditingController =
|
|
new TextEditingController();
|
|
TextEditingController _toTimeEditingController = new TextEditingController();
|
|
TextEditingController _noOfPackageEditingController =
|
|
new TextEditingController();
|
|
TextEditingController _weightEditingController = new TextEditingController();
|
|
|
|
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);
|
|
}
|
|
}
|
|
|
|
@override
|
|
void dispose() {
|
|
super.dispose();
|
|
}
|
|
|
|
final DateFormat dateFormat = DateFormat("d MMM yyyy");
|
|
|
|
@override
|
|
Widget build(BuildContext 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("package.edit.title")),
|
|
),
|
|
body: Card(
|
|
child: Column(
|
|
children: <Widget>[
|
|
isNew ? Container() : Center(child: nameWidget(_package.market)),
|
|
isNew
|
|
? Center(
|
|
child: Container(
|
|
padding: EdgeInsets.all(8),
|
|
child: Text("New Package")))
|
|
: Center(child: nameWidget(_package.trackingID)),
|
|
Expanded(
|
|
child: ListView(
|
|
children: [
|
|
ExpansionTile(
|
|
title: Text(
|
|
'Receiving',
|
|
style: TextStyle(
|
|
color: primaryColor, fontWeight: FontWeight.bold),
|
|
),
|
|
children: [
|
|
Padding(
|
|
padding: const EdgeInsets.only(left: 20.0, right: 20),
|
|
child: TextFormField(
|
|
initialValue: isNew ? "" : "PKG2039",
|
|
decoration: InputDecoration(
|
|
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 ? "" : "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',
|
|
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: _package.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: () {})),
|
|
),
|
|
),
|
|
Padding(
|
|
padding: const EdgeInsets.only(left: 20.0, right: 20),
|
|
child: TextFormField(
|
|
initialValue: isNew ? "" : "",
|
|
decoration: InputDecoration(
|
|
fillColor: Colors.white,
|
|
labelText: 'Pickup ID',
|
|
filled: true,
|
|
icon: Icon(MaterialCommunityIcons.directions,
|
|
color: primaryColor),
|
|
suffixIcon: IconButton(
|
|
icon: Icon(Icons.search),
|
|
onPressed: () {})),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
isNew
|
|
? Container()
|
|
: ExpansionTile(
|
|
title: Text(
|
|
'Processing',
|
|
style: TextStyle(
|
|
color: primaryColor,
|
|
fontWeight: FontWeight.bold),
|
|
),
|
|
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),
|
|
),
|
|
);
|
|
}
|
|
},
|
|
),
|
|
),
|
|
],
|
|
),
|
|
],
|
|
),
|
|
),
|
|
widget.package == null
|
|
? Align(
|
|
alignment: Alignment.bottomCenter,
|
|
child: Center(
|
|
child: Container(
|
|
width: 250,
|
|
child: FlatButton(
|
|
child: Text('Complete receiving'),
|
|
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 processing'),
|
|
color: primaryColor,
|
|
textColor: Colors.white,
|
|
onPressed: () {
|
|
Navigator.pop(context);
|
|
},
|
|
),
|
|
))),
|
|
],
|
|
))
|
|
],
|
|
),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|