Merge branch 'master' of phyothandar/fcs into master
This commit is contained in:
@@ -321,9 +321,21 @@
|
|||||||
"discount.status":"Status",
|
"discount.status":"Status",
|
||||||
"Discount End ================================================================":"",
|
"Discount End ================================================================":"",
|
||||||
|
|
||||||
"Shipping_addresses Start ================================================================":"",
|
"delivery_addresses Start ================================================================":"",
|
||||||
"shipping_addresses": "ADDRESSES",
|
"delivery_addresses": "Delivery Addresses",
|
||||||
"Shipping_addresses End ================================================================":"",
|
"delivery_address": "Delivery Address",
|
||||||
|
"delivery_address.full_name": "Full Name",
|
||||||
|
"delivery_address.address_line1": "Address Line 1",
|
||||||
|
"delivery_address.address_line2": "Address Line 2",
|
||||||
|
"delivery_address.state_region": "State/Region",
|
||||||
|
"delivery_address.city": "City",
|
||||||
|
"delivery_address.country": "Country",
|
||||||
|
"delivery_address.phonenumber": "Phone Number",
|
||||||
|
"delivery_address.create": "Create Delivery Address",
|
||||||
|
"delivery_address.update": "Update Delivery Address",
|
||||||
|
"delivery_address.new_address":"Add New\nAddress",
|
||||||
|
"delivery_address.change_address": "Change Address",
|
||||||
|
"delivery_addresses End ================================================================":"",
|
||||||
|
|
||||||
"Receiving Start ================================================================":"",
|
"Receiving Start ================================================================":"",
|
||||||
"receiving.title":"Receiving",
|
"receiving.title":"Receiving",
|
||||||
|
|||||||
@@ -261,7 +261,7 @@
|
|||||||
"FCSshipment.dms":"Download DMS",
|
"FCSshipment.dms":"Download DMS",
|
||||||
"FCSshipment.cargo_manifest":"Download Cargo Manifest",
|
"FCSshipment.cargo_manifest":"Download Cargo Manifest",
|
||||||
"FCSshipment.create":"FCS တင်ပို့ခြင်းပြုလုပ်ရန်",
|
"FCSshipment.create":"FCS တင်ပို့ခြင်းပြုလုပ်ရန်",
|
||||||
"FCSshipment.update":"FCS တင်ပို့ခြင်းပြင်ရန်",
|
"FCSshipment.update":"FCS တင်ပို့ခြင်းပြုပြင်ရန်",
|
||||||
"FCS Shipment End ================================================================":"",
|
"FCS Shipment End ================================================================":"",
|
||||||
|
|
||||||
"Shipment Start ================================================================":"",
|
"Shipment Start ================================================================":"",
|
||||||
@@ -321,9 +321,21 @@
|
|||||||
"discount.status":"အခြေအနေ",
|
"discount.status":"အခြေအနေ",
|
||||||
"Discount End ================================================================":"",
|
"Discount End ================================================================":"",
|
||||||
|
|
||||||
"Shipping_addresses Start ================================================================":"",
|
"delivery_addresses Start ================================================================":"",
|
||||||
"shipping_addresses": "လိပ်စာများ",
|
"delivery_addresses": "ပို့ဆောင်ရမည့်လိပ်စာများ",
|
||||||
"Shipping_addresses End ================================================================":"",
|
"delivery_address": "ပို့ဆောင်ရမည့်လိပ်စာ",
|
||||||
|
"delivery_address.full_name": "နာမည် အပြည့်အစုံ",
|
||||||
|
"delivery_address.address_line1": "လိပ်စာ ၁",
|
||||||
|
"delivery_address.address_line2": "လိပ်စာ ၂",
|
||||||
|
"delivery_address.state_region": "ပြည်နယ်/တိုင်း",
|
||||||
|
"delivery_address.city": "မြို့",
|
||||||
|
"delivery_address.country": "နိုင်ငံ",
|
||||||
|
"delivery_address.phonenumber": "ဖုန်းနံပါတ်",
|
||||||
|
"delivery_address.create": "ပြုလုပ်ရန်",
|
||||||
|
"delivery_address.update": "ပြုပြင်ရန်",
|
||||||
|
"delivery_address.new_address":"လိပ်စာအသစ်",
|
||||||
|
"delivery_address.change_address": "လိပ်စာပြောင်းပါ",
|
||||||
|
"delivery_addresses End ================================================================":"",
|
||||||
|
|
||||||
"Receiving Start ================================================================":"",
|
"Receiving Start ================================================================":"",
|
||||||
"receiving.title":"လက်ခံခြင်းများ",
|
"receiving.title":"လက်ခံခြင်းများ",
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import 'package:fcs/pages/box/model/box_model.dart';
|
|||||||
import 'package:fcs/pages/chat/model/message_model.dart';
|
import 'package:fcs/pages/chat/model/message_model.dart';
|
||||||
import 'package:fcs/pages/contact/model/contact_model.dart';
|
import 'package:fcs/pages/contact/model/contact_model.dart';
|
||||||
import 'package:fcs/pages/customer/model/customer_model.dart';
|
import 'package:fcs/pages/customer/model/customer_model.dart';
|
||||||
|
import 'package:fcs/pages/delivery_address/model/delivery_address_model.dart';
|
||||||
import 'package:fcs/pages/discount/model/discount_model.dart';
|
import 'package:fcs/pages/discount/model/discount_model.dart';
|
||||||
import 'package:fcs/pages/faq/model/faq_model.dart';
|
import 'package:fcs/pages/faq/model/faq_model.dart';
|
||||||
import 'package:fcs/pages/fcs_shipment/model/fcs_shipment_model.dart';
|
import 'package:fcs/pages/fcs_shipment/model/fcs_shipment_model.dart';
|
||||||
@@ -17,7 +18,6 @@ import 'package:fcs/pages/package/model/package_model.dart';
|
|||||||
import 'package:fcs/pages/payment_methods/model/payment_method_model.dart';
|
import 'package:fcs/pages/payment_methods/model/payment_method_model.dart';
|
||||||
import 'package:fcs/pages/rates/model/shipment_rate_model.dart';
|
import 'package:fcs/pages/rates/model/shipment_rate_model.dart';
|
||||||
import 'package:fcs/pages/shipment/model/shipment_model.dart';
|
import 'package:fcs/pages/shipment/model/shipment_model.dart';
|
||||||
import 'package:fcs/pages/shipment_address/model/shipment_address_model.dart';
|
|
||||||
import 'package:fcs/pages/main/splash_page.dart';
|
import 'package:fcs/pages/main/splash_page.dart';
|
||||||
import 'package:fcs/pages/staff/model/staff_model.dart';
|
import 'package:fcs/pages/staff/model/staff_model.dart';
|
||||||
import 'package:fcs/pages/term/model/term_model.dart';
|
import 'package:fcs/pages/term/model/term_model.dart';
|
||||||
@@ -48,7 +48,7 @@ class _AppState extends State<App> {
|
|||||||
final CustomerModel customerModel = new CustomerModel();
|
final CustomerModel customerModel = new CustomerModel();
|
||||||
final DiscountModel discountModel = new DiscountModel();
|
final DiscountModel discountModel = new DiscountModel();
|
||||||
final StaffModel staffModel = new StaffModel();
|
final StaffModel staffModel = new StaffModel();
|
||||||
final ShipmentAddressModel shipmentAddressModel = new ShipmentAddressModel();
|
final DeliveryAddressModel deliveryAddressModel = new DeliveryAddressModel();
|
||||||
final PackageModel packageModel = new PackageModel();
|
final PackageModel packageModel = new PackageModel();
|
||||||
final MarketModel marketModel = new MarketModel();
|
final MarketModel marketModel = new MarketModel();
|
||||||
|
|
||||||
@@ -60,7 +60,7 @@ class _AppState extends State<App> {
|
|||||||
mainModel
|
mainModel
|
||||||
..addModel(customerModel)
|
..addModel(customerModel)
|
||||||
..addModel(staffModel)
|
..addModel(staffModel)
|
||||||
..addModel(shipmentAddressModel)
|
..addModel(deliveryAddressModel)
|
||||||
..addModel(packageModel)
|
..addModel(packageModel)
|
||||||
..addModel(messageModel)
|
..addModel(messageModel)
|
||||||
..addModel(fcsShipmentModel)
|
..addModel(fcsShipmentModel)
|
||||||
@@ -100,7 +100,7 @@ class _AppState extends State<App> {
|
|||||||
ChangeNotifierProvider.value(value: lanuguageModel),
|
ChangeNotifierProvider.value(value: lanuguageModel),
|
||||||
ChangeNotifierProvider.value(value: shipmentModel),
|
ChangeNotifierProvider.value(value: shipmentModel),
|
||||||
ChangeNotifierProvider.value(value: shipmentRateModel),
|
ChangeNotifierProvider.value(value: shipmentRateModel),
|
||||||
ChangeNotifierProvider.value(value: shipmentAddressModel),
|
ChangeNotifierProvider.value(value: deliveryAddressModel),
|
||||||
ChangeNotifierProvider.value(value: packageModel),
|
ChangeNotifierProvider.value(value: packageModel),
|
||||||
ChangeNotifierProvider.value(value: boxModel),
|
ChangeNotifierProvider.value(value: boxModel),
|
||||||
ChangeNotifierProvider.value(value: messageModel),
|
ChangeNotifierProvider.value(value: messageModel),
|
||||||
|
|||||||
@@ -8,7 +8,8 @@ class DeliveryAddress {
|
|||||||
String country;
|
String country;
|
||||||
String phoneNumber;
|
String phoneNumber;
|
||||||
DeliveryAddress(
|
DeliveryAddress(
|
||||||
{this.fullName,
|
{this.id,
|
||||||
|
this.fullName,
|
||||||
this.addressLine1,
|
this.addressLine1,
|
||||||
this.addressLine2,
|
this.addressLine2,
|
||||||
this.city,
|
this.city,
|
||||||
@@ -16,6 +17,19 @@ class DeliveryAddress {
|
|||||||
this.country,
|
this.country,
|
||||||
this.phoneNumber});
|
this.phoneNumber});
|
||||||
|
|
||||||
|
factory DeliveryAddress.fromMap(Map<String, dynamic> map, String docID) {
|
||||||
|
return DeliveryAddress(
|
||||||
|
id: docID,
|
||||||
|
fullName: map['full_name'],
|
||||||
|
addressLine1: map['address_line1'],
|
||||||
|
addressLine2: map['address_line2'],
|
||||||
|
city: map['city'],
|
||||||
|
state: map['state'],
|
||||||
|
country: map['country'],
|
||||||
|
phoneNumber: map['phone_number'],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
Map<String, dynamic> toMap() {
|
Map<String, dynamic> toMap() {
|
||||||
return {
|
return {
|
||||||
"id": id,
|
"id": id,
|
||||||
@@ -25,7 +39,7 @@ class DeliveryAddress {
|
|||||||
'city': city,
|
'city': city,
|
||||||
'state': state,
|
'state': state,
|
||||||
'phone_number': phoneNumber,
|
'phone_number': phoneNumber,
|
||||||
'contry': country,
|
'country': country,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,9 +4,9 @@ import 'package:fcs/domain/entities/package.dart';
|
|||||||
import 'package:fcs/domain/vo/delivery_address.dart';
|
import 'package:fcs/domain/vo/delivery_address.dart';
|
||||||
import 'package:fcs/helpers/theme.dart';
|
import 'package:fcs/helpers/theme.dart';
|
||||||
import 'package:fcs/localization/app_translations.dart';
|
import 'package:fcs/localization/app_translations.dart';
|
||||||
|
import 'package:fcs/pages/delivery_address/delivery_address_row.dart';
|
||||||
|
import 'package:fcs/pages/delivery_address/model/delivery_address_model.dart';
|
||||||
import 'package:fcs/pages/main/model/main_model.dart';
|
import 'package:fcs/pages/main/model/main_model.dart';
|
||||||
import 'package:fcs/pages/shipment_address/model/shipment_address_model.dart';
|
|
||||||
import 'package:fcs/pages/shipment_address/shipping_address_row.dart';
|
|
||||||
import 'package:fcs/pages/main/util.dart';
|
import 'package:fcs/pages/main/util.dart';
|
||||||
import 'package:fcs/pages/widgets/local_text.dart';
|
import 'package:fcs/pages/widgets/local_text.dart';
|
||||||
import 'package:fcs/pages/widgets/my_data_table.dart';
|
import 'package:fcs/pages/widgets/my_data_table.dart';
|
||||||
@@ -73,8 +73,8 @@ class _BoxEditorState extends State<BoxEditor> {
|
|||||||
];
|
];
|
||||||
|
|
||||||
var shipmentModel =
|
var shipmentModel =
|
||||||
Provider.of<ShipmentAddressModel>(context, listen: false);
|
Provider.of<DeliveryAddressModel>(context, listen: false);
|
||||||
_shippingAddress = shipmentModel.shippingAddresses[1];
|
_shippingAddress = shipmentModel.deliveryAddresses[1];
|
||||||
|
|
||||||
isNew = true;
|
isNew = true;
|
||||||
_box = Box(
|
_box = Box(
|
||||||
@@ -417,7 +417,7 @@ class _BoxEditorState extends State<BoxEditor> {
|
|||||||
color: primaryColor, fontWeight: FontWeight.bold),
|
color: primaryColor, fontWeight: FontWeight.bold),
|
||||||
),
|
),
|
||||||
children: [
|
children: [
|
||||||
ShippingAddressRow(shippingAddress: _shippingAddress),
|
DeliveryAddressRow(shippingAddress: _shippingAddress),
|
||||||
Container(
|
Container(
|
||||||
padding:
|
padding:
|
||||||
EdgeInsets.only(top: 20, bottom: 15, right: 15),
|
EdgeInsets.only(top: 20, bottom: 15, right: 15),
|
||||||
@@ -550,7 +550,7 @@ class _BoxEditorState extends State<BoxEditor> {
|
|||||||
return addresses.asMap().entries.map((s) {
|
return addresses.asMap().entries.map((s) {
|
||||||
return InkWell(
|
return InkWell(
|
||||||
onTap: () {},
|
onTap: () {},
|
||||||
child: ShippingAddressRow(shippingAddress: s.value, index: s.key),
|
child: DeliveryAddressRow(shippingAddress: s.value, index: s.key),
|
||||||
);
|
);
|
||||||
}).toList();
|
}).toList();
|
||||||
}
|
}
|
||||||
|
|||||||
240
lib/pages/delivery_address/delivery_address_editor.dart
Normal file
240
lib/pages/delivery_address/delivery_address_editor.dart
Normal file
@@ -0,0 +1,240 @@
|
|||||||
|
import 'package:fcs/domain/vo/delivery_address.dart';
|
||||||
|
import 'package:fcs/helpers/theme.dart';
|
||||||
|
import 'package:fcs/pages/delivery_address/model/delivery_address_model.dart';
|
||||||
|
import 'package:fcs/pages/main/util.dart';
|
||||||
|
import 'package:fcs/pages/widgets/input_text.dart';
|
||||||
|
import 'package:fcs/pages/widgets/local_text.dart';
|
||||||
|
import 'package:fcs/pages/widgets/progress.dart';
|
||||||
|
import 'package:flutter_icons/flutter_icons.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:provider/provider.dart';
|
||||||
|
|
||||||
|
class DeliveryAddressEditor extends StatefulWidget {
|
||||||
|
final DeliveryAddress deliveryAddress;
|
||||||
|
DeliveryAddressEditor({this.deliveryAddress});
|
||||||
|
|
||||||
|
@override
|
||||||
|
_DeliveryAddressEditorState createState() => _DeliveryAddressEditorState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _DeliveryAddressEditorState extends State<DeliveryAddressEditor> {
|
||||||
|
TextEditingController _nameController = new TextEditingController();
|
||||||
|
TextEditingController _address1Controller = new TextEditingController();
|
||||||
|
TextEditingController _address2Controller = new TextEditingController();
|
||||||
|
TextEditingController _cityController = new TextEditingController();
|
||||||
|
TextEditingController _stateController = new TextEditingController();
|
||||||
|
TextEditingController _countryController = new TextEditingController();
|
||||||
|
TextEditingController _phoneController = new TextEditingController();
|
||||||
|
|
||||||
|
DeliveryAddress _deliveryAddress = new DeliveryAddress();
|
||||||
|
|
||||||
|
bool _isLoading = false;
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
super.initState();
|
||||||
|
if (widget.deliveryAddress != null) {
|
||||||
|
_deliveryAddress = widget.deliveryAddress;
|
||||||
|
_nameController.text = _deliveryAddress.fullName;
|
||||||
|
_address1Controller.text = _deliveryAddress.addressLine1;
|
||||||
|
_address2Controller.text = _deliveryAddress.addressLine2;
|
||||||
|
_cityController.text = _deliveryAddress.city;
|
||||||
|
_stateController.text = _deliveryAddress.state;
|
||||||
|
_countryController.text = _deliveryAddress.country;
|
||||||
|
_phoneController.text = _deliveryAddress.phoneNumber;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void dispose() {
|
||||||
|
super.dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
final usaAddress = InputText(
|
||||||
|
labelTextKey: 'delivery_address.full_name',
|
||||||
|
iconData: Icons.text_format,
|
||||||
|
controller: _nameController);
|
||||||
|
|
||||||
|
final addressLine1 = InputText(
|
||||||
|
labelTextKey: 'delivery_address.address_line1',
|
||||||
|
iconData: Icons.location_on,
|
||||||
|
controller: _address1Controller);
|
||||||
|
|
||||||
|
final addressLine2 = InputText(
|
||||||
|
labelTextKey: 'delivery_address.address_line2',
|
||||||
|
iconData: Icons.location_on,
|
||||||
|
controller: _address2Controller);
|
||||||
|
|
||||||
|
final cityBox = InputText(
|
||||||
|
labelTextKey: 'delivery_address.city',
|
||||||
|
iconData: Icons.location_city,
|
||||||
|
controller: _cityController);
|
||||||
|
|
||||||
|
final regionBox = InputText(
|
||||||
|
labelTextKey: 'delivery_address.state_region',
|
||||||
|
iconData: Entypo.location,
|
||||||
|
controller: _stateController);
|
||||||
|
|
||||||
|
final countryBox = InputText(
|
||||||
|
labelTextKey: 'delivery_address.country',
|
||||||
|
iconData: Entypo.flag,
|
||||||
|
controller: _countryController);
|
||||||
|
|
||||||
|
final phoneNumberBox = InputText(
|
||||||
|
labelTextKey: 'delivery_address.phonenumber',
|
||||||
|
iconData: Icons.phone,
|
||||||
|
controller: _phoneController);
|
||||||
|
|
||||||
|
final createBtn = fcsButton(
|
||||||
|
context,
|
||||||
|
getLocalString(context, "delivery_address.create"),
|
||||||
|
callack: _create,
|
||||||
|
);
|
||||||
|
|
||||||
|
final updateBtn = fcsButton(
|
||||||
|
context,
|
||||||
|
getLocalString(context, "delivery_address.update"),
|
||||||
|
callack: _update,
|
||||||
|
);
|
||||||
|
|
||||||
|
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(
|
||||||
|
padding: const EdgeInsets.only(left: 10.0, right: 10),
|
||||||
|
child: ListView(children: <Widget>[
|
||||||
|
usaAddress,
|
||||||
|
SizedBox(height: 5),
|
||||||
|
addressLine1,
|
||||||
|
SizedBox(height: 5),
|
||||||
|
addressLine2,
|
||||||
|
SizedBox(height: 5),
|
||||||
|
cityBox,
|
||||||
|
SizedBox(height: 5),
|
||||||
|
regionBox,
|
||||||
|
SizedBox(height: 5),
|
||||||
|
countryBox,
|
||||||
|
SizedBox(height: 5),
|
||||||
|
phoneNumberBox,
|
||||||
|
SizedBox(height: 10),
|
||||||
|
]),
|
||||||
|
)),
|
||||||
|
widget.deliveryAddress == null ? createBtn : updateBtn,
|
||||||
|
SizedBox(height: 10)
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
DeliveryAddress _getPayload() {
|
||||||
|
DeliveryAddress deliveryAddress = DeliveryAddress();
|
||||||
|
deliveryAddress.id = _deliveryAddress.id;
|
||||||
|
|
||||||
|
try {
|
||||||
|
deliveryAddress.fullName = _nameController.text;
|
||||||
|
deliveryAddress.addressLine1 = _address1Controller.text;
|
||||||
|
deliveryAddress.addressLine2 = _address2Controller.text;
|
||||||
|
deliveryAddress.city = _cityController.text;
|
||||||
|
deliveryAddress.state = _stateController.text;
|
||||||
|
deliveryAddress.country = _countryController.text;
|
||||||
|
deliveryAddress.phoneNumber = _phoneController.text;
|
||||||
|
} catch (e) {
|
||||||
|
showMsgDialog(context, "Error", e.toString()); // shold never happen
|
||||||
|
}
|
||||||
|
return deliveryAddress;
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<bool> _validate(DeliveryAddress deliveryAddress) async {
|
||||||
|
if (deliveryAddress.addressLine1 == "") {
|
||||||
|
await showMsgDialog(context, "Error", "Invalid address line 1!");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (deliveryAddress.city == null) {
|
||||||
|
await showMsgDialog(context, "Error", "Invalid city!");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (deliveryAddress.state == null) {
|
||||||
|
await showMsgDialog(context, "Error", "Invalid state!");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (deliveryAddress.country == null) {
|
||||||
|
await showMsgDialog(context, "Error", "Invalid country!");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (deliveryAddress.phoneNumber == null) {
|
||||||
|
await showMsgDialog(context, "Error", "Invalid phone number!");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> _create() async {
|
||||||
|
DeliveryAddress deliveryAddress = _getPayload();
|
||||||
|
bool valid = await _validate(deliveryAddress);
|
||||||
|
if (!valid) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
setState(() {
|
||||||
|
_isLoading = true;
|
||||||
|
});
|
||||||
|
var deliveryAddressModel =
|
||||||
|
Provider.of<DeliveryAddressModel>(context, listen: false);
|
||||||
|
try {
|
||||||
|
await deliveryAddressModel.createDeliveryAddress(deliveryAddress);
|
||||||
|
Navigator.pop(context);
|
||||||
|
} catch (e) {
|
||||||
|
showMsgDialog(context, "Error", e.toString());
|
||||||
|
} finally {
|
||||||
|
setState(() {
|
||||||
|
_isLoading = false;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> _update() async {
|
||||||
|
DeliveryAddress deliveryAddress = _getPayload();
|
||||||
|
print('deliveryAddress => ${deliveryAddress.country}');
|
||||||
|
bool valid = await _validate(deliveryAddress);
|
||||||
|
if (!valid) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
setState(() {
|
||||||
|
_isLoading = true;
|
||||||
|
});
|
||||||
|
var deliveryAddressModel =
|
||||||
|
Provider.of<DeliveryAddressModel>(context, listen: false);
|
||||||
|
try {
|
||||||
|
await deliveryAddressModel.updateDeliveryAddress(deliveryAddress);
|
||||||
|
Navigator.pop(context);
|
||||||
|
} catch (e) {
|
||||||
|
showMsgDialog(context, "Error", e.toString());
|
||||||
|
} finally {
|
||||||
|
setState(() {
|
||||||
|
_isLoading = false;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,20 +1,25 @@
|
|||||||
import 'package:fcs/domain/vo/delivery_address.dart';
|
import 'package:fcs/domain/vo/delivery_address.dart';
|
||||||
import 'package:fcs/helpers/theme.dart';
|
import 'package:fcs/helpers/theme.dart';
|
||||||
|
import 'package:fcs/pages/delivery_address/delivery_address_editor.dart';
|
||||||
|
import 'package:fcs/pages/main/util.dart';
|
||||||
import 'package:fcs/pages/widgets/bottom_up_page_route.dart';
|
import 'package:fcs/pages/widgets/bottom_up_page_route.dart';
|
||||||
import 'package:fcs/pages/widgets/local_text.dart';
|
import 'package:fcs/pages/widgets/local_text.dart';
|
||||||
import 'package:fcs/pages/widgets/progress.dart';
|
import 'package:fcs/pages/widgets/progress.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
|
|
||||||
import 'model/shipment_address_model.dart';
|
import 'model/delivery_address_model.dart';
|
||||||
import 'shipping_address_row.dart';
|
import 'delivery_address_row.dart';
|
||||||
|
|
||||||
class ShippingAddressList extends StatefulWidget {
|
class DeliveryAddressList extends StatefulWidget {
|
||||||
|
final DeliveryAddress deliveryAddress;
|
||||||
|
|
||||||
|
const DeliveryAddressList({Key key, this.deliveryAddress}) : super(key: key);
|
||||||
@override
|
@override
|
||||||
_ShippingAddressListState createState() => _ShippingAddressListState();
|
_DeliveryAddressListState createState() => _DeliveryAddressListState();
|
||||||
}
|
}
|
||||||
|
|
||||||
class _ShippingAddressListState extends State<ShippingAddressList> {
|
class _DeliveryAddressListState extends State<DeliveryAddressList> {
|
||||||
bool _isLoading = false;
|
bool _isLoading = false;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@@ -29,7 +34,7 @@ class _ShippingAddressListState extends State<ShippingAddressList> {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
var shipmentModel = Provider.of<ShipmentAddressModel>(context);
|
var shipmentModel = Provider.of<DeliveryAddressModel>(context);
|
||||||
|
|
||||||
return LocalProgress(
|
return LocalProgress(
|
||||||
inAsyncCall: _isLoading,
|
inAsyncCall: _isLoading,
|
||||||
@@ -38,32 +43,22 @@ class _ShippingAddressListState extends State<ShippingAddressList> {
|
|||||||
centerTitle: true,
|
centerTitle: true,
|
||||||
leading: new IconButton(
|
leading: new IconButton(
|
||||||
icon: new Icon(Icons.close),
|
icon: new Icon(Icons.close),
|
||||||
onPressed: () => Navigator.of(context).pop(),
|
onPressed: () => Navigator.pop(context, widget.deliveryAddress),
|
||||||
),
|
),
|
||||||
backgroundColor: primaryColor,
|
backgroundColor: primaryColor,
|
||||||
title: LocalText(
|
title: LocalText(
|
||||||
context,
|
context,
|
||||||
"shipping_addresses",
|
"delivery_addresses",
|
||||||
fontSize: 20,
|
fontSize: 20,
|
||||||
color: Colors.white,
|
color: Colors.white,
|
||||||
),
|
),
|
||||||
actions: <Widget>[
|
|
||||||
IconButton(
|
|
||||||
icon: Icon(
|
|
||||||
Icons.search,
|
|
||||||
color: Colors.white,
|
|
||||||
),
|
|
||||||
iconSize: 30,
|
|
||||||
// onPressed: () => showPlacesSearch(context),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
),
|
||||||
body: Column(
|
body: Column(
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
Expanded(
|
Expanded(
|
||||||
child: Column(
|
child: Column(
|
||||||
children:
|
children:
|
||||||
getAddressList(context, shipmentModel.shippingAddresses),
|
getAddressList(context, shipmentModel.deliveryAddresses),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
Container(
|
Container(
|
||||||
@@ -78,12 +73,12 @@ class _ShippingAddressListState extends State<ShippingAddressList> {
|
|||||||
onPressed: () {
|
onPressed: () {
|
||||||
Navigator.push(
|
Navigator.push(
|
||||||
context,
|
context,
|
||||||
BottomUpPageRoute(ShippingAddressList()),
|
BottomUpPageRoute(DeliveryAddressEditor()),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
icon: Icon(Icons.add),
|
icon: Icon(Icons.add),
|
||||||
label: Text(
|
label: Text(
|
||||||
'Add New\nAddress',
|
getLocalString(context, 'delivery_address.new_address'),
|
||||||
style: TextStyle(fontSize: 12),
|
style: TextStyle(fontSize: 12),
|
||||||
),
|
),
|
||||||
backgroundColor: primaryColor,
|
backgroundColor: primaryColor,
|
||||||
@@ -101,9 +96,9 @@ class _ShippingAddressListState extends State<ShippingAddressList> {
|
|||||||
return addresses.asMap().entries.map((s) {
|
return addresses.asMap().entries.map((s) {
|
||||||
return InkWell(
|
return InkWell(
|
||||||
onTap: () {
|
onTap: () {
|
||||||
Navigator.pop(context, s.value);
|
// Navigator.pop(context, s.value);
|
||||||
},
|
},
|
||||||
child: ShippingAddressRow(shippingAddress: s.value, index: s.key),
|
child: DeliveryAddressRow(shippingAddress: s.value, index: s.key),
|
||||||
);
|
);
|
||||||
}).toList();
|
}).toList();
|
||||||
}
|
}
|
||||||
146
lib/pages/delivery_address/delivery_address_row.dart
Normal file
146
lib/pages/delivery_address/delivery_address_row.dart
Normal file
@@ -0,0 +1,146 @@
|
|||||||
|
import 'package:fcs/domain/vo/delivery_address.dart';
|
||||||
|
import 'package:fcs/pages/delivery_address/model/delivery_address_model.dart';
|
||||||
|
import 'package:fcs/pages/widgets/bottom_up_page_route.dart';
|
||||||
|
import 'package:flutter/cupertino.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:provider/provider.dart';
|
||||||
|
|
||||||
|
import 'delivery_address_editor.dart';
|
||||||
|
|
||||||
|
class DeliveryAddressRow extends StatelessWidget {
|
||||||
|
final DeliveryAddress shippingAddress;
|
||||||
|
final int index;
|
||||||
|
|
||||||
|
const DeliveryAddressRow({Key key, this.shippingAddress, this.index})
|
||||||
|
: super(key: key);
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
var deliveryAddressModel = Provider.of<DeliveryAddressModel>(context);
|
||||||
|
return Container(
|
||||||
|
padding: EdgeInsets.only(left: 10, right: 10),
|
||||||
|
child: Column(
|
||||||
|
children: <Widget>[
|
||||||
|
Row(
|
||||||
|
children: <Widget>[
|
||||||
|
Expanded(
|
||||||
|
child: new Padding(
|
||||||
|
padding: const EdgeInsets.symmetric(vertical: 10.0),
|
||||||
|
child: Row(
|
||||||
|
children: <Widget>[
|
||||||
|
InkWell(
|
||||||
|
onTap: () {
|
||||||
|
Navigator.pop(context, shippingAddress);
|
||||||
|
},
|
||||||
|
child: new Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
mainAxisAlignment: MainAxisAlignment.start,
|
||||||
|
children: <Widget>[
|
||||||
|
Padding(
|
||||||
|
padding: const EdgeInsets.only(left: 8.0),
|
||||||
|
child: new Text(
|
||||||
|
shippingAddress.fullName == null
|
||||||
|
? ''
|
||||||
|
: shippingAddress.fullName,
|
||||||
|
style: new TextStyle(
|
||||||
|
fontSize: 15.0,
|
||||||
|
color: Colors.black,
|
||||||
|
fontWeight: FontWeight.bold),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Padding(
|
||||||
|
padding: const EdgeInsets.only(left: 8.0),
|
||||||
|
child: new Text(
|
||||||
|
shippingAddress.addressLine1 == null
|
||||||
|
? ''
|
||||||
|
: shippingAddress.addressLine1,
|
||||||
|
style: new TextStyle(
|
||||||
|
fontSize: 14.0, color: Colors.grey),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Padding(
|
||||||
|
padding: const EdgeInsets.only(left: 8.0),
|
||||||
|
child: new Text(
|
||||||
|
shippingAddress.addressLine2 == null
|
||||||
|
? ''
|
||||||
|
: shippingAddress.addressLine2,
|
||||||
|
style: new TextStyle(
|
||||||
|
fontSize: 14.0, color: Colors.grey),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Padding(
|
||||||
|
padding: const EdgeInsets.only(left: 8.0),
|
||||||
|
child: new Text(
|
||||||
|
shippingAddress.city == null
|
||||||
|
? ''
|
||||||
|
: shippingAddress.city,
|
||||||
|
style: new TextStyle(
|
||||||
|
fontSize: 14.0, color: Colors.grey),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Padding(
|
||||||
|
padding: const EdgeInsets.only(left: 8.0),
|
||||||
|
child: new Text(
|
||||||
|
shippingAddress.state == null
|
||||||
|
? ''
|
||||||
|
: shippingAddress.state,
|
||||||
|
style: new TextStyle(
|
||||||
|
fontSize: 14.0, color: Colors.grey),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Padding(
|
||||||
|
padding: const EdgeInsets.only(left: 8.0),
|
||||||
|
child: new Text(
|
||||||
|
shippingAddress.country == null
|
||||||
|
? ''
|
||||||
|
: shippingAddress.country,
|
||||||
|
style: new TextStyle(
|
||||||
|
fontSize: 14.0, color: Colors.grey),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Padding(
|
||||||
|
padding: const EdgeInsets.only(left: 8.0),
|
||||||
|
child: new Text(
|
||||||
|
shippingAddress.phoneNumber == null
|
||||||
|
? ''
|
||||||
|
: "Phone:${shippingAddress.phoneNumber}",
|
||||||
|
style: new TextStyle(
|
||||||
|
fontSize: 14.0, color: Colors.grey),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
IconButton(
|
||||||
|
padding: EdgeInsets.only(right: 30),
|
||||||
|
icon: Icon(Icons.edit, color: Colors.black45),
|
||||||
|
onPressed: () {
|
||||||
|
Navigator.push(
|
||||||
|
context,
|
||||||
|
BottomUpPageRoute(DeliveryAddressEditor(
|
||||||
|
deliveryAddress: shippingAddress)),
|
||||||
|
);
|
||||||
|
}),
|
||||||
|
IconButton(
|
||||||
|
padding: EdgeInsets.only(right: 30),
|
||||||
|
icon: Icon(Icons.delete, color: Colors.black45),
|
||||||
|
onPressed: () async {
|
||||||
|
await deliveryAddressModel
|
||||||
|
.deleteDeliveryAddress(shippingAddress);
|
||||||
|
})
|
||||||
|
],
|
||||||
|
),
|
||||||
|
index == null
|
||||||
|
? Container()
|
||||||
|
: index == deliveryAddressModel.deliveryAddresses.length - 1
|
||||||
|
? Container()
|
||||||
|
: Divider(color: Colors.black)
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
64
lib/pages/delivery_address/model/delivery_address_model.dart
Normal file
64
lib/pages/delivery_address/model/delivery_address_model.dart
Normal file
@@ -0,0 +1,64 @@
|
|||||||
|
import 'dart:async';
|
||||||
|
import 'package:cloud_firestore/cloud_firestore.dart';
|
||||||
|
import 'package:fcs/data/services/services.dart';
|
||||||
|
import 'package:fcs/domain/vo/delivery_address.dart';
|
||||||
|
import 'package:fcs/pages/main/model/base_model.dart';
|
||||||
|
import 'package:fcs/domain/constants.dart';
|
||||||
|
import 'package:logging/logging.dart';
|
||||||
|
|
||||||
|
class DeliveryAddressModel extends BaseModel {
|
||||||
|
final log = Logger('FcsShipmentModel');
|
||||||
|
List<DeliveryAddress> deliveryAddresses = [];
|
||||||
|
|
||||||
|
StreamSubscription<QuerySnapshot> listener;
|
||||||
|
|
||||||
|
@override
|
||||||
|
void privilegeChanged() {
|
||||||
|
super.privilegeChanged();
|
||||||
|
_loadDeliveryAddresses();
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> _loadDeliveryAddresses() async {
|
||||||
|
if (user == null) return;
|
||||||
|
String path = "$delivery_address_collection/";
|
||||||
|
if (listener != null) listener.cancel();
|
||||||
|
deliveryAddresses = [];
|
||||||
|
try {
|
||||||
|
listener = Firestore.instance
|
||||||
|
.collection('users')
|
||||||
|
.document("${user.id}")
|
||||||
|
.collection("$path")
|
||||||
|
.snapshots()
|
||||||
|
.listen((QuerySnapshot snapshot) {
|
||||||
|
deliveryAddresses.clear();
|
||||||
|
deliveryAddresses = snapshot.documents.map((documentSnapshot) {
|
||||||
|
var s = DeliveryAddress.fromMap(
|
||||||
|
documentSnapshot.data, documentSnapshot.documentID);
|
||||||
|
return s;
|
||||||
|
}).toList();
|
||||||
|
notifyListeners();
|
||||||
|
});
|
||||||
|
} catch (e) {
|
||||||
|
log.warning("Error!! $e");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void initUser(user) {
|
||||||
|
super.initUser(user);
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> createDeliveryAddress(DeliveryAddress deliveryAddress) {
|
||||||
|
return Services.instance.deliveryAddressService
|
||||||
|
.createDeliveryAddress(deliveryAddress);
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> updateDeliveryAddress(DeliveryAddress deliveryAddress) {
|
||||||
|
return Services.instance.deliveryAddressService
|
||||||
|
.updateDeliveryAddress(deliveryAddress);
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> deleteDeliveryAddress(DeliveryAddress deliveryAddress) {
|
||||||
|
return Services.instance.deliveryAddressService
|
||||||
|
.deleteDeliveryAddress(deliveryAddress);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -2,12 +2,11 @@ import 'package:fcs/domain/entities/role.dart';
|
|||||||
import 'package:fcs/domain/vo/delivery_address.dart';
|
import 'package:fcs/domain/vo/delivery_address.dart';
|
||||||
import 'package:fcs/localization/app_translations.dart';
|
import 'package:fcs/localization/app_translations.dart';
|
||||||
import 'package:fcs/localization/transalation.dart';
|
import 'package:fcs/localization/transalation.dart';
|
||||||
|
import 'package:fcs/pages/delivery_address/delivery_address_list.dart';
|
||||||
|
import 'package:fcs/pages/delivery_address/model/delivery_address_model.dart';
|
||||||
import 'package:fcs/pages/main/model/language_model.dart';
|
import 'package:fcs/pages/main/model/language_model.dart';
|
||||||
import 'package:fcs/pages/main/model/main_model.dart';
|
import 'package:fcs/pages/main/model/main_model.dart';
|
||||||
import 'package:fcs/pages/profile/profile_edit.dart';
|
import 'package:fcs/pages/profile/profile_edit.dart';
|
||||||
import 'package:fcs/pages/shipment_address/model/shipment_address_model.dart';
|
|
||||||
import 'package:fcs/pages/shipment_address/shipping_address_editor.dart';
|
|
||||||
import 'package:fcs/pages/shipment_address/shipping_address_row.dart';
|
|
||||||
import 'package:fcs/pages/widgets/bottom_up_page_route.dart';
|
import 'package:fcs/pages/widgets/bottom_up_page_route.dart';
|
||||||
import 'package:fcs/pages/widgets/display_text.dart';
|
import 'package:fcs/pages/widgets/display_text.dart';
|
||||||
import 'package:fcs/pages/widgets/fcs_id_icon.dart';
|
import 'package:fcs/pages/widgets/fcs_id_icon.dart';
|
||||||
@@ -34,6 +33,8 @@ class _ProfileState extends State<Profile> {
|
|||||||
String selectedLanguage;
|
String selectedLanguage;
|
||||||
TextEditingController bizNameController = new TextEditingController();
|
TextEditingController bizNameController = new TextEditingController();
|
||||||
|
|
||||||
|
DeliveryAddress _deliveryAddress = new DeliveryAddress();
|
||||||
|
|
||||||
static final List<String> languagesList = Translation().supportedLanguages;
|
static final List<String> languagesList = Translation().supportedLanguages;
|
||||||
static final List<String> languageCodesList =
|
static final List<String> languageCodesList =
|
||||||
Translation().supportedLanguagesCodes;
|
Translation().supportedLanguagesCodes;
|
||||||
@@ -52,6 +53,17 @@ class _ProfileState extends State<Profile> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
super.initState();
|
||||||
|
var shipmentModel =
|
||||||
|
Provider.of<DeliveryAddressModel>(context, listen: false);
|
||||||
|
|
||||||
|
if (shipmentModel.deliveryAddresses.length != 0) {
|
||||||
|
_deliveryAddress = shipmentModel.deliveryAddresses[0];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
MainModel mainModel = Provider.of<MainModel>(context);
|
MainModel mainModel = Provider.of<MainModel>(context);
|
||||||
@@ -85,6 +97,7 @@ class _ProfileState extends State<Profile> {
|
|||||||
)
|
)
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
|
|
||||||
final usaShippingAddressBox = Row(
|
final usaShippingAddressBox = Row(
|
||||||
children: [
|
children: [
|
||||||
Expanded(
|
Expanded(
|
||||||
@@ -175,17 +188,26 @@ class _ProfileState extends State<Profile> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Widget getShippingAddressList(BuildContext context) {
|
Widget getShippingAddressList(BuildContext context) {
|
||||||
var shipmentModel = Provider.of<ShipmentAddressModel>(context);
|
var languageModel = Provider.of<LanguageModel>(context);
|
||||||
return ExpansionTile(
|
return ListTileTheme(
|
||||||
|
contentPadding: EdgeInsets.all(10),
|
||||||
|
child: ExpansionTile(
|
||||||
title: Text(
|
title: Text(
|
||||||
"My Addresses",
|
getLocalString(context, 'delivery_addresses'),
|
||||||
style:
|
style: languageModel.isEng
|
||||||
TextStyle(fontWeight: FontWeight.bold, fontStyle: FontStyle.normal),
|
? TextStyle(
|
||||||
|
fontSize: 16.0,
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
fontStyle: FontStyle.normal,
|
||||||
|
)
|
||||||
|
: TextStyle(
|
||||||
|
fontSize: 15.0,
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
fontStyle: FontStyle.normal,
|
||||||
|
fontFamily: "Myanmar3"),
|
||||||
),
|
),
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
Column(
|
showDeliveryAddress(_deliveryAddress),
|
||||||
children: getAddressList(context, shipmentModel.shippingAddresses),
|
|
||||||
),
|
|
||||||
Container(
|
Container(
|
||||||
padding: EdgeInsets.only(top: 20, bottom: 15, right: 15),
|
padding: EdgeInsets.only(top: 20, bottom: 15, right: 15),
|
||||||
child: Align(
|
child: Align(
|
||||||
@@ -195,16 +217,20 @@ class _ProfileState extends State<Profile> {
|
|||||||
height: 40,
|
height: 40,
|
||||||
child: FloatingActionButton.extended(
|
child: FloatingActionButton.extended(
|
||||||
materialTapTargetSize: MaterialTapTargetSize.shrinkWrap,
|
materialTapTargetSize: MaterialTapTargetSize.shrinkWrap,
|
||||||
onPressed: () {
|
onPressed: () async {
|
||||||
Navigator.push(
|
DeliveryAddress deliveryAddress = await Navigator.push(
|
||||||
context,
|
context,
|
||||||
BottomUpPageRoute(ShippingAddressEditor()),
|
BottomUpPageRoute(DeliveryAddressList(
|
||||||
|
deliveryAddress: _deliveryAddress)),
|
||||||
);
|
);
|
||||||
|
setState(() {
|
||||||
|
_deliveryAddress = deliveryAddress;
|
||||||
|
});
|
||||||
},
|
},
|
||||||
icon: Icon(Icons.add),
|
label: LocalText(context,
|
||||||
label: Text(
|
'delivery_address.change_address',
|
||||||
'Add New\nAddress',
|
fontSize: 12,
|
||||||
style: TextStyle(fontSize: 12),
|
color: Colors.white,
|
||||||
),
|
),
|
||||||
backgroundColor: primaryColor,
|
backgroundColor: primaryColor,
|
||||||
),
|
),
|
||||||
@@ -212,22 +238,109 @@ class _ProfileState extends State<Profile> {
|
|||||||
),
|
),
|
||||||
)
|
)
|
||||||
],
|
],
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
List<Widget> getAddressList(
|
Widget showDeliveryAddress(DeliveryAddress deliveryAddress) {
|
||||||
BuildContext context, List<DeliveryAddress> addresses) {
|
return Container(
|
||||||
return addresses.asMap().entries.map((s) {
|
padding: EdgeInsets.only(left: 10, right: 10),
|
||||||
return InkWell(
|
child: Column(
|
||||||
onTap: () {
|
children: <Widget>[
|
||||||
Navigator.push(
|
Row(
|
||||||
context,
|
children: <Widget>[
|
||||||
BottomUpPageRoute(ShippingAddressEditor(shippingAddress: s.value)),
|
Expanded(
|
||||||
|
child: new Padding(
|
||||||
|
padding: const EdgeInsets.symmetric(vertical: 10.0),
|
||||||
|
child: Row(
|
||||||
|
children: <Widget>[
|
||||||
|
new Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
mainAxisAlignment: MainAxisAlignment.start,
|
||||||
|
children: <Widget>[
|
||||||
|
Padding(
|
||||||
|
padding: const EdgeInsets.only(left: 8.0),
|
||||||
|
child: new Text(
|
||||||
|
deliveryAddress.fullName == null
|
||||||
|
? ''
|
||||||
|
: deliveryAddress.fullName,
|
||||||
|
style: new TextStyle(
|
||||||
|
fontSize: 15.0,
|
||||||
|
color: Colors.black,
|
||||||
|
fontWeight: FontWeight.bold),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Padding(
|
||||||
|
padding: const EdgeInsets.only(left: 8.0),
|
||||||
|
child: new Text(
|
||||||
|
deliveryAddress.addressLine1 == null
|
||||||
|
? ''
|
||||||
|
: deliveryAddress.addressLine1,
|
||||||
|
style: new TextStyle(
|
||||||
|
fontSize: 14.0, color: Colors.grey),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Padding(
|
||||||
|
padding: const EdgeInsets.only(left: 8.0),
|
||||||
|
child: new Text(
|
||||||
|
deliveryAddress.addressLine2 == null
|
||||||
|
? ''
|
||||||
|
: deliveryAddress.addressLine2,
|
||||||
|
style: new TextStyle(
|
||||||
|
fontSize: 14.0, color: Colors.grey),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Padding(
|
||||||
|
padding: const EdgeInsets.only(left: 8.0),
|
||||||
|
child: new Text(
|
||||||
|
deliveryAddress.city == null
|
||||||
|
? ''
|
||||||
|
: deliveryAddress.city,
|
||||||
|
style: new TextStyle(
|
||||||
|
fontSize: 14.0, color: Colors.grey),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Padding(
|
||||||
|
padding: const EdgeInsets.only(left: 8.0),
|
||||||
|
child: new Text(
|
||||||
|
deliveryAddress.state == null
|
||||||
|
? ''
|
||||||
|
: deliveryAddress.state,
|
||||||
|
style: new TextStyle(
|
||||||
|
fontSize: 14.0, color: Colors.grey),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Padding(
|
||||||
|
padding: const EdgeInsets.only(left: 8.0),
|
||||||
|
child: new Text(
|
||||||
|
deliveryAddress.country == null
|
||||||
|
? ''
|
||||||
|
: deliveryAddress.country,
|
||||||
|
style: new TextStyle(
|
||||||
|
fontSize: 14.0, color: Colors.grey),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Padding(
|
||||||
|
padding: const EdgeInsets.only(left: 8.0),
|
||||||
|
child: new Text(
|
||||||
|
deliveryAddress.phoneNumber == null
|
||||||
|
? ''
|
||||||
|
: "Phone:${deliveryAddress.phoneNumber}",
|
||||||
|
style: new TextStyle(
|
||||||
|
fontSize: 14.0, color: Colors.grey),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
);
|
);
|
||||||
},
|
|
||||||
child: ShippingAddressRow(shippingAddress: s.value, index: s.key),
|
|
||||||
);
|
|
||||||
}).toList();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
List<Privilege> privileges = [
|
List<Privilege> privileges = [
|
||||||
|
|||||||
@@ -4,8 +4,8 @@ import 'package:fcs/domain/entities/package.dart';
|
|||||||
import 'package:fcs/domain/vo/delivery_address.dart';
|
import 'package:fcs/domain/vo/delivery_address.dart';
|
||||||
import 'package:fcs/helpers/theme.dart';
|
import 'package:fcs/helpers/theme.dart';
|
||||||
import 'package:fcs/localization/app_translations.dart';
|
import 'package:fcs/localization/app_translations.dart';
|
||||||
import 'package:fcs/pages/shipment_address/model/shipment_address_model.dart';
|
import 'package:fcs/pages/delivery_address/delivery_address_row.dart';
|
||||||
import 'package:fcs/pages/shipment_address/shipping_address_row.dart';
|
import 'package:fcs/pages/delivery_address/model/delivery_address_model.dart';
|
||||||
import 'package:fcs/pages/widgets/local_text.dart';
|
import 'package:fcs/pages/widgets/local_text.dart';
|
||||||
import 'package:fcs/pages/widgets/my_data_table.dart';
|
import 'package:fcs/pages/widgets/my_data_table.dart';
|
||||||
import 'package:fcs/pages/widgets/progress.dart';
|
import 'package:fcs/pages/widgets/progress.dart';
|
||||||
@@ -54,8 +54,8 @@ class _PickupBoxEditorState extends State<PickupBoxEditor> {
|
|||||||
];
|
];
|
||||||
|
|
||||||
var shipmentModel =
|
var shipmentModel =
|
||||||
Provider.of<ShipmentAddressModel>(context, listen: false);
|
Provider.of<DeliveryAddressModel>(context, listen: false);
|
||||||
_shippingAddress = shipmentModel.shippingAddresses[1];
|
_shippingAddress = shipmentModel.deliveryAddresses[1];
|
||||||
|
|
||||||
isNew = true;
|
isNew = true;
|
||||||
_box = Box(
|
_box = Box(
|
||||||
@@ -222,7 +222,7 @@ class _PickupBoxEditorState extends State<PickupBoxEditor> {
|
|||||||
color: primaryColor, fontWeight: FontWeight.bold),
|
color: primaryColor, fontWeight: FontWeight.bold),
|
||||||
),
|
),
|
||||||
children: [
|
children: [
|
||||||
ShippingAddressRow(shippingAddress: _shippingAddress),
|
DeliveryAddressRow(shippingAddress: _shippingAddress),
|
||||||
Container(
|
Container(
|
||||||
padding:
|
padding:
|
||||||
EdgeInsets.only(top: 20, bottom: 15, right: 15),
|
EdgeInsets.only(top: 20, bottom: 15, right: 15),
|
||||||
|
|||||||
@@ -5,10 +5,10 @@ import 'package:fcs/domain/vo/delivery_address.dart';
|
|||||||
import 'package:fcs/helpers/theme.dart';
|
import 'package:fcs/helpers/theme.dart';
|
||||||
import 'package:fcs/localization/app_translations.dart';
|
import 'package:fcs/localization/app_translations.dart';
|
||||||
import 'package:fcs/pages/box/model/box_model.dart';
|
import 'package:fcs/pages/box/model/box_model.dart';
|
||||||
|
import 'package:fcs/pages/delivery_address/delivery_address_row.dart';
|
||||||
|
import 'package:fcs/pages/delivery_address/model/delivery_address_model.dart';
|
||||||
import 'package:fcs/pages/main/model/main_model.dart';
|
import 'package:fcs/pages/main/model/main_model.dart';
|
||||||
import 'package:fcs/pages/shipment/model/shipment_model.dart';
|
import 'package:fcs/pages/shipment/model/shipment_model.dart';
|
||||||
import 'package:fcs/pages/shipment_address/model/shipment_address_model.dart';
|
|
||||||
import 'package:fcs/pages/shipment_address/shipping_address_row.dart';
|
|
||||||
import 'package:fcs/pages/main/util.dart';
|
import 'package:fcs/pages/main/util.dart';
|
||||||
import 'package:fcs/pages/widgets/bottom_up_page_route.dart';
|
import 'package:fcs/pages/widgets/bottom_up_page_route.dart';
|
||||||
import 'package:fcs/pages/widgets/input_text.dart';
|
import 'package:fcs/pages/widgets/input_text.dart';
|
||||||
@@ -93,8 +93,8 @@ class _ShipmentEditorState extends State<ShipmentEditor> {
|
|||||||
_pickUp = Shipment(cargoTypes: _cargoTypes);
|
_pickUp = Shipment(cargoTypes: _cargoTypes);
|
||||||
}
|
}
|
||||||
var shipmentModel =
|
var shipmentModel =
|
||||||
Provider.of<ShipmentAddressModel>(context, listen: false);
|
Provider.of<DeliveryAddressModel>(context, listen: false);
|
||||||
_shippingAddress = shipmentModel.shippingAddresses[1];
|
_shippingAddress = shipmentModel.deliveryAddresses[1];
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@@ -303,7 +303,7 @@ class _ShipmentEditorState extends State<ShipmentEditor> {
|
|||||||
),
|
),
|
||||||
_currVal == 3
|
_currVal == 3
|
||||||
? Container(
|
? Container(
|
||||||
child: ShippingAddressRow(
|
child: DeliveryAddressRow(
|
||||||
shippingAddress: DeliveryAddress(
|
shippingAddress: DeliveryAddress(
|
||||||
fullName: 'FCS Office',
|
fullName: 'FCS Office',
|
||||||
addressLine1: '154-19 64th Ave.',
|
addressLine1: '154-19 64th Ave.',
|
||||||
@@ -411,7 +411,7 @@ class _ShipmentEditorState extends State<ShipmentEditor> {
|
|||||||
),
|
),
|
||||||
Padding(
|
Padding(
|
||||||
padding: const EdgeInsets.only(left: 10.0),
|
padding: const EdgeInsets.only(left: 10.0),
|
||||||
child: ShippingAddressRow(
|
child: DeliveryAddressRow(
|
||||||
shippingAddress: _shippingAddress),
|
shippingAddress: _shippingAddress),
|
||||||
),
|
),
|
||||||
Container(
|
Container(
|
||||||
|
|||||||
@@ -1,41 +0,0 @@
|
|||||||
import 'package:fcs/data/services/services.dart';
|
|
||||||
import 'package:fcs/domain/vo/delivery_address.dart';
|
|
||||||
import 'package:fcs/pages/main/model/base_model.dart';
|
|
||||||
|
|
||||||
class ShipmentAddressModel extends BaseModel {
|
|
||||||
List<DeliveryAddress> shippingAddresses = [
|
|
||||||
DeliveryAddress(
|
|
||||||
fullName: 'U Nyi Nyi',
|
|
||||||
addressLine1: '154-19 64th Ave.',
|
|
||||||
addressLine2: 'Flushing',
|
|
||||||
city: 'NY',
|
|
||||||
state: 'NY',
|
|
||||||
phoneNumber: '+1 (292)215-2247'),
|
|
||||||
DeliveryAddress(
|
|
||||||
fullName: 'Mg Myo',
|
|
||||||
addressLine1: '153-154 5th Thitsar.',
|
|
||||||
addressLine2: 'South Okkalapa Township',
|
|
||||||
city: 'Yangon',
|
|
||||||
state: 'Myanmar',
|
|
||||||
phoneNumber: '+09 95724 8750'),
|
|
||||||
];
|
|
||||||
|
|
||||||
void initUser(user) {
|
|
||||||
super.initUser(user);
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<void> createDeliveryAddress(DeliveryAddress deliveryAddress) {
|
|
||||||
return Services.instance.deliveryAddressService
|
|
||||||
.createDeliveryAddress(deliveryAddress);
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<void> updateDeliveryAddress(DeliveryAddress deliveryAddress) {
|
|
||||||
return Services.instance.deliveryAddressService
|
|
||||||
.updateDeliveryAddress(deliveryAddress);
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<void> deleteDeliveryAddress(DeliveryAddress deliveryAddress) {
|
|
||||||
return Services.instance.deliveryAddressService
|
|
||||||
.deleteDeliveryAddress(deliveryAddress);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,139 +0,0 @@
|
|||||||
import 'package:fcs/domain/vo/delivery_address.dart';
|
|
||||||
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';
|
|
||||||
import 'package:flutter_icons/flutter_icons.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
|
||||||
|
|
||||||
class ShippingAddressEditor extends StatefulWidget {
|
|
||||||
final DeliveryAddress shippingAddress;
|
|
||||||
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();
|
|
||||||
|
|
||||||
DeliveryAddress _shippingAddress = new DeliveryAddress();
|
|
||||||
|
|
||||||
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(
|
|
||||||
padding: const EdgeInsets.only(left: 10.0, right: 10),
|
|
||||||
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)
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,121 +0,0 @@
|
|||||||
import 'package:fcs/domain/vo/delivery_address.dart';
|
|
||||||
import 'package:fcs/pages/shipment_address/model/shipment_address_model.dart';
|
|
||||||
import 'package:flutter/cupertino.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
|
||||||
import 'package:provider/provider.dart';
|
|
||||||
|
|
||||||
class ShippingAddressRow extends StatelessWidget {
|
|
||||||
final DeliveryAddress shippingAddress;
|
|
||||||
final int index;
|
|
||||||
|
|
||||||
const ShippingAddressRow({Key key, this.shippingAddress, this.index})
|
|
||||||
: super(key: key);
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
var shipmentAddressModel = Provider.of<ShipmentAddressModel>(context);
|
|
||||||
return Container(
|
|
||||||
padding: EdgeInsets.only(left: 10, right: 10),
|
|
||||||
child: Column(
|
|
||||||
children: <Widget>[
|
|
||||||
Row(
|
|
||||||
children: <Widget>[
|
|
||||||
Expanded(
|
|
||||||
child: new Padding(
|
|
||||||
padding: const EdgeInsets.symmetric(vertical: 10.0),
|
|
||||||
child: Row(
|
|
||||||
children: <Widget>[
|
|
||||||
// Padding(
|
|
||||||
// padding: EdgeInsets.all(5.0),
|
|
||||||
// child: Icon(
|
|
||||||
// SimpleLineIcons.location_pin,
|
|
||||||
// color: primaryColor,
|
|
||||||
// )),
|
|
||||||
new Column(
|
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
|
||||||
mainAxisAlignment: MainAxisAlignment.start,
|
|
||||||
children: <Widget>[
|
|
||||||
Padding(
|
|
||||||
padding: const EdgeInsets.only(left: 8.0),
|
|
||||||
child: new Text(
|
|
||||||
shippingAddress.fullName == null
|
|
||||||
? ''
|
|
||||||
: shippingAddress.fullName,
|
|
||||||
style: new TextStyle(
|
|
||||||
fontSize: 15.0,
|
|
||||||
color: Colors.black,
|
|
||||||
fontWeight: FontWeight.bold),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
Padding(
|
|
||||||
padding: const EdgeInsets.only(left: 8.0),
|
|
||||||
child: new Text(
|
|
||||||
shippingAddress.addressLine1 == null
|
|
||||||
? ''
|
|
||||||
: shippingAddress.addressLine1,
|
|
||||||
style: new TextStyle(
|
|
||||||
fontSize: 14.0, color: Colors.grey),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
Padding(
|
|
||||||
padding: const EdgeInsets.only(left: 8.0),
|
|
||||||
child: new Text(
|
|
||||||
shippingAddress.addressLine2 == null
|
|
||||||
? ''
|
|
||||||
: shippingAddress.addressLine2,
|
|
||||||
style: new TextStyle(
|
|
||||||
fontSize: 14.0, color: Colors.grey),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
Padding(
|
|
||||||
padding: const EdgeInsets.only(left: 8.0),
|
|
||||||
child: new Text(
|
|
||||||
shippingAddress.city == null
|
|
||||||
? ''
|
|
||||||
: shippingAddress.city,
|
|
||||||
style: new TextStyle(
|
|
||||||
fontSize: 14.0, color: Colors.grey),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
Padding(
|
|
||||||
padding: const EdgeInsets.only(left: 8.0),
|
|
||||||
child: new Text(
|
|
||||||
shippingAddress.state == null
|
|
||||||
? ''
|
|
||||||
: shippingAddress.state,
|
|
||||||
style: new TextStyle(
|
|
||||||
fontSize: 14.0, color: Colors.grey),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
Padding(
|
|
||||||
padding: const EdgeInsets.only(left: 8.0),
|
|
||||||
child: new Text(
|
|
||||||
shippingAddress.phoneNumber == null
|
|
||||||
? ''
|
|
||||||
: "Phone:${shippingAddress.phoneNumber}",
|
|
||||||
style: new TextStyle(
|
|
||||||
fontSize: 14.0, color: Colors.grey),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
// IconButton(
|
|
||||||
// padding: EdgeInsets.only(right: 30),
|
|
||||||
// icon: Icon(Icons.delete, color: Colors.black45),
|
|
||||||
// onPressed: null)
|
|
||||||
],
|
|
||||||
),
|
|
||||||
index == null
|
|
||||||
? Container()
|
|
||||||
: index == shipmentAddressModel.shippingAddresses.length - 1
|
|
||||||
? Container()
|
|
||||||
: Divider(color: Colors.black)
|
|
||||||
],
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user