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.
 
 
 
 
 

194 lines
9.2 KiB

import 'package:dating_touchme_app/components/page_appbar.dart';
import 'package:dating_touchme_app/controller/setting/task_controller.dart';
import 'package:dating_touchme_app/model/live/matchmaker_task.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:tdesign_flutter/tdesign_flutter.dart';
class MatchTaskPage extends StatelessWidget {
const MatchTaskPage({super.key});
@override
Widget build(BuildContext context) {
return GetX<TaskController>(
init: TaskController(),
builder: (controller){
return Scaffold(
appBar: PageAppbar(title: "红娘任务"),
body: controller.loading.value ? Center(
child: TDLoading(
size: TDLoadingSize.medium,
icon: TDLoadingIcon.activity,
text: '加载中...',
axis: Axis.vertical,
duration: 500,
)
) : SingleChildScrollView(
child: Column(
children: [
Container(
padding: EdgeInsets.symmetric(vertical: 12.w, horizontal: 18.w),
child: Column(
children: [
if(controller.dayTask.value.taskName != null && controller.dayTask.value.taskName!.isNotEmpty)Row(
children: [
TDText(controller.dayTask.value.taskName, style: TextStyle(color: Color(0xFF333333), fontWeight: FontWeight.bold, fontSize: 16.w)),
SizedBox(width: 4.w),
Container(
width: 4,
height: 4,
decoration: BoxDecoration(
color: Color(0xFF999999), // 圆点颜色
shape: BoxShape.circle, // 圆形
),
),
SizedBox(width: 4.w),
TDText('任务截止时间:${controller.dayTask.value.taskEndDate}', style: TextStyle(color: Color(0xFF666666), fontSize: 16.w)),
],
),
if(controller.dayTask.value.taskName != null && controller.dayTask.value.taskName!.isNotEmpty)SizedBox(height: 12.w,),
if(controller.dayTask.value.taskName != null && controller.dayTask.value.taskName!.isNotEmpty)...controller.dayTask.value.subList!.asMap().entries.map((entry){
return TaskItem(item: entry.value);
}),
if(controller.weekTask.value.taskName != null && controller.weekTask.value.taskName!.isNotEmpty) SizedBox(height: 24.w,),
if(controller.weekTask.value.taskName != null && controller.weekTask.value.taskName!.isNotEmpty) Row(
children: [
TDText(controller.weekTask.value.taskName, style: TextStyle(color: Color(0xFF333333), fontWeight: FontWeight.bold, fontSize: 16.w)),
SizedBox(width: 4.w),
Container(
width: 4,
height: 4,
decoration: BoxDecoration(
color: Color(0xFF999999), // 圆点颜色
shape: BoxShape.circle, // 圆形
),
),
SizedBox(width: 4.w),
TDText('任务截止时间:${controller.weekTask.value.taskEndDate}', style: TextStyle(color: Color(0xFF666666), fontSize: 16.w)),
],
),
if(controller.weekTask.value.taskName != null && controller.weekTask.value.taskName!.isNotEmpty)SizedBox(height: 12.w,),
if(controller.weekTask.value.taskName != null && controller.weekTask.value.taskName!.isNotEmpty)...controller.weekTask.value.subList!.asMap().entries.map((entry){
return TaskItem(item: entry.value);
}),
if(controller.monthTask.value.taskName != null && controller.monthTask.value.taskName!.isNotEmpty) SizedBox(height: 24.w,),
if(controller.monthTask.value.taskName != null && controller.monthTask.value.taskName!.isNotEmpty) Row(
children: [
TDText(controller.monthTask.value.taskName, style: TextStyle(color: Color(0xFF333333), fontWeight: FontWeight.bold, fontSize: 16.w)),
SizedBox(width: 4.w),
Container(
width: 4,
height: 4,
decoration: BoxDecoration(
color: Color(0xFF999999), // 圆点颜色
shape: BoxShape.circle, // 圆形
),
),
SizedBox(width: 4.w),
TDText('任务截止时间:${controller.monthTask.value.taskEndDate}', style: TextStyle(color: Color(0xFF666666), fontSize: 16.w)),
],
),
if(controller.monthTask.value.taskName != null && controller.monthTask.value.taskName!.isNotEmpty)SizedBox(height: 12.w,),
if(controller.monthTask.value.taskName != null && controller.monthTask.value.taskName!.isNotEmpty)...controller.monthTask.value.subList!.asMap().entries.map((entry){
return TaskItem(item: entry.value);
}),
!controller.isEmpty.value ? Column(
children: [
SizedBox(height: 12.w,),
Row(
children: [
TDText('注意事项', style: TextStyle(color: Color(0xFF333333), fontSize: 16.w)),
],
),
SizedBox(height: 4.w,),
Row(
children: [
Text('1.月任务未通过将受到惩罚;', style: TextStyle(fontSize: 12.w, color: Color(0xFF999999))),
],
),
SizedBox(height: 4.w,),
Row(
children: [
Text('2.任务开始时间为成为红娘的那一刻起;', style: TextStyle(fontSize: 12.w, color: Color(0xFF999999))),
],
),
SizedBox(height: 12.w),
],
) : Center(
child: TDResult(
icon: Column(
children: [
SizedBox(height: 100,),
Icon(TDIcons.task_time, size: 70, color: Color(0xFFCCCCCC)),
SizedBox(height: 24,),
],
),
description: '暂无任务',
),
)
],
),
)
],
)
)
);
},
);
}
}
class TaskItem extends StatelessWidget {
final SubListItem item;
const TaskItem({super.key, required this.item });
@override
Widget build(BuildContext context) {
return Container(
margin: EdgeInsets.only(bottom: 12.w, left: 8.w, top: 8.w),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
TDText(item.subTaskName, style: TextStyle(color: Color(0xFF333333), fontSize: 16.w)),
SizedBox(height: 4.w),
TDProgress(
type: TDProgressType.linear,
value: _getTaskProgress(item),
strokeWidth: 6,
progressLabelPosition: TDProgressLabelPosition.right,
color: Color(0xFF7562F9),
),
SizedBox(height: 2.w),
TDText(_getTaskLabel(item), style: TextStyle(color: Color(0xFF999999), fontSize: 12.w)),
],
),
);
}
double _getTaskProgress(SubListItem item) {
if(item.completeCount! <= 0){
return 0;
}
if(item.requiredCount! <= 0){
return 0;
}
double progress = item.completeCount! / item.requiredCount!;
return double.parse(progress.toStringAsFixed(3));
}
// 子任务类型。1:每日有效直播时长,2:有效相亲次数,3:直播间打卡人数
String _getTaskLabel(SubListItem item) {
if(item.subTaskType == 1){
return '目前直播时长:${item.completeCount}分钟';
}
if(item.subTaskType == 2){
return '目前相亲次数:${item.completeCount}';
}
if(item.subTaskType == 3){
return '目前打卡人数:${item.completeCount}';
}
return '';
}
}