diff --git a/lib/Screens/Quizz/questions_list.dart b/lib/Screens/Quizz/questions_list.dart index 2f8e215..3c4557b 100644 --- a/lib/Screens/Quizz/questions_list.dart +++ b/lib/Screens/Quizz/questions_list.dart @@ -62,177 +62,179 @@ class _QuestionsListWidget extends State { //color: Colors.orange, child: Stack( children: [ - Column( - crossAxisAlignment: CrossAxisAlignment.center, - mainAxisAlignment: MainAxisAlignment.start, - children: [ - if(_questionsSubDTO.isNotEmpty) - CarouselSlider( - carouselController: sliderController, - options: CarouselOptions( - onPageChanged: (int index, CarouselPageChangedReason reason) { - setState(() { - currentIndex = index + 1; - }); - }, - height: widget.isShowResponse ? widget.orientation == Orientation.portrait ? MediaQuery.of(context).size.height * 0.79 : MediaQuery.of(context).size.height * 0.6 : MediaQuery.of(context).size.height * 0.85, - enlargeCenterPage: true, - scrollPhysics: const NeverScrollableScrollPhysics(), - reverse: false, - ), - items: _questionsSubDTO.map((i) { - return Builder( - builder: (BuildContext context) { - return Padding( - padding: const EdgeInsets.only(left: 7.5, right: 7.5, bottom: 10.0, top: 8.0), - child: Container( - width: MediaQuery.of(context).size.width, - // height: widget.isShowResponse ? MediaQuery.of(context).size.height *0.55 : MediaQuery.of(context).size.height, - margin: const EdgeInsets.symmetric(horizontal: 1.5), - decoration: BoxDecoration( - //color: Colors.orange, //kBackgroundLight - shape: BoxShape.rectangle, - borderRadius: BorderRadius.circular(20.0), - image: i.source_ != null ? DecorationImage( - fit: BoxFit.cover, - opacity: 0.35, - image: NetworkImage( - i.source_!, - ), - ): null, - boxShadow: const [ - BoxShadow( - color: kBackgroundSecondGrey, - spreadRadius: 0.5, - blurRadius: 5, - offset: Offset(0, 1.5), // changes position of shadow - ), - ], - ), - child: Column( - //crossAxisAlignment: CrossAxisAlignment.center, - //mainAxisAlignment: MainAxisAlignment.spaceEvenly, - children: [ - SizedBox( - //color: Colors.red, - //width: MediaQuery.of(context).size.width *0.65, - height: MediaQuery.of(context).size.height *0.25, - child: Stack( - children: [ - Center( - child: Container( - decoration: BoxDecoration( - color: kBackgroundLight, //kBackgroundLight - shape: BoxShape.rectangle, - borderRadius: BorderRadius.circular(10.0), - boxShadow: const [ - BoxShadow( - color: kBackgroundSecondGrey, - spreadRadius: 0.3, - blurRadius: 4, - offset: Offset(0, 2), // changes position of shadow - ), - ], - ), - width: MediaQuery.of(context).size.width *0.7, - height: MediaQuery.of(context).size.height *0.2, - child: Center( - child: SingleChildScrollView( - child: Padding( - padding: const EdgeInsets.all(2.5), - child: Text(TranslationHelper.get(i.label, appContext.getContext() as VisitAppContext), textAlign: TextAlign.center, style: const TextStyle(fontSize: kDescriptionSize)), - ), - ), - ), - ) - ), - ] + SingleChildScrollView( + child: Column( + crossAxisAlignment: CrossAxisAlignment.center, + mainAxisAlignment: MainAxisAlignment.start, + children: [ + if(_questionsSubDTO.isNotEmpty) + CarouselSlider( + carouselController: sliderController, + options: CarouselOptions( + onPageChanged: (int index, CarouselPageChangedReason reason) { + setState(() { + currentIndex = index + 1; + }); + }, + height: widget.isShowResponse ? widget.orientation == Orientation.portrait ? MediaQuery.of(context).size.height * 0.79 : MediaQuery.of(context).size.height * 0.6 : MediaQuery.of(context).size.height * 0.85, + enlargeCenterPage: true, + scrollPhysics: const NeverScrollableScrollPhysics(), + reverse: false, + ), + items: _questionsSubDTO.map((i) { + return Builder( + builder: (BuildContext context) { + return Padding( + padding: const EdgeInsets.only(left: 7.5, right: 7.5, bottom: 10.0, top: 8.0), + child: Container( + width: MediaQuery.of(context).size.width, + // height: widget.isShowResponse ? MediaQuery.of(context).size.height *0.55 : MediaQuery.of(context).size.height, + margin: const EdgeInsets.symmetric(horizontal: 1.5), + decoration: BoxDecoration( + //color: Colors.orange, //kBackgroundLight + shape: BoxShape.rectangle, + borderRadius: BorderRadius.circular(20.0), + image: i.source_ != null ? DecorationImage( + fit: BoxFit.cover, + opacity: 0.35, + image: NetworkImage( + i.source_!, ), - ), - /*SizedBox( - height: MediaQuery.of(context).size.height * 0.01, - ),*/ - Expanded( - child: Padding( - padding: const EdgeInsets.all(5.0), - child: SizedBox( - //height: MediaQuery.of(context).size.height * 0.75, - width: MediaQuery.of(context).size.width * 0.72, - //color: Colors.green, - child: Padding( - padding: const EdgeInsets.all(10.0), - child: GridView.builder( - gridDelegate: SliverGridDelegateWithFixedCrossAxisCount( - crossAxisCount: widget.orientation == Orientation.portrait ? 1 : 2, // TODO HERE IS TABLET - mainAxisExtent: widget.isShowResponse ? - widget.orientation == Orientation.portrait ? - 60 : - 50 : - widget.orientation == Orientation.portrait ? - 60 : - 60, // TODO depends on percentage - mainAxisSpacing: widget.isShowResponse ? - widget.orientation == Orientation.portrait ? - 30 : - 10 : - widget.orientation == Orientation.portrait ? - 32.5 : - 32.5, // TODO depends on percentage - crossAxisSpacing: widget.isShowResponse ? 0 : 0, // TODO depends on percentage - ), - itemCount: i.responsesSubDTO!.length, - itemBuilder: (BuildContext ctx, index) { - return InkWell( - onTap: () { - if(!widget.isShowResponse) { - setState(() { - i.chosen = index; - if(currentIndex == _questionsSubDTO.length && i.chosen == index) - { - widget.onShowResponse(); - //showResult = true; - //_controllerCenter!.play(); // TODO Maybe show only confetti on super score .. - } else { - sliderController!.nextPage(duration: const Duration(milliseconds: 650), curve: Curves.fastOutSlowIn); - } - }); - } - }, - child: Padding( - padding: const EdgeInsets.all(2.5), - child: Container( - alignment: Alignment.center, - child: Text(TranslationHelper.get(i.responsesSubDTO![index].label, appContext.getContext() as VisitAppContext), textAlign: TextAlign.center, style: TextStyle(fontSize: kDescriptionSize, color: i.chosen == index ? Colors.white : Colors.black)), - decoration: BoxDecoration( - color: !widget.isShowResponse ? i.chosen == index ? kTestSecondColor : kBackgroundLight : i.responsesSubDTO![index].isGood! ? kGreen : i.chosen == index ? kTextRed : kBackgroundLight, - shape: BoxShape.rectangle, - borderRadius: BorderRadius.circular(10.0), - boxShadow: const [ - BoxShadow( - color: kBackgroundSecondGrey, - spreadRadius: 0.3, - blurRadius: 4, - offset: Offset(0, 2), // changes position of shadow - ), - ], + ): null, + boxShadow: const [ + BoxShadow( + color: kBackgroundSecondGrey, + spreadRadius: 0.5, + blurRadius: 5, + offset: Offset(0, 1.5), // changes position of shadow + ), + ], + ), + child: Column( + //crossAxisAlignment: CrossAxisAlignment.center, + //mainAxisAlignment: MainAxisAlignment.spaceEvenly, + children: [ + SizedBox( + //color: Colors.red, + //width: MediaQuery.of(context).size.width *0.65, + height: MediaQuery.of(context).size.height *0.25, + child: Stack( + children: [ + Center( + child: Container( + decoration: BoxDecoration( + color: kBackgroundLight, //kBackgroundLight + shape: BoxShape.rectangle, + borderRadius: BorderRadius.circular(10.0), + boxShadow: const [ + BoxShadow( + color: kBackgroundSecondGrey, + spreadRadius: 0.3, + blurRadius: 4, + offset: Offset(0, 2), // changes position of shadow + ), + ], + ), + width: MediaQuery.of(context).size.width *0.7, + height: MediaQuery.of(context).size.height *0.2, + child: Center( + child: SingleChildScrollView( + child: Padding( + padding: const EdgeInsets.all(2.5), + child: Text(TranslationHelper.get(i.label, appContext.getContext() as VisitAppContext), textAlign: TextAlign.center, style: const TextStyle(fontSize: kDescriptionSize)), ), ), ), - ); - }), + ) + ), + ] + ), + ), + /*SizedBox( + height: MediaQuery.of(context).size.height * 0.01, + ),*/ + Expanded( + child: Padding( + padding: const EdgeInsets.all(5.0), + child: SizedBox( + //height: MediaQuery.of(context).size.height * 0.75, + width: MediaQuery.of(context).size.width * 0.72, + //color: Colors.green, + child: Padding( + padding: const EdgeInsets.all(10.0), + child: GridView.builder( + gridDelegate: SliverGridDelegateWithFixedCrossAxisCount( + crossAxisCount: widget.orientation == Orientation.portrait ? 1 : 2, // TODO HERE IS TABLET + mainAxisExtent: widget.isShowResponse ? + widget.orientation == Orientation.portrait ? + 60 : + 50 : + widget.orientation == Orientation.portrait ? + 60 : + 60, // TODO depends on percentage + mainAxisSpacing: widget.isShowResponse ? + widget.orientation == Orientation.portrait ? + 30 : + 10 : + widget.orientation == Orientation.portrait ? + 32.5 : + 32.5, // TODO depends on percentage + crossAxisSpacing: widget.isShowResponse ? 0 : 0, // TODO depends on percentage + ), + itemCount: i.responsesSubDTO!.length, + itemBuilder: (BuildContext ctx, index) { + return InkWell( + onTap: () { + if(!widget.isShowResponse) { + setState(() { + i.chosen = index; + if(currentIndex == _questionsSubDTO.length && i.chosen == index) + { + widget.onShowResponse(); + //showResult = true; + //_controllerCenter!.play(); // TODO Maybe show only confetti on super score .. + } else { + sliderController!.nextPage(duration: const Duration(milliseconds: 650), curve: Curves.fastOutSlowIn); + } + }); + } + }, + child: Padding( + padding: const EdgeInsets.all(2.5), + child: Container( + alignment: Alignment.center, + child: Text(TranslationHelper.get(i.responsesSubDTO![index].label, appContext.getContext() as VisitAppContext), textAlign: TextAlign.center, style: TextStyle(fontSize: kDescriptionSize, color: i.chosen == index ? Colors.white : Colors.black)), + decoration: BoxDecoration( + color: !widget.isShowResponse ? i.chosen == index ? kTestSecondColor : kBackgroundLight : i.responsesSubDTO![index].isGood! ? kGreen : i.chosen == index ? kTextRed : kBackgroundLight, + shape: BoxShape.rectangle, + borderRadius: BorderRadius.circular(10.0), + boxShadow: const [ + BoxShadow( + color: kBackgroundSecondGrey, + spreadRadius: 0.3, + blurRadius: 4, + offset: Offset(0, 2), // changes position of shadow + ), + ], + ), + ), + ), + ); + }), + ), ), ), ), - ), - ], - ) - ), - ); - }, - ); - }).toList(), - ), - ], + ], + ) + ), + ); + }, + ); + }).toList(), + ), + ], + ), ), if(widget.questionsSubDTO!.isNotEmpty && _questionsSubDTO.length > 1 && currentIndex != _questionsSubDTO.length && _questionsSubDTO[currentIndex-1].chosen != null) Positioned(