From b2384d772dd7d87f4d745a58e062878a3a7b0197 Mon Sep 17 00:00:00 2001 From: zhang <494089941@qq.com> Date: Sun, 7 Feb 2021 16:08:10 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E9=97=AE=E5=8D=B7=E8=B0=83?= =?UTF-8?q?=E6=9F=A5=E5=A4=9A=E9=80=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../questionnaire_detail_page.dart | 58 ++++-------- .../questionnaire_siglecheck.dart | 10 ++- .../questionnarie_raido_check.dart | 90 +++++++++++++++++++ lib/widget/buttons/bee_check_radio.dart | 6 +- 4 files changed, 119 insertions(+), 45 deletions(-) create mode 100644 lib/ui/manager/questionnaire/questionnarie_raido_check.dart diff --git a/lib/ui/manager/questionnaire/questionnaire_detail_page.dart b/lib/ui/manager/questionnaire/questionnaire_detail_page.dart index d6d5825b..4b1ba498 100644 --- a/lib/ui/manager/questionnaire/questionnaire_detail_page.dart +++ b/lib/ui/manager/questionnaire/questionnaire_detail_page.dart @@ -3,6 +3,7 @@ import 'package:akuCommunity/constants/api.dart'; import 'package:akuCommunity/model/manager/questionnaire_detail_model.dart'; import 'package:akuCommunity/pages/manager_func.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/buttons/bee_single_check.dart'; import 'package:akuCommunity/widget/buttons/bottom_button.dart'; @@ -23,46 +24,11 @@ class _QuestionnaireDetailPageState extends State { QuestionnaireDetialModel _model; bool _onload = true; int _select; + List _radio = []; Widget _emptyWidget() { return Container(); } - // Widget _singleCheck(String title, List 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: [ - // ...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 Widget build(BuildContext context) { return BeeScaffold( @@ -111,12 +77,24 @@ class _QuestionnaireDetailPageState extends State { selected: _select, onPressed: (id) { _select = id; - setState(() { - - }); + setState(() {}); }, 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(() {}); + }, + ), ], ), ), diff --git a/lib/ui/manager/questionnaire/questionnaire_siglecheck.dart b/lib/ui/manager/questionnaire/questionnaire_siglecheck.dart index 1970e827..e86e4663 100644 --- a/lib/ui/manager/questionnaire/questionnaire_siglecheck.dart +++ b/lib/ui/manager/questionnaire/questionnaire_siglecheck.dart @@ -7,9 +7,13 @@ class QuestionnaireSingleCheck extends StatefulWidget { final String title; final List answers; final int selected; - final Function(int) onPressed; + final Function(int id) onPressed; 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); @override @@ -54,7 +58,7 @@ class _QuestionnaireSingleCheckState extends State { }).toList(), ].sepWidget(separate: 48.w.heightBox), ).expand(flex: 1), - Column( + Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ ...widget.answers.evenList().map((e) { diff --git a/lib/ui/manager/questionnaire/questionnarie_raido_check.dart b/lib/ui/manager/questionnaire/questionnarie_raido_check.dart new file mode 100644 index 00000000..17252f82 --- /dev/null +++ b/lib/ui/manager/questionnaire/questionnarie_raido_check.dart @@ -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 answers; + final List 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 { + @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.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.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), + ], + ), + ) + ], + ), + ); + } +} diff --git a/lib/widget/buttons/bee_check_radio.dart b/lib/widget/buttons/bee_check_radio.dart index 8e611811..2400c283 100644 --- a/lib/widget/buttons/bee_check_radio.dart +++ b/lib/widget/buttons/bee_check_radio.dart @@ -27,6 +27,7 @@ class _BeeCheckRadioState extends State { 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 { curve: Curves.easeInOutCubic, opacity: _selected ? 1 : 0, child: Icon( - CupertinoIcons.chevron_forward, - size: 24.w, + CupertinoIcons.checkmark, + color: Colors.white, + size: 28.w, ), ), );