Merge branch 'zhang'

# 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.dart
hmxc
张萌 4 years ago
commit 471257cc4d

@ -157,6 +157,12 @@ class _Manager {
///applist
String get questionnaireList => '/user/questionnaire/list';
///id
String get questionnairefindById => '/user/questionnaire/findById';
///app
String get questionnaireSubmit => '/user/questionnaire/submit';
}
class _Community {

@ -4,6 +4,7 @@ import 'package:akuCommunity/pages/mine_car_page/mine_car_page.dart';
import 'package:akuCommunity/pages/mine_house_page/mine_house_page.dart';
import 'package:akuCommunity/pages/setting_page/settings_page.dart';
import 'package:akuCommunity/ui/community/activity/activity_list_page.dart';
import 'package:akuCommunity/ui/manager/questionnaire/questionnaire_page.dart';
import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';
@ -19,7 +20,6 @@ import 'package:akuCommunity/pages/life_pay/life_pay_page.dart';
import 'package:akuCommunity/pages/one_alarm/widget/alarm_page.dart';
import 'package:akuCommunity/pages/open_door_page/open_door_page.dart';
import 'package:akuCommunity/pages/opening_code_page/opening_code_page.dart';
import 'package:akuCommunity/pages/questionnaire_page/questionnaire_page.dart';
import 'package:akuCommunity/pages/things_page/fixed_submit_page.dart';
import 'package:akuCommunity/pages/visitor_access_page/visitor_access_page.dart';
import 'package:akuCommunity/ui/home/application/all_application.dart';

@ -15,3 +15,27 @@ extension WidgetListExt on List<Widget> {
});
}
}
extension OddListExt<T> on List<T> {
List<T> oddList() {
List<T> _newList = [];
this.forEach((element) {
if (this.indexOf(element).isEven) {
_newList.add(element);
}
});
return _newList;
}
}
extension EvenListExt<T> on List<T> {
List<T> evenList() {
List<T> _newList = [];
this.forEach((element) {
if (this.indexOf(element).isOdd) {
_newList.add(element);
}
});
return _newList;
}
}

@ -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;
}
}

@ -1,13 +1,17 @@
// Package imports:
import 'dart:convert';
import 'package:akuCommunity/model/manager/article_QR_code_model.dart';
import 'package:akuCommunity/model/manager/moving_company_model.dart';
import 'package:akuCommunity/model/manager/questionnaire_detail_model.dart';
import 'package:akuCommunity/model/manager/quetionnaire_submit_model.dart';
import 'package:akuCommunity/model/manager/voting_detail_model.dart';
import 'package:dio/dio.dart';
import 'package:flustars/flustars.dart';
// Project imports:
import 'package:akuCommunity/constants/api.dart';
import 'package:akuCommunity/model/manager/article_QR_code_model.dart';
import 'package:akuCommunity/model/manager/fixed_detail_model.dart';
import 'package:akuCommunity/model/manager/moving_company_model.dart';
import 'package:akuCommunity/model/manager/voting_detail_model.dart';
import 'package:akuCommunity/utils/network/base_model.dart';
import 'package:akuCommunity/utils/network/net_util.dart';
@ -182,4 +186,28 @@ class ManagerFunc {
});
return baseModel;
}
static Future<QuestionnaireDetialModel> questionnairefindById(int id) async {
BaseModel baseModel = await NetUtil().get(
API.manager.questionnairefindById,
params: {
'questionnaireId': id,
},
showMessage: false,
);
return QuestionnaireDetialModel.fromJson(baseModel.data);
}
static Future<BaseModel> questionnaireSubmit(
int id, List<AppQuestionnaireAnswerSubmits> model) async {
BaseModel baseModel = await NetUtil().post(
API.manager.questionnaireSubmit,
params: {
'id': id,
'appQuestionnaireAnswerSubmits':model,
},
showMessage: true,
);
return baseModel;
}
}

