256 lines
8.8 KiB
Dart
256 lines
8.8 KiB
Dart
|
|
import 'package:fcs/model/pickup_model.dart';
|
||
|
|
import 'package:fcs/vo/pickup.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';
|
||
|
|
|
||
|
|
import '../theme/theme.dart';
|
||
|
|
|
||
|
|
class CalculateShipmentCostEditor extends StatefulWidget {
|
||
|
|
final PickUp pickUp;
|
||
|
|
CalculateShipmentCostEditor({this.pickUp});
|
||
|
|
|
||
|
|
@override
|
||
|
|
_CalculateShipmentCostEditorState createState() => _CalculateShipmentCostEditorState();
|
||
|
|
}
|
||
|
|
|
||
|
|
class _CalculateShipmentCostEditorState extends State<CalculateShipmentCostEditor> {
|
||
|
|
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,
|
||
|
|
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,
|
||
|
|
textAlign: TextAlign.left,
|
||
|
|
decoration: InputDecoration(
|
||
|
|
contentPadding: EdgeInsets.all(10.0),
|
||
|
|
enabledBorder: OutlineInputBorder(
|
||
|
|
borderSide: BorderSide(color: Colors.grey[300], width: 2),
|
||
|
|
),
|
||
|
|
focusedBorder: OutlineInputBorder(
|
||
|
|
borderSide: const BorderSide(color: primaryColor, width: 2.0),
|
||
|
|
),
|
||
|
|
),
|
||
|
|
)),
|
||
|
|
Padding(
|
||
|
|
padding: const EdgeInsets.all(8.0),
|
||
|
|
child: Text(' to '),
|
||
|
|
),
|
||
|
|
Container(
|
||
|
|
width: 70.0,
|
||
|
|
child: TextFormField(
|
||
|
|
controller: _toTimeEditingController,
|
||
|
|
cursorColor: primaryColor,
|
||
|
|
textAlign: TextAlign.left,
|
||
|
|
decoration: InputDecoration(
|
||
|
|
contentPadding: EdgeInsets.all(10.0),
|
||
|
|
enabledBorder: OutlineInputBorder(
|
||
|
|
borderSide: BorderSide(color: Colors.grey[300], width: 2),
|
||
|
|
),
|
||
|
|
focusedBorder: OutlineInputBorder(
|
||
|
|
borderSide: const BorderSide(color: primaryColor, width: 2.0),
|
||
|
|
),
|
||
|
|
),
|
||
|
|
)),
|
||
|
|
]),
|
||
|
|
);
|
||
|
|
|
||
|
|
final noOfPackageBox = Container(
|
||
|
|
height: 50.0,
|
||
|
|
child: Row(children: <Widget>[
|
||
|
|
Padding(
|
||
|
|
padding: const EdgeInsets.all(8.0),
|
||
|
|
child: Text('Number of Packages '),
|
||
|
|
),
|
||
|
|
Expanded(
|
||
|
|
child: TextFormField(
|
||
|
|
controller: _noOfPackageEditingController,
|
||
|
|
cursorColor: primaryColor,
|
||
|
|
textAlign: TextAlign.left,
|
||
|
|
decoration: InputDecoration(
|
||
|
|
contentPadding: EdgeInsets.all(10.0),
|
||
|
|
enabledBorder: OutlineInputBorder(
|
||
|
|
borderSide: BorderSide(color: Colors.grey[300], width: 2),
|
||
|
|
),
|
||
|
|
focusedBorder: OutlineInputBorder(
|
||
|
|
borderSide: const BorderSide(color: primaryColor, width: 2.0),
|
||
|
|
),
|
||
|
|
),
|
||
|
|
)),
|
||
|
|
]),
|
||
|
|
);
|
||
|
|
|
||
|
|
final weightBox = Container(
|
||
|
|
height: 50.0,
|
||
|
|
child: Row(children: <Widget>[
|
||
|
|
Padding(
|
||
|
|
padding: const EdgeInsets.all(8.0),
|
||
|
|
child: Text('Total Weight (lb) '),
|
||
|
|
),
|
||
|
|
Expanded(
|
||
|
|
child: TextFormField(
|
||
|
|
controller: _weightEditingController,
|
||
|
|
cursorColor: primaryColor,
|
||
|
|
textAlign: TextAlign.left,
|
||
|
|
decoration: InputDecoration(
|
||
|
|
contentPadding: EdgeInsets.all(10.0),
|
||
|
|
enabledBorder: OutlineInputBorder(
|
||
|
|
borderSide: BorderSide(color: Colors.grey[300], width: 2),
|
||
|
|
),
|
||
|
|
focusedBorder: OutlineInputBorder(
|
||
|
|
borderSide: const BorderSide(color: primaryColor, width: 2.0),
|
||
|
|
),
|
||
|
|
),
|
||
|
|
)),
|
||
|
|
]),
|
||
|
|
);
|
||
|
|
|
||
|
|
return LocalProgress(
|
||
|
|
inAsyncCall: _isLoading,
|
||
|
|
child: Scaffold(
|
||
|
|
appBar: AppBar(
|
||
|
|
backgroundColor: primaryColor,
|
||
|
|
title: Text(AppTranslations.of(context).text("pickup.edit.title")),
|
||
|
|
),
|
||
|
|
body: Card(
|
||
|
|
child: Column(
|
||
|
|
children: <Widget>[
|
||
|
|
Expanded(
|
||
|
|
child: Padding(
|
||
|
|
padding: const EdgeInsets.all(20.0),
|
||
|
|
child: ListView(children: <Widget>[
|
||
|
|
Text(
|
||
|
|
"U Aung Zaw",
|
||
|
|
style: TextStyle(fontSize: 15.0),
|
||
|
|
),
|
||
|
|
Text(
|
||
|
|
"+82054857695",
|
||
|
|
style: TextStyle(fontSize: 15.0),
|
||
|
|
),
|
||
|
|
pickUpAddress,
|
||
|
|
SizedBox(height: 15),
|
||
|
|
Text('Pickup Time'),
|
||
|
|
SizedBox(height: 15),
|
||
|
|
pickupTime,
|
||
|
|
SizedBox(height: 15),
|
||
|
|
noOfPackageBox,
|
||
|
|
SizedBox(height: 15),
|
||
|
|
weightBox
|
||
|
|
]),
|
||
|
|
)),
|
||
|
|
widget.pickUp == null
|
||
|
|
? Align(
|
||
|
|
alignment: Alignment.bottomCenter,
|
||
|
|
child: Center(
|
||
|
|
child: Container(
|
||
|
|
width: 250,
|
||
|
|
child: FlatButton(
|
||
|
|
shape: new RoundedRectangleBorder(
|
||
|
|
borderRadius: new BorderRadius.circular(10)),
|
||
|
|
child: Text('Request'),
|
||
|
|
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(
|
||
|
|
shape: new RoundedRectangleBorder(
|
||
|
|
borderRadius:
|
||
|
|
new BorderRadius.circular(10)),
|
||
|
|
child: Text('Pickuped'),
|
||
|
|
color: primaryColor,
|
||
|
|
textColor: Colors.white,
|
||
|
|
onPressed: () {
|
||
|
|
Navigator.pop(context);
|
||
|
|
},
|
||
|
|
),
|
||
|
|
))),
|
||
|
|
Align(
|
||
|
|
alignment: Alignment.bottomCenter,
|
||
|
|
child: Center(
|
||
|
|
child: Container(
|
||
|
|
width: 250,
|
||
|
|
child: FlatButton(
|
||
|
|
shape: new RoundedRectangleBorder(
|
||
|
|
borderRadius:
|
||
|
|
new BorderRadius.circular(10)),
|
||
|
|
child: Text('Cancel'),
|
||
|
|
color: primaryColor,
|
||
|
|
textColor: Colors.white,
|
||
|
|
onPressed: () {
|
||
|
|
Navigator.pop(context);
|
||
|
|
},
|
||
|
|
),
|
||
|
|
)))
|
||
|
|
],
|
||
|
|
))
|
||
|
|
],
|
||
|
|
),
|
||
|
|
),
|
||
|
|
),
|
||
|
|
);
|
||
|
|
}
|
||
|
|
}
|