|
|
|
@ -6,6 +6,7 @@ import 'package:flutter_svg/svg.dart';
|
|
|
|
import 'package:lottie/lottie.dart';
|
|
|
|
import 'package:lottie/lottie.dart';
|
|
|
|
import 'package:mohem_flutter_app/app_state/app_state.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/colors.dart';
|
|
|
|
|
|
|
|
import 'package:mohem_flutter_app/classes/consts.dart';
|
|
|
|
import 'package:mohem_flutter_app/classes/decorations_helper.dart';
|
|
|
|
import 'package:mohem_flutter_app/classes/decorations_helper.dart';
|
|
|
|
import 'package:mohem_flutter_app/classes/lottie_consts.dart';
|
|
|
|
import 'package:mohem_flutter_app/classes/lottie_consts.dart';
|
|
|
|
import 'package:mohem_flutter_app/config/routes.dart';
|
|
|
|
import 'package:mohem_flutter_app/config/routes.dart';
|
|
|
|
@ -21,6 +22,7 @@ import 'package:mohem_flutter_app/ui/marathon/widgets/marathon_qualifiers_contai
|
|
|
|
import 'package:mohem_flutter_app/ui/marathon/widgets/question_card.dart';
|
|
|
|
import 'package:mohem_flutter_app/ui/marathon/widgets/question_card.dart';
|
|
|
|
import 'package:mohem_flutter_app/ui/marathon/widgets/question_card_builder.dart';
|
|
|
|
import 'package:mohem_flutter_app/ui/marathon/widgets/question_card_builder.dart';
|
|
|
|
import 'package:mohem_flutter_app/widgets/app_bar_widget.dart';
|
|
|
|
import 'package:mohem_flutter_app/widgets/app_bar_widget.dart';
|
|
|
|
|
|
|
|
import 'package:mohem_flutter_app/widgets/button/default_button.dart';
|
|
|
|
import 'package:mohem_flutter_app/widgets/dialogs/confirm_dialog.dart';
|
|
|
|
import 'package:mohem_flutter_app/widgets/dialogs/confirm_dialog.dart';
|
|
|
|
import 'package:provider/provider.dart';
|
|
|
|
import 'package:provider/provider.dart';
|
|
|
|
|
|
|
|
|
|
|
|
@ -43,24 +45,13 @@ class MarathonScreen extends StatelessWidget {
|
|
|
|
return Image.asset(MyLottieConsts.congratsGif, height: 200);
|
|
|
|
return Image.asset(MyLottieConsts.congratsGif, height: 200);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// SizedBox(
|
|
|
|
|
|
|
|
// height: 200,
|
|
|
|
|
|
|
|
// child: Stack(
|
|
|
|
|
|
|
|
// fit: StackFit.expand,
|
|
|
|
|
|
|
|
// children: <Widget>[
|
|
|
|
|
|
|
|
// Lottie.asset(MyLottieConsts.celebrate1Lottie, height: 200),
|
|
|
|
|
|
|
|
// // Lottie.asset(MyLottieConsts.celebrate2Lottie, height: 200),
|
|
|
|
|
|
|
|
// ],
|
|
|
|
|
|
|
|
// ),
|
|
|
|
|
|
|
|
// ),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Widget getWinnerWidget(BuildContext context, {required MarathonProvider provider}) {
|
|
|
|
Widget getWinnerWidget(BuildContext context, {required MarathonProvider provider}) {
|
|
|
|
return Container(
|
|
|
|
return Container(
|
|
|
|
width: double.infinity,
|
|
|
|
width: double.infinity,
|
|
|
|
decoration: MyDecorations.shadowDecoration,
|
|
|
|
decoration: MyDecorations.shadowDecoration,
|
|
|
|
padding: const EdgeInsets.symmetric(vertical: 20, horizontal: 20),
|
|
|
|
padding: const EdgeInsets.symmetric(vertical: 20, horizontal: 20),
|
|
|
|
child: Stack(
|
|
|
|
child: Stack(
|
|
|
|
children: [
|
|
|
|
children: <Widget>[
|
|
|
|
Column(
|
|
|
|
Column(
|
|
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
|
|
children: <Widget>[
|
|
|
|
children: <Widget>[
|
|
|
|
@ -80,7 +71,7 @@ class MarathonScreen extends StatelessWidget {
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
16.height,
|
|
|
|
16.height,
|
|
|
|
!provider.iAmWinner
|
|
|
|
provider.iAmWinner
|
|
|
|
? Column(
|
|
|
|
? Column(
|
|
|
|
children: <Widget>[
|
|
|
|
children: <Widget>[
|
|
|
|
(AppState().isArabic(context) ? AppState().memberInformationList!.eMPLOYEEDISPLAYNAMEAr : AppState().memberInformationList!.eMPLOYEEDISPLAYNAMEEn)!.toText22(
|
|
|
|
(AppState().isArabic(context) ? AppState().memberInformationList!.eMPLOYEEDISPLAYNAMEAr : AppState().memberInformationList!.eMPLOYEEDISPLAYNAMEEn)!.toText22(
|
|
|
|
@ -103,7 +94,7 @@ class MarathonScreen extends StatelessWidget {
|
|
|
|
itemBuilder: (BuildContext context, int index) {
|
|
|
|
itemBuilder: (BuildContext context, int index) {
|
|
|
|
return Column(
|
|
|
|
return Column(
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
children: [
|
|
|
|
children: <Widget>[
|
|
|
|
(AppState().isArabic(context) ? provider.selectedWinners![index].nameEn : provider.selectedWinners![index].nameEn)!.toText16(
|
|
|
|
(AppState().isArabic(context) ? provider.selectedWinners![index].nameEn : provider.selectedWinners![index].nameEn)!.toText16(
|
|
|
|
color: MyColors.grey3AColor,
|
|
|
|
color: MyColors.grey3AColor,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
@ -127,10 +118,10 @@ class MarathonScreen extends StatelessWidget {
|
|
|
|
),
|
|
|
|
),
|
|
|
|
5.height,
|
|
|
|
5.height,
|
|
|
|
Image.network(
|
|
|
|
Image.network(
|
|
|
|
provider.marathonDetailModel.sponsors!.first.image!,
|
|
|
|
ApiConsts.marathonBaseUrlServices + provider.marathonDetailModel.sponsors!.first.image!,
|
|
|
|
height: 40,
|
|
|
|
height: 50,
|
|
|
|
width: 150,
|
|
|
|
width: 150,
|
|
|
|
fit: BoxFit.fill,
|
|
|
|
fit: BoxFit.contain,
|
|
|
|
errorBuilder: (BuildContext context, Object exception, StackTrace? stackTrace) {
|
|
|
|
errorBuilder: (BuildContext context, Object exception, StackTrace? stackTrace) {
|
|
|
|
return const Center();
|
|
|
|
return const Center();
|
|
|
|
},
|
|
|
|
},
|
|
|
|
@ -207,57 +198,74 @@ class MarathonScreen extends StatelessWidget {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
|
|
|
),
|
|
|
|
),
|
|
|
|
body: SingleChildScrollView(
|
|
|
|
body: Column(
|
|
|
|
child: Column(
|
|
|
|
children: <Widget>[
|
|
|
|
children: <Widget>[
|
|
|
|
ListView(
|
|
|
|
20.height,
|
|
|
|
children: [
|
|
|
|
if (provider.questionCardStatus == QuestionCardStatus.findingWinner) ...<Widget>[
|
|
|
|
20.height,
|
|
|
|
QualifiersContainer(provider: provider).paddingOnly(left: 21, right: 21),
|
|
|
|
if (provider.questionCardStatus == QuestionCardStatus.findingWinner) ...<Widget>[
|
|
|
|
] else if (provider.questionCardStatus == QuestionCardStatus.winnerFound)
|
|
|
|
QualifiersContainer(provider: provider).paddingOnly(left: 21, right: 21),
|
|
|
|
...<Widget>[]
|
|
|
|
] else if (provider.questionCardStatus == QuestionCardStatus.winnerFound)
|
|
|
|
else ...<Widget>[
|
|
|
|
...<Widget>[]
|
|
|
|
MarathonProgressContainer(provider: provider).paddingOnly(left: 21, right: 21),
|
|
|
|
else ...<Widget>[
|
|
|
|
],
|
|
|
|
MarathonProgressContainer(provider: provider).paddingOnly(left: 21, right: 21),
|
|
|
|
if (provider.questionCardStatus == QuestionCardStatus.findingWinner) ...<Widget>[
|
|
|
|
],
|
|
|
|
getNameContainer(context),
|
|
|
|
if (provider.questionCardStatus == QuestionCardStatus.findingWinner) ...<Widget>[
|
|
|
|
|
|
|
|
getNameContainer(context),
|
|
|
|
|
|
|
|
],
|
|
|
|
|
|
|
|
QuestionCardBuilder(
|
|
|
|
|
|
|
|
onQuestion: (BuildContext context) => const QuestionCard(),
|
|
|
|
|
|
|
|
onCompleted: (BuildContext context) => CustomStatusWidget(
|
|
|
|
|
|
|
|
asset: Lottie.asset(MyLottieConsts.allQuestions, height: 200),
|
|
|
|
|
|
|
|
title: LocaleKeys.congrats.tr().toText22(color: MyColors.greenColor),
|
|
|
|
|
|
|
|
subTitle: LocaleKeys.allQuestionsCorrect.toText18(color: MyColors.darkTextColor, isCentered: true),
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
onCorrectAnswer: (BuildContext context) => CustomStatusWidget(
|
|
|
|
|
|
|
|
asset: getSuccessWidget(gapType: provider.gapTimeType, gapImage: provider.gapTimeImage, gapText: provider.gapTimeText),
|
|
|
|
|
|
|
|
title: LocaleKeys.congrats.tr().toText22(color: MyColors.greenColor),
|
|
|
|
|
|
|
|
subTitle: LocaleKeys.yourAnswerCorrect.tr().toText18(color: MyColors.darkTextColor, isCentered: true),
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
onWinner: (BuildContext context) => getWinnerWidget(context, provider: provider),
|
|
|
|
|
|
|
|
onWrongAnswer: (BuildContext context) => CustomStatusWidget(
|
|
|
|
|
|
|
|
asset: Image.asset(MyLottieConsts.wrongAnswerGif, height: 200),
|
|
|
|
|
|
|
|
title: LocaleKeys.oops.tr().toText22(color: MyColors.redColor),
|
|
|
|
|
|
|
|
subTitle: LocaleKeys.wrongAnswer.tr().toText18(color: MyColors.darkTextColor, isCentered: true),
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
onSkippedAnswer: (BuildContext context) => CustomStatusWidget(
|
|
|
|
|
|
|
|
asset: Image.asset(MyLottieConsts.wrongAnswerGif, height: 200),
|
|
|
|
|
|
|
|
title: LocaleKeys.oops.tr().toText22(color: MyColors.redColor),
|
|
|
|
|
|
|
|
subTitle: LocaleKeys.youMissedTheQuestion.tr().toText18(color: MyColors.darkTextColor, isCentered: true),
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
onFindingWinner: (BuildContext context) => CustomStatusWidget(
|
|
|
|
|
|
|
|
asset: Lottie.asset(MyLottieConsts.winnerLottie, height: 168),
|
|
|
|
|
|
|
|
title: LocaleKeys.fingersCrossed.tr().toText22(color: MyColors.greenColor),
|
|
|
|
|
|
|
|
subTitle: LocaleKeys.winnerSelectedRandomly.tr().toText18(color: MyColors.darkTextColor, isCentered: true),
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
questionCardStatus: provider.questionCardStatus,
|
|
|
|
|
|
|
|
).paddingOnly(top: 12, left: 21, right: 21),
|
|
|
|
],
|
|
|
|
],
|
|
|
|
QuestionCardBuilder(
|
|
|
|
).expanded,
|
|
|
|
onQuestion: (BuildContext context) => const QuestionCard(),
|
|
|
|
provider.questionCardStatus == QuestionCardStatus.winnerFound
|
|
|
|
onCompleted: (BuildContext context) => CustomStatusWidget(
|
|
|
|
? DefaultButton(LocaleKeys.ok.tr(), () {
|
|
|
|
asset: Lottie.asset(MyLottieConsts.allQuestions, height: 200),
|
|
|
|
provider.resetValues();
|
|
|
|
title: LocaleKeys.congrats.tr().toText22(color: MyColors.greenColor),
|
|
|
|
Navigator.of(context).popUntil(ModalRoute.withName(AppRoutes.dashboard));
|
|
|
|
subTitle: LocaleKeys.allQuestionsCorrect.toText18(color: MyColors.darkTextColor, isCentered: true),
|
|
|
|
}).insideContainer
|
|
|
|
),
|
|
|
|
: const SizedBox()
|
|
|
|
onCorrectAnswer: (BuildContext context) => CustomStatusWidget(
|
|
|
|
],
|
|
|
|
asset: getSuccessWidget(gapType: provider.currentQuestion.gapType, gapImage: provider.currentQuestion.gapImage, gapText: provider.currentQuestion.gapText),
|
|
|
|
|
|
|
|
title: LocaleKeys.congrats.tr().toText22(color: MyColors.greenColor),
|
|
|
|
|
|
|
|
subTitle: LocaleKeys.yourAnswerCorrect.toText18(color: MyColors.darkTextColor, isCentered: true),
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
onWinner: (BuildContext context) => getWinnerWidget(context, provider: provider),
|
|
|
|
|
|
|
|
onWrongAnswer: (BuildContext context) => CustomStatusWidget(
|
|
|
|
|
|
|
|
asset: Image.asset(MyLottieConsts.wrongAnswerGif, height: 200),
|
|
|
|
|
|
|
|
title: LocaleKeys.oops.tr().toText22(color: MyColors.redColor),
|
|
|
|
|
|
|
|
subTitle: LocaleKeys.wrongAnswer.tr().toText18(color: MyColors.darkTextColor, isCentered: true),
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
onSkippedAnswer: (BuildContext context) => CustomStatusWidget(
|
|
|
|
|
|
|
|
asset: Image.asset(MyLottieConsts.wrongAnswerGif, height: 200),
|
|
|
|
|
|
|
|
title: LocaleKeys.oops.tr().toText22(color: MyColors.redColor),
|
|
|
|
|
|
|
|
subTitle: LocaleKeys.youMissedTheQuestion.tr().toText18(color: MyColors.darkTextColor, isCentered: true),
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
onFindingWinner: (BuildContext context) => CustomStatusWidget(
|
|
|
|
|
|
|
|
asset: Lottie.asset(MyLottieConsts.winnerLottie, height: 168),
|
|
|
|
|
|
|
|
title: LocaleKeys.fingersCrossed.tr().toText22(color: MyColors.greenColor),
|
|
|
|
|
|
|
|
subTitle: LocaleKeys.winnerSelectedRandomly.tr().toText18(color: MyColors.darkTextColor, isCentered: true),
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
questionCardStatus: provider.questionCardStatus,
|
|
|
|
|
|
|
|
).paddingOnly(top: 12, left: 21, right: 21),
|
|
|
|
|
|
|
|
],
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
onWillPop: () {
|
|
|
|
onWillPop: () {
|
|
|
|
provider.resetValues();
|
|
|
|
showDialog(
|
|
|
|
return Future<bool>.value(true);
|
|
|
|
context: context,
|
|
|
|
|
|
|
|
builder: (BuildContext context) => ConfirmDialog(
|
|
|
|
|
|
|
|
message: LocaleKeys.youWantToLeaveMarathon.tr(),
|
|
|
|
|
|
|
|
onTap: () {
|
|
|
|
|
|
|
|
provider.resetValues();
|
|
|
|
|
|
|
|
Navigator.of(context).popUntil(ModalRoute.withName(AppRoutes.dashboard));
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
return Future<bool>.value(false);
|
|
|
|
},
|
|
|
|
},
|
|
|
|
);
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|