2021-01-10 15:56:27 +06:30
|
|
|
import 'package:fcs/domain/entities/user.dart';
|
2020-10-13 07:50:25 +06:30
|
|
|
import 'package:fcs/domain/vo/delivery_address.dart';
|
|
|
|
|
import 'package:fcs/helpers/theme.dart';
|
|
|
|
|
import 'package:fcs/pages/delivery_address/delivery_address_editor.dart';
|
|
|
|
|
import 'package:fcs/pages/delivery_address/delivery_address_row.dart';
|
|
|
|
|
import 'package:fcs/pages/widgets/local_text.dart';
|
2020-10-14 13:54:42 +06:30
|
|
|
import 'package:flutter/cupertino.dart';
|
2020-10-13 07:50:25 +06:30
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
|
|
|
|
|
class DeliveryAddressSelection extends StatelessWidget {
|
|
|
|
|
final DeliveryAddress deliveryAddress;
|
2021-01-07 18:15:39 +06:30
|
|
|
final List<DeliveryAddress> deliveryAddresses;
|
2021-01-10 15:56:27 +06:30
|
|
|
final User user;
|
2020-10-13 07:50:25 +06:30
|
|
|
|
2021-01-07 18:15:39 +06:30
|
|
|
const DeliveryAddressSelection(
|
2021-01-10 15:56:27 +06:30
|
|
|
{Key key, this.deliveryAddress, this.deliveryAddresses, this.user})
|
2020-10-13 07:50:25 +06:30
|
|
|
: super(key: key);
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
|
return Scaffold(
|
|
|
|
|
appBar: AppBar(
|
|
|
|
|
centerTitle: true,
|
|
|
|
|
leading: new IconButton(
|
2020-10-15 03:06:13 +06:30
|
|
|
icon: new Icon(CupertinoIcons.back, color: primaryColor),
|
|
|
|
|
onPressed: () => Navigator.of(context).pop(),
|
2020-10-13 07:50:25 +06:30
|
|
|
),
|
2020-10-15 03:06:13 +06:30
|
|
|
backgroundColor: Colors.white,
|
|
|
|
|
shadowColor: Colors.transparent,
|
|
|
|
|
title: LocalText(context, 'delivery_addresses',
|
|
|
|
|
color: primaryColor, fontSize: 20),
|
2020-10-13 07:50:25 +06:30
|
|
|
),
|
|
|
|
|
floatingActionButton: FloatingActionButton.extended(
|
2021-01-10 15:56:27 +06:30
|
|
|
onPressed: () async {
|
2020-10-14 13:54:42 +06:30
|
|
|
Navigator.of(context).push(CupertinoPageRoute(
|
2021-01-10 15:56:27 +06:30
|
|
|
builder: (context) => DeliveryAddressEditor(
|
|
|
|
|
user: user,
|
|
|
|
|
)));
|
2020-10-13 07:50:25 +06:30
|
|
|
},
|
|
|
|
|
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,
|
|
|
|
|
),
|
2021-01-07 18:15:39 +06:30
|
|
|
itemCount: deliveryAddresses.length,
|
2020-10-13 07:50:25 +06:30
|
|
|
itemBuilder: (context, index) {
|
2021-01-07 18:15:39 +06:30
|
|
|
return _row(context, deliveryAddresses[index]);
|
2020-10-13 07:50:25 +06:30
|
|
|
}),
|
|
|
|
|
));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_row(BuildContext context, DeliveryAddress _deliveryAddress) {
|
|
|
|
|
return InkWell(
|
|
|
|
|
onTap: () => _select(context, _deliveryAddress),
|
|
|
|
|
child: Row(
|
|
|
|
|
children: [
|
|
|
|
|
Padding(
|
|
|
|
|
padding: const EdgeInsets.all(10.0),
|
|
|
|
|
child: Icon(Icons.check,
|
|
|
|
|
color: deliveryAddress != null &&
|
|
|
|
|
_deliveryAddress.id == deliveryAddress.id
|
|
|
|
|
? primaryColor
|
|
|
|
|
: Colors.black26),
|
|
|
|
|
),
|
|
|
|
|
Expanded(
|
|
|
|
|
child: DeliveryAddressRow(
|
|
|
|
|
key: ValueKey(_deliveryAddress.id),
|
|
|
|
|
deliveryAddress: _deliveryAddress,
|
|
|
|
|
)),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_select(BuildContext context, DeliveryAddress _deliveryAddress) {
|
|
|
|
|
Navigator.pop(context, _deliveryAddress);
|
|
|
|
|
}
|
|
|
|
|
}
|