change name to delivery address

This commit is contained in:
PhyoThandar
2020-10-08 15:54:43 +06:30
parent 7ae74275cd
commit 7ecb25409b
15 changed files with 689 additions and 403 deletions

View File

@@ -2,12 +2,11 @@ import 'package:fcs/domain/entities/role.dart';
import 'package:fcs/domain/vo/delivery_address.dart';
import 'package:fcs/localization/app_translations.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/main_model.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/display_text.dart';
import 'package:fcs/pages/widgets/fcs_id_icon.dart';
@@ -34,6 +33,8 @@ class _ProfileState extends State<Profile> {
String selectedLanguage;
TextEditingController bizNameController = new TextEditingController();
DeliveryAddress _deliveryAddress = new DeliveryAddress();
static final List<String> languagesList = Translation().supportedLanguages;
static final List<String> languageCodesList =
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
Widget build(BuildContext context) {
MainModel mainModel = Provider.of<MainModel>(context);
@@ -85,6 +97,7 @@ class _ProfileState extends State<Profile> {
)
],
);
final usaShippingAddressBox = Row(
children: [
Expanded(
@@ -175,59 +188,150 @@ class _ProfileState extends State<Profile> {
}
Widget getShippingAddressList(BuildContext context) {
var shipmentModel = Provider.of<ShipmentAddressModel>(context);
return ExpansionTile(
title: Text(
"My Addresses",
style:
TextStyle(fontWeight: FontWeight.bold, fontStyle: FontStyle.normal),
),
children: <Widget>[
Column(
children: getAddressList(context, shipmentModel.shippingAddresses),
return ListTileTheme(
contentPadding: EdgeInsets.all(10),
child: ExpansionTile(
title: Text(
getLocalString(context, 'delivery_addresses'),
style: TextStyle(
fontWeight: FontWeight.bold,
fontStyle: FontStyle.normal,
fontSize: 14),
),
Container(
padding: EdgeInsets.only(top: 20, bottom: 15, right: 15),
child: Align(
alignment: Alignment.bottomRight,
child: Container(
width: 130,
height: 40,
child: FloatingActionButton.extended(
materialTapTargetSize: MaterialTapTargetSize.shrinkWrap,
onPressed: () {
Navigator.push(
context,
BottomUpPageRoute(ShippingAddressEditor()),
);
},
icon: Icon(Icons.add),
label: Text(
'Add New\nAddress',
style: TextStyle(fontSize: 12),
children: <Widget>[
showDeliveryAddress(_deliveryAddress),
Container(
padding: EdgeInsets.only(top: 20, bottom: 15, right: 15),
child: Align(
alignment: Alignment.bottomRight,
child: Container(
width: 130,
height: 40,
child: FloatingActionButton.extended(
materialTapTargetSize: MaterialTapTargetSize.shrinkWrap,
onPressed: () async {
DeliveryAddress deliveryAddress = await Navigator.push(
context,
BottomUpPageRoute(DeliveryAddressList(
deliveryAddress: _deliveryAddress)),
);
setState(() {
_deliveryAddress = deliveryAddress;
});
},
label: Text(
getLocalString(context, 'delivery_address.change_address'),
style: TextStyle(fontSize: 12),
),
backgroundColor: primaryColor,
),
backgroundColor: primaryColor,
),
),
),
)
],
)
],
),
);
}
List<Widget> getAddressList(
BuildContext context, List<DeliveryAddress> addresses) {
return addresses.asMap().entries.map((s) {
return InkWell(
onTap: () {
Navigator.push(
context,
BottomUpPageRoute(ShippingAddressEditor(shippingAddress: s.value)),
);
},
child: ShippingAddressRow(shippingAddress: s.value, index: s.key),
);
}).toList();
Widget showDeliveryAddress(DeliveryAddress deliveryAddress) {
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>[
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),
),
),
],
),
],
),
),
),
],
),
],
),
);
}
List<Privilege> privileges = [