@ -1,282 +0,0 @@
// Flutter imports:
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
// Package imports:
import 'package:flutter_html/flutter_html.dart';
// Project imports:
import 'package:akuCommunity/base/base_style.dart';
import 'package:akuCommunity/routers/page_routers.dart';
import 'package:akuCommunity/utils/headers.dart';
import 'package:akuCommunity/widget/bee_scaffold.dart';
import 'package:akuCommunity/widget/cached_image_wrapper.dart';
class QuestionnaireDetailsPage extends StatefulWidget {
final Bundle bundle;
QuestionnaireDetailsPage({Key key, this.bundle}) : super(key: key);
@override
_QuestionnaireDetailsPageState createState() =>
_QuestionnaireDetailsPageState();
}
const htmlData = '''
<p>
<br/>
</p>
''';
class _QuestionnaireDetailsPageState extends State<QuestionnaireDetailsPage> {
TextEditingController _ideaContent = new TextEditingController();
String hintText = '您的宝贵意见是我们前进的明灯';
List<Map<String, dynamic>> _listQuestion = [
{
'title': '您的身份是?',
'option': <Map<String, dynamic>>[
{'title': '学员', 'isCheck': false},
{'title': '家长', 'isCheck': false}
]
},
{
'title': '您所学习的课程是?',
'option': <Map<String, dynamic>>[
{'title': '儿童美术', 'isCheck': false},
{'title': '素描', 'isCheck': false},
{'title': '国画', 'isCheck': false},
{'title': '漫画', 'isCheck': false},
{'title': '书法', 'isCheck': false},
{'title': '陶艺', 'isCheck': false}
]
},
{
'title': '您选择我们的原因是?',
'option': <Map<String, dynamic>>[
{'title': '师资力量', 'isCheck': false},
{'title': '教学口碑', 'isCheck': false},
{'title': '地理位置', 'isCheck': false},
{'title': '其他人介绍', 'isCheck': false}
]
},
{
'title': '学习后孩子的成绩是否有所提升?',
'option': <Map<String, dynamic>>[
{'title': '有很大变化有很大变化有很大变化有很大变化有很大变化有很大变化', 'isCheck': false},
{'title': '变化一般', 'isCheck': false},
{'title': '没变化', 'isCheck': false}
]
}
];
Widget _questionCard(String title, List<Map<String, dynamic>> optionList) {
return Container(
margin: EdgeInsets.only(top: 64.w),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
title,
style: TextStyle(
fontWeight: FontWeight.w600,
fontSize: BaseStyle.fontSize32,
color: BaseStyle.color4a4b51,
),
),
Container(
margin: EdgeInsets.only(top: 64.w),
child: Wrap(
runSpacing: 48.w,
children: optionList
.map((item) => InkWell(
onTap: () {
setState(() {
item['isCheck'] = !item['isCheck'];
});
},
child: Container(
margin: EdgeInsets.only(left: 15.w),
width: MediaQuery.of(context).size.width / 2.35,
child: Row(
children: [
Icon(
item['isCheck']
? Icons.radio_button_checked
: Icons.radio_button_unchecked,
color: item['isCheck']
? BaseStyle.colorffc40c
: BaseStyle.color979797,
size: 32.w,
),
Container(
margin: EdgeInsets.only(left: 16.w),
width: MediaQuery.of(context).size.width / 3.2,
child: Text(
item['title'],
maxLines: 2,
style: TextStyle(
fontWeight: item['isCheck']
? FontWeight.w600
: FontWeight.normal,
fontSize: BaseStyle.fontSize28,
color: BaseStyle.color4a4b51,
),
),
),
],
),
),
))
.toList(),
),
),
],
),
);
}
Widget _containerTextField() {
return Container(
padding: EdgeInsets.only(top: 24.w, left: 24.w, right: 32.w),
decoration: BoxDecoration(
borderRadius: BorderRadius.all(Radius.circular(6)),
border: Border.all(color: Color(0xffd4cfbe), width: 1.0),
),
child: TextFormField(
cursorColor: Color(0xffffc40c),
style: TextStyle(
fontSize: BaseStyle.fontSize28,
fontWeight: FontWeight.w600,
),
controller: _ideaContent,
onChanged: (String value) {},
maxLines: 10,
decoration: InputDecoration(
isDense: true,
contentPadding: EdgeInsets.only(
top: 0,
bottom: 0,
),
hintText: hintText,
border: InputBorder.none, //线
fillColor: Colors.white,
filled: true,
hintStyle: TextStyle(
color: BaseStyle.color999999,
fontSize: BaseStyle.fontSize28,
fontWeight: FontWeight.normal,
),
),
),
);
}
Widget _positionedBottomBar() {
return Positioned(
bottom: 0,
child: Container(
alignment: Alignment.center,
height: 98.w,
width: MediaQuery.of(context).size.width,
child: InkWell(
onTap: () {},
child: Container(
alignment: Alignment.center,
color: BaseStyle.colorffc40c,
padding: EdgeInsets.symmetric(
vertical: 26.5.w,
),
child: Text(
'确认提交',
style: TextStyle(
fontWeight: FontWeight.w600,
fontSize: BaseStyle.fontSize32,
color: ktextPrimary,
),
),
),
),
),
);
}
@override
Widget build(BuildContext context) {
return BeeScaffold(
title: '问卷调查',
body: Container(
color: Colors.white,
child: Stack(
children: [
Container(
padding: EdgeInsets.only(
left: 32.w,
right: 32.w,
bottom: 155.w,
),
child: ListView(
children: [
Container(
margin: EdgeInsets.only(top: 24.w),
child: ClipRRect(
borderRadius: BorderRadius.all(Radius.circular(4.w)),
child: CachedImageWrapper(
url: widget.bundle.getMap('details')['imagePath'],
width: 686.w,
height: 228.w,
),
),
),
Container(
margin: EdgeInsets.only(top: 40.w),
alignment: Alignment.center,
child: Text(
widget.bundle.getMap('details')['title'],
style: TextStyle(
fontSize: BaseStyle.fontSize32,
color: BaseStyle.color4a4b51,
fontWeight: FontWeight.w600,
),
),
),
Container(
margin: EdgeInsets.only(top: 35.w),
alignment: Alignment.center,
width: 672.w,
child: Html(data: htmlData),
),
Container(
margin: EdgeInsets.only(top: 129.w),
child: Column(
children: _listQuestion
.map((item) => _questionCard(
item['title'],
item['option'],
))
.toList(),
),
),
Container(
margin: EdgeInsets.only(top: 80.w, bottom: 24.w),
child: Text(
'您的觉得我们需要改进的地方',
style: TextStyle(
fontSize: BaseStyle.fontSize28, color: ktextPrimary),
),
),
_containerTextField(),
],
),
),
_positionedBottomBar(),
],
),
),
);
}
}

