import 'package:flutter/material.dart'; import 'package:flutter_staggered_grid_view/flutter_staggered_grid_view.dart'; import 'package:flutter_svg/svg.dart'; import 'package:huixiang/generated/l10n.dart'; import 'package:huixiang/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 createState() { return _InForPoints(); } } class _InForPoints extends State { @override Widget build(BuildContext context) { return Container( width: double.infinity, margin: EdgeInsets.symmetric(horizontal: 14.w, vertical: 6.h), padding: EdgeInsets.symmetric(horizontal: 12.w, vertical: 16.h), decoration: BoxDecoration( color: Colors.white, borderRadius: BorderRadius.circular(8), boxShadow: [ BoxShadow( color: Colors.black.withAlpha(12), offset: Offset(0, 3), blurRadius: 14, spreadRadius: 0, ), ], ), child: Column( mainAxisAlignment: MainAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.start, children: [ 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), ), ), ], ), SizedBox( height: 12.h, ), StaggeredGrid.count( crossAxisCount: 4, mainAxisSpacing: 8, crossAxisSpacing: 18, children: childItems(), ), InkWell( onTap: () { widget.signIn?.call(); }, child: Container( alignment: Alignment.center, child: RoundButton( width: double.infinity, height: 34.h, text: (widget.signInfo?.todayHasSignin ?? false) ? S.of(context).yiqiandao : "签到", textColor: (widget.signInfo?.todayHasSignin ?? false) ? Color(0xFFB3B3B3) : Colors.white, backgroup: (widget.signInfo?.todayHasSignin ?? false) ? Color(0xFFF5F6FA) : Color(0xFF32A060), fontSize: 16.sp, fontWeight: MyFontWeight.bold, padding: EdgeInsets.symmetric( horizontal: 16.w, vertical: 6.h, ), radius: 20.w, ), ), ), ], ), ); } List childItems() { List widgets = []; for (int i = 0; i < 7; i++) { widgets.add(signInItem(i)); } return widgets; } // StaggeredTile.count(position == 6 ? 2 : 1, 1.28); Widget signInItem(position) { if (position == 6) { return StaggeredGridTile.count( crossAxisCellCount: 2, mainAxisCellCount: 1.28, child: Container( padding: EdgeInsets.all(4), decoration: BoxDecoration( color: Color(0xFFF5F6FA), 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, ), ), ], ), ), ); } else { return StaggeredGridTile.count( crossAxisCellCount: 1, mainAxisCellCount: 1.28, child: Container( padding: EdgeInsets.all(4), decoration: BoxDecoration( color: ((widget.signInfo?.signInList?.length ?? 0) > position) ? Color(0xFF32A060) : Color(0xFFF5F6FA), borderRadius: BorderRadius.circular(4), ), child: Column( mainAxisAlignment: MainAxisAlignment.spaceEvenly, crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( "0${position + 1}", style: TextStyle( color: ((widget.signInfo?.signInList?.length ?? 0) > 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, ), ), Container( alignment: Alignment.center, margin: EdgeInsets.only( top: 2.h, ), child: Text( ((widget.signInfo?.rewardList?.length ?? 0) > position) ? "+${widget.signInfo?.rewardList?[position]}" : "+10", style: TextStyle( color: ((widget.signInfo?.rewardList?.length ?? 0) > position) ? Colors.white : Color(0xFF727272), fontSize: 12.sp, fontWeight: MyFontWeight.regular, ), ), ), ], ), ), ); } } }