fix profile
This commit is contained in:
@@ -53,53 +53,79 @@ class _DeliveryAddressListState extends State<DeliveryAddressList> {
|
||||
color: Colors.white,
|
||||
),
|
||||
),
|
||||
body: Column(
|
||||
children: <Widget>[
|
||||
Expanded(
|
||||
child: Column(
|
||||
children:
|
||||
getAddressList(context, shipmentModel.deliveryAddresses),
|
||||
),
|
||||
),
|
||||
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(DeliveryAddressEditor()),
|
||||
);
|
||||
},
|
||||
icon: Icon(Icons.add),
|
||||
label: Text(
|
||||
getLocalString(context, 'delivery_address.new_address'),
|
||||
style: TextStyle(fontSize: 12),
|
||||
),
|
||||
backgroundColor: primaryColor,
|
||||
floatingActionButton: FloatingActionButton.extended(
|
||||
onPressed: () {
|
||||
Navigator.of(context)
|
||||
.push(BottomUpPageRoute(DeliveryAddressEditor()));
|
||||
},
|
||||
icon: Icon(Icons.add),
|
||||
label: LocalText(context, "delivery_address.new_address",
|
||||
color: Colors.white),
|
||||
backgroundColor: primaryColor,
|
||||
),
|
||||
body: Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: ListView.separated(
|
||||
separatorBuilder: (c, i) => Divider(
|
||||
color: primaryColor,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
itemCount: shipmentModel.deliveryAddresses.length,
|
||||
itemBuilder: (context, index) {
|
||||
return _row(context, shipmentModel.deliveryAddresses[index]);
|
||||
}),
|
||||
)),
|
||||
);
|
||||
}
|
||||
|
||||
List<Widget> getAddressList(
|
||||
BuildContext context, List<DeliveryAddress> addresses) {
|
||||
return addresses.asMap().entries.map((s) {
|
||||
return InkWell(
|
||||
onTap: () {
|
||||
// Navigator.pop(context, s.value);
|
||||
},
|
||||
child: DeliveryAddressRow(shippingAddress: s.value, index: s.key),
|
||||
);
|
||||
}).toList();
|
||||
_row(BuildContext context, DeliveryAddress deliveryAddress) {
|
||||
return Row(
|
||||
children: [
|
||||
InkWell(
|
||||
onTap: () => _select(deliveryAddress),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(10.0),
|
||||
child: Icon(Icons.check,
|
||||
color:
|
||||
deliveryAddress.isDefault ? primaryColor : Colors.black26),
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
child: DeliveryAddressRow(
|
||||
key: ValueKey(deliveryAddress.id),
|
||||
deliveryAddress: deliveryAddress,
|
||||
selectionCallback: (d) => _edit(context, deliveryAddress)),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
_edit(BuildContext context, DeliveryAddress deliveryAddress) {
|
||||
Navigator.push(
|
||||
context,
|
||||
BottomUpPageRoute(
|
||||
DeliveryAddressEditor(deliveryAddress: deliveryAddress)),
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> _select(DeliveryAddress deliveryAddress) async {
|
||||
if (deliveryAddress.isDefault) {
|
||||
Navigator.pop(context);
|
||||
return;
|
||||
}
|
||||
setState(() {
|
||||
_isLoading = true;
|
||||
});
|
||||
var deliveryAddressModel =
|
||||
Provider.of<DeliveryAddressModel>(context, listen: false);
|
||||
try {
|
||||
await deliveryAddressModel.selectDefalutDeliveryAddress(deliveryAddress);
|
||||
Navigator.pop(context);
|
||||
} catch (e) {
|
||||
showMsgDialog(context, "Error", e.toString());
|
||||
} finally {
|
||||
setState(() {
|
||||
_isLoading = false;
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user