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.
 
 
 
 
 
 

199 lines
6.1 KiB

import 'package:flutter/material.dart';
import 'package:huixiang/generated/l10n.dart';
import 'package:huixiang/data/base_data.dart';
import 'package:huixiang/data/store.dart';
import 'package:huixiang/retrofit/retrofit_api.dart';
import 'package:huixiang/utils/font_weight.dart';
import 'package:huixiang/view_widget/icon_text.dart';
import 'package:huixiang/view_widget/my_appbar.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import '../view_widget/no_data_view.dart';
class StoreSelectorPage extends StatefulWidget {
final Map<String, dynamic>? arguments;
///兑换订单
StoreSelectorPage({this.arguments});
@override
State<StatefulWidget> createState() {
return _StoreSelectorPage();
}
}
class _StoreSelectorPage extends State<StoreSelectorPage> {
ApiService? apiService;
List<Store>? exchangeStoreList;
@override
void initState() {
super.initState();
exchangeShop(widget.arguments?["creditGoodsId"]);
}
///兑换门店列表
exchangeShop(creditGoodsId) async {
BaseData<List<Store>>? baseData = await apiService?.storeListByCreditId(creditGoodsId)
.catchError((error) {});
if (baseData?.isSuccess ?? false) {
setState((){
exchangeStoreList = baseData!.data;
});
}
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: MyAppBar(
title: S.of(context).mendianxuanzhe,
titleColor: Colors.black,
titleSize: 18.sp,
background: Color(0xFFFAFAFA),
leadingColor: Colors.black,
),
body: Container(
margin: EdgeInsets.only(top: 18.h),
child: Column(
children: [
Expanded(
child: (exchangeStoreList?.length == 0)
? NoDataView(
src: "assets/image/xiao_fei.webp",
isShowBtn: false,
text: "当前暂无自提门店可选择",
fontSize: 16.sp,
margin: EdgeInsets.only(top: 120.h, left: 60.w, right: 60.w),
)
: ListView.builder(
itemCount: exchangeStoreList?.length ?? 0,
physics: BouncingScrollPhysics(),
itemBuilder: (context, position) {
return GestureDetector(
onTap: () {
setState(() {
groupValue = position;
});
},
child: buildStoreItem(exchangeStoreList![position], position),
);
},
),
),
InkWell(
onTap: () {
Store? store = exchangeStoreList?[groupValue];
Navigator.of(context).pop({
"id": store?.id,
"address": store?.address,
});
},
child: Container(
padding: EdgeInsets.only(top: 16.h, bottom: 16.h),
decoration: BoxDecoration(
color: Color(0xFF32A060),
borderRadius: BorderRadius.only(
topLeft: Radius.circular(4),
topRight: Radius.circular(4),
),
),
alignment: Alignment.center,
child: Text(
S.of(context).queren,
style: TextStyle(
fontSize: 16.sp,
color: Color(0xFFFFFFFF),
fontWeight: MyFontWeight.semi_bold,
),
),
),
),
],
),
),
);
}
Widget buildStoreItem(Store store, position) {
return Container(
margin: EdgeInsets.only(left: 16.w, right: 16.w, top: 8.h, bottom: 8.h),
padding: EdgeInsets.all(16),
decoration: BoxDecoration(
color: Colors.white,
boxShadow: [
BoxShadow(
color: Colors.black.withAlpha(12),
offset: Offset(0, 3),
blurRadius: 14,
spreadRadius: 0,
)
],
borderRadius: BorderRadius.circular(8),
),
child: Row(
children: [
Expanded(
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
store.storeName ?? "",
style: TextStyle(
fontSize: 16.sp,
fontWeight: MyFontWeight.semi_bold,
color: Color(0xFF353535),
),
),
SizedBox(
height: 12.h,
),
IconText(
store.address ?? "",
isMax: true,
textAxisAlignment: CrossAxisAlignment.start,
textStyle: TextStyle(
color: Color(0xFF353535),
fontSize: 14.sp,
),
leftIcon: Icons.location_on,
iconColor: Color(0xFF32A060),
iconSize: 16,
),
SizedBox(
height: 4.h,
),
IconText(
(store.openStartTime == null && store.openEndTime == null)
? S.of(context).quantian
: "${store.openStartTime}-${store.openEndTime}",
textStyle: TextStyle(
color: Color(0xFF353535),
fontSize: 14.sp,
),
leftIcon: Icons.access_time,
iconColor: Color(0xFF32A060),
iconSize: 16,
),
],
),
),
Radio<int>(
value: position,
groupValue: groupValue,
activeColor: Colors.green,
onChanged: (value) {
setState(() {
groupValue = value ?? position;
});
},
)
],
),
);
}
int groupValue = 0;
}