|
|
|
@ -190,6 +190,7 @@ class MarathonProvider extends ChangeNotifier {
|
|
|
|
|
oneSec,
|
|
|
|
|
(Timer timer) async {
|
|
|
|
|
if (totalSecondsToWaitForMarathon == 0) {
|
|
|
|
|
timer.cancel();
|
|
|
|
|
if (isUserWaiting) {
|
|
|
|
|
MarathonApiClient().joinMarathonAsParticipant().whenComplete(() async {
|
|
|
|
|
await callNextQuestionApi();
|
|
|
|
@ -197,7 +198,6 @@ class MarathonProvider extends ChangeNotifier {
|
|
|
|
|
} else {
|
|
|
|
|
isButtonEnabled = false;
|
|
|
|
|
}
|
|
|
|
|
timer.cancel();
|
|
|
|
|
return;
|
|
|
|
|
} else {
|
|
|
|
|
totalSecondsToWaitForMarathon--;
|
|
|
|
@ -210,20 +210,24 @@ class MarathonProvider extends ChangeNotifier {
|
|
|
|
|
int totalCurrentQuestionTime = 0;
|
|
|
|
|
int currentGapTime = 0;
|
|
|
|
|
Timer timerForQuestion = Timer.periodic(const Duration(seconds: 1), (Timer timer) {});
|
|
|
|
|
int callCountThreshold = 0;
|
|
|
|
|
|
|
|
|
|
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 1 and then update card status
|
|
|
|
|
// This 1 is just to show the color of answer tile for 1 and then update card status
|
|
|
|
|
if (totalCurrentQuestionTime - currentGapTime == 1) {
|
|
|
|
|
getCorrectAnswerAndUpdateAnswerColor();
|
|
|
|
|
if (callCountThreshold == 0) {
|
|
|
|
|
getCorrectAnswerAndUpdateAnswerColor();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (totalCurrentQuestionTime - currentGapTime == -2) {
|
|
|
|
|
updateCardStatusToAnswer();
|
|
|
|
|
|
|
|
|
|
if (callCountThreshold == 0) {
|
|
|
|
|
updateCardStatusToAnswer();
|
|
|
|
|
}
|
|
|
|
|
// scheduleMicrotask(() async {
|
|
|
|
|
// if (AppState().getIsDemoMarathon || isUserOutOfGame) {
|
|
|
|
|
// await callNextQuestionApi();
|
|
|
|
@ -243,6 +247,7 @@ class MarathonProvider extends ChangeNotifier {
|
|
|
|
|
notifyListeners();
|
|
|
|
|
}
|
|
|
|
|
totalCurrentQuestionTime--;
|
|
|
|
|
callCountThreshold = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (totalCurrentQuestionTime == 0) {
|
|
|
|
@ -255,6 +260,7 @@ class MarathonProvider extends ChangeNotifier {
|
|
|
|
|
} else {
|
|
|
|
|
if (totalCurrentQuestionTime - currentGapTime != -2) {
|
|
|
|
|
totalCurrentQuestionTime--;
|
|
|
|
|
callCountThreshold = 0;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -413,6 +419,7 @@ class MarathonProvider extends ChangeNotifier {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void getCorrectAnswerAndUpdateAnswerColor() {
|
|
|
|
|
callCountThreshold = 1;
|
|
|
|
|
if (selectedOptionIndex != null) {
|
|
|
|
|
scheduleMicrotask(() async {
|
|
|
|
|
if (AppState().getIsDemoMarathon) {
|
|
|
|
@ -447,7 +454,7 @@ class MarathonProvider extends ChangeNotifier {
|
|
|
|
|
if (currentQuestionNumber == 0) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
callCountThreshold = 1;
|
|
|
|
|
scheduleMicrotask(() async {
|
|
|
|
|
await callNextQuestionApi();
|
|
|
|
|
});
|
|
|
|
@ -478,6 +485,7 @@ class MarathonProvider extends ChangeNotifier {
|
|
|
|
|
|
|
|
|
|
void resetValues() async {
|
|
|
|
|
_currentQuestionNumber = 0;
|
|
|
|
|
iAmWinner = false;
|
|
|
|
|
cardContentList.clear();
|
|
|
|
|
itsMarathonTime = false;
|
|
|
|
|
timerForWinnerSelection.cancel();
|
|
|
|
|