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.

226 lines
7.4 KiB

3 years ago
import 'package:flutter/material.dart';
import 'package:huixiang/generated/l10n.dart';
import 'package:huixiang/data/sign_info.dart';
import 'package:huixiang/data/task.dart';
3 years ago
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';
3 years ago
class IntegralTask extends StatefulWidget {
final SignInfo? signInfo;
3 years ago
IntegralTask(this.signInfo);
@override
State<StatefulWidget> createState() {
return _IntegralTask();
}
}
class _IntegralTask extends State<IntegralTask> {
@override
Widget build(BuildContext context) {
return Container(
width: MediaQuery.of(context).size.width - 32,
3 years ago
height: 320.h,
3 years ago
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,
3 years ago
),
3 years ago
],
),
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),
),
3 years ago
),
flex: 1,
),
3 years ago
],
),
);
}
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]),
3 years ago
],
),
);
}
taskImg(String? taskType) {
3 years ago
switch (taskType) {
case "bill_type_point_order":
return "assets/image/icon_integral_login.webp";
3 years ago
break;
case "bill_type_point_share":
return "assets/image/icon_integral_share.webp";
3 years ago
break;
case "bill_type_point_login":
return "assets/image/icon_integral_order.webp";
3 years ago
break;
case "bill_type_point_signin":
return "assets/image/icon_integral_sign.webp";
3 years ago
break;
}
return "assets/image/icon_integral_login.webp";
3 years ago
}
Widget taskItem(Task? task) {
3 years ago
return Container(
margin: EdgeInsets.only(top: 8.h, bottom: 8.h),
alignment: Alignment.center,
child: Row(
children: [
3 years ago
Image.asset(
taskImg(task?.type),
3 years ago
width: 24.w,
height: 24.h,
),
3 years ago
SizedBox(
width: 21.w,
),
Expanded(
flex: 1,
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
task?.name ?? "",
3 years ago
style: TextStyle(
fontSize: 14.sp,
fontWeight: MyFontWeight.regular,
color: Color(0xFF353535),
),
),
SizedBox(
height: 7.h,
),
Row(
children: [
Text(
"+${(double.tryParse("${task?.rewardValue}") ?? 0).toInt()}",
3 years ago
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}"),
3 years ago
style: TextStyle(
fontSize: 12.sp,
fontWeight: MyFontWeight.regular,
color: Color(0xFF727272),
),
),
],
),
],
),
),
task?.limitDay == (task?.complateNum ?? task?.conplateNum)
3 years ago
? RoundButton(
text: task?.limitDay == (task?.complateNum ?? task?.conplateNum)
3 years ago
? S.of(context).yiwancheng
: S.of(context).quwancheng,
textColor:
task?.limitDay == (task?.complateNum ?? task?.conplateNum)
3 years ago
? Color(0xFF808080)
: Colors.white,
backgroup:
task?.limitDay == (task?.complateNum ?? task?.conplateNum)
3 years ago
? 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()}",
3 years ago
textColor:
task?.limitDay == (task?.complateNum ?? task?.conplateNum)
3 years ago
? Color(0xFF808080)
: Colors.white,
backgroup:
task?.limitDay == (task?.complateNum ?? task?.conplateNum)
3 years ago
? Color(0xFFF5F6FA)
3 years ago
: Color(0xFF00BF00),
3 years ago
icons: Image.asset(
"assets/image/icon_gold_coin.webp",
3 years ago
width: 16,
height: 16,
),
radius: 12.w,
fontSize: 12.sp,
fontWeight: MyFontWeight.semi_bold,
padding: EdgeInsets.symmetric(
vertical: 4.h,
horizontal: 14.w,
),
),
3 years ago
],
),
);
}
}