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.
173 lines
5.1 KiB
173 lines
5.1 KiB
import 'package:flutter/material.dart'; |
|
import 'package:huixiang/generated/l10n.dart'; |
|
import 'package:huixiang/retrofit/data/store.dart'; |
|
import 'package:flutter_screenutil/flutter_screenutil.dart'; |
|
import 'package:huixiang/view_widget/border_text.dart'; |
|
import 'package:huixiang/view_widget/custom_image.dart'; |
|
import 'package:huixiang/view_widget/round_button.dart'; |
|
|
|
class SelectorStoreWidget extends StatefulWidget { |
|
final List<Store> stores; |
|
|
|
SelectorStoreWidget(this.stores); |
|
|
|
@override |
|
State<StatefulWidget> createState() { |
|
return _SelectorStoreWidget(); |
|
} |
|
} |
|
|
|
class _SelectorStoreWidget extends State<SelectorStoreWidget> { |
|
int selectIndex = 0; |
|
|
|
@override |
|
Widget build(BuildContext context) { |
|
return Container( |
|
height: ((widget.stores != null |
|
? (widget.stores.length > 4 ? 4 : widget.stores.length) |
|
: 0.0) * |
|
52.0.h) + |
|
54.0.h + |
|
158.0.h, |
|
padding: EdgeInsets.only( |
|
top: 16.h, |
|
left: 16.w, |
|
right: 10.w, |
|
bottom: 16.h, |
|
), |
|
decoration: BoxDecoration( |
|
color: Colors.white, |
|
borderRadius: BorderRadius.horizontal( |
|
left: Radius.circular(8), |
|
right: Radius.circular(8), |
|
), |
|
), |
|
child: Column( |
|
mainAxisAlignment: MainAxisAlignment.start, |
|
crossAxisAlignment: CrossAxisAlignment.start, |
|
children: [ |
|
Text( |
|
S.of(context).qingxuanzeshiyongmendian, |
|
textAlign: TextAlign.left, |
|
style: TextStyle( |
|
color: Color(0xFF353535), |
|
fontSize: 16.sp, |
|
fontWeight: FontWeight.bold, |
|
), |
|
), |
|
SizedBox( |
|
height: 12.h, |
|
), |
|
Container( |
|
height: (widget.stores != null |
|
? (widget.stores.length > 4 ? 4 : widget.stores.length) |
|
: 0) * |
|
52.h, |
|
child: ListView.builder( |
|
physics: BouncingScrollPhysics(), |
|
itemBuilder: (context, position) { |
|
return storeItem(widget.stores[position], position); |
|
}, |
|
itemCount: widget.stores != null ? widget.stores.length : 0, |
|
), |
|
), |
|
SizedBox( |
|
height: 38.h, |
|
), |
|
Row( |
|
mainAxisAlignment: MainAxisAlignment.center, |
|
crossAxisAlignment: CrossAxisAlignment.center, |
|
children: [ |
|
InkWell( |
|
onTap: () { |
|
Navigator.of(context).pop(); |
|
}, |
|
child: BorderText( |
|
text: S.of(context).quxiao, |
|
borderColor: Color(0xFF32A060), |
|
textColor: Color(0xFF32A060), |
|
radius: 4, |
|
fontSize: 16.sp, |
|
fontWeight: FontWeight.bold, |
|
borderWidth: 1.w, |
|
padding: EdgeInsets.symmetric( |
|
vertical: 12.h, |
|
horizontal: 42.w, |
|
), |
|
), |
|
), |
|
SizedBox( |
|
width: 13.w, |
|
), |
|
InkWell( |
|
onTap: () { |
|
Navigator.of(context).popAndPushNamed( |
|
'/router/union_detail_page', |
|
arguments: {"id": widget.stores[selectIndex].id}); |
|
}, |
|
child: RoundButton( |
|
text: S.of(context).queding, |
|
textColor: Colors.white, |
|
backgroup: Color(0xFF32A060), |
|
radius: 4, |
|
fontSize: 16.sp, |
|
fontWeight: FontWeight.bold, |
|
padding: EdgeInsets.symmetric( |
|
vertical: 12.h, |
|
horizontal: 42.w, |
|
), |
|
), |
|
) |
|
], |
|
) |
|
], |
|
), |
|
); |
|
} |
|
|
|
Widget storeItem(Store store, position) { |
|
return Container( |
|
height: 52.h, |
|
child: Row( |
|
mainAxisAlignment: MainAxisAlignment.center, |
|
crossAxisAlignment: CrossAxisAlignment.center, |
|
children: [ |
|
MImage( |
|
store.logo, |
|
width: 28.w, |
|
height: 28.h, |
|
fit: BoxFit.cover, |
|
radius: BorderRadius.circular(2), |
|
errorSrc: "assets/image/default_1.png", |
|
fadeSrc: "assets/image/default_1.png", |
|
), |
|
SizedBox( |
|
width: 12.w, |
|
), |
|
Expanded( |
|
flex: 1, |
|
child: Text( |
|
store.storeName, |
|
style: TextStyle( |
|
color: Color(0xFF353535), |
|
fontSize: 16.sp, |
|
), |
|
), |
|
), |
|
Checkbox( |
|
value: position == selectIndex, |
|
onChanged: (value) { |
|
setState(() { |
|
selectIndex = position; |
|
}); |
|
}, |
|
checkColor: Color(0xFFFFFFFF), |
|
fillColor: MaterialStateProperty.all(Color(0xFF39B54A)), |
|
materialTapTargetSize: MaterialTapTargetSize.shrinkWrap, |
|
shape: CircleBorder(), |
|
), |
|
], |
|
), |
|
); |
|
} |
|
}
|
|
|