Files
fcs/lib/pages_fcs/package_editor.dart

268 lines
11 KiB
Dart
Raw Normal View History

2020-06-01 11:52:12 +06:30
import 'package:fcs/model/main_model.dart';
import 'package:fcs/model/pickup_model.dart';
2020-06-02 16:19:10 +06:30
import 'package:fcs/pages/util.dart';
2020-06-01 11:52:12 +06:30
import 'package:fcs/vo/package.dart';
import 'package:fcs/widget/localization/app_translations.dart';
import 'package:fcs/widget/progress.dart';
2020-06-02 00:00:05 +06:30
import 'package:flutter/material.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
import 'package:provider/provider.dart';
2020-06-01 11:52:12 +06:30
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;
@override
void initState() {
super.initState();
if (widget.package != null) {
_package = widget.package;
// _addressEditingController.text = _pickUp.address;
// _fromTimeEditingController.text = _pickUp.fromTime;
// _toTimeEditingController.text = _pickUp.toTime;
// _noOfPackageEditingController.text = _pickUp.numberOfPackage.toString();
// _weightEditingController.text = _pickUp.weight.toString();
2020-06-02 16:19:10 +06:30
} else {
_package = Package(rate: 0, weight: 0);
2020-06-01 11:52:12 +06:30
}
}
@override
void dispose() {
super.dispose();
}
@override
Widget build(BuildContext 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("package.edit.title")),
),
body: Card(
child: Column(
children: <Widget>[
Expanded(
2020-06-02 16:19:10 +06:30
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'),
children: [
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)
),
items: ["A102", "A103", "A201", "A202"]
.map((e) =>
DropdownMenuItem(child: Text(e), value: e))
.toList(),
onChanged: (map) => {},
),
2020-06-01 11:52:12 +06:30
),
2020-06-02 16:19:10 +06:30
Padding(
padding: const EdgeInsets.only(left: 20.0),
child: TextFormField(
initialValue: "FCS383-283-1",
decoration: InputDecoration(
fillColor: Colors.white,
labelText: 'FCS_ID',
hintText: 'FCS_ID',
filled: true,
icon: Icon(
Icons.account_box,
),
suffixIcon: IconButton(
icon: Icon(Icons.search),
onPressed: () {})),
),
2020-06-01 11:52:12 +06:30
),
2020-06-02 16:19:10 +06:30
Padding(
padding: const EdgeInsets.only(left: 20.0),
child: DropdownButtonFormField(
value: _package.packageType,
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) => {},
),
2020-06-01 11:52:12 +06:30
),
2020-06-02 16:19:10 +06:30
Padding(
padding: const EdgeInsets.only(left: 20.0),
child: TextFormField(
initialValue: _package.weight.toString(),
textAlign: TextAlign.end,
decoration: InputDecoration(
fillColor: Colors.white,
labelText: 'Weight',
filled: true,
icon: Icon(
FontAwesomeIcons.weightHanging,
),
)),
2020-06-01 11:52:12 +06:30
),
2020-06-02 16:19:10 +06:30
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,
),
)),
2020-06-02 00:00:05 +06:30
),
2020-06-02 16:19:10 +06:30
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,
),
)),
2020-06-02 00:00:05 +06:30
),
2020-06-02 16:19:10 +06:30
Padding(
padding: const EdgeInsets.only(left: 20.0),
child: TextFormField(
initialValue: "P0203",
decoration: InputDecoration(
fillColor: Colors.white,
labelText: 'Pickup ID',
filled: true,
icon: Icon(
Icons.account_box,
),
suffixIcon: IconButton(
icon: Icon(Icons.search),
onPressed: () {})),
),
2020-06-01 11:52:12 +06:30
),
2020-06-02 16:19:10 +06:30
],
),
ExpansionTile(
title: Text('Photos'),
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)
),
items: ["A102", "A103", "A201", "A202"]
.map((e) => DropdownMenuItem(
child: Text(e), value: e))
.toList(),
onChanged: (map) => {},
),
),
],
),
),
],
)
],
),
),
2020-06-01 11:52:12 +06:30
widget.package == null
? Align(
alignment: Alignment.bottomCenter,
child: Center(
child: Container(
width: 250,
child: FlatButton(
child: Text('Create package'),
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('Save package'),
color: primaryColor,
textColor: Colors.white,
onPressed: () {
Navigator.pop(context);
},
),
))),
],
))
],
),
),
),
);
}
}