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.

246 lines
7.8 KiB

3 years ago
import 'package:flutter/material.dart';
import 'package:flutter_staggered_grid_view/flutter_staggered_grid_view.dart';
import 'package:flutter_svg/svg.dart';
3 years ago
import 'package:huixiang/generated/l10n.dart';
import 'package:huixiang/retrofit/data/sign_info.dart';
import 'package:huixiang/utils/font_weight.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:huixiang/view_widget/round_button.dart';
class InForPoints extends StatefulWidget {
final SignInfo signInfo;
final Function signIn;
InForPoints(this.signInfo, this.signIn);
@override
State<StatefulWidget> createState() {
return _InForPoints();
}
}
class _InForPoints extends State<InForPoints> {
@override
Widget build(BuildContext context) {
return Container(
width: double.infinity,
3 years ago
margin: EdgeInsets.symmetric(horizontal: 14.w, vertical: 6.h),
padding: EdgeInsets.symmetric(horizontal:12.w, vertical: 16.h),
3 years ago
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(8),
boxShadow: [
BoxShadow(
color: Colors.black.withAlpha(12),
offset: Offset(0, 3),
blurRadius: 14,
spreadRadius: 0,
3 years ago
),
3 years ago
],
),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
3 years ago
Row(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.end,
children: [
Text(
S.of(context).qiandaolingjifen,
style: TextStyle(
fontWeight: MyFontWeight.bold,
fontSize: 16.sp,
color: Color(0xFF4C4C4C),
),
),
SizedBox(
width:3.w,
),
Text(
S.of(context).lianxuqiandaolingqushuangbeijifen,
style: TextStyle(
fontWeight: MyFontWeight.regular,
fontSize: 11.sp,
color: Color(0xFFB3B3B3),
),
),
],
3 years ago
),
SizedBox(
3 years ago
height: 12.h,
3 years ago
),
StaggeredGridView.countBuilder(
crossAxisCount: 4,
shrinkWrap: true,
itemCount: 7,
mainAxisSpacing: 8,
crossAxisSpacing: 18,
padding: EdgeInsets.only(bottom: 32),
physics: NeverScrollableScrollPhysics(),
itemBuilder: (context, position) {
return signInItem(position);
},
staggeredTileBuilder: (position) {
return StaggeredTile.count(position == 6 ? 2 : 1, 1.28);
},
),
InkWell(
onTap: widget.signIn,
child: Container(
alignment: Alignment.center,
child: RoundButton(
3 years ago
width: double.infinity,
3 years ago
height: 34.h,
text: (widget.signInfo != null && widget.signInfo.todayHasSignin)
? S.of(context).yiqiandao
3 years ago
: "签到",
3 years ago
textColor: (widget.signInfo != null && widget.signInfo.todayHasSignin)
3 years ago
? Color(0xFFB3B3B3)
3 years ago
: Colors.white,
3 years ago
backgroup: (widget.signInfo != null && widget.signInfo.todayHasSignin)
3 years ago
? Color(0xFFF5F6FA)
3 years ago
: Color(0xFF32A060),
3 years ago
fontSize: 16.sp,
3 years ago
fontWeight: MyFontWeight.bold,
3 years ago
padding: EdgeInsets.symmetric(horizontal: 16.w, vertical: 6.h),
3 years ago
radius: 20.w,
3 years ago
),
),
),
],
),
);
}
Widget signInItem(position) {
if (position == 6) {
return Container(
padding: EdgeInsets.all(4),
decoration: BoxDecoration(
3 years ago
color: Color(0xFFF5F6FA),
3 years ago
borderRadius: BorderRadius.circular(4),
),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Expanded(
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
"0${position + 1}",
style: TextStyle(
color: Color(0xFF353535),
fontSize: 14.sp,
fontWeight: MyFontWeight.medium,
),
),
Container(
alignment: Alignment.center,
height: 30.h,
child: Text(
S.of(context).shenmijifendali,
style: TextStyle(
color: Color(0xFF727272),
fontWeight: FontWeight.bold,
fontSize: 10.sp,
),
),
),
Text(
"",
style: TextStyle(
color: Color(0xFF353535),
fontSize: 14.sp,
fontWeight: MyFontWeight.medium,
),
),
],
),
flex: 1,
),
Container(
alignment: Alignment.center,
child: Image.asset(
"assets/image/icon_gold_blessing.webp",
width: 59,
height: 59,
3 years ago
),
),
],
),
);
} else {
return Container(
padding: EdgeInsets.all(4),
decoration: BoxDecoration(
color: (widget.signInfo != null &&
widget.signInfo.signInList != null &&
widget.signInfo.signInList.length > position)
3 years ago
? Color(0xFF32A060)
3 years ago
: Color(0xFFF5F6FA),
3 years ago
borderRadius: BorderRadius.circular(4),
),
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
"0${position + 1}",
style: TextStyle(
color: (widget.signInfo != null &&
widget.signInfo.signInList != null &&
widget.signInfo.signInList.length > position)
? Colors.white
: Color(0xFF353535),
fontSize: 14.sp,
fontWeight: MyFontWeight.medium,
),
),
Container(
alignment: Alignment.center,
child: SvgPicture.asset(
"assets/svg/qiandao.svg",
width: 30,
height: 30,
3 years ago
),
),
Container(
alignment: Alignment.center,
margin: EdgeInsets.only(
top: 2.h,
),
child: Text(
(widget.signInfo != null &&
widget.signInfo.rewardList != null &&
widget.signInfo.rewardList.length > position)
? "+${widget.signInfo.rewardList[position]}"
: "+10",
style: TextStyle(
color: (widget.signInfo != null &&
widget.signInfo.signInList != null &&
widget.signInfo.signInList.length > position)
? Colors.white
: Color(0xFF727272),
fontSize: 12.sp,
fontWeight: MyFontWeight.regular,
),
),
),
],
),
);
}
}
}