From e4c956ef413ccbfffc3712f2864b1684f1b54268 Mon Sep 17 00:00:00 2001 From: Fransolet Thomas Date: Fri, 25 Mar 2022 19:02:35 +0100 Subject: [PATCH] Fix bad level + show image result better --- lib/Screens/Quizz/quizz_view.dart | 47 +++++++++++++++++++++++-------- 1 file changed, 35 insertions(+), 12 deletions(-) diff --git a/lib/Screens/Quizz/quizz_view.dart b/lib/Screens/Quizz/quizz_view.dart index 0448568..5efe7f4 100644 --- a/lib/Screens/Quizz/quizz_view.dart +++ b/lib/Screens/Quizz/quizz_view.dart @@ -71,9 +71,8 @@ class _QuizzViewWidget extends State { log("goodResponses =" + goodResponses.toString()); var levelToShow; var test = goodResponses/quizzDTO.questions.length; - log("test" + test.toString()); - if(0 == test && test < 0.25) + if(0 == test || test < 0.25) levelToShow = quizzDTO.badLevel; if(test>=0.25 && test < 0.5) levelToShow = quizzDTO.mediumLevel; @@ -81,6 +80,7 @@ class _QuizzViewWidget extends State { levelToShow = quizzDTO.goodLevel; if(test>=0.75 && test <= 1) levelToShow = quizzDTO.greatLevel; + return Column( mainAxisAlignment: MainAxisAlignment.spaceAround, crossAxisAlignment: CrossAxisAlignment.center, @@ -105,15 +105,16 @@ class _QuizzViewWidget extends State { ), ), ), - if (levelToShow.source_ != null) + if (levelToShow?.source_ != null) Container( - height: size.height * 0.2, - width: size.width * 0.25, - margin: EdgeInsets.symmetric(horizontal: 5.0), + //height: size.height * 0.2, + //width: size.width * 0.25, + constraints: BoxConstraints( + maxHeight: size.height * 0.25, + maxWidth: size.width * 0.25, + ), + alignment: Alignment.center, decoration: BoxDecoration( - color: kBackgroundLight, - shape: BoxShape.rectangle, - borderRadius: BorderRadius.circular(20.0), image: levelToShow.source_ != null ? new DecorationImage( fit: BoxFit.contain, opacity: 0.85, @@ -121,6 +122,28 @@ class _QuizzViewWidget extends State { levelToShow.source_, ), ): null, + borderRadius: BorderRadius.all( Radius.circular(50.0)), + border: Border.all( + color: kBackgroundGrey, + width: 1.0, + ), + ), + child: Container( + //borderRadius: BorderRadius.all(Radius.circular(25.0)), + decoration: BoxDecoration( + color: const Color(0xff7c94b6), + image: DecorationImage( + image: new NetworkImage( + levelToShow.source_, + ), + fit: BoxFit.cover, + ), + borderRadius: BorderRadius.all( Radius.circular(50.0)), + border: Border.all( + color: kBackgroundGrey, + width: 1.0, + ), + ), ), ), Container( @@ -151,7 +174,7 @@ class _QuizzViewWidget extends State { child: SingleChildScrollView( child: Padding( padding: const EdgeInsets.all(15.0), - child: Text(levelToShow.label.firstWhere((translation) => translation.language == appContext.getContext().language).value != null ? levelToShow.label.firstWhere((translation) => translation.language == appContext.getContext().language).value : "", textAlign: TextAlign.center, style: TextStyle(fontSize: kDescriptionSize)), + child: levelToShow != null ? Text(levelToShow.label.firstWhere((translation) => translation.language == appContext.getContext().language).value != null ? levelToShow.label.firstWhere((translation) => translation.language == appContext.getContext().language).value : "", textAlign: TextAlign.center, style: TextStyle(fontSize: kDescriptionSize)): Text("No data"), ), ), ), @@ -320,9 +343,9 @@ class _QuizzViewWidget extends State { padding: const EdgeInsets.all(8.0), child: Container( alignment: Alignment.center, - child: Text(i.responsesSubDTO[index].label.firstWhere((translation) => translation.language == appContext.getContext().language).value != null ? i.responsesSubDTO[index].label.firstWhere((translation) => translation.language == appContext.getContext().language).value : "", textAlign: TextAlign.center, style: TextStyle(fontSize: kDescriptionSize)), + child: Text(i.responsesSubDTO[index].label.firstWhere((translation) => translation.language == appContext.getContext().language).value != null ? i.responsesSubDTO[index].label.firstWhere((translation) => translation.language == appContext.getContext().language).value : "", textAlign: TextAlign.center, style: TextStyle(fontSize: kDescriptionSize, color: i.chosen == index ? Colors.white : Colors.black)), decoration: BoxDecoration( - color: i.chosen == index ? Colors.green : kBackgroundLight, + color: i.chosen == index ? kTestSecondColor : kBackgroundLight, shape: BoxShape.rectangle, borderRadius: BorderRadius.circular(10.0), boxShadow: [