some fixes while testing

merge-requests/148/head
Faiz Hashmi 3 years ago
parent 7e235c9d8c
commit 580c7d62f5

@ -158,13 +158,15 @@ extension EmailValidator on String {
style: TextStyle(height: 1, color: color ?? MyColors.darkTextColor, fontSize: 22, letterSpacing: -1.44, fontWeight: isBold ? FontWeight.bold : FontWeight.w600), style: TextStyle(height: 1, color: color ?? MyColors.darkTextColor, fontSize: 22, letterSpacing: -1.44, fontWeight: isBold ? FontWeight.bold : FontWeight.w600),
); );
Widget toText24({Color? color, bool isBold = false}) => Text( Widget toText24({Color? color, bool isBold = false, bool isCentered = false}) => Text(
this, this,
textAlign: isCentered ? TextAlign.center : null,
style: TextStyle(height: 23 / 24, color: color ?? MyColors.darkTextColor, fontSize: 24, letterSpacing: -1.44, fontWeight: isBold ? FontWeight.bold : FontWeight.w600), style: TextStyle(height: 23 / 24, color: color ?? MyColors.darkTextColor, fontSize: 24, letterSpacing: -1.44, fontWeight: isBold ? FontWeight.bold : FontWeight.w600),
); );
Widget toText30({Color? color, bool isBold = false}) => Text( Widget toText30({Color? color, bool isBold = false, bool isCentered = false}) => Text(
this, this,
textAlign: isCentered ? TextAlign.center : null,
style: TextStyle(height: 20 / 32, color: color ?? MyColors.darkTextColor, fontSize: 32, letterSpacing: -1.2, fontWeight: isBold ? FontWeight.bold : FontWeight.w600), style: TextStyle(height: 20 / 32, color: color ?? MyColors.darkTextColor, fontSize: 32, letterSpacing: -1.2, fontWeight: isBold ? FontWeight.bold : FontWeight.w600),
); );

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

@ -169,9 +169,20 @@ class MarathonScreen extends StatelessWidget {
], ],
) )
: const SizedBox(), : const SizedBox(),
36.height, 34.height,
if (provider.selectedWinners != null) ...<Widget>[ if (provider.selectedWinners != null) ...<Widget>[
ListView.separated( provider.selectedWinners!.length == 1
? Column(
children: <Widget>[
(AppState().isArabic(context) ? provider.selectedWinners![0].nameEn : provider.selectedWinners![0].nameEn)!.toText24(
color: MyColors.grey3AColor,
isCentered: true,
),
8.height,
AppState().memberInformationList!.eMPLOYEENUMBER!.toText22(color: MyColors.grey57Color),
],
)
: ListView.separated(
shrinkWrap: true, shrinkWrap: true,
itemCount: provider.selectedWinners!.length, itemCount: provider.selectedWinners!.length,
separatorBuilder: (BuildContext context, int index) { separatorBuilder: (BuildContext context, int index) {

@ -431,7 +431,7 @@ class MarathonBanner extends StatelessWidget {
), ),
Flexible( Flexible(
child: Text( child: Text(
(AppState().isArabic(context) ? provider.marathonDetailModel.titleAr ?? "" : provider.marathonDetailModel.titleEn ?? "").trimString(15), (AppState().isArabic(context) ? provider.marathonDetailModel.titleAr ?? "" : provider.marathonDetailModel.titleEn ?? "").trimString(isTablet ? 25 : 15),
overflow: TextOverflow.ellipsis, overflow: TextOverflow.ellipsis,
style: TextStyle( style: TextStyle(
fontStyle: FontStyle.italic, fontStyle: FontStyle.italic,

Loading…
Cancel
Save