添加问卷调查多选

hmxc
张萌 4 years ago
parent c0e98280a7
commit b2384d772d

@ -3,6 +3,7 @@ import 'package:akuCommunity/constants/api.dart';
import 'package:akuCommunity/model/manager/questionnaire_detail_model.dart'; import 'package:akuCommunity/model/manager/questionnaire_detail_model.dart';
import 'package:akuCommunity/pages/manager_func.dart'; import 'package:akuCommunity/pages/manager_func.dart';
import 'package:akuCommunity/ui/manager/questionnaire/questionnaire_siglecheck.dart'; import 'package:akuCommunity/ui/manager/questionnaire/questionnaire_siglecheck.dart';
import 'package:akuCommunity/ui/manager/questionnaire/questionnarie_raido_check.dart';
import 'package:akuCommunity/widget/bee_scaffold.dart'; import 'package:akuCommunity/widget/bee_scaffold.dart';
import 'package:akuCommunity/widget/buttons/bee_single_check.dart'; import 'package:akuCommunity/widget/buttons/bee_single_check.dart';
import 'package:akuCommunity/widget/buttons/bottom_button.dart'; import 'package:akuCommunity/widget/buttons/bottom_button.dart';
@ -23,46 +24,11 @@ class _QuestionnaireDetailPageState extends State<QuestionnaireDetailPage> {
QuestionnaireDetialModel _model; QuestionnaireDetialModel _model;
bool _onload = true; bool _onload = true;
int _select; int _select;
List<int> _radio = [];
Widget _emptyWidget() { Widget _emptyWidget() {
return Container(); return Container();
} }
// Widget _singleCheck(String title, List<QuestionnaireChoiceVoList> answers) {
// return Container(
// width: double.infinity,
// child: Column(
// crossAxisAlignment: CrossAxisAlignment.start,
// children: [
// title.text.black.size(32.sp).bold.make(),
// 64.w.heightBox,
// Flex(
// direction: Axis.horizontal,
// children: [
// Column(
// crossAxisAlignment: CrossAxisAlignment.start,
// children: <Widget>[
// ...answers.oddList().map((e){
// return Row(
// children: [
// BeeSingleCheck(
// value: e.id,
// groupValue: ,
// ),
// ],
// );
// }).toList(),
// ].sepWidget(separate: 48.w.heightBox),
// ).expand(flex: 1),
// Column(
// children: [],
// ).expand(flex: 1),
// ],
// )
// ],
// ),
// );
// }
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return BeeScaffold( return BeeScaffold(
@ -111,12 +77,24 @@ class _QuestionnaireDetailPageState extends State<QuestionnaireDetailPage> {
selected: _select, selected: _select,
onPressed: (id) { onPressed: (id) {
_select = id; _select = id;
setState(() { setState(() {});
});
}, },
answers: _model.questionnaireTopicVoList.first answers: _model.questionnaireTopicVoList.first
.questionnaireChoiceVoList) .questionnaireChoiceVoList),
QuestionnaireRadioCheck(
title: 'title',
selected: _radio,
answers: _model.questionnaireTopicVoList.first
.questionnaireChoiceVoList,
onPressed: (id) {
if (_radio.contains(id)) {
_radio.remove(id);
} else {
_radio.add(id);
}
setState(() {});
},
),
], ],
), ),
), ),

@ -7,9 +7,13 @@ class QuestionnaireSingleCheck extends StatefulWidget {
final String title; final String title;
final List<QuestionnaireChoiceVoList> answers; final List<QuestionnaireChoiceVoList> answers;
final int selected; final int selected;
final Function(int) onPressed; final Function(int id) onPressed;
QuestionnaireSingleCheck( QuestionnaireSingleCheck(
{Key key, this.title, this.answers, this.selected, this.onPressed}) {Key key,
@required this.title,
@required this.answers,
@required this.selected,
@required this.onPressed})
: super(key: key); : super(key: key);
@override @override
@ -54,7 +58,7 @@ class _QuestionnaireSingleCheckState extends State<QuestionnaireSingleCheck> {
}).toList(), }).toList(),
].sepWidget(separate: 48.w.heightBox), ].sepWidget(separate: 48.w.heightBox),
).expand(flex: 1), ).expand(flex: 1),
Column( Column(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[ children: <Widget>[
...widget.answers.evenList().map((e) { ...widget.answers.evenList().map((e) {

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

Loading…
Cancel
Save