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.

104 lines
3.4 KiB

4 years ago
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:huixiang/generated/l10n.dart';
import 'package:huixiang/retrofit/data/coupon.dart';
4 years ago
import 'package:huixiang/view_widget/new_coupon_widget.dart';
4 years ago
class CouponsPage extends StatefulWidget {
@override
State<StatefulWidget> createState() {
return _CouponsPage();
}
}
class _CouponsPage extends State<CouponsPage> {
4 years ago
int btnStatus = 0;
4 years ago
@override
void initState() {
super.initState();
}
4 years ago
List<Coupon> coupons = [
Coupon.test("",0,false),Coupon.test("",1,false),Coupon.test("",1,false),Coupon.test("",0,false),Coupon.test("",0,false)
];
4 years ago
@override
Widget build(BuildContext context) {
return Scaffold(
4 years ago
body: Column(children: [
Row(
children: [
Container(
width: 68,
height: 26,
alignment: Alignment.center,
margin: EdgeInsets.only(left: 16, right: 12, top: 10, bottom: 14),
decoration: BoxDecoration(
borderRadius: BorderRadius.all(Radius.circular(2)),
color: btnStatus == 0 ? Colors.white : Color(0xffE5E5E5),
4 years ago
),
4 years ago
child: GestureDetector(
onTap: () {
setState(() {
btnStatus = 0;
coupons = [Coupon.test("",0,false),Coupon.test("",1,false),Coupon.test("",1,false),Coupon.test("",0,false),Coupon.test("",0,false)];
});
},
child: Text(
S.of(context).keyongquan,
style: TextStyle(
fontSize: 14,
fontWeight: btnStatus == 0 ? FontWeight.bold : FontWeight.normal,
color: btnStatus == 0 ? Colors.black : Color(0xff727272),
),
4 years ago
),
4 years ago
),
),
Container(
width: 68,
height: 26,
alignment: Alignment.center,
margin: EdgeInsets.only(left: 16, top: 10, bottom: 14),
decoration: BoxDecoration(
borderRadius: BorderRadius.all(Radius.circular(2)),
color: btnStatus == 1 ? Colors.white : Color(0xffE5E5E5),
),
child: GestureDetector(
onTap: () {
setState(() {
btnStatus = 1;
coupons = [Coupon.test("",2,false),Coupon.test("",2,false),Coupon.test("",2,false),Coupon.test("",2,false),Coupon.test("",2,false)];
});
},
child: Text(
S.of(context).shixiaoquan,
style: TextStyle(
fontSize: 14,
fontWeight: btnStatus == 1 ? FontWeight.bold : FontWeight.normal,
color: btnStatus == 1 ? Colors.black : Color(0xff727272),
),
4 years ago
),
4 years ago
),
4 years ago
),
4 years ago
],
),
Expanded(child: ListView.builder(
itemBuilder: (context, position) {
return GestureDetector(
4 years ago
child: NewCouponWidget(coupons[position],(type){
4 years ago
},(){
setState(() {
coupons[position].isEx = !coupons[position].isEx;
});
}),
);
},
4 years ago
itemCount: coupons!= null ? coupons.length : 0,
4 years ago
),)
]),
4 years ago
);
}
}