From 38a56095503b9f714bd03996c6a2c299d5f03215 Mon Sep 17 00:00:00 2001 From: Fransolet Thomas Date: Fri, 3 Mar 2023 17:02:02 +0100 Subject: [PATCH] Update to float button quiz redo --- lib/Screens/Quizz/questions_list.dart | 2 +- lib/Screens/Quizz/quizz_page.dart | 63 ++++++++++++++++----------- 2 files changed, 39 insertions(+), 26 deletions(-) diff --git a/lib/Screens/Quizz/questions_list.dart b/lib/Screens/Quizz/questions_list.dart index af3c7c7..fe0dedc 100644 --- a/lib/Screens/Quizz/questions_list.dart +++ b/lib/Screens/Quizz/questions_list.dart @@ -51,7 +51,7 @@ class _QuestionsListWidget extends State { /*return OrientationBuilder( builder: (context, orientation) {*/ return SizedBox( - height: widget.isShowResponse ? widget.orientation == Orientation.portrait ? MediaQuery.of(context).size.height * 0.84 : MediaQuery.of(context).size.height * 0.625 : MediaQuery.of(context).size.height, + height: widget.isShowResponse ? widget.orientation == Orientation.portrait ? MediaQuery.of(context).size.height * 0.85 : MediaQuery.of(context).size.height * 0.625 : MediaQuery.of(context).size.height, width: double.infinity, //color: Colors.orange, child: Stack( diff --git a/lib/Screens/Quizz/quizz_page.dart b/lib/Screens/Quizz/quizz_page.dart index 78614c0..82af330 100644 --- a/lib/Screens/Quizz/quizz_page.dart +++ b/lib/Screens/Quizz/quizz_page.dart @@ -50,6 +50,7 @@ class _QuizzPageState extends State { bool showResponses = false; bool kIsWeb = false; + bool isResultPage = false; @override void initState() { @@ -184,14 +185,14 @@ class _QuizzPageState extends State { // RESPONSE BOX //ShowReponsesWidget(questionsSubDTO: _questionsSubDTO), - if(orientation == Orientation.portrait) + if(orientation == Orientation.portrait && !showResponses) // Buttons Column( mainAxisAlignment: MainAxisAlignment.spaceEvenly, crossAxisAlignment: CrossAxisAlignment.center, children: resultButtons(size, orientation, visitAppContext!), ), - if(orientation == Orientation.landscape) + if(orientation == Orientation.landscape && !showResponses) // Buttons Row( mainAxisAlignment: MainAxisAlignment.spaceEvenly, @@ -221,6 +222,19 @@ class _QuizzPageState extends State { ); } ), + floatingActionButton: showResponses ? FloatingActionButton( + onPressed: () { + setState(() { + showResult = false; + showResponses = false; + currentIndex = 1; + _questionsSubDTO = QuestionSubDTO().fromJSON(quizzDTO!.questions!); + }); + }, + backgroundColor: kBackgroundSecondGrey, + child: const Icon(Icons.undo), + ) : null, + floatingActionButtonLocation: FloatingActionButtonLocation.miniEndFloat, ); } @@ -382,31 +396,30 @@ class _QuizzPageState extends State { resultButtons(Size size, Orientation orientation, VisitAppContext visitAppContext) { return [ - Padding( - padding: const EdgeInsets.all(4), - child: SizedBox( - height: kIsWeb ? 50 : 40, - width: orientation == Orientation.portrait ? size.width * 0.6 : size.width * 0.35, - child: RoundedButton( - text: TranslationHelper.getFromLocale("restart", visitAppContext), - color: kBackgroundSecondGrey, - textColor: kBackgroundLight, - icon: Icons.undo, - press: () { - setState(() { - showResult = false; - showResponses = false; - currentIndex = 1; - _questionsSubDTO = QuestionSubDTO().fromJSON(quizzDTO!.questions!); - }); - }, - fontSize: 18, - horizontal: 20, - vertical: 5 + Padding( + padding: const EdgeInsets.all(4), + child: SizedBox( + height: kIsWeb ? 50 : 40, + width: orientation == Orientation.portrait ? size.width * 0.6 : size.width * 0.35, + child: RoundedButton( + text: TranslationHelper.getFromLocale("restart", visitAppContext), + color: kBackgroundSecondGrey, + textColor: kBackgroundLight, + icon: Icons.undo, + press: () { + setState(() { + showResult = false; + showResponses = false; + currentIndex = 1; + _questionsSubDTO = QuestionSubDTO().fromJSON(quizzDTO!.questions!); + }); + }, + fontSize: 18, + horizontal: 20, + vertical: 5 + ), ), ), - ), - if(!showResponses) Padding( padding: const EdgeInsets.all(4.0), child: SizedBox(