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.

244 lines
8.2 KiB

3 years ago
import 'package:flutter/material.dart';
import 'package:huixiang/generated/l10n.dart';
import 'package:huixiang/retrofit/data/sign_info.dart';
import 'package:huixiang/retrofit/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';
3 years ago
class IntegralTask extends StatefulWidget {
final SignInfo signInfo;
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 != null &&
widget.signInfo.taskList != null &&
widget.signInfo.taskList.length > 0)
? ListView.builder(
padding: EdgeInsets.only(left: 10.w, top: 20.h),
physics: BouncingScrollPhysics(),
// loop: false,
// pagination: SwiperPagination(
// alignment: Alignment.bottomCenter,
// builder: DotSwiperPaginationBuilder(
// size: 8,
// activeSize: 8,
// space: 5,
// activeColor: Colors.black,
// color: Colors.black.withAlpha(76),
// ),
// ),
itemBuilder: (context, position) {
return taskItem(widget.signInfo.taskList[position]);
},
itemCount: (widget.signInfo != null &&
widget.signInfo.taskList != null &&
widget.signInfo.taskList.length > 0)
? 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,
)
],
),
);
}
Widget taskPage(position) {
if (widget.signInfo == null || widget.signInfo.taskList == null)
return Container();
return Container(
margin: EdgeInsets.only(left: 10.w, right: 10.w, top: 16.h),
child: Column(
children: [
3 years ago
taskItem(widget.signInfo.taskList[position * 3 + 0]),
3 years ago
if (widget.signInfo.taskList.length > (position * 3 + 1))
3 years ago
taskItem(widget.signInfo.taskList[position * 3 + 1]),
3 years ago
if (widget.signInfo.taskList.length > (position * 3 + 2))
3 years ago
taskItem(widget.signInfo.taskList[position * 3 + 2]),
3 years ago
],
),
);
}
taskImg(String taskType) {
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
}
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),
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,
style: TextStyle(
fontSize: 14.sp,
fontWeight: MyFontWeight.regular,
color: Color(0xFF353535),
),
),
SizedBox(
height: 7.h,
),
Row(
children: [
Text(
"+${double.tryParse(task.rewardValue).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),
),
),
],
),
],
),
),
3 years ago
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).toInt()}",
3 years ago
textColor:
task.limitDay == (task.complateNum ?? task.conplateNum)
? Color(0xFF808080)
: Colors.white,
backgroup:
task.limitDay == (task.complateNum ?? task.conplateNum)
? 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
],
),
);
}
}