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.
266 lines
12 KiB
266 lines
12 KiB
import 'package:dating_touchme_app/components/page_appbar.dart';
|
|
import 'package:dating_touchme_app/controller/home/test_controller.dart';
|
|
import 'package:dating_touchme_app/extension/ex_widget.dart';
|
|
import 'package:dating_touchme_app/generated/assets.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 TestPage extends StatelessWidget {
|
|
final int type;
|
|
const TestPage({super.key, required this.type});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Stack(
|
|
children: [
|
|
Image.asset(
|
|
Assets.imagesTestBg,
|
|
width: 375.w,
|
|
fit: BoxFit.cover,
|
|
),
|
|
Scaffold(
|
|
backgroundColor: Colors.transparent,
|
|
appBar: PageAppbar(title: type == 1 ? "人格类型测试" : "情绪状态测试", color: Colors.white, backgroundColor: Colors.transparent,),
|
|
body: GetX<TestController>(
|
|
init: TestController(type: type),
|
|
builder: (controller) {
|
|
return Container(
|
|
width: 375.w,
|
|
padding: EdgeInsets.symmetric(
|
|
vertical: 40.w,
|
|
horizontal: 12.w
|
|
),
|
|
child: controller.testData.value.id != null ? Column(
|
|
children: [
|
|
if(controller.resultTitle.value == "") ...[
|
|
Container(
|
|
width: 350.w,
|
|
padding: EdgeInsets.all(30.w),
|
|
margin: EdgeInsets.only(bottom: 5.w),
|
|
decoration: BoxDecoration(
|
|
borderRadius: BorderRadius.all(Radius.circular(16.w)),
|
|
color: const Color.fromRGBO(39, 48, 89, 1)
|
|
),
|
|
child: Center(
|
|
child: Text(
|
|
controller.testData.value.questionList![controller.index.value].title ?? "",
|
|
style: TextStyle(
|
|
fontSize: 16.w,
|
|
color: Colors.white
|
|
),
|
|
),
|
|
),
|
|
),
|
|
Container(
|
|
width: 350.w,
|
|
margin: EdgeInsets.only(bottom: 5.w),
|
|
padding: EdgeInsets.only(
|
|
top: 10.w,
|
|
right: 10.w,
|
|
bottom: 5.w,
|
|
left: 10.w
|
|
),
|
|
decoration: BoxDecoration(
|
|
borderRadius: BorderRadius.all(Radius.circular(16.w)),
|
|
color: const Color.fromRGBO(0, 0, 0, .5)
|
|
),
|
|
child: Column(
|
|
children: [
|
|
for(var i = 0; i < controller.testData.value.questionList![controller.index.value].optionList!.length; i++)
|
|
Container(
|
|
width: 330.w,
|
|
height: 35.w,
|
|
margin: EdgeInsets.only(bottom: 5.w),
|
|
padding: EdgeInsets.symmetric(horizontal: 24.w),
|
|
decoration: BoxDecoration(
|
|
borderRadius: BorderRadius.all(Radius.circular(35.w)),
|
|
color: const Color.fromRGBO(255, 255, 255, .1)
|
|
),
|
|
alignment: Alignment.centerLeft,
|
|
child: Text(
|
|
"${String.fromCharCode(65 + i)}.${controller.testData.value.questionList![controller.index.value].optionList![i].text}",
|
|
style: TextStyle(
|
|
fontSize: 14.w,
|
|
color: Colors.white
|
|
),
|
|
),
|
|
).onTap((){
|
|
controller.select(int.parse(controller.testData.value.questionList![controller.index.value].id ?? "0"), int.parse(controller.testData.value.questionList![controller.index.value].optionList![i].id ?? "0"));
|
|
}),
|
|
|
|
|
|
],
|
|
),
|
|
),
|
|
TDProgress(
|
|
type: TDProgressType.linear,
|
|
value: (controller.sIndex.value)/controller.testData.value.questionList!.length,
|
|
strokeWidth: 6,
|
|
color: const Color.fromRGBO(117, 98, 249, 1),
|
|
progressLabelPosition: TDProgressLabelPosition.right,
|
|
label: TDTextLabel(
|
|
"${controller.sIndex.value}/${controller.testData.value.questionList!.length}",
|
|
style: TextStyle(
|
|
color: Colors.white
|
|
),
|
|
),
|
|
),
|
|
SizedBox(height: 5.w,),
|
|
Text(
|
|
"注:${controller.testData.value.disclaimer ?? ""}",
|
|
style: TextStyle(
|
|
fontSize: 12.w,
|
|
color: const Color.fromRGBO(255, 255, 255, .5 )
|
|
),
|
|
),
|
|
Spacer(),
|
|
if((controller.index.value == controller.testData.value.questionList!.length - 1) && controller.subData.length == controller.testData.value.questionList!.length)Container(
|
|
width: 350.w,
|
|
height: 45.w,
|
|
decoration: BoxDecoration(
|
|
borderRadius: BorderRadius.all(Radius.circular(45.w)),
|
|
color: const Color.fromRGBO(117, 98, 249, 1),
|
|
),
|
|
child: Center(
|
|
child: Text(
|
|
"查看结果",
|
|
style: TextStyle(
|
|
fontSize: 19.w,
|
|
color: Colors.white
|
|
),
|
|
),
|
|
),
|
|
).onTap(() {
|
|
controller.submit();
|
|
})
|
|
],
|
|
if(controller.resultTitle.value != "") ...[
|
|
Container(
|
|
width: 350.w,
|
|
padding: EdgeInsets.all(30.w),
|
|
margin: EdgeInsets.only(bottom: 5.w),
|
|
decoration: BoxDecoration(
|
|
borderRadius: BorderRadius.all(Radius.circular(16.w)),
|
|
color: const Color.fromRGBO(39, 48, 89, 1)
|
|
),
|
|
child: Center(
|
|
child: Text(
|
|
controller.resultTitle.value ?? "",
|
|
style: TextStyle(
|
|
fontSize: 16.w,
|
|
color: Colors.white
|
|
),
|
|
),
|
|
),
|
|
),
|
|
Container(
|
|
width: 350.w,
|
|
margin: EdgeInsets.only(bottom: 5.w),
|
|
padding: EdgeInsets.only(
|
|
top: 10.w,
|
|
right: 10.w,
|
|
bottom: 5.w,
|
|
left: 10.w
|
|
),
|
|
decoration: BoxDecoration(
|
|
borderRadius: BorderRadius.all(Radius.circular(16.w)),
|
|
color: const Color.fromRGBO(0, 0, 0, .5)
|
|
),
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
Text(
|
|
"解析:",
|
|
style: TextStyle(
|
|
fontSize: 16.w,
|
|
color: Colors.white
|
|
),
|
|
),
|
|
SizedBox(height: 15.w,),
|
|
Text(
|
|
"${controller.resultData.value["总结"]}",
|
|
style: TextStyle(
|
|
fontSize: 14.w,
|
|
color: Colors.white
|
|
),
|
|
),
|
|
if(type == 1) ...[
|
|
SizedBox(height: 10.w,),
|
|
Text(
|
|
"${controller.resultData.value["人际关系"]}",
|
|
style: TextStyle(
|
|
fontSize: 14.w,
|
|
color: Colors.white
|
|
),
|
|
),
|
|
SizedBox(height: 10.w,),
|
|
RichText(
|
|
text: TextSpan(
|
|
style: TextStyle(
|
|
fontSize: 14.w,
|
|
color: Colors.white
|
|
),
|
|
children: [
|
|
TextSpan(
|
|
text: "你的优势:"
|
|
),
|
|
...controller.resultData.value["优势"].map((e){
|
|
return TextSpan(text: "$e,");
|
|
})
|
|
]
|
|
),
|
|
),
|
|
],
|
|
SizedBox(height: 10.w,),
|
|
RichText(
|
|
text: TextSpan(
|
|
style: TextStyle(
|
|
fontSize: 14.w,
|
|
color: Colors.white
|
|
),
|
|
children: [
|
|
TextSpan(
|
|
text: "给你的建议:"
|
|
),
|
|
...controller.resultData.value["建议"].map((e){
|
|
return TextSpan(text: "$e,");
|
|
})
|
|
]
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
Spacer(),
|
|
Container(
|
|
width: 350.w,
|
|
height: 45.w,
|
|
decoration: BoxDecoration(
|
|
borderRadius: BorderRadius.all(Radius.circular(45.w)),
|
|
color: const Color.fromRGBO(117, 98, 249, 1),
|
|
),
|
|
child: Center(
|
|
child: Text(
|
|
"重新测试",
|
|
style: TextStyle(
|
|
fontSize: 19.w,
|
|
color: Colors.white
|
|
),
|
|
),
|
|
),
|
|
).onTap(() {
|
|
controller.reTest();
|
|
})
|
|
]
|
|
],
|
|
) : Container(),
|
|
);
|
|
},
|
|
),
|
|
)
|
|
],
|
|
);
|
|
}
|
|
}
|