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.
 
 
 
 
 
 

169 lines
5.7 KiB

import 'package:flutter/material.dart';
import 'package:huixiang/data/settle_order_info.dart';
import 'package:huixiang/data/store_info.dart';
import 'package:huixiang/settlement/settlement_view/activity.dart';
import 'package:huixiang/utils/font_weight.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
class SettlementActivity extends StatefulWidget {
final StoreInfo? storeInfo;
final SettleOrderInfo? settleOrderInfo;
SettlementActivity(this.settleOrderInfo, this.storeInfo);
@override
State<StatefulWidget> createState() {
return _SettlementActivity();
}
}
class _SettlementActivity extends State<SettlementActivity> {
List<PromotionInfoListBean> promotionInfoCan = [];
List<PromotionInfoListBean> promotionInfoNo = [];
@override
void initState() {
super.initState();
promotionInfoCan.clear();
promotionInfoNo.clear();
if (widget.settleOrderInfo?.promotionInfoList?.isNotEmpty ?? false) {
widget.settleOrderInfo!.promotionInfoList?.forEach((element) {
if (element.canPartake ?? false) {
promotionInfoCan.add(element);
} else {
promotionInfoNo.add(element);
}
});
setState(() {});
}
}
@override
Widget build(BuildContext context) {
return StatefulBuilder(
builder: (context1, state) {
return Container(
alignment: Alignment.topCenter,
width: double.infinity,
height: MediaQuery.of(context).size.height / 3 * 2,
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.only(
topLeft: Radius.circular(8),
topRight: Radius.circular(8),
),
),
child: SingleChildScrollView(
physics: BouncingScrollPhysics(),
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Container(
padding: EdgeInsets.only(
top: 16,
left: 16,
right: 16,
bottom: 8,
),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Expanded(
child: Text(
"可参加的活动(${promotionInfoCan.length})",
style: TextStyle(
color: Color(0xFF000000),
fontSize: 14.sp,
fontWeight: MyFontWeight.medium,
),
),
),
InkWell(
onTap: () {
Navigator.of(context).pop();
},
child: Image.asset(
"assets/image/cancel.webp",
width: 24,
height: 24,
),
),
],
),
),
Container(
padding: EdgeInsets.only(
top: 8,
left: 16,
right: 16,
),
child: ListView.builder(
itemCount: (promotionInfoCan.length == 0)
? 0
: promotionInfoCan.length,
shrinkWrap: true,
physics: NeverScrollableScrollPhysics(),
itemBuilder: (context, position) {
return ActivityWidget(
promotionInfoCan[position],
widget.storeInfo,
position,
callback: (){
Navigator.of(context).pop(promotionInfoCan[position]);
},
);
},
),
),
if (promotionInfoNo != null || promotionInfoNo.length > 0)
Container(
padding: EdgeInsets.only(
top: 16,
left: 16,
right: 16,
bottom: 8,
),
child: Text(
"不可参加的活动",
style: TextStyle(
color: Color(0xFF000000),
fontSize: 14.sp,
fontWeight: MyFontWeight.medium,
),
),
),
if (promotionInfoNo != null || promotionInfoNo.length > 0)
Container(
padding: EdgeInsets.only(
top: 8,
left: 16,
right: 16,
),
child: ListView.builder(
itemCount: (promotionInfoNo.length == 0)
? 0
: promotionInfoNo.length,
shrinkWrap: true,
physics: NeverScrollableScrollPhysics(),
itemBuilder: (context, position) {
return ActivityWidget(
promotionInfoNo[position],
widget.storeInfo,
position,
);
},
),
),
],
),
),
);
},
);
}
}