You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

187 lines
5.2 KiB

// Flutter imports:
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
// Package imports:
import 'package:extended_text/extended_text.dart';
import 'package:flutter_icons/flutter_icons.dart';
4 years ago
import 'package:get/get.dart';
// Project imports:
import 'package:akuCommunity/pages/address_page/address_edit_page.dart';
import 'package:akuCommunity/routers/page_routers.dart';
import 'package:akuCommunity/utils/headers.dart';
class AddressItem extends StatelessWidget {
final String name, phone, address;
final bool isDefualt;
AddressItem({Key key, this.name, this.phone, this.address, this.isDefualt})
: super(key: key);
Widget _containerImage() {
return Container(
alignment: Alignment.center,
4 years ago
width: 76.w,
height: 76.w,
margin: EdgeInsets.only(
4 years ago
right: 20.w,
),
4 years ago
padding: EdgeInsets.symmetric(vertical: 12.w),
decoration: BoxDecoration(
gradient: LinearGradient(
begin: Alignment.centerLeft,
end: Alignment.centerRight,
colors: isDefualt
? [Color(0xffffd000), Color(0xffff8500)]
: [Color(0xffd8d8d8), Color(0xffd8d8d8)],
),
4 years ago
borderRadius: BorderRadius.all(Radius.circular(76.w)),
),
child: Icon(SimpleLineIcons.location_pin, color: Colors.white),
);
}
Widget _containerColumn() {
return Container(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
children: [
Text(
name,
style: TextStyle(
4 years ago
fontSize: 28.sp,
color: Color(0xff333333),
),
),
4 years ago
SizedBox(width: 20.w),
Text(
phone,
style: TextStyle(
4 years ago
fontSize: 24.sp,
color: Color(0xff999999),
),
),
],
),
4 years ago
SizedBox(height: 12.w),
Container(
4 years ago
width: 432.w,
child: ExtendedText.rich(
TextSpan(
children: [
isDefualt
? ExtendedWidgetSpan(
child: Container(
4 years ago
margin: EdgeInsets.only(right: 16.w),
decoration: BoxDecoration(
color: Color(0xfffff7d2),
border: Border.all(
color: Color(0xffffd000), width: 0.5),
borderRadius:
BorderRadius.all(Radius.circular(4))),
padding: EdgeInsets.symmetric(
4 years ago
horizontal: 20.w,
vertical: 4.w,
),
child: Text(
'默认',
style: TextStyle(
4 years ago
fontSize: 24.sp,
color: Color(0xff333333),
),
),
),
)
: ExtendedWidgetSpan(child: SizedBox()),
TextSpan(
text: address,
style: TextStyle(
4 years ago
fontSize: 24.sp, color: Color(0xff999999), height: 1.5),
)
],
),
maxLines: 2,
overflow: TextOverflow.ellipsis,
),
),
],
),
);
}
Widget _positionedEdit(BuildContext context) {
return Positioned(
right: 0,
4 years ago
top: 55.w,
child: InkWell(
onTap: () {
4 years ago
Get.to(
AddressEditPage(
bundle: Bundle()
..putMap('details', {
'title': '编辑地址',
'name': name,
'phone': phone,
'address': address,
'isDelete': true
4 years ago
}),
),
);
},
child: Row(
children: [
4 years ago
SizedBox(width: 13.w),
SizedBox(
width: 1,
4 years ago
height: 30.w,
child: DecoratedBox(
decoration: BoxDecoration(color: Color(0xffd8d8d8)),
),
),
4 years ago
SizedBox(width: 13.w),
Text(
'编辑',
style: TextStyle(
4 years ago
fontSize: 24.sp,
color: Color(0xff999999),
),
),
],
),
),
);
}
@override
Widget build(BuildContext context) {
return Container(
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.all(Radius.circular(8)),
),
margin: EdgeInsets.only(
4 years ago
left: 32.w,
right: 32.w,
top: 20.w,
),
padding: EdgeInsets.symmetric(
4 years ago
horizontal: 20.w,
vertical: 32.w,
),
child: Stack(
children: [
Row(
children: [
_containerImage(),
_containerColumn(),
],
),
_positionedEdit(context),
],
),
);
}
}