Committing after API replacement from SignalR => InProgress

merge-requests/89/head
Faiz Hashmi 3 years ago
parent 3e1b24eb00
commit 603ff1b19f

@ -508,5 +508,6 @@
"winner": "الفائز",
"youWantToLeaveMarathon": "هل أنت متأكد أنك تريد العودة؟ سوف تخرج من المسابقة.",
"ourSponsor": "راعينا:",
"startingIn": "يبدأ في"
"startingIn": "يبدأ في",
"youAreOutOfContest": "أنت خارج المسابقة."
}

@ -508,6 +508,7 @@
"winner": "WINNER",
"youWantToLeaveMarathon": "Are you sure you want to go back? You will be out of the contest.",
"ourSponsor": "Our Sponsor:",
"startingIn": "Starting in"
"startingIn": "Starting in",
"youAreOutOfContest": "You are out of the contest."
}

@ -65,9 +65,14 @@ class MarathonApiClient {
Response response = await ApiClient().getJsonForResponse(ApiConsts.marathonUpcomingUrl + payrollString, token: AppState().getMarathonToken ?? await getMarathonToken());
var json = jsonDecode(response.body);
logger.i("json in getMarathonDetails: $json");
MarathonGenericModel marathonGenericModel = MarathonGenericModel.fromJson(json);
if (marathonGenericModel.data == null) {
return MarathonDetailModel();
}
MarathonDetailModel marathonDetailModel = MarathonDetailModel.fromJson(marathonGenericModel.data);
AppState().setMarathonProjectId = marathonDetailModel.id!;
@ -85,11 +90,17 @@ class MarathonApiClient {
Response response = await ApiClient().postJsonForResponse(ApiConsts.marathonJoinParticipantUrl, jsonObject, token: AppState().getMarathonToken ?? await getMarathonToken());
var json = jsonDecode(response.body);
MarathonGenericModel marathonModel = MarathonGenericModel.fromJson(json);
if (marathonModel.statusCode == 208) {
// means participant is already in the marathon i.e already joined
return true;
}
if (marathonModel.statusCode == 200) {
if (marathonModel.data != null && marathonModel.isSuccessful == true) {
logger.i("message: ${marathonModel.data}");
logger.i("joinMarathonAsParticipant: ${marathonModel.data}");
return true;
} else {
return false;
@ -99,9 +110,8 @@ class MarathonApiClient {
}
}
Future<QuestionModel?> getNextQuestion({required String? selectedOptionId, required String? questionId, required String marathonId}) async {
Future<QuestionModel?> getNextQuestion({required String? questionId, required String marathonId}) async {
Map<String, String?> jsonObject = <String, String?>{
"selectedOptionId": selectedOptionId,
"questionId": questionId,
"marathonId": marathonId,
};
@ -109,20 +119,34 @@ class MarathonApiClient {
Response response = await ApiClient().postJsonForResponse(ApiConsts.marathonNextQuestionUrl, jsonObject, token: AppState().getMarathonToken ?? await getMarathonToken());
var json = jsonDecode(response.body);
MarathonGenericModel marathonModel = MarathonGenericModel.fromJson(json);
if (marathonModel.statusCode == 200) {
if (marathonModel.data != null && marathonModel.isSuccessful == true) {
logger.i("message: ${marathonModel.data}");
return null;
} else {
return null;
}
var data = json["data"];
if (data != null) {
QuestionModel newQuestion = QuestionModel.fromJson(data);
return newQuestion;
} else {
return null;
}
}
Future<bool> submitSelectedOption({required String? selectedAnswerId}) async {
Map<String, String?> jsonObject = <String, String?>{"selectedOptionId": selectedAnswerId};
Response response = await ApiClient().postJsonForResponse(ApiConsts.marathonSubmitAnswerUrl, jsonObject, token: AppState().getMarathonToken ?? await getMarathonToken());
var json = jsonDecode(response.body);
logger.i("json: $json");
MarathonGenericModel marathonModel = MarathonGenericModel.fromJson(json);
if (marathonModel.isSuccessful == null) {
return false;
}
return marathonModel.isSuccessful!;
}
// Future<void> buildHubConnection(BuildContext context, String prizeId) async {
// HttpConnectionOptions httpOptions = HttpConnectionOptions(skipNegotiation: false, logMessageContent: true);
// hubConnection = HubConnectionBuilder()

@ -28,15 +28,15 @@ class ApiConsts {
static String chatUserImages = chatServerBaseUrl + "empservice/api/employee/";
//Brain Marathon Constants
static String marathonBaseUrl = "https://18.188.181.12/service/api/";
static String marathonHubConnectionUrl = "https://18.188.181.12/service/MarathonBroadCast";
static String marathonBaseUrl = "https://marathoon.com/service/api/";
// static String marathonHubConnectionUrl = "https://18.188.181.12/service/MarathonBroadCast";
static String marathonParticipantLoginUrl = marathonBaseUrl + "auth/participantlogin";
static String marathonProjectGetUrl = marathonBaseUrl + "Project/Project_Get";
static String marathonUpcomingUrl = marathonBaseUrl + "marathon/upcoming/";
static String marathonJoinParticipantUrl = marathonBaseUrl + "participant/participant_join";
static String marathonNextQuestionUrl = marathonBaseUrl + "question/next";
static String marathonSubmitAnswerUrl = marathonBaseUrl + "question/submit";
static String marathonSubmitAnswerUrl = marathonBaseUrl + "question/submitquestion";
static String marathonQualifiersUrl = marathonBaseUrl + "winner/getWinner/";
static String marathonSelectedWinner = marathonBaseUrl + "winner/getSelectedWinner/";

@ -495,5 +495,6 @@ abstract class LocaleKeys {
static const youWantToLeaveMarathon = 'youWantToLeaveMarathon';
static const ourSponsor = 'ourSponsor';
static const startingIn = 'startingIn';
static const youAreOutOfContest = 'youAreOutOfContest';
}

@ -14,6 +14,7 @@ class QuestionModel {
String? gapText;
String? gapImage;
int? questOptionsLimit;
int? remainingParticipantCount;
List<QuestionOptions>? questionOptions;
QuestionModel({
@ -28,6 +29,7 @@ class QuestionModel {
String? gapText,
String? gapImage,
int? questOptionsLimit,
int? remainingParticipantCount,
List<QuestionOptions>? questionOptions,
});
@ -43,6 +45,7 @@ class QuestionModel {
gapText = json['gapText'];
gapImage = json['gapImage'];
questOptionsLimit = json['questOptionsLimit'];
remainingParticipantCount = json['remainingParticipantCount'];
if (json['questionOptions'] != null) {
questionOptions = <QuestionOptions>[];
json['questionOptions'].forEach((v) {
@ -64,6 +67,7 @@ class QuestionModel {
data['gapText'] = gapText;
data['gapImage'] = gapImage;
data['questOptionsLimit'] = questOptionsLimit;
data['remainingParticipantCount'] = remainingParticipantCount;
if (questionOptions != null) {
data['questionOptions'] = questionOptions!.map((v) => v.toJson()).toList();
}

@ -1,15 +1,12 @@
import 'dart:async';
import 'dart:convert';
import 'dart:io';
import 'package:easy_localization/easy_localization.dart';
import 'package:flutter/material.dart';
import 'package:flutter_countdown_timer/flutter_countdown_timer.dart';
import 'package:flutter_svg/flutter_svg.dart';
import 'package:mohem_flutter_app/api/dashboard_api_client.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/consts.dart';
import 'package:mohem_flutter_app/classes/utils.dart';
import 'package:mohem_flutter_app/config/routes.dart';
import 'package:mohem_flutter_app/extensions/int_extensions.dart';
@ -18,7 +15,6 @@ import 'package:mohem_flutter_app/extensions/widget_extensions.dart';
import 'package:mohem_flutter_app/generated/locale_keys.g.dart';
import 'package:mohem_flutter_app/models/offers_and_discounts/get_offers_list.dart';
import 'package:mohem_flutter_app/provider/dashboard_provider_model.dart';
import 'package:mohem_flutter_app/ui/landing/itg/its_add_screen_video_image.dart';
import 'package:mohem_flutter_app/ui/landing/widget/app_drawer.dart';
import 'package:mohem_flutter_app/ui/landing/widget/menus_widget.dart';
import 'package:mohem_flutter_app/ui/landing/widget/services_widget.dart';
@ -321,9 +317,11 @@ class _DashboardScreenState extends State<DashboardScreen> {
),
],
).paddingOnly(left: 21, right: 21, top: 7),
context.watch<MarathonProvider>().isLoading ? MarathonBannerShimmer().paddingAll(20) : MarathonBanner().paddingAll(20),
context.watch<MarathonProvider>().isLoading
? const MarathonBannerShimmer().paddingAll(20)
: MarathonBanner(isMarathonUpcoming: context.watch<MarathonProvider>().isUpComingMarathon).paddingAll(20),
ServicesWidget(),
// 8.height,
8.height,
Container(
width: double.infinity,
padding: const EdgeInsets.only(top: 31),

@ -13,7 +13,7 @@ import 'package:mohem_flutter_app/ui/marathon/widgets/question_card.dart';
import 'package:video_player/video_player.dart';
class MarathonProvider extends ChangeNotifier {
// VARIABLES
//****************VARIABLES**********
final AppinioSwiperController swiperController = AppinioSwiperController();
@ -24,9 +24,7 @@ class MarathonProvider extends ChangeNotifier {
QuestionCardStatus questionCardStatus = QuestionCardStatus.question;
int? selectedOptionIndex;
int currentQuestionTime = 0;
int totalSecondsToWaitForWinner = 30;
int totalSecondsToWaitForMarathon = 20;
String? selectedOptionId;
int totalQualifiers = 0;
bool _isLoading = false;
@ -38,6 +36,15 @@ class MarathonProvider extends ChangeNotifier {
notifyListeners();
}
bool _isUpComingMarathon = true;
bool get isUpComingMarathon => _isUpComingMarathon;
set isUpComingMarathon(bool value) {
_isUpComingMarathon = value;
notifyListeners();
}
bool _itsMarathonTime = false;
bool get itsMarathonTime => _itsMarathonTime;
@ -72,7 +79,7 @@ class MarathonProvider extends ChangeNotifier {
notifyListeners();
}
int _totalMarathoners = 23;
int _totalMarathoners = 0;
int get totalMarathoners => _totalMarathoners;
@ -81,7 +88,7 @@ class MarathonProvider extends ChangeNotifier {
notifyListeners();
}
//VIDEO PLAYER
//****************SPONSOR VIDEO PLAYER**********
late VideoPlayerController videoController;
@ -101,6 +108,8 @@ class MarathonProvider extends ChangeNotifier {
notifyListeners();
}
//****************TIMERS**********
int totalSponsorVideoSeconds = 0;
Timer timerForSponsorVideo = Timer.periodic(const Duration(seconds: 1), (Timer timer) {});
@ -122,8 +131,7 @@ class MarathonProvider extends ChangeNotifier {
);
}
// FUNCTIONS
int totalSecondsToWaitForMarathon = 20;
Timer timerToWaitForMarathon = Timer.periodic(const Duration(seconds: 1), (Timer timer) {});
void startTimerToMarathon(BuildContext context) {
@ -140,42 +148,123 @@ class MarathonProvider extends ChangeNotifier {
);
}
void populateQuestionStatusesList() {
if (marathonDetailModel.totalQuestions != null) {
for (int i = 0; i < marathonDetailModel.totalQuestions! - 1; i++) {
answerStatusesList.add(QuestionCardStatus.question);
}
notifyListeners();
}
int totalCurrentQuestionTime = 0;
int currentGapTime = 0;
Timer timerForQuestion = Timer.periodic(const Duration(seconds: 1), (Timer timer) {});
void startTimerForQuestion() {
const Duration oneSec = Duration(seconds: 1);
timerForQuestion = Timer.periodic(
oneSec,
(Timer timer) async {
// This 2 is just to show the color of answer tile for 2 seconds and then update card status
if (totalCurrentQuestionTime - currentGapTime == currentQuestion.questionTime! - 2) {
getCorrectAnswerAndUpdateAnswerColor();
}
if (totalCurrentQuestionTime == currentGapTime) {
updateCardStatusToAnswer();
await callSubmitOptionApi().then((bool value) async {
if (value) {
await callNextQuestionApi();
}
});
}
if (totalCurrentQuestionTime == 0) {
updateCardData();
if (currentQuestionNumber == marathonDetailModel.totalQuestions! - 1) {
updateQuestionCardStatus(QuestionCardStatus.findingWinner);
timer.cancel();
cancelTimer();
notifyListeners();
}
return;
} else {
totalCurrentQuestionTime--;
}
notifyListeners();
},
);
}
void updateAnswerStatusesList(QuestionCardStatus status) {
answerStatusesList[currentQuestionNumber - 1] = status;
notifyListeners();
int totalSecondsToWaitForWinner = 30;
Timer timerForWinnerSelection = Timer.periodic(const Duration(seconds: 1), (Timer timer) {});
void startTimerForWinnerSelection() {
const Duration oneSec = Duration(seconds: 1);
timerForWinnerSelection = Timer.periodic(
oneSec,
(Timer timer) async {
if (totalSecondsToWaitForWinner == 0) {
timer.cancel();
updateQuestionCardStatus(QuestionCardStatus.winnerFound);
return;
} else {
totalSecondsToWaitForWinner--;
}
notifyListeners();
},
);
}
//****************FUNCTIONS*********
Future<bool> callSubmitOptionApi() async {
return await MarathonApiClient().submitSelectedOption(selectedAnswerId: selectedOptionId);
}
void onNewQuestionReceived(QuestionModel newQuestion) {
// TODO: here I need to add a logic where I should call this function for Api but for the 1st question it should behave differently
// TODO: Verify the callings!!!
Future<void> callNextQuestionApi() async {
if (currentQuestionNumber < marathonDetailModel.totalQuestions!) {
if (currentQuestionNumber == 0) {
currentQuestion = (await MarathonApiClient().getNextQuestion(questionId: null, marathonId: marathonDetailModel.id!))!;
if (Utils.isLoading) {
Utils.hideLoading(AppRoutes.navigatorKey.currentContext!);
}
startTimerForQuestion(AppRoutes.navigatorKey.currentContext!);
startTimerForQuestion();
updateCardData();
Navigator.pushReplacementNamed(AppRoutes.navigatorKey.currentContext!, AppRoutes.marathonScreen);
} else {
currentQuestion = (await MarathonApiClient().getNextQuestion(questionId: currentQuestion.id, marathonId: marathonDetailModel.id!))!;
}
if (currentQuestionNumber > 0) {
swipeCardLeft();
notifyListeners();
}
}
void updateCardData() {
if (currentQuestionNumber > 0) {
print("swiped it away!!");
swipeCardLeft();
}
selectedOptionIndex = null;
currentQuestionNumber++;
cardContentList.add(const CardContent());
totalCurrentQuestionTime = currentQuestion.questionTime! + currentQuestion.nextQuestGap!;
currentGapTime = currentQuestion.nextQuestGap!;
totalMarathoners = currentQuestion.remainingParticipantCount!;
questionCardStatus = QuestionCardStatus.question;
}
void populateQuestionStatusesList() {
if (marathonDetailModel.totalQuestions != null) {
for (int i = 0; i < marathonDetailModel.totalQuestions! - 1; i++) {
answerStatusesList.add(QuestionCardStatus.question);
}
selectedOptionIndex = null;
currentQuestionNumber++;
currentQuestion = newQuestion;
cardContentList.add(const CardContent());
currentQuestionTime = newQuestion.questionTime!;
questionCardStatus = QuestionCardStatus.question;
notifyListeners();
}
}
void updateAnswerStatusesList(QuestionCardStatus status) {
answerStatusesList[currentQuestionNumber - 1] = status;
notifyListeners();
}
void addItemToList(CardContent value) {
cardContentList.add(value);
notifyListeners();
@ -227,57 +316,6 @@ class MarathonProvider extends ChangeNotifier {
}
}
Timer timerForQuestion = Timer.periodic(const Duration(seconds: 1), (Timer timer) {});
void startTimerForQuestion(BuildContext context) {
const Duration oneSec = Duration(seconds: 1);
timerForQuestion = Timer.periodic(
oneSec,
(Timer timer) async {
if (currentQuestionTime == 2) {
getCorrectAnswerAndUpdateAnswerColor();
}
if (currentQuestionTime == 0) {
// we can enable this check if we do not want to show the user QuestionGapImages
// if (!isUserOutOfGame) {
updateCardStatusToAnswer();
// }
//todo: we will need to remove this -2 when API is all set
if (currentQuestionNumber == marathonDetailModel.totalQuestions! - 1) {
updateQuestionCardStatus(QuestionCardStatus.findingWinner);
timer.cancel();
cancelTimer();
notifyListeners();
return;
}
} else {
currentQuestionTime--;
}
notifyListeners();
},
);
}
Timer timerForWinnerSelection = Timer.periodic(const Duration(seconds: 1), (Timer timer) {});
void startTimerForWinnerSelection() {
const Duration oneSec = Duration(seconds: 1);
timerForWinnerSelection = Timer.periodic(
oneSec,
(Timer timer) async {
if (totalSecondsToWaitForWinner == 0) {
timer.cancel();
updateQuestionCardStatus(QuestionCardStatus.winnerFound);
return;
} else {
totalSecondsToWaitForWinner--;
}
notifyListeners();
},
);
}
void swipeCardLeft() {
swiperController.swipeLeft();
notifyListeners();
@ -289,7 +327,7 @@ class MarathonProvider extends ChangeNotifier {
timerForWinnerSelection.cancel();
timerForQuestion.cancel();
_isMarathonCompleted = false;
currentQuestionTime = 0;
totalCurrentQuestionTime = 0;
currentQuestion = QuestionModel();
notifyListeners();
@ -305,6 +343,11 @@ class MarathonProvider extends ChangeNotifier {
notifyListeners();
await MarathonApiClient().getMarathonToken().whenComplete(() async {
marathonDetailModel = await MarathonApiClient().getMarathonDetails();
if (marathonDetailModel.id == null) {
isUpComingMarathon = false;
notifyListeners();
return;
}
populateQuestionStatusesList();
isLoading = false;
notifyListeners();
@ -334,7 +377,17 @@ class MarathonProvider extends ChangeNotifier {
Navigator.pushNamed(context, AppRoutes.marathonSponsorVideoScreen);
});
} else {
Navigator.pushReplacementNamed(context, AppRoutes.marathonWaitingScreen);
try {
Utils.showLoading(context);
bool isJoined = await MarathonApiClient().joinMarathonAsParticipant();
if (isJoined) {
print("joined");
callNextQuestionApi();
}
} catch (e, s) {
Utils.hideLoading(context);
Utils.confirmDialog(context, e.toString());
}
}
}
}

@ -83,8 +83,8 @@ class MarathonScreen extends StatelessWidget {
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
LocaleKeys.sponsoredBy.tr().toText14(color: MyColors.grey77Color),
(AppState().isArabic(context) ? provider.marathonDetailModel.sponsors!.first.nameEn ?? "" : provider.marathonDetailModel.sponsors!.first.nameAr ?? "").toText14(
"${LocaleKeys.sponsoredBy.tr()} ".toText14(color: MyColors.grey77Color),
(AppState().isArabic(context) ? provider.marathonDetailModel.sponsors!.first.nameAr ?? "" : provider.marathonDetailModel.sponsors!.first.nameEn ?? "").toText14(
color: MyColors.darkTextColor,
isBold: true,
),
@ -103,7 +103,7 @@ class MarathonScreen extends StatelessWidget {
],
],
),
).paddingOnly(left: 21, right: 21);
);
}
Widget getNameContainer(BuildContext context) {
@ -129,14 +129,18 @@ class MarathonScreen extends StatelessWidget {
@override
Widget build(BuildContext context) {
MarathonProvider provider = context.watch<MarathonProvider>();
return WillPopScope(
child: Scaffold(
appBar: AppBarWidget(context, title: LocaleKeys.brainMarathon.tr(), onHomeTapped: () {
Utils.confirmDialog(context, LocaleKeys.youWantToLeaveMarathon.tr());
}, onBackTapped: () {
Utils.confirmDialog(context, LocaleKeys.youWantToLeaveMarathon.tr());
}),
appBar: AppBarWidget(
context,
title: LocaleKeys.brainMarathon.tr(),
onHomeTapped: () {
Utils.confirmDialog(context, LocaleKeys.youWantToLeaveMarathon.tr());
},
onBackTapped: () {
Utils.confirmDialog(context, LocaleKeys.youWantToLeaveMarathon.tr());
},
),
body: SingleChildScrollView(
child: Column(
children: <Widget>[
@ -151,40 +155,36 @@ class MarathonScreen extends StatelessWidget {
if (provider.questionCardStatus == QuestionCardStatus.findingWinner) ...<Widget>[
getNameContainer(context),
],
if (provider.questionCardStatus == QuestionCardStatus.winnerFound) ...<Widget>[
getWinnerWidget(context, provider: provider),
] else ...<Widget>[
QuestionCardBuilder(
onQuestion: (BuildContext context) => QuestionCard(provider: provider),
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.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) => QuestionCard(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(
onQuestion: (BuildContext context) => QuestionCard(provider: provider),
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.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),
],
),
),

@ -47,8 +47,8 @@ class MarathonWaitingScreen extends StatelessWidget {
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
LocaleKeys.startingIn.tr().toText16(),
"00:${provider.currentQuestionTime < 10 ? "0${provider.currentQuestionTime}" : provider.currentQuestionTime}"
.toText18(color: provider.currentQuestionTime < 5 ? MyColors.redColor : MyColors.black),
"00:${provider.totalSecondsToWaitForMarathon < 10 ? "0${provider.totalSecondsToWaitForMarathon}" : provider.totalSecondsToWaitForMarathon}"
.toText18(color: provider.totalSecondsToWaitForMarathon < 5 ? MyColors.redColor : MyColors.black),
],
),
),

@ -16,7 +16,9 @@ import 'package:mohem_flutter_app/ui/marathon/widgets/countdown_timer.dart';
import 'package:provider/provider.dart';
class MarathonBanner extends StatelessWidget {
const MarathonBanner({Key? key}) : super(key: key);
final bool isMarathonUpcoming;
const MarathonBanner({Key? key, required this.isMarathonUpcoming}) : super(key: key);
@override
Widget build(BuildContext context) {
@ -76,7 +78,7 @@ class MarathonBanner extends StatelessWidget {
height: double.infinity,
),
),
Expanded(
Expanded(
flex: AppState().isArabic(context) ? 4 : 5,
child: SizedBox(
width: double.infinity,

@ -32,8 +32,10 @@ class MarathonProgressContainer extends StatelessWidget {
child: "${provider.currentQuestionNumber.toString()} / ${provider.marathonDetailModel.totalQuestions.toString()} ${LocaleKeys.question.tr()}".toText12(color: MyColors.white),
),
"${provider.totalMarathoners} ${LocaleKeys.marathoners.tr()}".toText14(),
"00:${provider.currentQuestionTime < 10 ? "0${provider.currentQuestionTime}" : provider.currentQuestionTime}"
.toText18(color: provider.currentQuestionTime < 5 ? MyColors.redColor : MyColors.black),
provider.questionCardStatus == QuestionCardStatus.question
? "00:${(provider.totalCurrentQuestionTime - provider.currentGapTime) < 10 ? "0${provider.totalCurrentQuestionTime - provider.currentGapTime}" : provider.totalCurrentQuestionTime - provider.currentGapTime}"
.toText18(color: provider.totalCurrentQuestionTime - provider.currentGapTime < 5 ? MyColors.redColor : MyColors.black)
: const SizedBox(),
],
),
12.height,

Loading…
Cancel
Save