2020-10-08 11:38:05 +06:30
|
|
|
import 'package:fcs/domain/vo/delivery_address.dart';
|
2020-10-07 02:33:06 +06:30
|
|
|
import 'package:fcs/helpers/theme.dart';
|
|
|
|
|
import 'package:fcs/pages/main/util.dart';
|
|
|
|
|
import 'package:fcs/pages/widgets/local_text.dart';
|
|
|
|
|
import 'package:fcs/pages/widgets/progress.dart';
|
2020-06-24 16:06:40 +06:30
|
|
|
import 'package:flutter_icons/flutter_icons.dart';
|
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
|
|
|
|
|
class ShippingAddressEditor extends StatefulWidget {
|
2020-10-08 11:38:05 +06:30
|
|
|
final DeliveryAddress shippingAddress;
|
2020-06-24 16:06:40 +06:30
|
|
|
ShippingAddressEditor({this.shippingAddress});
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
_ShippingAddressEditorState createState() => _ShippingAddressEditorState();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class _ShippingAddressEditorState extends State<ShippingAddressEditor> {
|
|
|
|
|
TextEditingController _nameController = new TextEditingController();
|
|
|
|
|
TextEditingController _address1Controller = new TextEditingController();
|
|
|
|
|
TextEditingController _address2Controller = new TextEditingController();
|
|
|
|
|
TextEditingController _cityController = new TextEditingController();
|
|
|
|
|
TextEditingController _stateController = new TextEditingController();
|
|
|
|
|
TextEditingController _phoneController = new TextEditingController();
|
|
|
|
|
|
2020-10-08 11:38:05 +06:30
|
|
|
DeliveryAddress _shippingAddress = new DeliveryAddress();
|
2020-06-24 16:06:40 +06:30
|
|
|
|
|
|
|
|
bool _isLoading = false;
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
void initState() {
|
|
|
|
|
super.initState();
|
|
|
|
|
if (widget.shippingAddress != null) {
|
|
|
|
|
_shippingAddress = widget.shippingAddress;
|
|
|
|
|
_nameController.text = _shippingAddress.fullName;
|
|
|
|
|
_address1Controller.text = _shippingAddress.addressLine1;
|
|
|
|
|
_address2Controller.text = _shippingAddress.addressLine2;
|
|
|
|
|
_cityController.text = _shippingAddress.city;
|
|
|
|
|
_stateController.text = _shippingAddress.state;
|
|
|
|
|
_phoneController.text = _shippingAddress.phoneNumber;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
void dispose() {
|
|
|
|
|
super.dispose();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
|
final usaAddress =
|
|
|
|
|
fcsInput('Full Name', Icons.text_format, controller: _nameController);
|
|
|
|
|
final mmAddress = fcsInput('Address Line 1', Icons.location_on,
|
|
|
|
|
controller: _address1Controller);
|
|
|
|
|
|
|
|
|
|
final contactNumber = fcsInput('Address Line 2', Icons.location_on,
|
|
|
|
|
controller: _address2Controller);
|
|
|
|
|
final mmContactNumber =
|
|
|
|
|
fcsInput('City', Icons.location_city, controller: _cityController);
|
|
|
|
|
|
|
|
|
|
final mailBox =
|
|
|
|
|
fcsInput('State/Region', Entypo.location, controller: _stateController);
|
|
|
|
|
final fbLinkBox =
|
|
|
|
|
fcsInput('Phone Number', Icons.phone, controller: _phoneController);
|
|
|
|
|
|
|
|
|
|
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: LocalText(
|
|
|
|
|
context,
|
|
|
|
|
'user.form.shipping_address',
|
|
|
|
|
color: Colors.white,
|
|
|
|
|
fontSize: 20,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
body: Card(
|
|
|
|
|
child: Column(
|
|
|
|
|
children: <Widget>[
|
|
|
|
|
Expanded(
|
|
|
|
|
child: Padding(
|
2020-08-30 21:26:37 +06:30
|
|
|
padding: const EdgeInsets.only(left: 10.0, right: 10),
|
2020-06-24 16:06:40 +06:30
|
|
|
child: ListView(children: <Widget>[
|
|
|
|
|
usaAddress,
|
|
|
|
|
SizedBox(height: 10),
|
|
|
|
|
mmAddress,
|
|
|
|
|
SizedBox(height: 10),
|
|
|
|
|
contactNumber,
|
|
|
|
|
SizedBox(height: 10),
|
|
|
|
|
mmContactNumber,
|
|
|
|
|
SizedBox(height: 10),
|
|
|
|
|
mailBox,
|
|
|
|
|
SizedBox(height: 10),
|
|
|
|
|
fbLinkBox,
|
|
|
|
|
SizedBox(height: 10),
|
|
|
|
|
]),
|
|
|
|
|
)),
|
|
|
|
|
widget.shippingAddress == null
|
|
|
|
|
? Align(
|
|
|
|
|
alignment: Alignment.bottomCenter,
|
|
|
|
|
child: Center(
|
|
|
|
|
child: Container(
|
|
|
|
|
width: 250,
|
|
|
|
|
child: FlatButton(
|
|
|
|
|
child: Text('Create'),
|
|
|
|
|
color: primaryColor,
|
|
|
|
|
textColor: Colors.white,
|
|
|
|
|
onPressed: () {
|
|
|
|
|
Navigator.pop(context);
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
)))
|
|
|
|
|
: Align(
|
|
|
|
|
alignment: Alignment.bottomCenter,
|
|
|
|
|
child: Center(
|
|
|
|
|
child: Container(
|
|
|
|
|
width: 250,
|
|
|
|
|
child: FlatButton(
|
|
|
|
|
child: Text('Update'),
|
|
|
|
|
color: primaryColor,
|
|
|
|
|
textColor: Colors.white,
|
|
|
|
|
onPressed: () {
|
|
|
|
|
Navigator.pop(context);
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
))),
|
|
|
|
|
SizedBox(height: 10)
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|