Update to float button quiz redo

This commit is contained in:
Fransolet Thomas 2023-03-03 17:02:02 +01:00
parent efa6cfe3f1
commit 38a5609550
2 changed files with 39 additions and 26 deletions

View File

@ -51,7 +51,7 @@ class _QuestionsListWidget extends State<QuestionsListWidget> {
/*return OrientationBuilder( /*return OrientationBuilder(
builder: (context, orientation) {*/ builder: (context, orientation) {*/
return SizedBox( 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, width: double.infinity,
//color: Colors.orange, //color: Colors.orange,
child: Stack( child: Stack(

View File

@ -50,6 +50,7 @@ class _QuizzPageState extends State<QuizzPage> {
bool showResponses = false; bool showResponses = false;
bool kIsWeb = false; bool kIsWeb = false;
bool isResultPage = false;
@override @override
void initState() { void initState() {
@ -184,14 +185,14 @@ class _QuizzPageState extends State<QuizzPage> {
// RESPONSE BOX // RESPONSE BOX
//ShowReponsesWidget(questionsSubDTO: _questionsSubDTO), //ShowReponsesWidget(questionsSubDTO: _questionsSubDTO),
if(orientation == Orientation.portrait) if(orientation == Orientation.portrait && !showResponses)
// Buttons // Buttons
Column( Column(
mainAxisAlignment: MainAxisAlignment.spaceEvenly, mainAxisAlignment: MainAxisAlignment.spaceEvenly,
crossAxisAlignment: CrossAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.center,
children: resultButtons(size, orientation, visitAppContext!), children: resultButtons(size, orientation, visitAppContext!),
), ),
if(orientation == Orientation.landscape) if(orientation == Orientation.landscape && !showResponses)
// Buttons // Buttons
Row( Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly, mainAxisAlignment: MainAxisAlignment.spaceEvenly,
@ -221,6 +222,19 @@ class _QuizzPageState extends State<QuizzPage> {
); );
} }
), ),
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<QuizzPage> {
resultButtons(Size size, Orientation orientation, VisitAppContext visitAppContext) { resultButtons(Size size, Orientation orientation, VisitAppContext visitAppContext) {
return [ return [
Padding( Padding(
padding: const EdgeInsets.all(4), padding: const EdgeInsets.all(4),
child: SizedBox( child: SizedBox(
height: kIsWeb ? 50 : 40, height: kIsWeb ? 50 : 40,
width: orientation == Orientation.portrait ? size.width * 0.6 : size.width * 0.35, width: orientation == Orientation.portrait ? size.width * 0.6 : size.width * 0.35,
child: RoundedButton( child: RoundedButton(
text: TranslationHelper.getFromLocale("restart", visitAppContext), text: TranslationHelper.getFromLocale("restart", visitAppContext),
color: kBackgroundSecondGrey, color: kBackgroundSecondGrey,
textColor: kBackgroundLight, textColor: kBackgroundLight,
icon: Icons.undo, icon: Icons.undo,
press: () { press: () {
setState(() { setState(() {
showResult = false; showResult = false;
showResponses = false; showResponses = false;
currentIndex = 1; currentIndex = 1;
_questionsSubDTO = QuestionSubDTO().fromJSON(quizzDTO!.questions!); _questionsSubDTO = QuestionSubDTO().fromJSON(quizzDTO!.questions!);
}); });
}, },
fontSize: 18, fontSize: 18,
horizontal: 20, horizontal: 20,
vertical: 5 vertical: 5
),
), ),
), ),
),
if(!showResponses)
Padding( Padding(
padding: const EdgeInsets.all(4.0), padding: const EdgeInsets.all(4.0),
child: SizedBox( child: SizedBox(