Fix bad level + show image result better

This commit is contained in:
Fransolet Thomas 2022-03-25 19:02:35 +01:00
parent e6e084a77d
commit e4c956ef41

View File

@ -71,9 +71,8 @@ class _QuizzViewWidget extends State<QuizzViewWidget> {
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<QuizzViewWidget> {
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<QuizzViewWidget> {
),
),
),
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<QuizzViewWidget> {
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<QuizzViewWidget> {
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<QuizzViewWidget> {
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: [