123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182 |
- import 'package:farmer_client/models/entities/Address.dart';
- import 'package:flutter/material.dart';
- import 'package:flutter_screenutil/flutter_screenutil.dart';
-
- class AddressCard extends StatefulWidget {
- final Address item;
- final int No;
- final bool isBack;
- final GestureTapCallback onChange;
- final GestureTapCallback onDelete;
- final GestureTapCallback onEdit;
- final GestureTapCallback onBack;
- const AddressCard(
- {Key? key,
- required this.item,
- required this.No,
- required this.isBack,
- required this.onChange,
- required this.onDelete,
- required this.onEdit,
- required this.onBack})
- : super(key: key);
-
- @override
- _AddressCard createState() =>
- _AddressCard(item, No, onChange, onDelete, onEdit, isBack, onBack);
- }
-
- class _AddressCard extends State<AddressCard> {
- final Address item;
- final int No;
- final bool isBack;
- final GestureTapCallback onChange;
- final GestureTapCallback onDelete;
- final GestureTapCallback onEdit;
- final GestureTapCallback onBack;
- _AddressCard(this.item, this.No, this.onChange, this.onDelete, this.onEdit,
- this.isBack, this.onBack);
-
- @override
- Widget build(BuildContext context) {
- return Container(
- width: 345.w,
- padding: EdgeInsets.all(15.w),
- margin: EdgeInsets.fromLTRB(0, 0, 0, 15.w),
- decoration: BoxDecoration(
- color: const Color(0xFFFFFFFF),
- borderRadius: BorderRadius.all(Radius.circular(10.w)),
- boxShadow: [
- BoxShadow(
- color: const Color(0x19000000),
- offset: Offset(0, 5.w),
- blurRadius: 12.w),
- ],
- ),
- child: Column(
- crossAxisAlignment: CrossAxisAlignment.start,
- children: [
- GestureDetector(
- onTap: isBack ? onBack : () {},
- child: Row(
- children: [
- if (item.isDefault == true)
- Container(
- margin: EdgeInsets.fromLTRB(0, 0, 5.w, 0),
- padding:
- EdgeInsets.symmetric(vertical: 1.w, horizontal: 5.w),
- decoration: BoxDecoration(
- color: const Color(0xffff0000),
- borderRadius: BorderRadius.all(Radius.circular(5.w)),
- ),
- child: Text(
- '默认地址',
- style: TextStyle(
- fontSize: 15.sp,
- fontWeight: FontWeight.bold,
- color: const Color(0xffffffff),
- ),
- ),
- ),
- Text(
- '我的地址' + No.toString(),
- style:
- TextStyle(fontSize: 15.sp, fontWeight: FontWeight.w700),
- ),
- ],
- ),
- ),
- Container(
- padding: EdgeInsets.symmetric(vertical: 5.h, horizontal: 0),
- decoration: BoxDecoration(
- border: Border(
- bottom: BorderSide(
- width: 1.h,
- color: const Color(0xcc000000),
- style: BorderStyle.solid),
- ),
- ),
- child: GestureDetector(
- onTap: isBack ? onBack : () {},
- child: Row(
- mainAxisAlignment: MainAxisAlignment.spaceBetween,
- children: [
- Container(
- padding: EdgeInsets.symmetric(vertical: 5.w, horizontal: 0),
- width: 282.w,
- child: Text(
- item.address.toString(),
- //最多显示两行
- maxLines: 2,
- //多余文本用点点点表示
- overflow: TextOverflow.ellipsis,
- style: TextStyle(
- fontSize: 15.sp,
- color: const Color(0xff666666),
- ),
- ),
- ),
- GestureDetector(
- onTap: onEdit,
- child: Image.asset(
- 'images/icons/edit.png',
- width: 33.w,
- height: 33.w,
- ),
- ),
- ],
- ),
- ),
- ),
- if (isBack)
- GestureDetector(
- onTap: onBack,
- child: Container(
- width: 315.w,
- margin: EdgeInsets.fromLTRB(0, 5.w, 0, 0),
- child: Text(
- '选择此地址',
- style:
- TextStyle(fontSize: 17.sp, fontWeight: FontWeight.w800),
- ),
- ),
- ),
- if (!isBack)
- Row(
- mainAxisAlignment: MainAxisAlignment.spaceBetween,
- children: [
- GestureDetector(
- // onTap: onChange,
- child: Row(
- children: [
- const Text('设为默认地址'),
- Radio<bool>(
- value: true,
- activeColor: const Color(0xFFFF703B),
- groupValue: item.isDefault,
- onChanged: (value) {
- onChange();
- }),
- ],
- ),
- ),
- GestureDetector(
- onTap: onDelete,
- child: Row(
- children: [
- const Text('删除'),
- Image.asset(
- 'images/icons/delete.png',
- width: 25.w,
- height: 25.w,
- ),
- ],
- ),
- ),
- ],
- ),
- ],
- ),
- );
- }
- }
|