|
|
|
|
@ -1,4 +1,5 @@
|
|
|
|
|
import 'dart:async';
|
|
|
|
|
import 'dart:developer';
|
|
|
|
|
|
|
|
|
|
import 'package:appinio_swiper/appinio_swiper.dart';
|
|
|
|
|
import 'package:flutter/cupertino.dart';
|
|
|
|
|
@ -134,6 +135,7 @@ class MarathonProvider extends ChangeNotifier {
|
|
|
|
|
late VideoPlayerController videoController;
|
|
|
|
|
|
|
|
|
|
Future<void> initializeVideoPlayer() async {
|
|
|
|
|
log("VIDEO PLAYER INITIALIZED!!!");
|
|
|
|
|
videoController = VideoPlayerController.network(ApiConsts.marathonBaseUrlServices + marathonDetailModel.sponsors!.first.video!);
|
|
|
|
|
await videoController.initialize();
|
|
|
|
|
await videoController.play();
|
|
|
|
|
@ -190,6 +192,7 @@ class MarathonProvider extends ChangeNotifier {
|
|
|
|
|
oneSec,
|
|
|
|
|
(Timer timer) async {
|
|
|
|
|
if (totalSecondsToWaitForMarathon == 0) {
|
|
|
|
|
timer.cancel();
|
|
|
|
|
if (isUserWaiting) {
|
|
|
|
|
MarathonApiClient().joinMarathonAsParticipant().whenComplete(() async {
|
|
|
|
|
await callNextQuestionApi();
|
|
|
|
|
@ -197,7 +200,6 @@ class MarathonProvider extends ChangeNotifier {
|
|
|
|
|
} else {
|
|
|
|
|
isButtonEnabled = false;
|
|
|
|
|
}
|
|
|
|
|
timer.cancel();
|
|
|
|
|
return;
|
|
|
|
|
} else {
|
|
|
|
|
totalSecondsToWaitForMarathon--;
|
|
|
|
|
@ -210,20 +212,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 +249,7 @@ class MarathonProvider extends ChangeNotifier {
|
|
|
|
|
notifyListeners();
|
|
|
|
|
}
|
|
|
|
|
totalCurrentQuestionTime--;
|
|
|
|
|
callCountThreshold = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (totalCurrentQuestionTime == 0) {
|
|
|
|
|
@ -255,6 +262,7 @@ class MarathonProvider extends ChangeNotifier {
|
|
|
|
|
} else {
|
|
|
|
|
if (totalCurrentQuestionTime - currentGapTime != -2) {
|
|
|
|
|
totalCurrentQuestionTime--;
|
|
|
|
|
callCountThreshold = 0;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -413,6 +421,7 @@ class MarathonProvider extends ChangeNotifier {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void getCorrectAnswerAndUpdateAnswerColor() {
|
|
|
|
|
callCountThreshold = 1;
|
|
|
|
|
if (selectedOptionIndex != null) {
|
|
|
|
|
scheduleMicrotask(() async {
|
|
|
|
|
if (AppState().getIsDemoMarathon) {
|
|
|
|
|
@ -447,7 +456,7 @@ class MarathonProvider extends ChangeNotifier {
|
|
|
|
|
if (currentQuestionNumber == 0) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
callCountThreshold = 1;
|
|
|
|
|
scheduleMicrotask(() async {
|
|
|
|
|
await callNextQuestionApi();
|
|
|
|
|
});
|
|
|
|
|
@ -478,6 +487,7 @@ class MarathonProvider extends ChangeNotifier {
|
|
|
|
|
|
|
|
|
|
void resetValues() async {
|
|
|
|
|
_currentQuestionNumber = 0;
|
|
|
|
|
iAmWinner = false;
|
|
|
|
|
cardContentList.clear();
|
|
|
|
|
itsMarathonTime = false;
|
|
|
|
|
timerForWinnerSelection.cancel();
|
|
|
|
|
|