# Conflicts: # lib/constants/application_objects.dart # lib/pages/manager_func.dart # lib/pages/things_page/widget/bee_list_view.dart # lib/ui/manager/questionnaire/questionnaire_page.darthmxc
commit
471257cc4d
@ -0,0 +1,142 @@
|
|||||||
|
class QuestionnaireDetialModel {
|
||||||
|
int id;
|
||||||
|
String title;
|
||||||
|
String description;
|
||||||
|
String beginDate;
|
||||||
|
String endDate;
|
||||||
|
List<QuestionnaireTopicVoList> questionnaireTopicVoList;
|
||||||
|
List<VoResourcesImgList> voResourcesImgList;
|
||||||
|
|
||||||
|
QuestionnaireDetialModel(
|
||||||
|
{this.id,
|
||||||
|
this.title,
|
||||||
|
this.description,
|
||||||
|
this.beginDate,
|
||||||
|
this.endDate,
|
||||||
|
this.questionnaireTopicVoList,
|
||||||
|
this.voResourcesImgList});
|
||||||
|
|
||||||
|
QuestionnaireDetialModel.fromJson(Map<String, dynamic> json) {
|
||||||
|
id = json['id'];
|
||||||
|
title = json['title'];
|
||||||
|
description = json['description'];
|
||||||
|
beginDate = json['beginDate'];
|
||||||
|
endDate = json['endDate'];
|
||||||
|
if (json['questionnaireTopicVoList'] != null) {
|
||||||
|
questionnaireTopicVoList = new List<QuestionnaireTopicVoList>();
|
||||||
|
json['questionnaireTopicVoList'].forEach((v) {
|
||||||
|
questionnaireTopicVoList.add(new QuestionnaireTopicVoList.fromJson(v));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
if (json['voResourcesImgList'] != null) {
|
||||||
|
voResourcesImgList = new List<VoResourcesImgList>();
|
||||||
|
json['voResourcesImgList'].forEach((v) {
|
||||||
|
voResourcesImgList.add(new VoResourcesImgList.fromJson(v));
|
||||||
|
});
|
||||||
|
}else voResourcesImgList=[];
|
||||||
|
}
|
||||||
|
|
||||||
|
Map<String, dynamic> toJson() {
|
||||||
|
final Map<String, dynamic> data = new Map<String, dynamic>();
|
||||||
|
data['id'] = this.id;
|
||||||
|
data['title'] = this.title;
|
||||||
|
data['description'] = this.description;
|
||||||
|
data['beginDate'] = this.beginDate;
|
||||||
|
data['endDate'] = this.endDate;
|
||||||
|
if (this.questionnaireTopicVoList != null) {
|
||||||
|
data['questionnaireTopicVoList'] =
|
||||||
|
this.questionnaireTopicVoList.map((v) => v.toJson()).toList();
|
||||||
|
}
|
||||||
|
if (this.voResourcesImgList != null) {
|
||||||
|
data['voResourcesImgList'] =
|
||||||
|
this.voResourcesImgList.map((v) => v.toJson()).toList();
|
||||||
|
}
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class QuestionnaireTopicVoList {
|
||||||
|
int id;
|
||||||
|
int type;
|
||||||
|
String topic;
|
||||||
|
List<QuestionnaireChoiceVoList> questionnaireChoiceVoList;
|
||||||
|
|
||||||
|
QuestionnaireTopicVoList(
|
||||||
|
{this.id, this.type, this.topic, this.questionnaireChoiceVoList});
|
||||||
|
|
||||||
|
QuestionnaireTopicVoList.fromJson(Map<String, dynamic> json) {
|
||||||
|
id = json['id'];
|
||||||
|
type = json['type'];
|
||||||
|
topic = json['topic'];
|
||||||
|
if (json['questionnaireChoiceVoList'] != null) {
|
||||||
|
questionnaireChoiceVoList = new List<QuestionnaireChoiceVoList>();
|
||||||
|
json['questionnaireChoiceVoList'].forEach((v) {
|
||||||
|
questionnaireChoiceVoList
|
||||||
|
.add(new QuestionnaireChoiceVoList.fromJson(v));
|
||||||
|
});
|
||||||
|
}else questionnaireChoiceVoList=[];
|
||||||
|
}
|
||||||
|
|
||||||
|
Map<String, dynamic> toJson() {
|
||||||
|
final Map<String, dynamic> data = new Map<String, dynamic>();
|
||||||
|
data['id'] = this.id;
|
||||||
|
data['type'] = this.type;
|
||||||
|
data['topic'] = this.topic;
|
||||||
|
if (this.questionnaireChoiceVoList != null) {
|
||||||
|
data['questionnaireChoiceVoList'] =
|
||||||
|
this.questionnaireChoiceVoList.map((v) => v.toJson()).toList();
|
||||||
|
}else questionnaireChoiceVoList=[];
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class QuestionnaireChoiceVoList {
|
||||||
|
int id;
|
||||||
|
String options;
|
||||||
|
String answer;
|
||||||
|
|
||||||
|
QuestionnaireChoiceVoList({this.id, this.options, this.answer});
|
||||||
|
|
||||||
|
QuestionnaireChoiceVoList.fromJson(Map<String, dynamic> json) {
|
||||||
|
id = json['id'];
|
||||||
|
options = json['options'];
|
||||||
|
answer = json['answer'];
|
||||||
|
}
|
||||||
|
|
||||||
|
Map<String, dynamic> toJson() {
|
||||||
|
final Map<String, dynamic> data = new Map<String, dynamic>();
|
||||||
|
data['id'] = this.id;
|
||||||
|
data['options'] = this.options;
|
||||||
|
data['answer'] = this.answer;
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class VoResourcesImgList {
|
||||||
|
String url;
|
||||||
|
String size;
|
||||||
|
int longs;
|
||||||
|
int paragraph;
|
||||||
|
int sort;
|
||||||
|
|
||||||
|
VoResourcesImgList(
|
||||||
|
{this.url, this.size, this.longs, this.paragraph, this.sort});
|
||||||
|
|
||||||
|
VoResourcesImgList.fromJson(Map<String, dynamic> json) {
|
||||||
|
url = json['url'];
|
||||||
|
size = json['size'];
|
||||||
|
longs = json['longs'];
|
||||||
|
paragraph = json['paragraph'];
|
||||||
|
sort = json['sort'];
|
||||||
|
}
|
||||||
|
|
||||||
|
Map<String, dynamic> toJson() {
|
||||||
|
final Map<String, dynamic> data = new Map<String, dynamic>();
|
||||||
|
data['url'] = this.url;
|
||||||
|
data['size'] = this.size;
|
||||||
|
data['longs'] = this.longs;
|
||||||
|
data['paragraph'] = this.paragraph;
|
||||||
|
data['sort'] = this.sort;
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,50 @@
|
|||||||
|
class QuestionnaireSubmitModel {
|
||||||
|
int id;
|
||||||
|
List<AppQuestionnaireAnswerSubmits> appQuestionnaireAnswerSubmits;
|
||||||
|
|
||||||
|
QuestionnaireSubmitModel({this.id, this.appQuestionnaireAnswerSubmits});
|
||||||
|
|
||||||
|
QuestionnaireSubmitModel.fromJson(Map<String, dynamic> json) {
|
||||||
|
id = json['id'];
|
||||||
|
if (json['appQuestionnaireAnswerSubmits'] != null) {
|
||||||
|
appQuestionnaireAnswerSubmits = new List<AppQuestionnaireAnswerSubmits>();
|
||||||
|
json['appQuestionnaireAnswerSubmits'].forEach((v) {
|
||||||
|
appQuestionnaireAnswerSubmits
|
||||||
|
.add(new AppQuestionnaireAnswerSubmits.fromJson(v));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Map<String, dynamic> toJson() {
|
||||||
|
final Map<String, dynamic> data = new Map<String, dynamic>();
|
||||||
|
data['id'] = this.id;
|
||||||
|
if (this.appQuestionnaireAnswerSubmits != null) {
|
||||||
|
data['appQuestionnaireAnswerSubmits'] =
|
||||||
|
this.appQuestionnaireAnswerSubmits.map((v) => v.toJson()).toList();
|
||||||
|
}
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class AppQuestionnaireAnswerSubmits {
|
||||||
|
int topicId;
|
||||||
|
List<int> choiceAnswer;
|
||||||
|
String shortAnswer;
|
||||||
|
|
||||||
|
AppQuestionnaireAnswerSubmits(
|
||||||
|
{this.topicId, this.choiceAnswer, this.shortAnswer});
|
||||||
|
|
||||||
|
AppQuestionnaireAnswerSubmits.fromJson(Map<String, dynamic> json) {
|
||||||
|
topicId = json['topicId'];
|
||||||
|
choiceAnswer = json['choiceAnswer'].cast<int>();
|
||||||
|
shortAnswer = json['shortAnswer'];
|
||||||
|
}
|
||||||
|
|
||||||
|
Map<String, dynamic> toJson() {
|
||||||
|
final Map<String, dynamic> data = new Map<String, dynamic>();
|
||||||
|
data['topicId'] = this.topicId;
|
||||||
|
data['choiceAnswer'] = this.choiceAnswer;
|
||||||
|
data['shortAnswer'] = this.shortAnswer;
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,256 @@
|
|||||||
|
import 'package:akuCommunity/base/base_style.dart';
|
||||||
|
import 'package:akuCommunity/constants/api.dart';
|
||||||
|
import 'package:akuCommunity/model/manager/questionnaire_detail_model.dart';
|
||||||
|
import 'package:akuCommunity/model/manager/quetionnaire_submit_model.dart';
|
||||||
|
import 'package:akuCommunity/pages/manager_func.dart';
|
||||||
|
import 'package:akuCommunity/ui/manager/questionnaire/questionnaire_siglecheck.dart';
|
||||||
|
import 'package:akuCommunity/ui/manager/questionnaire/questionnaire_truefalse.dart';
|
||||||
|
import 'package:akuCommunity/ui/manager/questionnaire/questionnarie_raido_check.dart';
|
||||||
|
import 'package:akuCommunity/widget/bee_divider.dart';
|
||||||
|
import 'package:akuCommunity/widget/bee_scaffold.dart';
|
||||||
|
import 'package:akuCommunity/widget/buttons/bottom_button.dart';
|
||||||
|
import 'package:flutter/cupertino.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:akuCommunity/utils/headers.dart';
|
||||||
|
import 'package:flutter_easyrefresh/easy_refresh.dart';
|
||||||
|
import 'package:get/get.dart';
|
||||||
|
|
||||||
|
class QuestionnaireDetailPage extends StatefulWidget {
|
||||||
|
final int id;
|
||||||
|
QuestionnaireDetailPage({Key key, this.id}) : super(key: key);
|
||||||
|
|
||||||
|
@override
|
||||||
|
_QuestionnaireDetailPageState createState() =>
|
||||||
|
_QuestionnaireDetailPageState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _QuestionnaireDetailPageState extends State<QuestionnaireDetailPage> {
|
||||||
|
QuestionnaireDetialModel _model;
|
||||||
|
bool _onload = true;
|
||||||
|
|
||||||
|
List<AppQuestionnaireAnswerSubmits> _submitModels = [];
|
||||||
|
Widget _emptyWidget() {
|
||||||
|
return Container();
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget _expandedCheck(String title, List<QuestionnaireChoiceVoList> answers,
|
||||||
|
List<AppQuestionnaireAnswerSubmits> submitModels, int index) {
|
||||||
|
return Container(
|
||||||
|
width: double.infinity,
|
||||||
|
child: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
title.text.black.size(32.sp).bold.make(),
|
||||||
|
64.w.heightBox,
|
||||||
|
GestureDetector(
|
||||||
|
onTap: () {
|
||||||
|
Get.bottomSheet(
|
||||||
|
CupertinoActionSheet(
|
||||||
|
// title: ,
|
||||||
|
cancelButton: CupertinoActionSheetAction(
|
||||||
|
child: '取消'.text.black.size(28.sp).make(),
|
||||||
|
onPressed: () {
|
||||||
|
Get.back();
|
||||||
|
},
|
||||||
|
),
|
||||||
|
actions: answers
|
||||||
|
.map((e) => CupertinoActionSheetAction(
|
||||||
|
onPressed: () {
|
||||||
|
submitModels[index].choiceAnswer.first = e.id;
|
||||||
|
submitModels[index].shortAnswer = e.answer;
|
||||||
|
Get.back();
|
||||||
|
setState(() {});
|
||||||
|
},
|
||||||
|
child: e.answer.text.black
|
||||||
|
.size(28.sp)
|
||||||
|
.isIntrinsic
|
||||||
|
.make()))
|
||||||
|
.toList(),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
child: Row(
|
||||||
|
children: [
|
||||||
|
Container(
|
||||||
|
// decoration: BoxDecoration(
|
||||||
|
// border: Border(
|
||||||
|
// bottom: BorderSide(
|
||||||
|
// width: 1.w, color: Color(0xFFE8E8E8)))),
|
||||||
|
height: 96.w,
|
||||||
|
width: double.infinity,
|
||||||
|
padding:
|
||||||
|
EdgeInsets.symmetric(horizontal: 32.w, vertical: 28.w),
|
||||||
|
child: (submitModels[index].shortAnswer ?? '请选择')
|
||||||
|
.text
|
||||||
|
.color(ktextSubColor)
|
||||||
|
.size(28.sp)
|
||||||
|
.make(),
|
||||||
|
).expand(),
|
||||||
|
Icon(
|
||||||
|
CupertinoIcons.chevron_forward,
|
||||||
|
color: Color(0xFFD8D8D8),
|
||||||
|
size: 40.w,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
BeeDivider.horizontal()
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget _shortAnswer(String title,
|
||||||
|
List<AppQuestionnaireAnswerSubmits> submitModels, int index) {
|
||||||
|
return Container(
|
||||||
|
width: double.infinity,
|
||||||
|
child: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
title.text.color(ktextPrimary).size(28.sp).make(),
|
||||||
|
24.w.heightBox,
|
||||||
|
Container(
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
border: Border.all(
|
||||||
|
width: 1.w,
|
||||||
|
color: Color(0xFFD4CFBE),
|
||||||
|
),
|
||||||
|
borderRadius: BorderRadius.circular(8.w),
|
||||||
|
),
|
||||||
|
child: TextField(
|
||||||
|
minLines: 5,
|
||||||
|
maxLines: 10,
|
||||||
|
scrollPadding: EdgeInsets.zero,
|
||||||
|
decoration: InputDecoration(
|
||||||
|
border: InputBorder.none,
|
||||||
|
contentPadding:
|
||||||
|
EdgeInsets.symmetric(horizontal: 32.w, vertical: 28.w),
|
||||||
|
isDense: true),
|
||||||
|
onChanged: (value) {
|
||||||
|
submitModels[index].shortAnswer = value;
|
||||||
|
setState(() {});
|
||||||
|
},
|
||||||
|
),
|
||||||
|
)
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget _topicWidget(QuestionnaireTopicVoList questionModel,
|
||||||
|
List<AppQuestionnaireAnswerSubmits> submitModels, int index) {
|
||||||
|
switch (questionModel.type) {
|
||||||
|
case 1:
|
||||||
|
return QuestionnaireSingleCheck(
|
||||||
|
title: questionModel.topic,
|
||||||
|
selected: submitModels[index].choiceAnswer.first,
|
||||||
|
onPressed: (id) {
|
||||||
|
submitModels[index].choiceAnswer.first = id;
|
||||||
|
setState(() {});
|
||||||
|
},
|
||||||
|
answers: questionModel.questionnaireChoiceVoList);
|
||||||
|
|
||||||
|
case 2:
|
||||||
|
submitModels[index].choiceAnswer.remove(-1);
|
||||||
|
return QuestionnaireRadioCheck(
|
||||||
|
title: questionModel.topic,
|
||||||
|
selected: submitModels[index].choiceAnswer,
|
||||||
|
answers: questionModel.questionnaireChoiceVoList,
|
||||||
|
onPressed: (id) {
|
||||||
|
if (submitModels[index].choiceAnswer.contains(id)) {
|
||||||
|
submitModels[index].choiceAnswer.remove(id);
|
||||||
|
} else {
|
||||||
|
submitModels[index].choiceAnswer.add(id);
|
||||||
|
}
|
||||||
|
setState(() {});
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
|
case 3:
|
||||||
|
return _expandedCheck(questionModel.topic,
|
||||||
|
questionModel.questionnaireChoiceVoList, submitModels, index);
|
||||||
|
case 4:
|
||||||
|
return QuestionnaireTruefalse(
|
||||||
|
title: questionModel.topic,
|
||||||
|
selected: submitModels[index].choiceAnswer.first,
|
||||||
|
onPressed: (id) {
|
||||||
|
submitModels[index].choiceAnswer.first = id;
|
||||||
|
setState(() {});
|
||||||
|
},
|
||||||
|
);
|
||||||
|
case 5:
|
||||||
|
return _shortAnswer(questionModel.topic, submitModels, index);
|
||||||
|
|
||||||
|
default:
|
||||||
|
return Container();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return BeeScaffold(
|
||||||
|
title: '问卷调查',
|
||||||
|
body: EasyRefresh(
|
||||||
|
firstRefresh: true,
|
||||||
|
header: MaterialHeader(),
|
||||||
|
onRefresh: () async {
|
||||||
|
_model = await ManagerFunc.questionnairefindById(widget.id);
|
||||||
|
_onload = false;
|
||||||
|
_submitModels = _model.questionnaireTopicVoList
|
||||||
|
.map((e) => AppQuestionnaireAnswerSubmits(
|
||||||
|
topicId: e.id,
|
||||||
|
choiceAnswer: [-1],
|
||||||
|
))
|
||||||
|
.toList();
|
||||||
|
print(_submitModels);
|
||||||
|
setState(() {});
|
||||||
|
},
|
||||||
|
child: _onload
|
||||||
|
? _emptyWidget()
|
||||||
|
: ListView(
|
||||||
|
padding: EdgeInsets.symmetric(horizontal: 32.w, vertical: 24.w),
|
||||||
|
children: [
|
||||||
|
Container(
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
borderRadius: BorderRadius.circular(4.w),
|
||||||
|
),
|
||||||
|
width: double.infinity,
|
||||||
|
height: 228.w,
|
||||||
|
clipBehavior: Clip.antiAlias,
|
||||||
|
child: FadeInImage.assetNetwork(
|
||||||
|
placeholder: R.ASSETS_IMAGES_LOGO_PNG,
|
||||||
|
image: API.image(_model.voResourcesImgList.first.url)),
|
||||||
|
),
|
||||||
|
40.w.heightBox,
|
||||||
|
Container(
|
||||||
|
width: double.infinity,
|
||||||
|
alignment: Alignment.center,
|
||||||
|
child: _model.title.text
|
||||||
|
.color(ktextPrimary)
|
||||||
|
.size(32.sp)
|
||||||
|
.bold
|
||||||
|
.make()),
|
||||||
|
36.w.heightBox,
|
||||||
|
_model.description.text
|
||||||
|
.color(ktextPrimary)
|
||||||
|
.size(28.sp)
|
||||||
|
.make(),
|
||||||
|
130.w.heightBox,
|
||||||
|
...List.generate(
|
||||||
|
_model.questionnaireTopicVoList.length,
|
||||||
|
(index) => _topicWidget(
|
||||||
|
_model.questionnaireTopicVoList[index],
|
||||||
|
_submitModels,
|
||||||
|
index)).sepWidget(separate: 80.w.heightBox),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
bottomNavi: BottomButton(
|
||||||
|
child: '确认提交'.text.black.size(32.sp).bold.make(),
|
||||||
|
onPressed: () async {
|
||||||
|
await ManagerFunc.questionnaireSubmit(widget.id, _submitModels);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,90 @@
|
|||||||
|
import 'package:akuCommunity/model/manager/questionnaire_detail_model.dart';
|
||||||
|
import 'package:akuCommunity/widget/buttons/bee_single_check.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:akuCommunity/utils/headers.dart';
|
||||||
|
|
||||||
|
class QuestionnaireSingleCheck extends StatefulWidget {
|
||||||
|
final String title;
|
||||||
|
final List<QuestionnaireChoiceVoList> answers;
|
||||||
|
final int selected;
|
||||||
|
final Function(int id) onPressed;
|
||||||
|
QuestionnaireSingleCheck(
|
||||||
|
{Key key,
|
||||||
|
@required this.title,
|
||||||
|
@required this.answers,
|
||||||
|
@required this.selected,
|
||||||
|
@required this.onPressed})
|
||||||
|
: super(key: key);
|
||||||
|
|
||||||
|
@override
|
||||||
|
_QuestionnaireSingleCheckState createState() =>
|
||||||
|
_QuestionnaireSingleCheckState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _QuestionnaireSingleCheckState extends State<QuestionnaireSingleCheck> {
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Container(
|
||||||
|
width: double.infinity,
|
||||||
|
child: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
widget.title.text.black.size(32.sp).bold.make(),
|
||||||
|
64.w.heightBox,
|
||||||
|
Padding(
|
||||||
|
padding: EdgeInsets.symmetric(horizontal: 96.w),
|
||||||
|
child: Flex(
|
||||||
|
direction: Axis.horizontal,
|
||||||
|
children: [
|
||||||
|
Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: <Widget>[
|
||||||
|
...widget.answers.oddList().map((e) {
|
||||||
|
return Row(
|
||||||
|
children: [
|
||||||
|
GestureDetector(
|
||||||
|
onTap: () {
|
||||||
|
widget.onPressed(e.id);
|
||||||
|
},
|
||||||
|
child: BeeSingleCheck(
|
||||||
|
value: e.id,
|
||||||
|
groupValue: widget.selected,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
16.w.widthBox,
|
||||||
|
e.answer.text.black.size(28.sp).make(),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}).toList(),
|
||||||
|
].sepWidget(separate: 48.w.heightBox),
|
||||||
|
).expand(flex: 1),
|
||||||
|
Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: <Widget>[
|
||||||
|
...widget.answers.evenList().map((e) {
|
||||||
|
return Row(
|
||||||
|
children: [
|
||||||
|
GestureDetector(
|
||||||
|
onTap: () {
|
||||||
|
widget.onPressed(e.id);
|
||||||
|
},
|
||||||
|
child: BeeSingleCheck(
|
||||||
|
value: e.id,
|
||||||
|
groupValue: widget.selected,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
16.w.widthBox,
|
||||||
|
e.answer.text.black.size(28.sp).make(),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}).toList(),
|
||||||
|
].sepWidget(separate: 48.w.heightBox),
|
||||||
|
).expand(flex: 1),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
)
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,69 @@
|
|||||||
|
import 'package:akuCommunity/widget/buttons/bee_single_check.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:velocity_x/velocity_x.dart';
|
||||||
|
import 'package:akuCommunity/utils/headers.dart';
|
||||||
|
|
||||||
|
class QuestionnaireTruefalse extends StatefulWidget {
|
||||||
|
final String title;
|
||||||
|
final int selected;
|
||||||
|
final Function(int id) onPressed;
|
||||||
|
QuestionnaireTruefalse({Key key, this.title, this.selected, this.onPressed})
|
||||||
|
: super(key: key);
|
||||||
|
|
||||||
|
@override
|
||||||
|
_QuestionnaireTruefalseState createState() => _QuestionnaireTruefalseState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _QuestionnaireTruefalseState extends State<QuestionnaireTruefalse> {
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Container(
|
||||||
|
width: double.infinity,
|
||||||
|
child: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
widget.title.text.black.size(32.sp).bold.make(),
|
||||||
|
64.w.heightBox,
|
||||||
|
Padding(
|
||||||
|
padding: EdgeInsets.symmetric(horizontal: 96.w),
|
||||||
|
child: Flex(
|
||||||
|
direction: Axis.horizontal,
|
||||||
|
children: [
|
||||||
|
Row(
|
||||||
|
children: [
|
||||||
|
GestureDetector(
|
||||||
|
onTap: () {
|
||||||
|
widget.onPressed(1);
|
||||||
|
},
|
||||||
|
child: BeeSingleCheck(
|
||||||
|
value: 1,
|
||||||
|
groupValue: widget.selected,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
16.w.widthBox,
|
||||||
|
'正确'.text.black.size(28.sp).make(),
|
||||||
|
],
|
||||||
|
).expand(flex: 1),
|
||||||
|
Row(
|
||||||
|
children: [
|
||||||
|
GestureDetector(
|
||||||
|
onTap: () {
|
||||||
|
widget.onPressed(0);
|
||||||
|
},
|
||||||
|
child: BeeSingleCheck(
|
||||||
|
value: 0,
|
||||||
|
groupValue: widget.selected,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
16.w.widthBox,
|
||||||
|
'错误'.text.black.size(28.sp).make(),
|
||||||
|
],
|
||||||
|
).expand(flex: 1),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
)
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,90 @@
|
|||||||
|
import 'package:akuCommunity/model/manager/questionnaire_detail_model.dart';
|
||||||
|
import 'package:akuCommunity/widget/buttons/bee_check_radio.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:akuCommunity/utils/headers.dart';
|
||||||
|
|
||||||
|
class QuestionnaireRadioCheck extends StatefulWidget {
|
||||||
|
final String title;
|
||||||
|
final List<QuestionnaireChoiceVoList> answers;
|
||||||
|
final List<int> selected;
|
||||||
|
final Function(int id) onPressed;
|
||||||
|
QuestionnaireRadioCheck(
|
||||||
|
{Key key,
|
||||||
|
@required this.title,
|
||||||
|
@required this.answers,
|
||||||
|
@required this.selected,
|
||||||
|
@required this.onPressed})
|
||||||
|
: super(key: key);
|
||||||
|
|
||||||
|
@override
|
||||||
|
_QuestionnaireRadioCheckState createState() =>
|
||||||
|
_QuestionnaireRadioCheckState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _QuestionnaireRadioCheckState extends State<QuestionnaireRadioCheck> {
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Container(
|
||||||
|
width: double.infinity,
|
||||||
|
child: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
widget.title.text.black.size(32.sp).bold.make(),
|
||||||
|
64.w.heightBox,
|
||||||
|
Padding(
|
||||||
|
padding: EdgeInsets.symmetric(horizontal: 96.w),
|
||||||
|
child: Flex(
|
||||||
|
direction: Axis.horizontal,
|
||||||
|
children: [
|
||||||
|
Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: <Widget>[
|
||||||
|
...widget.answers.oddList().map((e) {
|
||||||
|
return Row(
|
||||||
|
children: [
|
||||||
|
GestureDetector(
|
||||||
|
onTap: () {
|
||||||
|
widget.onPressed(e.id);
|
||||||
|
},
|
||||||
|
child: BeeCheckRadio(
|
||||||
|
value: e.id,
|
||||||
|
groupValue: widget.selected,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
16.w.widthBox,
|
||||||
|
e.answer.text.black.size(28.sp).make(),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}).toList(),
|
||||||
|
].sepWidget(separate: 48.w.heightBox),
|
||||||
|
).expand(flex: 1),
|
||||||
|
Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: <Widget>[
|
||||||
|
...widget.answers.evenList().map((e) {
|
||||||
|
return Row(
|
||||||
|
children: [
|
||||||
|
GestureDetector(
|
||||||
|
onTap: () {
|
||||||
|
widget.onPressed(e.id);
|
||||||
|
},
|
||||||
|
child: BeeCheckRadio(
|
||||||
|
value: e.id,
|
||||||
|
groupValue: widget.selected,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
16.w.widthBox,
|
||||||
|
e.answer.text.black.size(28.sp).make(),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}).toList(),
|
||||||
|
].sepWidget(separate: 48.w.heightBox),
|
||||||
|
).expand(flex: 1),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
)
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in new issue