2020-06-01 11:52:12 +06:30
|
|
|
import 'package:fcs/model/main_model.dart';
|
|
|
|
|
import 'package:fcs/model/pickup_model.dart';
|
|
|
|
|
import 'package:fcs/pages/util.dart';
|
|
|
|
|
import 'package:fcs/vo/pickup.dart';
|
|
|
|
|
import 'package:flutter_icons/flutter_icons.dart';
|
|
|
|
|
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
|
|
|
|
|
import 'package:provider/provider.dart';
|
|
|
|
|
import 'package:fcs/widget/localization/app_translations.dart';
|
|
|
|
|
|
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
import 'package:fcs/widget/progress.dart';
|
|
|
|
|
|
2020-08-30 21:26:37 +06:30
|
|
|
import '../fcs/common/theme.dart';
|
2020-06-01 11:52:12 +06:30
|
|
|
|
|
|
|
|
class PickUpEditor extends StatefulWidget {
|
|
|
|
|
final PickUp pickUp;
|
|
|
|
|
PickUpEditor({this.pickUp});
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
_PickUpEditorState createState() => _PickUpEditorState();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class _PickUpEditorState extends State<PickUpEditor> {
|
|
|
|
|
TextEditingController _addressEditingController = new TextEditingController();
|
|
|
|
|
TextEditingController _fromTimeEditingController =
|
|
|
|
|
new TextEditingController();
|
|
|
|
|
TextEditingController _toTimeEditingController = new TextEditingController();
|
|
|
|
|
TextEditingController _noOfPackageEditingController =
|
|
|
|
|
new TextEditingController();
|
|
|
|
|
TextEditingController _weightEditingController = new TextEditingController();
|
|
|
|
|
|
|
|
|
|
PickUp _pickUp;
|
|
|
|
|
bool _isLoading = false;
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
void initState() {
|
|
|
|
|
super.initState();
|
|
|
|
|
if (widget.pickUp != null) {
|
|
|
|
|
_pickUp = widget.pickUp;
|
|
|
|
|
_addressEditingController.text = _pickUp.address;
|
|
|
|
|
_fromTimeEditingController.text = _pickUp.fromTime;
|
|
|
|
|
_toTimeEditingController.text = _pickUp.toTime;
|
|
|
|
|
_noOfPackageEditingController.text = _pickUp.numberOfPackage.toString();
|
|
|
|
|
_weightEditingController.text = _pickUp.weight.toString();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
void dispose() {
|
|
|
|
|
super.dispose();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
|
var pickupModel = Provider.of<PickUpModel>(context);
|
|
|
|
|
|
|
|
|
|
final pickUpAddress = Container(
|
|
|
|
|
child: TextFormField(
|
|
|
|
|
maxLines: null,
|
|
|
|
|
controller: _addressEditingController,
|
|
|
|
|
cursorColor: primaryColor,
|
|
|
|
|
style: textStyle,
|
|
|
|
|
minLines: 2,
|
|
|
|
|
decoration: new InputDecoration(
|
|
|
|
|
labelText: 'Pickup Address',
|
|
|
|
|
enabledBorder: UnderlineInputBorder(
|
|
|
|
|
borderSide: BorderSide(color: primaryColor, width: 1.0)),
|
|
|
|
|
focusedBorder: UnderlineInputBorder(
|
|
|
|
|
borderSide: BorderSide(color: primaryColor, width: 1.0)),
|
|
|
|
|
),
|
|
|
|
|
));
|
|
|
|
|
|
|
|
|
|
final pickupTime = Container(
|
|
|
|
|
height: 50.0,
|
|
|
|
|
child: Row(children: <Widget>[
|
|
|
|
|
Container(
|
|
|
|
|
width: 70.0,
|
|
|
|
|
child: TextFormField(
|
|
|
|
|
controller: _fromTimeEditingController,
|
|
|
|
|
cursorColor: primaryColor,
|
|
|
|
|
decoration: new InputDecoration(
|
|
|
|
|
labelText: 'From',
|
|
|
|
|
enabledBorder: UnderlineInputBorder(
|
|
|
|
|
borderSide: BorderSide(color: primaryColor, width: 1.0)),
|
|
|
|
|
focusedBorder: UnderlineInputBorder(
|
|
|
|
|
borderSide: BorderSide(color: primaryColor, width: 1.0)),
|
|
|
|
|
),
|
|
|
|
|
)),
|
|
|
|
|
Padding(
|
|
|
|
|
padding: const EdgeInsets.all(8.0),
|
|
|
|
|
child: Text(' - '),
|
|
|
|
|
),
|
|
|
|
|
Container(
|
|
|
|
|
width: 70.0,
|
|
|
|
|
child: TextFormField(
|
|
|
|
|
controller: _toTimeEditingController,
|
|
|
|
|
cursorColor: primaryColor,
|
|
|
|
|
decoration: new InputDecoration(
|
|
|
|
|
labelText: 'To',
|
|
|
|
|
enabledBorder: UnderlineInputBorder(
|
|
|
|
|
borderSide: BorderSide(color: primaryColor, width: 1.0)),
|
|
|
|
|
focusedBorder: UnderlineInputBorder(
|
|
|
|
|
borderSide: BorderSide(color: primaryColor, width: 1.0)),
|
|
|
|
|
),
|
|
|
|
|
)),
|
|
|
|
|
]),
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
final noOfPackageBox = Container(
|
|
|
|
|
height: 50.0,
|
|
|
|
|
child: Row(children: <Widget>[
|
|
|
|
|
Expanded(
|
|
|
|
|
child: TextFormField(
|
|
|
|
|
controller: _noOfPackageEditingController,
|
|
|
|
|
cursorColor: primaryColor,
|
|
|
|
|
textAlign: TextAlign.left,
|
|
|
|
|
decoration: new InputDecoration(
|
|
|
|
|
labelText: 'Number of Packages',
|
|
|
|
|
enabledBorder: UnderlineInputBorder(
|
|
|
|
|
borderSide: BorderSide(color: primaryColor, width: 1.0)),
|
|
|
|
|
focusedBorder: UnderlineInputBorder(
|
|
|
|
|
borderSide: BorderSide(color: primaryColor, width: 1.0)),
|
|
|
|
|
),
|
|
|
|
|
)),
|
|
|
|
|
]),
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
final weightBox = Container(
|
|
|
|
|
height: 50.0,
|
|
|
|
|
child: Row(children: <Widget>[
|
|
|
|
|
Expanded(
|
|
|
|
|
child: TextFormField(
|
|
|
|
|
controller: _weightEditingController,
|
|
|
|
|
cursorColor: primaryColor,
|
|
|
|
|
textAlign: TextAlign.left,
|
|
|
|
|
decoration: new InputDecoration(
|
|
|
|
|
labelText: 'Total Weight (lb)',
|
|
|
|
|
enabledBorder: UnderlineInputBorder(
|
|
|
|
|
borderSide: BorderSide(color: primaryColor, width: 1.0)),
|
|
|
|
|
focusedBorder: UnderlineInputBorder(
|
|
|
|
|
borderSide: BorderSide(color: primaryColor, width: 1.0)),
|
|
|
|
|
),
|
|
|
|
|
)),
|
|
|
|
|
]),
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
MainModel mainModel = Provider.of<MainModel>(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("pickup.edit.title")),
|
|
|
|
|
),
|
|
|
|
|
body: Card(
|
|
|
|
|
child: Column(
|
|
|
|
|
children: <Widget>[
|
|
|
|
|
Expanded(
|
|
|
|
|
child: Padding(
|
|
|
|
|
padding: const EdgeInsets.all(10.0),
|
|
|
|
|
child: ListView(children: <Widget>[
|
|
|
|
|
Center(child: nameWidget(mainModel.customer.name)),
|
|
|
|
|
phoneWidget(context, mainModel.customer.phoneNumber),
|
|
|
|
|
Row(
|
|
|
|
|
children: <Widget>[
|
|
|
|
|
Padding(
|
|
|
|
|
padding: const EdgeInsets.only(right: 8.0),
|
|
|
|
|
child: Icon(Icons.location_on),
|
|
|
|
|
),
|
|
|
|
|
Expanded(child: pickUpAddress),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
SizedBox(height: 25),
|
|
|
|
|
Row(
|
|
|
|
|
children: <Widget>[
|
|
|
|
|
Padding(
|
|
|
|
|
padding: const EdgeInsets.only(right: 8.0),
|
|
|
|
|
child: Icon(Icons.timer),
|
|
|
|
|
),
|
|
|
|
|
Text('Pickup Time',
|
|
|
|
|
style: TextStyle(color: Colors.grey, fontSize: 18)),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
SizedBox(height: 5),
|
|
|
|
|
Padding(
|
|
|
|
|
padding: const EdgeInsets.only(left: 33),
|
|
|
|
|
child: pickupTime,
|
|
|
|
|
),
|
|
|
|
|
SizedBox(height: 15),
|
|
|
|
|
Row(
|
|
|
|
|
children: <Widget>[
|
|
|
|
|
Padding(
|
|
|
|
|
padding: const EdgeInsets.only(right: 8.0),
|
|
|
|
|
child: Icon(Octicons.package),
|
|
|
|
|
),
|
|
|
|
|
Expanded(child: noOfPackageBox),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
SizedBox(
|
|
|
|
|
height: 15,
|
|
|
|
|
),
|
|
|
|
|
fcsInput("Total Weight (lb)", FontAwesomeIcons.weightHanging),
|
|
|
|
|
SizedBox(
|
|
|
|
|
height: 15,
|
|
|
|
|
),
|
|
|
|
|
widget.pickUp != null
|
|
|
|
|
? fcsDropDown("Assigned", MaterialCommunityIcons.worker)
|
|
|
|
|
: Container(),
|
|
|
|
|
fcsInput("Remark", MaterialCommunityIcons.note)
|
|
|
|
|
]),
|
|
|
|
|
)),
|
|
|
|
|
widget.pickUp == null
|
|
|
|
|
? Align(
|
|
|
|
|
alignment: Alignment.bottomCenter,
|
|
|
|
|
child: Center(
|
|
|
|
|
child: Container(
|
|
|
|
|
width: 250,
|
|
|
|
|
child: FlatButton(
|
|
|
|
|
child: Text('Request for pickup'),
|
|
|
|
|
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('Update'),
|
|
|
|
|
color: primaryColor,
|
|
|
|
|
textColor: Colors.white,
|
|
|
|
|
onPressed: () {
|
|
|
|
|
Navigator.pop(context);
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
))),
|
|
|
|
|
Align(
|
|
|
|
|
alignment: Alignment.bottomCenter,
|
|
|
|
|
child: Center(
|
|
|
|
|
child: Container(
|
|
|
|
|
width: 250,
|
|
|
|
|
child: FlatButton(
|
|
|
|
|
child: Text('Cancel Pickup'),
|
|
|
|
|
color: Colors.grey[600],
|
|
|
|
|
textColor: Colors.white,
|
|
|
|
|
onPressed: () {
|
|
|
|
|
Navigator.pop(context);
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
)))
|
|
|
|
|
],
|
|
|
|
|
))
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|