add shipments
This commit is contained in:
@@ -12,12 +12,7 @@ import 'model/delivery_address_model.dart';
|
||||
import 'delivery_address_row.dart';
|
||||
|
||||
class DeliveryAddressList extends StatefulWidget {
|
||||
final DeliveryAddress deliveryAddress;
|
||||
final bool forSelection;
|
||||
|
||||
const DeliveryAddressList(
|
||||
{Key key, this.deliveryAddress, this.forSelection = false})
|
||||
: super(key: key);
|
||||
const DeliveryAddressList({Key key}) : super(key: key);
|
||||
@override
|
||||
_DeliveryAddressListState createState() => _DeliveryAddressListState();
|
||||
}
|
||||
@@ -46,7 +41,7 @@ class _DeliveryAddressListState extends State<DeliveryAddressList> {
|
||||
centerTitle: true,
|
||||
leading: new IconButton(
|
||||
icon: new Icon(Icons.close),
|
||||
onPressed: () => Navigator.pop(context, widget.deliveryAddress),
|
||||
onPressed: () => Navigator.pop(context),
|
||||
),
|
||||
backgroundColor: primaryColor,
|
||||
title: LocalText(
|
||||
@@ -83,18 +78,15 @@ class _DeliveryAddressListState extends State<DeliveryAddressList> {
|
||||
_row(BuildContext context, DeliveryAddress deliveryAddress) {
|
||||
return Row(
|
||||
children: [
|
||||
widget.forSelection
|
||||
? Container()
|
||||
: InkWell(
|
||||
onTap: () => _select(deliveryAddress),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(10.0),
|
||||
child: Icon(Icons.check,
|
||||
color: deliveryAddress.isDefault
|
||||
? primaryColor
|
||||
: Colors.black26),
|
||||
),
|
||||
),
|
||||
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),
|
||||
@@ -106,11 +98,6 @@ class _DeliveryAddressListState extends State<DeliveryAddressList> {
|
||||
}
|
||||
|
||||
_edit(BuildContext context, DeliveryAddress deliveryAddress) {
|
||||
if (widget.forSelection) {
|
||||
Navigator.pop(context, deliveryAddress);
|
||||
return;
|
||||
}
|
||||
|
||||
Navigator.push(
|
||||
context,
|
||||
BottomUpPageRoute(
|
||||
@@ -119,10 +106,6 @@ class _DeliveryAddressListState extends State<DeliveryAddressList> {
|
||||
}
|
||||
|
||||
Future<void> _select(DeliveryAddress deliveryAddress) async {
|
||||
if (widget.forSelection) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (deliveryAddress.isDefault) {
|
||||
Navigator.pop(context);
|
||||
return;
|
||||
|
||||
@@ -15,6 +15,9 @@ class DeliveryAddressModel extends BaseModel {
|
||||
DeliveryAddress get defalutAddress =>
|
||||
deliveryAddresses.firstWhere((e) => e.isDefault, orElse: () => null);
|
||||
|
||||
DeliveryAddress getLocalDeliveryAddress(String id) =>
|
||||
deliveryAddresses.firstWhere((e) => e.id == id, orElse: () => null);
|
||||
|
||||
@override
|
||||
void privilegeChanged() {
|
||||
super.privilegeChanged();
|
||||
@@ -52,6 +55,12 @@ class DeliveryAddressModel extends BaseModel {
|
||||
}
|
||||
}
|
||||
|
||||
Future<DeliveryAddress> getDeliveryAddress(String id) async {
|
||||
String path = "/$user_collection/${user.id}/$delivery_address_collection";
|
||||
var snap = await Firestore.instance.collection(path).document(id).get();
|
||||
return DeliveryAddress.fromMap(snap.data, snap.documentID);
|
||||
}
|
||||
|
||||
void initUser(user) {
|
||||
super.initUser(user);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user