|
|
|
|
@ -1,9 +1,11 @@
|
|
|
|
|
import 'package:appinio_swiper/appinio_swiper.dart';
|
|
|
|
|
import 'package:flutter/cupertino.dart';
|
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
import 'package:lottie/lottie.dart';
|
|
|
|
|
import 'package:mohem_flutter_app/app_state/app_state.dart';
|
|
|
|
|
import 'package:mohem_flutter_app/classes/colors.dart';
|
|
|
|
|
import 'package:mohem_flutter_app/classes/decorations_helper.dart';
|
|
|
|
|
import 'package:mohem_flutter_app/classes/lottie_consts.dart';
|
|
|
|
|
import 'package:mohem_flutter_app/extensions/widget_extensions.dart';
|
|
|
|
|
import 'package:mohem_flutter_app/models/marathon/question_model.dart';
|
|
|
|
|
import 'package:mohem_flutter_app/ui/marathon/marathon_provider.dart';
|
|
|
|
|
@ -24,36 +26,35 @@ class QuestionCard extends StatelessWidget {
|
|
|
|
|
@override
|
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
|
return CupertinoPageScaffold(
|
|
|
|
|
child: SizedBox(
|
|
|
|
|
height: 440,
|
|
|
|
|
width: double.infinity,
|
|
|
|
|
child: Consumer<MarathonProvider>(
|
|
|
|
|
builder: (BuildContext context, MarathonProvider provider, _) {
|
|
|
|
|
return AppinioSwiper(
|
|
|
|
|
padding: EdgeInsets.zero,
|
|
|
|
|
isDisabled: true,
|
|
|
|
|
controller: provider.swiperController,
|
|
|
|
|
unswipe: (int index, AppinioSwiperDirection direction) {},
|
|
|
|
|
onSwipe: (int index, AppinioSwiperDirection direction) {
|
|
|
|
|
print("here is the length: ${provider.cardContentList.length} and index : $index");
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
cards: provider.cardContentList,
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
child: provider.cardContentList.isEmpty
|
|
|
|
|
? Lottie.asset(MyLottieConsts.hourGlassLottie, height: 250).paddingOnly(top: 50)
|
|
|
|
|
: SizedBox(
|
|
|
|
|
height: 440,
|
|
|
|
|
width: double.infinity,
|
|
|
|
|
child: Consumer<MarathonProvider>(
|
|
|
|
|
builder: (BuildContext context, MarathonProvider provider, _) {
|
|
|
|
|
return AppinioSwiper(
|
|
|
|
|
duration: const Duration(milliseconds: 400),
|
|
|
|
|
padding: EdgeInsets.zero,
|
|
|
|
|
isDisabled: true,
|
|
|
|
|
controller: provider.swiperController,
|
|
|
|
|
unswipe: (int index, AppinioSwiperDirection direction) {},
|
|
|
|
|
onSwipe: (int index, AppinioSwiperDirection direction) {},
|
|
|
|
|
cards: provider.cardContentList,
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class CardContent extends StatelessWidget {
|
|
|
|
|
final QuestionModel question;
|
|
|
|
|
|
|
|
|
|
const CardContent({Key? key, required this.question}) : super(key: key);
|
|
|
|
|
const CardContent({Key? key}) : super(key: key);
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
|
MarathonProvider provider = context.watch<MarathonProvider>();
|
|
|
|
|
return Container(
|
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
|
borderRadius: BorderRadius.circular(10),
|
|
|
|
|
@ -92,7 +93,7 @@ class CardContent extends StatelessWidget {
|
|
|
|
|
child: Padding(
|
|
|
|
|
padding: const EdgeInsets.symmetric(horizontal: 13),
|
|
|
|
|
child: Text(
|
|
|
|
|
AppState().isArabic(context) ? question.titleAr ?? "" : question.titleEn ?? "",
|
|
|
|
|
AppState().isArabic(context) ? provider.currentQuestion.titleAr ?? "" : provider.currentQuestion.titleEn ?? "",
|
|
|
|
|
style: const TextStyle(
|
|
|
|
|
color: MyColors.white,
|
|
|
|
|
fontSize: 16,
|
|
|
|
|
@ -102,48 +103,21 @@ class CardContent extends StatelessWidget {
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
AnswerContent(question: question),
|
|
|
|
|
const AnswerContent(),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class AnswerContent extends StatefulWidget {
|
|
|
|
|
final QuestionModel question;
|
|
|
|
|
class AnswerContent extends StatelessWidget {
|
|
|
|
|
const AnswerContent({Key? key}) : super(key: key);
|
|
|
|
|
|
|
|
|
|
const AnswerContent({Key? key, required this.question}) : super(key: key);
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
State<AnswerContent> createState() => _AnswerContentState();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class _AnswerContentState extends State<AnswerContent> {
|
|
|
|
|
// void updateOption(int index, bool value) {
|
|
|
|
|
// isSelectedOptions[0] = false;
|
|
|
|
|
// isSelectedOptions[1] = false;
|
|
|
|
|
// isSelectedOptions[2] = false;
|
|
|
|
|
// isSelectedOptions[3] = false;
|
|
|
|
|
// isSelectedOptions[index] = value;
|
|
|
|
|
// setState(() {});
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// Decoration getContainerColor(int index) {
|
|
|
|
|
// if (!isSelectedOptions[index]) {
|
|
|
|
|
// return MyDecorations.getContainersDecoration(MyColors.greyF7Color);
|
|
|
|
|
// }
|
|
|
|
|
// if (isSelectedOptions[index] && context
|
|
|
|
|
// .watch<MarathonProvider>()
|
|
|
|
|
// .currentGapTime > 0) {
|
|
|
|
|
// return MyDecorations.getContainersDecoration(MyColors.yellowColorII);
|
|
|
|
|
// }
|
|
|
|
|
// return MyDecorations.getContainersDecoration(
|
|
|
|
|
// isSelectedOptions[index] ? MyColors.greenColor : MyColors.greyF7Color,
|
|
|
|
|
// );
|
|
|
|
|
// }
|
|
|
|
|
void onAnswerTapped(BuildContext context, QuestionOptions questionOption) {}
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
|
MarathonProvider provider = context.watch<MarathonProvider>();
|
|
|
|
|
return Container(
|
|
|
|
|
padding: const EdgeInsets.all(13),
|
|
|
|
|
decoration: const BoxDecoration(
|
|
|
|
|
@ -153,23 +127,35 @@ class _AnswerContentState extends State<AnswerContent> {
|
|
|
|
|
bottomRight: Radius.circular(10),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
child: widget.question.questionOptions != null
|
|
|
|
|
? Column(
|
|
|
|
|
mainAxisSize: MainAxisSize.min,
|
|
|
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.center,
|
|
|
|
|
children: widget.question.questionOptions!.map((QuestionOptions e) => AnswerTileForText(questionOption: e, onAnswerTapped: () {})).toList(),
|
|
|
|
|
child: provider.currentQuestion.questionOptions != null
|
|
|
|
|
? ListView.builder(
|
|
|
|
|
itemCount: provider.currentQuestion.questionOptions!.length,
|
|
|
|
|
shrinkWrap: true,
|
|
|
|
|
itemBuilder: (BuildContext context, int index) {
|
|
|
|
|
return AnswerTileForText(
|
|
|
|
|
index: index,
|
|
|
|
|
onAnswerTapped: () {
|
|
|
|
|
provider.updateCurrentQuestionOptionStatus(QuestionsOptionStatus.selected, index);
|
|
|
|
|
},
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
)
|
|
|
|
|
// Column(
|
|
|
|
|
// mainAxisSize: MainAxisSize.min,
|
|
|
|
|
// mainAxisAlignment: MainAxisAlignment.center,
|
|
|
|
|
// crossAxisAlignment: CrossAxisAlignment.center,
|
|
|
|
|
// children: question.questionOptions!.map((QuestionOptions e) => AnswerTileForText(questionOption: e, onAnswerTapped: () {})).toList(),
|
|
|
|
|
// )
|
|
|
|
|
: const SizedBox(),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class AnswerTileForText extends StatelessWidget {
|
|
|
|
|
final QuestionOptions questionOption;
|
|
|
|
|
final int index;
|
|
|
|
|
final Function() onAnswerTapped;
|
|
|
|
|
|
|
|
|
|
const AnswerTileForText({Key? key, required this.questionOption, required this.onAnswerTapped}) : super(key: key);
|
|
|
|
|
const AnswerTileForText({Key? key, required this.index, required this.onAnswerTapped}) : super(key: key);
|
|
|
|
|
|
|
|
|
|
// Decoration getContainerColor(int index) {
|
|
|
|
|
// if (!isSelectedOptions[index]) {
|
|
|
|
|
@ -185,18 +171,19 @@ class AnswerTileForText extends StatelessWidget {
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
|
MarathonProvider provider = context.watch<MarathonProvider>();
|
|
|
|
|
return InkWell(
|
|
|
|
|
onTap: () {
|
|
|
|
|
onAnswerTapped();
|
|
|
|
|
},
|
|
|
|
|
child: Container(
|
|
|
|
|
alignment: Alignment.centerLeft,
|
|
|
|
|
decoration: MyDecorations.getContainersDecoration(MyColors.greyF7Color),
|
|
|
|
|
decoration: MyDecorations.getAnswersContainerColor(provider.currentQuestion.questionOptions![index].optionStatus!),
|
|
|
|
|
child: Center(
|
|
|
|
|
child: Text(
|
|
|
|
|
questionOption.titleEn!,
|
|
|
|
|
AppState().isArabic(context) ? provider.currentQuestion.questionOptions![index].titleAr! : provider.currentQuestion.questionOptions![index].titleEn!,
|
|
|
|
|
style: TextStyle(
|
|
|
|
|
color: isSelectedOptions[0] ? MyColors.white : MyColors.darkTextColor,
|
|
|
|
|
color: provider.currentQuestion.questionOptions![index].optionStatus == QuestionsOptionStatus.unSelected ? MyColors.darkTextColor : MyColors.white,
|
|
|
|
|
fontWeight: FontWeight.w600,
|
|
|
|
|
fontSize: 16,
|
|
|
|
|
),
|
|
|
|
|
|