Merge branch 'faiz_cs' into 'master'

Minor Fixes While Testing

See merge request Cloud_Solution/mohemm-flutter-app!148
merge-requests/149/merge
haroon amjad 3 years ago
commit 06828cd711

@ -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) {
getCorrectAnswerAndUpdateAnswerColor(); if (callCountThreshold == 0) {
getCorrectAnswerAndUpdateAnswerColor();
}
} }
if (totalCurrentQuestionTime - currentGapTime == -2) { if (totalCurrentQuestionTime - currentGapTime == -2) {
updateCardStatusToAnswer(); if (callCountThreshold == 0) {
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,26 +169,37 @@ 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
shrinkWrap: true, ? Column(
itemCount: provider.selectedWinners!.length, children: <Widget>[
separatorBuilder: (BuildContext context, int index) { (AppState().isArabic(context) ? provider.selectedWinners![0].nameEn : provider.selectedWinners![0].nameEn)!.toText24(
return const Divider(); color: MyColors.grey3AColor,
}, isCentered: true,
itemBuilder: (BuildContext context, int index) { ),
return Column( 8.height,
crossAxisAlignment: CrossAxisAlignment.start, AppState().memberInformationList!.eMPLOYEENUMBER!.toText22(color: MyColors.grey57Color),
children: <Widget>[ ],
(AppState().isArabic(context) ? provider.selectedWinners![index].nameEn : provider.selectedWinners![index].nameEn)!.toText16( )
color: MyColors.grey3AColor, : ListView.separated(
), shrinkWrap: true,
provider.selectedWinners!.first.employeeId!.toText16(color: MyColors.grey57Color), itemCount: provider.selectedWinners!.length,
], separatorBuilder: (BuildContext context, int index) {
); return const Divider();
}, },
), itemBuilder: (BuildContext context, int index) {
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
(AppState().isArabic(context) ? provider.selectedWinners![index].nameEn : provider.selectedWinners![index].nameEn)!.toText16(
color: MyColors.grey3AColor,
),
provider.selectedWinners!.first.employeeId!.toText16(color: MyColors.grey57Color),
],
);
},
),
], ],
60.height, 60.height,
if (provider.marathonDetailModel.sponsors != null && provider.marathonDetailModel.sponsors!.isNotEmpty) ...<Widget>[ if (provider.marathonDetailModel.sponsors != null && provider.marathonDetailModel.sponsors!.isNotEmpty) ...<Widget>[

@ -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