Added Privileged logic for Marathon

merge-requests/102/head
Faiz Hashmi 3 years ago
parent 8ae8f6d2fe
commit 86d25d3ecc

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

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

@ -38,6 +38,7 @@ class AppState {
String? get getForgetPasswordTokenID => forgetPasswordTokenID; String? get getForgetPasswordTokenID => forgetPasswordTokenID;
//Wifi info //Wifi info
String? _mohemmWifiSSID; String? _mohemmWifiSSID;

@ -63,4 +63,5 @@ class MyColors {
static const Color darkDigitColor = Color(0xff2D2F39); static const Color darkDigitColor = Color(0xff2D2F39);
static const Color grey71Color = Color(0xff717171); static const Color grey71Color = Color(0xff717171);
static const Color darkGrey3BColor = Color(0xff3B3B3B); static const Color darkGrey3BColor = Color(0xff3B3B3B);
static const Color lightGreyIconColor = Color(0xff919191);
} }

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

@ -642,6 +642,7 @@ class _VerifyLoginScreenState extends State<VerifyLoginScreen> {
PrivilegeListModel.saveToPrefs(genericResponseModel.privilegeList ?? []); PrivilegeListModel.saveToPrefs(genericResponseModel.privilegeList ?? []);
AppState().setMohemmWifiSSID = genericResponseModel.mohemmWifiSSID; AppState().setMohemmWifiSSID = genericResponseModel.mohemmWifiSSID;
AppState().setMohemmWifiPassword = genericResponseModel.mohemmWifiPassword; AppState().setMohemmWifiPassword = genericResponseModel.mohemmWifiPassword;
AppState().setMohemmWifiPassword = genericResponseModel.mohemmWifiPassword;
Utils.saveStringFromPrefs(SharedPrefsConsts.username, AppState().getUserName!); Utils.saveStringFromPrefs(SharedPrefsConsts.username, AppState().getUserName!);
Utils.saveStringFromPrefs(SharedPrefsConsts.password, AppState().password!); Utils.saveStringFromPrefs(SharedPrefsConsts.password, AppState().password!);
Utils.saveStringFromPrefs(SharedPrefsConsts.mohemmWifiSSID, genericResponseModel.mohemmWifiSSID!); Utils.saveStringFromPrefs(SharedPrefsConsts.mohemmWifiSSID, genericResponseModel.mohemmWifiSSID!);

@ -5,11 +5,13 @@ import 'package:flutter/cupertino.dart';
import 'package:flutter/foundation.dart'; import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:mohem_flutter_app/api/marathon/marathon_api_client.dart'; import 'package:mohem_flutter_app/api/marathon/marathon_api_client.dart';
import 'package:mohem_flutter_app/app_state/app_state.dart';
import 'package:mohem_flutter_app/classes/utils.dart'; import 'package:mohem_flutter_app/classes/utils.dart';
import 'package:mohem_flutter_app/config/routes.dart'; import 'package:mohem_flutter_app/config/routes.dart';
import 'package:mohem_flutter_app/models/marathon/marathon_model.dart'; import 'package:mohem_flutter_app/models/marathon/marathon_model.dart';
import 'package:mohem_flutter_app/models/marathon/question_model.dart'; import 'package:mohem_flutter_app/models/marathon/question_model.dart';
import 'package:mohem_flutter_app/models/marathon/winner_model.dart'; import 'package:mohem_flutter_app/models/marathon/winner_model.dart';
import 'package:mohem_flutter_app/models/privilege_list_model.dart';
import 'package:mohem_flutter_app/ui/marathon/widgets/question_card.dart'; import 'package:mohem_flutter_app/ui/marathon/widgets/question_card.dart';
import 'package:video_player/video_player.dart'; import 'package:video_player/video_player.dart';
@ -28,6 +30,9 @@ class MarathonProvider extends ChangeNotifier {
String? selectedOptionId; String? selectedOptionId;
int? totalQualifiers; int? totalQualifiers;
bool iAmWinner = false;
bool isPrivilegedWithMarathon = false;
bool _isLoading = false; bool _isLoading = false;
bool get isLoading => _isLoading; bool get isLoading => _isLoading;
@ -164,7 +169,7 @@ class MarathonProvider extends ChangeNotifier {
oneSec, oneSec,
(Timer timer) async { (Timer timer) async {
// This 2 is just to show the color of answer tile for 2 seconds and then update card status // 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) { if (totalCurrentQuestionTime - currentGapTime == 1) {
getCorrectAnswerAndUpdateAnswerColor(); getCorrectAnswerAndUpdateAnswerColor();
} }
@ -182,7 +187,7 @@ class MarathonProvider extends ChangeNotifier {
if (totalCurrentQuestionTime == 0) { if (totalCurrentQuestionTime == 0) {
updateCardData(); updateCardData();
if (currentQuestionNumber == marathonDetailModel.totalQuestions! - 1) { if (currentQuestionNumber == marathonDetailModel.totalQuestions! ) {
callGetQualifiersApi(); callGetQualifiersApi();
updateQuestionCardStatus(QuestionCardStatus.findingWinner); updateQuestionCardStatus(QuestionCardStatus.findingWinner);
timer.cancel(); timer.cancel();
@ -235,6 +240,19 @@ class MarathonProvider extends ChangeNotifier {
Future<void> callGetSelectedWinnersApi() async { Future<void> callGetSelectedWinnersApi() async {
selectedWinners = await MarathonApiClient().getSelectedWinner(marathonId: marathonDetailModel.id!); selectedWinners = await MarathonApiClient().getSelectedWinner(marathonId: marathonDetailModel.id!);
if (selectedWinners != null) {
selectedWinners!.removeWhere((WinnerModel element) {
print("matching : ${AppState().memberInformationList!.eMPLOYEENUMBER} with ${element.employeeId}");
if (element.employeeId == AppState().memberInformationList!.eMPLOYEENUMBER) {
iAmWinner = true;
return true;
} else {
return false;
}
});
}
print("selectedWinners Length : ${selectedWinners!.length}");
notifyListeners(); notifyListeners();
} }
@ -361,20 +379,35 @@ class MarathonProvider extends ChangeNotifier {
notifyListeners(); notifyListeners();
} }
bool checkIfPrivilegedForMarathon() {
for (PrivilegeListModel element in AppState().privilegeListModel!) {
if (element.serviceName == "Marathon") {
if (element.previlege != null) {
return element.previlege!;
}
}
}
return false;
}
Future<void> getMarathonDetailsFromApi() async { Future<void> getMarathonDetailsFromApi() async {
isLoading = true; isLoading = true;
notifyListeners(); notifyListeners();
await MarathonApiClient().getMarathonToken().whenComplete(() async { isPrivilegedWithMarathon = checkIfPrivilegedForMarathon();
marathonDetailModel = await MarathonApiClient().getMarathonDetails(); if (isPrivilegedWithMarathon) {
if (marathonDetailModel.id == null) { await MarathonApiClient().getMarathonToken().whenComplete(() async {
isUpComingMarathon = false; marathonDetailModel = await MarathonApiClient().getMarathonDetails();
notifyListeners(); if (marathonDetailModel.id == null) {
return; isUpComingMarathon = false;
} isLoading = false;
populateQuestionStatusesList(); notifyListeners();
isLoading = false; return;
notifyListeners(); }
}); populateQuestionStatusesList();
});
}
isLoading = false;
notifyListeners();
} }
Future<void> onJoinMarathonPressed(BuildContext context) async { Future<void> onJoinMarathonPressed(BuildContext context) async {

@ -43,71 +43,102 @@ class MarathonScreen extends StatelessWidget {
return Image.asset(MyLottieConsts.congratsGif, height: 200); return Image.asset(MyLottieConsts.congratsGif, height: 200);
} }
// SizedBox(
// height: 200,
// child: Stack(
// fit: StackFit.expand,
// children: <Widget>[
// Lottie.asset(MyLottieConsts.celebrate1Lottie, height: 200),
// // Lottie.asset(MyLottieConsts.celebrate2Lottie, height: 200),
// ],
// ),
// ),
Widget getWinnerWidget(BuildContext context, {required MarathonProvider provider}) { Widget getWinnerWidget(BuildContext context, {required MarathonProvider provider}) {
return Container( return Container(
width: double.infinity, width: double.infinity,
decoration: MyDecorations.shadowDecoration, decoration: MyDecorations.shadowDecoration,
padding: const EdgeInsets.symmetric(vertical: 20, horizontal: 20), padding: const EdgeInsets.symmetric(vertical: 20, horizontal: 20),
child: Column( child: Stack(
mainAxisAlignment: MainAxisAlignment.center, children: [
children: <Widget>[ Column(
SizedBox( mainAxisAlignment: MainAxisAlignment.center,
height: 200, children: <Widget>[
child: Stack( SizedBox(
children: <Widget>[ height: 50,
Lottie.asset(MyLottieConsts.celebrate1Lottie, height: 200), child: Stack(
Lottie.asset(MyLottieConsts.celebrate2Lottie, height: 200), children: <Widget>[
Align(
alignment: Alignment.center,
child: SvgPicture.asset("assets/images/winner_ribbon.svg", height: 50),
),
Align(
alignment: Alignment.center,
child: LocaleKeys.winners.tr().toText32(color: MyColors.white, isBold: true, isCentered: true).paddingOnly(top: 07),
)
],
),
),
16.height,
!provider.iAmWinner
? Column(
children: <Widget>[
(AppState().isArabic(context) ? AppState().memberInformationList!.eMPLOYEEDISPLAYNAMEAr : AppState().memberInformationList!.eMPLOYEEDISPLAYNAMEEn)!.toText22(
color: MyColors.grey3AColor,
isCentered: true,
),
8.height,
AppState().memberInformationList!.eMPLOYEENUMBER!.toText22(color: MyColors.grey57Color),
],
)
: const SizedBox(),
36.height,
if (provider.selectedWinners != null) ...<Widget>[
ListView.separated(
shrinkWrap: true,
itemCount: provider.selectedWinners!.length,
separatorBuilder: (BuildContext context, int index) {
return const Divider();
},
itemBuilder: (BuildContext context, int index) {
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
(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,
), if (provider.marathonDetailModel.sponsors != null && provider.marathonDetailModel.sponsors!.isNotEmpty) ...<Widget>[
26.height, Row(
SizedBox( mainAxisAlignment: MainAxisAlignment.center,
height: 50, children: <Widget>[
child: Stack( "${LocaleKeys.sponsoredBy.tr()} ".toText14(color: MyColors.grey77Color),
children: <Widget>[ (AppState().isArabic(context) ? provider.marathonDetailModel.sponsors!.first.nameAr ?? "" : provider.marathonDetailModel.sponsors!.first.nameEn ?? "").toText14(
Align( color: MyColors.darkTextColor,
alignment: Alignment.center, isBold: true,
child: SvgPicture.asset("assets/images/winner_ribbon.svg", height: 50), ),
],
), ),
Align( 5.height,
alignment: Alignment.center, Image.network(
child: LocaleKeys.winner.tr().toText32(color: MyColors.white, isBold: true, isCentered: true).paddingOnly(top: 07), provider.marathonDetailModel.sponsors!.first.image!,
height: 40,
width: 150,
fit: BoxFit.fill,
errorBuilder: (BuildContext context, Object exception, StackTrace? stackTrace) {
return const Center();
},
) )
], ],
), ],
), ),
12.height, Lottie.asset(MyLottieConsts.celebrate1Lottie),
if (provider.selectedWinners != null) ...<Widget>[
(AppState().isArabic(context) ? provider.selectedWinners!.first.nameEn : provider.selectedWinners!.first.nameEn)!.toText22(
color: MyColors.grey3AColor,
isCentered: true,
),
8.height,
provider.selectedWinners!.first.employeeId!.toText22(color: MyColors.grey57Color),
],
60.height,
if (provider.marathonDetailModel.sponsors != null && provider.marathonDetailModel.sponsors!.isNotEmpty) ...<Widget>[
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
"${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,
),
],
),
5.height,
Image.network(
provider.marathonDetailModel.sponsors!.first.image!,
height: 40,
width: 150,
fit: BoxFit.fill,
errorBuilder: (BuildContext context, Object exception, StackTrace? stackTrace) {
return const Center();
},
)
],
], ],
), ),
); );

@ -22,200 +22,362 @@ class MarathonBanner extends StatelessWidget {
const MarathonBanner({Key? key, required this.isMarathonUpcoming}) : super(key: key); const MarathonBanner({Key? key, required this.isMarathonUpcoming}) : super(key: key);
@override Widget getUnPrivilegedMarathon(BuildContext context) {
Widget build(BuildContext context) { return Container(
MarathonProvider provider = context.read<MarathonProvider>(); decoration: MyDecorations.shadowDecoration,
return provider.marathonDetailModel.startTime != null height: isTablet ? MediaQuery.of(context).size.height * 0.17 : MediaQuery.of(context).size.height * 0.11,
? Container( clipBehavior: Clip.antiAlias,
decoration: MyDecorations.shadowDecoration, child: Stack(
height: isTablet ? MediaQuery.of(context).size.height * 0.17 : MediaQuery.of(context).size.height * 0.11, children: <Widget>[
clipBehavior: Clip.antiAlias, Transform(
child: Stack( alignment: Alignment.center,
transform: Matrix4.rotationY(
AppState().isArabic(context) ? math.pi : 0,
),
child: SvgPicture.asset(
"assets/images/marathon_banner_bg.svg",
fit: BoxFit.fill,
width: double.infinity,
),
),
AppState().isArabic(context)
? Positioned(
right: -15,
top: -10,
child: Transform.rotate(
angle: 10,
child: Container(
width: isTablet ? 70 : 65,
height: isTablet ? 40 : 32,
color: MyColors.darkDigitColor,
),
),
)
: Positioned(
left: -20,
top: -10,
child: Transform.rotate(
angle: 15,
child: Container(
width: isTablet ? 70 : 65,
height: isTablet ? 40 : 32,
color: MyColors.darkDigitColor,
),
),
),
SizedBox(
width: double.infinity,
height: double.infinity,
child: Row(
children: <Widget>[ children: <Widget>[
Transform( const Expanded(
alignment: Alignment.center, flex: 3,
transform: Matrix4.rotationY( child: SizedBox(
AppState().isArabic(context) ? math.pi : 0, width: double.infinity,
height: double.infinity,
), ),
child: SvgPicture.asset( ),
"assets/images/marathon_banner_bg.svg", Expanded(
fit: BoxFit.fill, flex: AppState().isArabic(context) ? 4 : 5,
child: SizedBox(
width: double.infinity, width: double.infinity,
height: double.infinity,
child: Row(
mainAxisAlignment: MainAxisAlignment.start,
children: <Widget>[
Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisSize: MainAxisSize.min,
children: <Widget>[
AppState().isArabic(context) ? 0.height : 5.height,
Text(
LocaleKeys.getReadyForContest.tr(),
style: TextStyle(
fontSize: isTablet ? 20 : 11,
fontStyle: FontStyle.italic,
fontWeight: FontWeight.w600,
color: MyColors.white.withOpacity(0.83),
letterSpacing: -0.4,
),
),
Text(
LocaleKeys.brainMarathon.tr(),
style: TextStyle(
fontStyle: FontStyle.italic,
fontSize: isTablet ? 30 : 19,
fontWeight: FontWeight.bold,
color: MyColors.white.withOpacity(0.83),
height: 32 / 22,
),
),
],
).paddingOnly(
left: AppState().isArabic(context) ? 12 : 3,
right: AppState().isArabic(context) ? 3 : 12,
)
],
),
), ),
), ),
AppState().isArabic(context) ],
? Positioned( ),
right: -15, ),
top: -10, AppState().isArabic(context)
child: Transform.rotate( ? Align(
angle: 10, alignment: Alignment.topRight,
child: Container( child: SizedBox(
width: isTablet ? 70 : 65, height: isTablet ? 30 : 20,
height: isTablet ? 40 : 32, width: isTablet ? 45 : 35,
color: MyColors.darkDigitColor, child: Transform.rotate(
), angle: math.pi / 4.5,
), child: Text(
) LocaleKeys.brainMarathon.tr(),
: Positioned( textAlign: TextAlign.center,
left: -20, maxLines: 2,
top: -10, style: TextStyle(
child: Transform.rotate( color: MyColors.white,
angle: 15, fontWeight: FontWeight.bold,
child: Container( fontSize: isTablet ? 8 : 6,
width: isTablet ? 70 : 65, height: 1.2,
height: isTablet ? 40 : 32,
color: MyColors.darkDigitColor,
),
), ),
), ),
SizedBox( ),
width: double.infinity, ),
height: double.infinity, ).paddingOnly(top: 5)
child: Row( : Align(
children: <Widget>[ alignment: Alignment.topLeft,
const Expanded( child: SizedBox(
flex: 3, height: isTablet ? 30 : 20,
child: SizedBox( width: isTablet ? 45 : 35,
width: double.infinity, child: Transform.rotate(
height: double.infinity, angle: -math.pi / 4.5,
child: Text(
LocaleKeys.brainMarathon.tr(),
textAlign: TextAlign.center,
maxLines: 2,
style: TextStyle(
color: MyColors.kWhiteColor,
fontWeight: FontWeight.bold,
fontSize: isTablet ? 8 : 6,
height: 1.2,
), ),
), ),
Expanded( ),
flex: AppState().isArabic(context) ? 4 : 5, ),
child: SizedBox( ).paddingOnly(top: 5),
width: double.infinity, Container(
height: double.infinity, height: double.infinity,
child: Row( width: double.infinity,
mainAxisAlignment: MainAxisAlignment.start, color: Colors.black.withOpacity(0.6),
children: <Widget>[ child: const Icon(
Column( Icons.lock_rounded,
mainAxisAlignment: MainAxisAlignment.center, color: MyColors.lightGreyIconColor,
crossAxisAlignment: CrossAxisAlignment.start, ),
mainAxisSize: MainAxisSize.min, ),
],
),
);
}
@override
Widget build(BuildContext context) {
MarathonProvider provider = context.read<MarathonProvider>();
return !provider.isPrivilegedWithMarathon
? getUnPrivilegedMarathon(context)
: provider.marathonDetailModel.startTime != null
? Container(
decoration: MyDecorations.shadowDecoration,
height: isTablet ? MediaQuery.of(context).size.height * 0.17 : MediaQuery.of(context).size.height * 0.11,
clipBehavior: Clip.antiAlias,
child: Stack(
children: <Widget>[
Transform(
alignment: Alignment.center,
transform: Matrix4.rotationY(
AppState().isArabic(context) ? math.pi : 0,
),
child: SvgPicture.asset(
"assets/images/marathon_banner_bg.svg",
fit: BoxFit.fill,
width: double.infinity,
),
),
AppState().isArabic(context)
? Positioned(
right: -15,
top: -10,
child: Transform.rotate(
angle: 10,
child: Container(
width: isTablet ? 70 : 65,
height: isTablet ? 40 : 32,
color: MyColors.darkDigitColor,
),
),
)
: Positioned(
left: -20,
top: -10,
child: Transform.rotate(
angle: 15,
child: Container(
width: isTablet ? 70 : 65,
height: isTablet ? 40 : 32,
color: MyColors.darkDigitColor,
),
),
),
SizedBox(
width: double.infinity,
height: double.infinity,
child: Row(
children: <Widget>[
const Expanded(
flex: 3,
child: SizedBox(
width: double.infinity,
height: double.infinity,
),
),
Expanded(
flex: AppState().isArabic(context) ? 4 : 5,
child: SizedBox(
width: double.infinity,
height: double.infinity,
child: Row(
mainAxisAlignment: MainAxisAlignment.start,
children: <Widget>[ children: <Widget>[
AppState().isArabic(context) ? 0.height : 5.height, Column(
Text( mainAxisAlignment: MainAxisAlignment.center,
LocaleKeys.getReadyForContest.tr(), crossAxisAlignment: CrossAxisAlignment.start,
style: TextStyle( mainAxisSize: MainAxisSize.min,
fontSize: isTablet ? 20 : 11, children: <Widget>[
fontStyle: FontStyle.italic, AppState().isArabic(context) ? 0.height : 5.height,
fontWeight: FontWeight.w600, Text(
color: MyColors.white.withOpacity(0.83), LocaleKeys.getReadyForContest.tr(),
letterSpacing: -0.4, style: TextStyle(
), fontSize: isTablet ? 20 : 11,
), fontStyle: FontStyle.italic,
Text( fontWeight: FontWeight.w600,
AppState().isArabic(context) ? provider.marathonDetailModel.titleAr ?? "" : provider.marathonDetailModel.titleEn ?? "", color: MyColors.white.withOpacity(0.83),
style: TextStyle( letterSpacing: -0.4,
fontStyle: FontStyle.italic, ),
fontSize: isTablet ? 30 : 19, ),
fontWeight: FontWeight.bold, Text(
color: MyColors.white.withOpacity(0.83), AppState().isArabic(context) ? provider.marathonDetailModel.titleAr ?? "" : provider.marathonDetailModel.titleEn ?? "",
height: 32 / 22, style: TextStyle(
), fontStyle: FontStyle.italic,
), fontSize: isTablet ? 30 : 19,
isTablet ? 10.height : 3.height, fontWeight: FontWeight.bold,
BuildCountdownTimer( color: MyColors.white.withOpacity(0.83),
timeToMarathon: DateTime.parse(provider.marathonDetailModel.startTime!).millisecondsSinceEpoch, height: 32 / 22,
provider: provider, ),
screenFlag: 0, ),
), isTablet ? 10.height : 3.height,
BuildCountdownTimer(
timeToMarathon: DateTime.parse(provider.marathonDetailModel.startTime!).millisecondsSinceEpoch,
provider: provider,
screenFlag: 0,
),
],
).paddingOnly(
left: AppState().isArabic(context) ? 12 : 3,
right: AppState().isArabic(context) ? 3 : 12,
)
], ],
).paddingOnly( ),
left: AppState().isArabic(context) ? 12 : 3, ),
right: AppState().isArabic(context) ? 3 : 12,
)
],
), ),
), ],
), ),
], ),
), AppState().isArabic(context)
), ? Align(
AppState().isArabic(context) alignment: Alignment.topRight,
? Align( child: SizedBox(
alignment: Alignment.topRight, height: isTablet ? 30 : 20,
child: SizedBox( width: isTablet ? 45 : 35,
height: isTablet ? 30 : 20, child: Transform.rotate(
width: isTablet ? 45 : 35, angle: math.pi / 4.5,
child: Transform.rotate( child: Text(
angle: math.pi / 4.5, LocaleKeys.brainMarathon.tr(),
child: Text( textAlign: TextAlign.center,
LocaleKeys.brainMarathon.tr(), maxLines: 2,
textAlign: TextAlign.center, style: TextStyle(
maxLines: 2, color: MyColors.white,
style: TextStyle( fontWeight: FontWeight.bold,
color: MyColors.white, fontSize: isTablet ? 8 : 6,
fontWeight: FontWeight.bold, height: 1.2,
fontSize: isTablet ? 8 : 6, ),
height: 1.2, ),
), ),
), ),
), ).paddingOnly(top: 5)
), : Align(
).paddingOnly(top: 5) alignment: Alignment.topLeft,
: Align( child: SizedBox(
alignment: Alignment.topLeft, height: isTablet ? 30 : 20,
child: SizedBox( width: isTablet ? 45 : 35,
height: isTablet ? 30 : 20, child: Transform.rotate(
width: isTablet ? 45 : 35, angle: -math.pi / 4.5,
child: Transform.rotate( child: Text(
angle: -math.pi / 4.5, LocaleKeys.brainMarathon.tr(),
child: Text( textAlign: TextAlign.center,
LocaleKeys.brainMarathon.tr(), maxLines: 2,
textAlign: TextAlign.center, style: TextStyle(
maxLines: 2, color: MyColors.kWhiteColor,
style: TextStyle( fontWeight: FontWeight.bold,
color: MyColors.kWhiteColor, fontSize: isTablet ? 8 : 6,
fontWeight: FontWeight.bold, height: 1.2,
fontSize: isTablet ? 8 : 6, ),
height: 1.2, ),
), ),
), ),
).paddingOnly(top: 5),
!AppState().isArabic(context)
? Positioned(
right: 0,
bottom: 0,
child: RotatedBox(
quarterTurns: 4,
child: SvgPicture.asset("assets/images/arrow_next.svg", color: MyColors.whiteColor),
).paddingAll(isTablet ? 20 : 15),
)
: Positioned(
bottom: 0,
left: 0,
child: RotatedBox(
quarterTurns: 2,
child: SvgPicture.asset("assets/images/arrow_next.svg", color: MyColors.whiteColor),
).paddingAll(isTablet ? 20 : 15),
), ),
),
).paddingOnly(top: 5),
!AppState().isArabic(context)
? Positioned(
right: 0,
bottom: 0,
child: RotatedBox(
quarterTurns: 4,
child: SvgPicture.asset("assets/images/arrow_next.svg", color: MyColors.whiteColor),
).paddingAll(isTablet ? 20 : 15),
)
: Positioned(
bottom: 0,
left: 0,
child: RotatedBox(
quarterTurns: 2,
child: SvgPicture.asset("assets/images/arrow_next.svg", color: MyColors.whiteColor),
).paddingAll(isTablet ? 20 : 15),
),
],
).onPress(() async {
int remainingTimeInMinutes = DateTime.parse(provider.marathonDetailModel.startTime!).difference(DateTime.now()).inMinutes;
if (remainingTimeInMinutes > 2) { ],
Utils.showLoading(context); ).onPress(() async {
try { int remainingTimeInMinutes = DateTime.parse(provider.marathonDetailModel.startTime!).difference(DateTime.now()).inMinutes;
await provider.initializeVideoPlayer().then((_) {
Utils.hideLoading(context); if (remainingTimeInMinutes > 2) {
provider.startTimerForSponsorVideo(); Utils.showLoading(context);
Navigator.pushNamed(context, AppRoutes.marathonSponsorVideoScreen); try {
}); await provider.initializeVideoPlayer().then((_) {
} catch (e, s) { Utils.hideLoading(context);
if (kDebugMode) { provider.startTimerForSponsorVideo();
print("Error in VideoPlayer: ${e.toString()}"); Navigator.pushNamed(context, AppRoutes.marathonSponsorVideoScreen);
} });
Utils.hideLoading(context); } catch (e) {
Navigator.pushNamed(context, AppRoutes.marathonIntroScreen); if (kDebugMode) {
} print("Error in VideoPlayer: ${e.toString()}");
} else { }
Navigator.pushNamed(context, AppRoutes.marathonIntroScreen); Utils.hideLoading(context);
} Navigator.pushNamed(context, AppRoutes.marathonIntroScreen);
}), }
) } else {
: const SizedBox(); Navigator.pushNamed(context, AppRoutes.marathonIntroScreen);
}
}),
)
: const SizedBox();
} }
} }

Loading…
Cancel
Save