fix profile

This commit is contained in:
Sai Naw Wun
2020-10-11 02:17:23 +06:30
parent b0ce53f856
commit 32e6be2abd
42 changed files with 938 additions and 626 deletions

View File

@@ -1,146 +1,78 @@
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:fcs/helpers/theme.dart';
import 'package:fcs/pages/widgets/local_text.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import 'package:flutter_icons/flutter_icons.dart';
import 'delivery_address_editor.dart';
typedef SelectionCallback(DeliveryAddress deliveryAddress);
class DeliveryAddressRow extends StatelessWidget {
final DeliveryAddress shippingAddress;
final int index;
const DeliveryAddressRow({Key key, this.shippingAddress, this.index})
final DeliveryAddress deliveryAddress;
final SelectionCallback selectionCallback;
const DeliveryAddressRow(
{Key key, this.deliveryAddress, this.selectionCallback})
: 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(
return InkWell(
onTap: selectionCallback == null
? null
: () => this.selectionCallback(deliveryAddress),
child: Row(
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),
),
),
],
),
),
],
),
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
line(context, deliveryAddress.fullName,
iconData: MaterialCommunityIcons.account_arrow_left,
color: primaryColor,
fontSize: 16),
line(context, deliveryAddress.phoneNumber,
iconData: Icons.phone, color: primaryColor, fontSize: 16),
SizedBox(
height: 5,
),
),
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);
})
],
line(context, deliveryAddress.addressLine1,
iconData: Icons.location_on),
line(
context,
deliveryAddress.addressLine2,
),
line(
context,
deliveryAddress.city,
),
line(context, deliveryAddress.state),
],
),
),
index == null
? Container()
: index == deliveryAddressModel.deliveryAddresses.length - 1
? Container()
: Divider(color: Colors.black)
],
),
);
}
Widget line(BuildContext context, String text,
{IconData iconData, Color color, double fontSize}) {
return Row(
children: [
iconData == null
? SizedBox(width: 40)
: Padding(
padding: const EdgeInsets.only(left: 8.0, right: 8),
child: Icon(iconData, color: Colors.black38),
),
Flexible(
child: TextLocalStyle(
context,
text ?? "",
fontSize: fontSize ?? 14,
color: color,
),
),
],
);
}
}