@ -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);
},
),
);
}
}

@ -10,6 +10,7 @@ import 'package:akuCommunity/constants/api.dart';
import 'package:akuCommunity/model/manager/questinnaire_model.dart';
import 'package:akuCommunity/pages/things_page/widget/bee_list_view.dart';
import 'package:akuCommunity/utils/headers.dart';
import 'package:akuCommunity/ui/manager/questionnaire/questionnaire_detail_page.dart';
import 'package:akuCommunity/widget/bee_scaffold.dart';
import 'package:akuCommunity/widget/others/stack_avatar.dart';
@ -116,7 +117,9 @@ class _QuestionnairePageState extends State<QuestionnairePage> {
// padding:
// EdgeInsets.symmetric(horizontal: 30.w, vertical: 8.w),
elevation: 0,
onPressed: () {},
onPressed: () {
QuestionnaireDetailPage(id: model.id,).to();
},
child: (_getButtonText(model.status))
.text
.black

@ -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),
],
),
)
],
),
);
}
}

@ -27,6 +27,7 @@ class _BeeCheckRadioState extends State<BeeCheckRadio> {
height: 40.w,
width: 40.w,
decoration: BoxDecoration(
color: kPrimaryColor.withOpacity(_selected ? 1 : 0),
border: Border.all(
color: _selected ? kPrimaryColor : Color(0xFF979797),
width: 3.w,
@ -41,8 +42,9 @@ class _BeeCheckRadioState extends State<BeeCheckRadio> {
curve: Curves.easeInOutCubic,
opacity: _selected ? 1 : 0,
child: Icon(
CupertinoIcons.chevron_forward,
size: 24.w,
CupertinoIcons.checkmark,
color: Colors.white,
size: 28.w,
),
),
);

Loading…
Cancel
Save