import 'package:flutter/material.dart'; import 'package:huixiang/generated/l10n.dart'; import 'package:huixiang/data/sign_info.dart'; import 'package:huixiang/data/task.dart'; import 'package:huixiang/utils/font_weight.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:huixiang/view_widget/round_button.dart'; import '../../view_widget/no_data_view.dart'; class IntegralTask extends StatefulWidget { final SignInfo? signInfo; IntegralTask(this.signInfo); @override State createState() { return _IntegralTask(); } } class _IntegralTask extends State { @override Widget build(BuildContext context) { return Container( width: MediaQuery.of(context).size.width - 32, height: 320.h, margin: EdgeInsets.all(16), padding: EdgeInsets.symmetric( horizontal: 10.w, vertical: 20.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.start, crossAxisAlignment: CrossAxisAlignment.start, children: [ Container( margin: EdgeInsets.only(left: 10.w), child: Text( S.of(context).zuorenwudejifen, style: TextStyle( color: Color(0xFF353535), fontWeight: MyFontWeight.medium, fontSize: 16.sp, ), ), ), Expanded( child: Container( child: (widget.signInfo?.taskList?.isNotEmpty ?? false) ? ListView.builder( padding: EdgeInsets.only(left: 10.w, top: 20.h), physics: BouncingScrollPhysics(), itemBuilder: (context, position) { return taskItem(widget.signInfo!.taskList![position]); }, itemCount: widget.signInfo?.taskList?.length ?? 0, ) : NoDataView( src: "assets/image/xiao_fei.webp", isShowBtn: false, text: "暂无任务可做~", fontSize: 16.sp, margin: EdgeInsets.only(left: 60.w, right: 60.w), ), ), flex: 1, ), ], ), ); } Widget taskPage(position) { return Container( margin: EdgeInsets.only(left: 10.w, right: 10.w, top: 16.h), child: Column( children: [ taskItem(widget.signInfo?.taskList?[position * 3 + 0]), if ((widget.signInfo?.taskList?.length ?? 0) > (position * 3 + 1)) taskItem(widget.signInfo?.taskList?[position * 3 + 1]), if ((widget.signInfo?.taskList?.length ?? 0) > (position * 3 + 2)) taskItem(widget.signInfo?.taskList?[position * 3 + 2]), ], ), ); } taskImg(String? taskType) { switch (taskType) { case "bill_type_point_order": return "assets/image/icon_integral_login.webp"; break; case "bill_type_point_share": return "assets/image/icon_integral_share.webp"; break; case "bill_type_point_login": return "assets/image/icon_integral_order.webp"; break; case "bill_type_point_signin": return "assets/image/icon_integral_sign.webp"; break; } return "assets/image/icon_integral_login.webp"; } Widget taskItem(Task? task) { return Container( margin: EdgeInsets.only(top: 8.h, bottom: 8.h), alignment: Alignment.center, child: Row( children: [ Image.asset( taskImg(task?.type), width: 24.w, height: 24.h, ), SizedBox( width: 21.w, ), Expanded( flex: 1, child: Column( mainAxisAlignment: MainAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( task?.name ?? "", style: TextStyle( fontSize: 14.sp, fontWeight: MyFontWeight.regular, color: Color(0xFF353535), ), ), SizedBox( height: 7.h, ), Row( children: [ Text( "+${(double.tryParse("${task?.rewardValue}") ?? 0).toInt()}", style: TextStyle( fontSize: 12.sp, fontWeight: MyFontWeight.regular, color: Color(0xFF727272), ), ), SizedBox( width: 20.w, ), Text( S.of(context).wancheng_( "${task?.complateNum ?? task?.conplateNum}/${task?.limitDay}"), style: TextStyle( fontSize: 12.sp, fontWeight: MyFontWeight.regular, color: Color(0xFF727272), ), ), ], ), ], ), ), task?.limitDay == (task?.complateNum ?? task?.conplateNum) ? RoundButton( text: task?.limitDay == (task?.complateNum ?? task?.conplateNum) ? S.of(context).yiwancheng : S.of(context).quwancheng, textColor: task?.limitDay == (task?.complateNum ?? task?.conplateNum) ? Color(0xFF808080) : Colors.white, backgroup: task?.limitDay == (task?.complateNum ?? task?.conplateNum) ? Color(0xFFF5F6FA) : Color(0xFF32A060), radius: 12.w, fontSize: 12.sp, fontWeight: MyFontWeight.semi_bold, padding: EdgeInsets.symmetric( vertical: 4.h, horizontal: 15.w, ), ) : RoundButton( text: "x${(double.tryParse("${task?.rewardValue}") ?? 0).toInt()}", textColor: task?.limitDay == (task?.complateNum ?? task?.conplateNum) ? Color(0xFF808080) : Colors.white, backgroup: task?.limitDay == (task?.complateNum ?? task?.conplateNum) ? Color(0xFFF5F6FA) : Color(0xFF00BF00), icons: Image.asset( "assets/image/icon_gold_coin.webp", width: 16, height: 16, ), radius: 12.w, fontSize: 12.sp, fontWeight: MyFontWeight.semi_bold, padding: EdgeInsets.symmetric( vertical: 4.h, horizontal: 14.w, ), ), ], ), ); } }