Added Disclosure
parent
368d109d9f
commit
8efab84515
@ -0,0 +1,47 @@
|
||||
{
|
||||
"id": "979813be-eafa-4d3e-d27e-08dae8a08a3b",
|
||||
"titleEn": "Upcoming Disclosure",
|
||||
"titleAr": "undefined",
|
||||
"descEn": "Submit disclosure using mobile app",
|
||||
"descAr": "undefined",
|
||||
"questionTime": 10,
|
||||
"winDeciderTime": 30,
|
||||
"winnersCount": 1,
|
||||
"questGapTime": 5,
|
||||
"startTime": "2022-12-28T10:44:41",
|
||||
"endTime": null,
|
||||
"marathoneStatusId": 4,
|
||||
"scheduleTime": "2022-12-28T10:14:41",
|
||||
"selectedLanguage": 0,
|
||||
"projects": {
|
||||
"id": "b1cd3fa3-bb27-422e-a4c1-08dac09254df",
|
||||
"nameEn": "Cloud Solutions",
|
||||
"nameAr": "شركة حلول السحابة للاتصالات وتقنية المعلومات",
|
||||
"projectCode": "CS"
|
||||
},
|
||||
"sponsors": [
|
||||
{
|
||||
"id": "3272b127-b388-4f09-425b-08dac2eb788e",
|
||||
"nameEn": "Cloud Solutions",
|
||||
"nameAr": "حل السحابة",
|
||||
"image": "SponsorImage/b9aed4a8-42b2-45fc-b6f1-47ee0c7b4138_sponsor.jpeg",
|
||||
"video": "SponsorVideo/9ab678ab-1b4c-4ea4-aaf2-32ce1353d3fe_sample-10s.mp4",
|
||||
"logo": "SponsorLogo/eb029f0d-bce1-4a61-b0c0-abaa484912a0_sponsor.jpeg",
|
||||
"videoDuration": null,
|
||||
"sponsorPrizes": [
|
||||
{
|
||||
"id": "e657a18c-6fb2-4099-07c8-08dae89efcd3",
|
||||
"marathonPrizeEn": "SAR 500",
|
||||
"marathonPrizeAr": "SAR 500"
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"questions": null,
|
||||
"isEmailSent": false,
|
||||
"totalQuestions": 10,
|
||||
"cancelReason": null,
|
||||
"marathonBufferTime": 30,
|
||||
"currentTime": "2022-12-28T08:03:24.3671803Z",
|
||||
"displayCorrectAnswer": true
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,242 @@
|
||||
class DisclosureDetailsModel {
|
||||
String? id;
|
||||
String? titleEn;
|
||||
String? titleAr;
|
||||
String? descEn;
|
||||
String? descAr;
|
||||
int? winDeciderTime;
|
||||
int? winnersCount;
|
||||
int? questGapTime;
|
||||
String? startTime;
|
||||
String? endTime;
|
||||
int? marathoneStatusId;
|
||||
String? scheduleTime;
|
||||
int? selectedLanguage;
|
||||
Projects? projects;
|
||||
List<Sponsors>? sponsors;
|
||||
List<Questions>? questions;
|
||||
int? totalQuestions;
|
||||
int? marathonBufferTime;
|
||||
bool? displayCorrectAnswer;
|
||||
|
||||
DisclosureDetailsModel({
|
||||
id,
|
||||
titleEn,
|
||||
titleAr,
|
||||
descEn,
|
||||
descAr,
|
||||
winDeciderTime,
|
||||
winnersCount,
|
||||
questGapTime,
|
||||
startTime,
|
||||
endTime,
|
||||
marathoneStatusId,
|
||||
scheduleTime,
|
||||
selectedLanguage,
|
||||
projects,
|
||||
sponsors,
|
||||
questions,
|
||||
totalQuestions,
|
||||
marathonBufferTime,
|
||||
displayCorrectAnswer,
|
||||
});
|
||||
|
||||
DisclosureDetailsModel.fromJson(Map<String, dynamic> json) {
|
||||
id = json['id'];
|
||||
titleEn = json['titleEn'];
|
||||
titleAr = json['titleAr'];
|
||||
descEn = json['descEn'];
|
||||
descAr = json['descAr'];
|
||||
winDeciderTime = json['winDeciderTime'];
|
||||
winnersCount = json['winnersCount'];
|
||||
questGapTime = json['questGapTime'];
|
||||
startTime = json['startTime'];
|
||||
endTime = json['endTime'];
|
||||
marathoneStatusId = json['marathoneStatusId'];
|
||||
scheduleTime = json['scheduleTime'];
|
||||
selectedLanguage = json['selectedLanguage'];
|
||||
projects = json['projects'] != null ? Projects.fromJson(json['projects']) : null;
|
||||
if (json['sponsors'] != null) {
|
||||
sponsors = <Sponsors>[];
|
||||
json['sponsors'].forEach((v) {
|
||||
sponsors!.add(Sponsors.fromJson(v));
|
||||
});
|
||||
}
|
||||
if (json['questions'] != null) {
|
||||
questions = <Questions>[];
|
||||
json['questions'].forEach((v) {
|
||||
questions!.add(Questions.fromJson(v));
|
||||
});
|
||||
}
|
||||
totalQuestions = json["totalQuestions"];
|
||||
marathonBufferTime = json["marathonBufferTime"];
|
||||
displayCorrectAnswer = json["displayCorrectAnswer"];
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
Map<String, dynamic> data = <String, dynamic>{};
|
||||
data['id'] = id;
|
||||
data['titleEn'] = titleEn;
|
||||
data['titleAr'] = titleAr;
|
||||
data['descEn'] = descEn;
|
||||
data['descAr'] = descAr;
|
||||
data['winDeciderTime'] = winDeciderTime;
|
||||
data['winnersCount'] = winnersCount;
|
||||
data['questGapTime'] = questGapTime;
|
||||
data['startTime'] = startTime;
|
||||
data['endTime'] = endTime;
|
||||
data['marathoneStatusId'] = marathoneStatusId;
|
||||
data['scheduleTime'] = scheduleTime;
|
||||
data['selectedLanguage'] = selectedLanguage;
|
||||
if (projects != null) {
|
||||
data['projects'] = projects!.toJson();
|
||||
}
|
||||
if (sponsors != null) {
|
||||
data['sponsors'] = sponsors!.map((v) => v.toJson()).toList();
|
||||
}
|
||||
if (questions != null) {
|
||||
data['questions'] = questions!.map((v) => v.toJson()).toList();
|
||||
}
|
||||
data['totalQuestions'] = totalQuestions;
|
||||
data['marathonBufferTime'] = marathonBufferTime;
|
||||
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
class Projects {
|
||||
String? id;
|
||||
String? nameEn;
|
||||
String? nameAr;
|
||||
String? projectCode;
|
||||
|
||||
Projects({id, nameEn, nameAr, projectCode});
|
||||
|
||||
Projects.fromJson(Map<String, dynamic> json) {
|
||||
id = json['id'];
|
||||
nameEn = json['nameEn'];
|
||||
nameAr = json['nameAr'];
|
||||
projectCode = json['projectCode'];
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
Map<String, dynamic> data = <String, dynamic>{};
|
||||
data['id'] = id;
|
||||
data['nameEn'] = nameEn;
|
||||
data['nameAr'] = nameAr;
|
||||
data['projectCode'] = projectCode;
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
class Sponsors {
|
||||
String? id;
|
||||
String? nameEn;
|
||||
String? nameAr;
|
||||
String? image;
|
||||
String? video;
|
||||
String? logo;
|
||||
List<SponsorPrizes>? sponsorPrizes;
|
||||
|
||||
Sponsors({id, nameEn, nameAr, image, video, logo, sponsorPrizes});
|
||||
|
||||
Sponsors.fromJson(Map<String, dynamic> json) {
|
||||
id = json['id'];
|
||||
nameEn = json['nameEn'];
|
||||
nameAr = json['nameAr'];
|
||||
image = json['image'];
|
||||
video = json['video'];
|
||||
logo = json['logo'];
|
||||
if (json['sponsorPrizes'] != null) {
|
||||
sponsorPrizes = <SponsorPrizes>[];
|
||||
json['sponsorPrizes'].forEach((v) {
|
||||
sponsorPrizes!.add(SponsorPrizes.fromJson(v));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
Map<String, dynamic> data = <String, dynamic>{};
|
||||
data['id'] = id;
|
||||
data['nameEn'] = nameEn;
|
||||
data['nameAr'] = nameAr;
|
||||
data['image'] = image;
|
||||
data['video'] = video;
|
||||
data['logo'] = logo;
|
||||
if (sponsorPrizes != null) {
|
||||
data['sponsorPrizes'] = sponsorPrizes!.map((v) => v.toJson()).toList();
|
||||
}
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
class SponsorPrizes {
|
||||
String? id;
|
||||
String? marathonPrizeEn;
|
||||
String? marathonPrizeAr;
|
||||
|
||||
SponsorPrizes({id, marathonPrizeEn, marathonPrizeAr});
|
||||
|
||||
SponsorPrizes.fromJson(Map<String, dynamic> json) {
|
||||
id = json['id'];
|
||||
marathonPrizeEn = json['marathonPrizeEn'];
|
||||
marathonPrizeAr = json['marathonPrizeAr'];
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
Map<String, dynamic> data = <String, dynamic>{};
|
||||
data['id'] = id;
|
||||
data['marathonPrizeEn'] = marathonPrizeEn;
|
||||
data['marathonPrizeAr'] = marathonPrizeAr;
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
class Questions {
|
||||
String? id;
|
||||
String? titleEn;
|
||||
String? titleAr;
|
||||
String? marathonId;
|
||||
int? questionTypeId;
|
||||
int? questionTime;
|
||||
int? nextQuestGap;
|
||||
int? gapType;
|
||||
String? gapValue;
|
||||
String? gapImage;
|
||||
int? questOptionsLimit;
|
||||
List? questionOptions;
|
||||
|
||||
Questions({id, titleEn, titleAr, marathonId, questionTypeId, questionTime, nextQuestGap, gapType, gapValue, gapImage, questOptionsLimit, questionOptions});
|
||||
|
||||
Questions.fromJson(Map<String, dynamic> json) {
|
||||
id = json['id'];
|
||||
titleEn = json['titleEn'];
|
||||
titleAr = json['titleAr'];
|
||||
marathonId = json['marathonId'];
|
||||
questionTypeId = json['questionTypeId'];
|
||||
questionTime = json['questionTime'];
|
||||
nextQuestGap = json['nextQuestGap'];
|
||||
gapType = json['gapType'];
|
||||
gapValue = json['gapValue'];
|
||||
gapImage = json['gapImage'];
|
||||
questOptionsLimit = json['questOptionsLimit'];
|
||||
questionOptions = json['questionOptions'];
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
Map<String, dynamic> data = <String, dynamic>{};
|
||||
data['id'] = id;
|
||||
data['titleEn'] = titleEn;
|
||||
data['titleAr'] = titleAr;
|
||||
data['marathonId'] = marathonId;
|
||||
data['questionTypeId'] = questionTypeId;
|
||||
data['questionTime'] = questionTime;
|
||||
data['nextQuestGap'] = nextQuestGap;
|
||||
data['gapType'] = gapType;
|
||||
data['gapValue'] = gapValue;
|
||||
data['gapImage'] = gapImage;
|
||||
data['questOptionsLimit'] = questOptionsLimit;
|
||||
data['questionOptions'] = questionOptions;
|
||||
return data;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,31 @@
|
||||
class DisclosureGenericModel {
|
||||
DisclosureGenericModel({
|
||||
this.data,
|
||||
this.isSuccessful,
|
||||
this.message,
|
||||
this.statusCode,
|
||||
this.errors,
|
||||
});
|
||||
|
||||
dynamic data;
|
||||
bool? isSuccessful;
|
||||
String? message;
|
||||
int? statusCode;
|
||||
dynamic errors;
|
||||
|
||||
factory DisclosureGenericModel.fromJson(Map<String, dynamic> json) => DisclosureGenericModel(
|
||||
data: json["data"],
|
||||
isSuccessful: json["isSuccessful"],
|
||||
message: json["message"],
|
||||
statusCode: json["statusCode"],
|
||||
errors: json["errors"],
|
||||
);
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
"data": data,
|
||||
"isSuccessful": isSuccessful,
|
||||
"message": message,
|
||||
"statusCode": statusCode,
|
||||
"errors": errors,
|
||||
};
|
||||
}
|
||||
@ -0,0 +1,122 @@
|
||||
enum DisclosureQuestionsOptionStatus { correct, wrong, selected, unSelected }
|
||||
|
||||
enum DisclosureQuestionCardStatus { question, wrongAnswer, correctAnswer, skippedAnswer, completed, findingWinner, winnerFound }
|
||||
|
||||
class DisclosureQuestionModel {
|
||||
String? id;
|
||||
String? titleEn;
|
||||
String? titleAr;
|
||||
String? marathonId;
|
||||
int? questionTypeId;
|
||||
int? questionTime;
|
||||
int? nextQuestGap;
|
||||
int? gapType;
|
||||
String? gapText;
|
||||
String? gapImage;
|
||||
int? questOptionsLimit;
|
||||
int? remainingParticipantCount;
|
||||
List<QuestionOptions>? questionOptions;
|
||||
|
||||
DisclosureQuestionModel({
|
||||
String? id,
|
||||
String? titleEn,
|
||||
String? titleAr,
|
||||
String? marathonId,
|
||||
int? questionTypeId,
|
||||
int? questionTime,
|
||||
int? nextQuestGap,
|
||||
int? gapType,
|
||||
String? gapText,
|
||||
String? gapImage,
|
||||
int? questOptionsLimit,
|
||||
int? remainingParticipantCount,
|
||||
List<QuestionOptions>? questionOptions,
|
||||
});
|
||||
|
||||
DisclosureQuestionModel.fromJson(Map<String, dynamic> json) {
|
||||
id = json['id'];
|
||||
titleEn = json['titleEn'];
|
||||
titleAr = json['titleAr'];
|
||||
marathonId = json['marathonId'];
|
||||
questionTypeId = json['questionTypeId'];
|
||||
questionTime = json['questionTime'];
|
||||
nextQuestGap = json['nextQuestGap'];
|
||||
gapType = json['gapType'];
|
||||
gapText = json['gapText'];
|
||||
gapImage = json['gapImage'];
|
||||
questOptionsLimit = json['questOptionsLimit'];
|
||||
remainingParticipantCount = json['remainingParticipantCount'];
|
||||
if (json['questionOptions'] != null) {
|
||||
questionOptions = <QuestionOptions>[];
|
||||
json['questionOptions'].forEach((v) {
|
||||
questionOptions!.add(QuestionOptions.fromJson(v));
|
||||
});
|
||||
questionOptions!.sort((QuestionOptions a, QuestionOptions b) => a.sequence!.compareTo(b.sequence!));
|
||||
}
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
Map<String, dynamic> data = <String, dynamic>{};
|
||||
data['id'] = id;
|
||||
data['titleEn'] = titleEn;
|
||||
data['titleAr'] = titleAr;
|
||||
data['marathonId'] = marathonId;
|
||||
data['questionTypeId'] = questionTypeId;
|
||||
data['questionTime'] = questionTime;
|
||||
data['nextQuestGap'] = nextQuestGap;
|
||||
data['gapType'] = gapType;
|
||||
data['gapText'] = gapText;
|
||||
data['gapImage'] = gapImage;
|
||||
data['questOptionsLimit'] = questOptionsLimit;
|
||||
data['remainingParticipantCount'] = remainingParticipantCount;
|
||||
if (questionOptions != null) {
|
||||
data['questionOptions'] = questionOptions!.map((v) => v.toJson()).toList();
|
||||
}
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
class QuestionOptions {
|
||||
String? id;
|
||||
String? titleEn;
|
||||
String? titleAr;
|
||||
String? questionId;
|
||||
int? sequence;
|
||||
String? image;
|
||||
bool? isCorrectOption;
|
||||
DisclosureQuestionsOptionStatus? optionStatus;
|
||||
|
||||
QuestionOptions({
|
||||
String? id,
|
||||
String? titleEn,
|
||||
String? titleAr,
|
||||
String? questionId,
|
||||
int? sequence,
|
||||
String? image,
|
||||
bool? isCorrectOption,
|
||||
DisclosureQuestionsOptionStatus? optionStatus,
|
||||
});
|
||||
|
||||
QuestionOptions.fromJson(Map<String, dynamic> json) {
|
||||
id = json['id'];
|
||||
titleEn = json['titleEn'];
|
||||
titleAr = json['titleAr'];
|
||||
questionId = json['questionId'];
|
||||
sequence = json['sequence'];
|
||||
image = json['image'];
|
||||
isCorrectOption = json['isCorrectOption'];
|
||||
optionStatus = DisclosureQuestionsOptionStatus.unSelected;
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
Map<String, dynamic> data = <String, dynamic>{};
|
||||
data['id'] = id;
|
||||
data['titleEn'] = titleEn;
|
||||
data['titleAr'] = titleAr;
|
||||
data['questionId'] = questionId;
|
||||
data['sequence'] = sequence;
|
||||
data['image'] = image;
|
||||
data['isCorrectOption'] = isCorrectOption;
|
||||
return data;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,52 @@
|
||||
import 'package:easy_localization/easy_localization.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:mohem_flutter_app/extensions/int_extensions.dart';
|
||||
import 'package:mohem_flutter_app/extensions/widget_extensions.dart';
|
||||
import 'package:mohem_flutter_app/generated/locale_keys.g.dart';
|
||||
import 'package:mohem_flutter_app/ui/disclosure/disclosure_provider.dart';
|
||||
import 'package:mohem_flutter_app/ui/disclosure/widgets/disclosure_details_card.dart';
|
||||
import 'package:mohem_flutter_app/ui/disclosure/widgets/disclosure_footer.dart';
|
||||
import 'package:mohem_flutter_app/widgets/app_bar_widget.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
class DisclosureIntroScreen extends StatelessWidget {
|
||||
const DisclosureIntroScreen({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
DisclosureProvider provider = context.watch<DisclosureProvider>();
|
||||
return Scaffold(
|
||||
appBar: AppBarWidget(
|
||||
context,
|
||||
title: LocaleKeys.disclosure.tr(),
|
||||
onHomeTapped: () {
|
||||
Navigator.pop(context);
|
||||
context.setLocale(provider.savedLocale);
|
||||
},
|
||||
onBackTapped: () {
|
||||
Navigator.pop(context);
|
||||
context.setLocale(provider.savedLocale);
|
||||
},
|
||||
),
|
||||
body: Column(
|
||||
children: <Widget>[
|
||||
ListView(
|
||||
padding: const EdgeInsets.all(21),
|
||||
children: <Widget>[
|
||||
DisclosureDetailsCard(disclosureDetailsCard: provider.disclosureDetailsModel),
|
||||
20.height,
|
||||
// provider.isUpComingMarathon
|
||||
// ? DisclosureTimerCard(
|
||||
// provider: provider,
|
||||
// timeToMarathon: DateTime.parse(provider.marathonDetailModel.startTime!).millisecondsSinceEpoch,
|
||||
// )
|
||||
// : const SizedBox(),
|
||||
],
|
||||
).expanded,
|
||||
1.divider,
|
||||
DisclosureFooter(provider: provider),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,343 @@
|
||||
import 'dart:async';
|
||||
import 'dart:developer';
|
||||
|
||||
import 'package:appinio_swiper/appinio_swiper.dart';
|
||||
import 'package:easy_localization/easy_localization.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:mohem_flutter_app/api/marathon/demo_marathon_repo.dart';
|
||||
import 'package:mohem_flutter_app/app_state/app_state.dart';
|
||||
import 'package:mohem_flutter_app/classes/utils.dart';
|
||||
import 'package:mohem_flutter_app/config/routes.dart';
|
||||
import 'package:mohem_flutter_app/models/disclosure/disclosure_details_model.dart';
|
||||
import 'package:mohem_flutter_app/models/disclosure/disclosure_question_model.dart';
|
||||
import 'package:mohem_flutter_app/models/privilege_list_model.dart';
|
||||
import 'package:mohem_flutter_app/ui/disclosure/widgets/disclosure_question_card.dart';
|
||||
|
||||
class DisclosureProvider extends ChangeNotifier {
|
||||
//************************************************ VARIABLES **********************************************************
|
||||
|
||||
final AppinioSwiperController swiperController = AppinioSwiperController();
|
||||
DisclosureQuestionsOptionStatus currentQuestionSelectionStatus = DisclosureQuestionsOptionStatus.unSelected;
|
||||
DisclosureDetailsModel disclosureDetailsModel = DisclosureDetailsModel();
|
||||
List<DisclosureCardContent> cardContentList = <DisclosureCardContent>[];
|
||||
DisclosureQuestionModel currentQuestion = DisclosureQuestionModel();
|
||||
List<DisclosureQuestionCardStatus> answerStatusesList = <DisclosureQuestionCardStatus>[];
|
||||
DisclosureQuestionCardStatus questionCardStatus = DisclosureQuestionCardStatus.question;
|
||||
int? selectedOptionIndex;
|
||||
String? selectedOptionId;
|
||||
int? totalQualifiers;
|
||||
Locale savedLocale = const Locale("en", "US");
|
||||
String? gapTimeImage;
|
||||
String? gapTimeText;
|
||||
int? gapTimeType;
|
||||
|
||||
bool iAmWinner = false;
|
||||
bool isGettingQualifiers = false;
|
||||
bool isPrivilegedWithMarathon = false;
|
||||
|
||||
bool _isLoading = false;
|
||||
|
||||
bool get isLoading => _isLoading;
|
||||
|
||||
set isLoading(bool value) {
|
||||
_isLoading = value;
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
bool _isButtonEnabled = false;
|
||||
|
||||
bool get isButtonEnabled => _isButtonEnabled;
|
||||
|
||||
set isButtonEnabled(bool value) {
|
||||
_isButtonEnabled = value;
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
bool _isUserWaiting = false;
|
||||
|
||||
bool get isUserWaiting => _isUserWaiting;
|
||||
|
||||
set isUserWaiting(bool value) {
|
||||
_isUserWaiting = value;
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
bool _isMarathonCompleted = false;
|
||||
|
||||
bool get isMarathonCompleted => _isMarathonCompleted;
|
||||
|
||||
set isMarathonCompleted(bool value) {
|
||||
_isMarathonCompleted = value;
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
bool isUserOutOfGame = false;
|
||||
|
||||
set updateIsUserOutOfGame(bool value) {
|
||||
isUserOutOfGame = value;
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
int _currentQuestionNumber = 0;
|
||||
|
||||
int get currentQuestionNumber => _currentQuestionNumber;
|
||||
|
||||
set currentQuestionNumber(int value) {
|
||||
_currentQuestionNumber = value;
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
void updateCurrentQuestionSelectionStatus(DisclosureQuestionsOptionStatus value) {
|
||||
currentQuestionSelectionStatus = value;
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
int _totalMarathoners = 0;
|
||||
|
||||
int get totalMarathoners => _totalMarathoners;
|
||||
|
||||
set totalMarathoners(int value) {
|
||||
_totalMarathoners = value;
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
//****************SPONSOR VIDEO PLAYER**********
|
||||
|
||||
// 9c47d281-c5b5-4b5d-a90a-08dacb8cbdb6
|
||||
// MarathonI
|
||||
//************************************************ TIMERS **********************************************************
|
||||
|
||||
int sponsorsSecondsCounter = 0;
|
||||
int totalSponsorVideoSeconds = 0;
|
||||
Timer timerForSponsorVideo = Timer.periodic(const Duration(seconds: 1), (Timer timer) {});
|
||||
|
||||
void startTimerForSponsorVideo() {
|
||||
const Duration oneSec = Duration(seconds: 1);
|
||||
timerForSponsorVideo = Timer.periodic(
|
||||
oneSec,
|
||||
(Timer timer) async {
|
||||
sponsorsSecondsCounter++;
|
||||
if (totalSponsorVideoSeconds == 0) {
|
||||
timer.cancel();
|
||||
notifyListeners();
|
||||
return;
|
||||
} else {
|
||||
totalSponsorVideoSeconds--;
|
||||
}
|
||||
|
||||
notifyListeners();
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
int totalSecondsToWaitForMarathon = 30;
|
||||
|
||||
set updateTotalSecondsToWaitForMarathon(int value) {
|
||||
totalSecondsToWaitForMarathon = value;
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
//************************************************ FUNCTIONS **********************************************************
|
||||
|
||||
void updateLanguageAsPerMarathon(BuildContext context, DisclosureDetailsModel detailModel) {
|
||||
savedLocale = context.locale;
|
||||
if (detailModel.selectedLanguage == 1) {
|
||||
context.setLocale(const Locale("en", "US"));
|
||||
} else if (detailModel.selectedLanguage == 2) {
|
||||
context.setLocale(const Locale("ar", "SA"));
|
||||
} else if (detailModel.selectedLanguage == 3) {
|
||||
} else {
|
||||
context.setLocale(const Locale("en", "US"));
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> callGetQualifiersApi() async {
|
||||
if (AppState().getIsDemoMarathon) {
|
||||
totalQualifiers = isUserOutOfGame ? 0 : 1;
|
||||
}
|
||||
isGettingQualifiers = false;
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
Future<void> callGetSelectedWinnersApi() async {
|
||||
if (AppState().getIsDemoMarathon) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> callNextQuestionApi() async {
|
||||
if (currentQuestionNumber < (disclosureDetailsModel.totalQuestions!)) {
|
||||
if (currentQuestionNumber == 0) {
|
||||
currentQuestion = await DisclosureRepo().getDisclosureNextQuestion(currentQuestionNumber: currentQuestionNumber);
|
||||
gapTimeImage = currentQuestion.gapImage;
|
||||
gapTimeText = currentQuestion.gapText;
|
||||
gapTimeType = currentQuestion.gapType;
|
||||
updateCardData();
|
||||
if (Utils.isLoading) {
|
||||
Utils.hideLoading(AppRoutes.navigatorKey.currentContext!);
|
||||
}
|
||||
Navigator.pushReplacementNamed(AppRoutes.navigatorKey.currentContext!, AppRoutes.disclosureScreen);
|
||||
} else {
|
||||
currentQuestion = await DisclosureRepo().getDisclosureNextQuestion(currentQuestionNumber: currentQuestionNumber);
|
||||
}
|
||||
notifyListeners();
|
||||
}
|
||||
}
|
||||
|
||||
void updateCardData() {
|
||||
if (currentQuestionNumber > 0) {
|
||||
// swiperController.swipeLeft();
|
||||
}
|
||||
selectedOptionIndex = null;
|
||||
currentQuestionNumber++;
|
||||
|
||||
cardContentList.add(const DisclosureCardContent());
|
||||
totalMarathoners = currentQuestion.remainingParticipantCount!;
|
||||
questionCardStatus = DisclosureQuestionCardStatus.question;
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
void populateQuestionStatusesList() {
|
||||
answerStatusesList.clear();
|
||||
if (disclosureDetailsModel.totalQuestions != null) {
|
||||
for (int i = 0; i < disclosureDetailsModel.totalQuestions!; i++) {
|
||||
answerStatusesList.add(DisclosureQuestionCardStatus.question);
|
||||
}
|
||||
notifyListeners();
|
||||
}
|
||||
}
|
||||
|
||||
void updateAnswerStatusesList(DisclosureQuestionCardStatus status) {
|
||||
answerStatusesList[currentQuestionNumber - 1] = status;
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
void updateCurrentQuestionOptionStatus({required DisclosureQuestionsOptionStatus status, required int selectedOptIndex, required int correctOptionIndex}) {
|
||||
if (selectedOptionIndex == 0) {}
|
||||
for (int i = 0; i < currentQuestion.questionOptions!.length; i++) {
|
||||
currentQuestion.questionOptions![i].optionStatus = DisclosureQuestionsOptionStatus.unSelected;
|
||||
}
|
||||
if (status == DisclosureQuestionsOptionStatus.wrong) {
|
||||
currentQuestion.questionOptions![correctOptionIndex].optionStatus = DisclosureQuestionsOptionStatus.correct; // if person's answer is wrong we have to show him the actual right answer
|
||||
}
|
||||
currentQuestion.questionOptions![selectedOptIndex].optionStatus = status;
|
||||
selectedOptionId = currentQuestion.questionOptions![selectedOptIndex].id;
|
||||
selectedOptionIndex = selectedOptIndex;
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
void updateQuestionCardStatus(DisclosureQuestionCardStatus status) {
|
||||
if (status == DisclosureQuestionCardStatus.wrongAnswer || status == DisclosureQuestionCardStatus.skippedAnswer) {
|
||||
if (AppState().getIsDemoMarathon) {
|
||||
updateIsUserOutOfGame = true;
|
||||
}
|
||||
}
|
||||
questionCardStatus = status;
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
void getCorrectAnswerAndUpdateAnswerColor() {
|
||||
log("correctOptionIndex");
|
||||
int correctOptionIndex = -1;
|
||||
if (disclosureDetailsModel.displayCorrectAnswer ?? false) {
|
||||
correctOptionIndex = currentQuestion.questionOptions!.indexWhere((QuestionOptions element) => element.isCorrectOption ?? false);
|
||||
log("correctOptionIndex: $correctOptionIndex");
|
||||
}
|
||||
|
||||
if (selectedOptionIndex != null) {
|
||||
scheduleMicrotask(() async {
|
||||
if (AppState().getIsDemoMarathon) {
|
||||
if (currentQuestion.questionOptions![selectedOptionIndex!].isCorrectOption!) {
|
||||
updateCurrentQuestionOptionStatus(status: DisclosureQuestionsOptionStatus.correct, selectedOptIndex: selectedOptionIndex!, correctOptionIndex: correctOptionIndex);
|
||||
} else {
|
||||
updateCurrentQuestionOptionStatus(status: DisclosureQuestionsOptionStatus.wrong, selectedOptIndex: selectedOptionIndex!, correctOptionIndex: correctOptionIndex);
|
||||
}
|
||||
}
|
||||
});
|
||||
} else {
|
||||
if (!AppState().getIsDemoMarathon) {}
|
||||
}
|
||||
}
|
||||
|
||||
void updateCardStatusToAnswer() {
|
||||
if (currentQuestionNumber == 0) {
|
||||
return;
|
||||
}
|
||||
scheduleMicrotask(() async {
|
||||
await callNextQuestionApi();
|
||||
});
|
||||
|
||||
if (selectedOptionIndex == null) {
|
||||
updateQuestionCardStatus(DisclosureQuestionCardStatus.skippedAnswer);
|
||||
updateAnswerStatusesList(DisclosureQuestionCardStatus.skippedAnswer);
|
||||
return;
|
||||
}
|
||||
if (AppState().getIsDemoMarathon) {
|
||||
if (currentQuestion.questionOptions![selectedOptionIndex!].isCorrectOption!) {
|
||||
updateQuestionCardStatus(DisclosureQuestionCardStatus.correctAnswer);
|
||||
updateAnswerStatusesList(DisclosureQuestionCardStatus.correctAnswer);
|
||||
} else {
|
||||
updateQuestionCardStatus(DisclosureQuestionCardStatus.wrongAnswer);
|
||||
updateAnswerStatusesList(DisclosureQuestionCardStatus.wrongAnswer);
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (!isUserOutOfGame) {
|
||||
updateQuestionCardStatus(DisclosureQuestionCardStatus.correctAnswer);
|
||||
updateAnswerStatusesList(DisclosureQuestionCardStatus.correctAnswer);
|
||||
return;
|
||||
}
|
||||
updateQuestionCardStatus(DisclosureQuestionCardStatus.wrongAnswer);
|
||||
updateAnswerStatusesList(DisclosureQuestionCardStatus.wrongAnswer);
|
||||
}
|
||||
|
||||
void resetValues() async {
|
||||
_currentQuestionNumber = 0;
|
||||
iAmWinner = false;
|
||||
cardContentList.clear();
|
||||
timerForSponsorVideo.cancel();
|
||||
_isMarathonCompleted = false;
|
||||
isUserOutOfGame = false;
|
||||
isButtonEnabled = false;
|
||||
isUserWaiting = false;
|
||||
sponsorsSecondsCounter = 0;
|
||||
totalSponsorVideoSeconds = 0;
|
||||
totalSecondsToWaitForMarathon = 30;
|
||||
AppState().setIsDemoMarathon = false;
|
||||
currentQuestion = DisclosureQuestionModel();
|
||||
if (answerStatusesList.isNotEmpty) {
|
||||
for (int i = 0; i < answerStatusesList.length; i++) {
|
||||
answerStatusesList[i] = DisclosureQuestionCardStatus.question;
|
||||
}
|
||||
}
|
||||
AppRoutes.navigatorKey.currentContext!.setLocale(savedLocale);
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
bool checkIfPrivilegedForMarathon() {
|
||||
for (PrivilegeListModel element in AppState().privilegeListModel!) {
|
||||
if (element.serviceName == "Marathon") {
|
||||
if (element.previlege != null) {
|
||||
return element.previlege!;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
Future<void> getDisclosureDetails() async {
|
||||
isLoading = true;
|
||||
notifyListeners();
|
||||
disclosureDetailsModel = await DisclosureRepo().getDisclosureDetails();
|
||||
log("here: ${disclosureDetailsModel.descEn}");
|
||||
populateQuestionStatusesList();
|
||||
isLoading = false;
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
Future<void> onJoinDemoMarathonPressed(BuildContext context) async {
|
||||
AppState().setIsDemoMarathon = true;
|
||||
await callNextQuestionApi();
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,243 @@
|
||||
import 'dart:async';
|
||||
import 'dart:developer';
|
||||
|
||||
import 'package:easy_localization/easy_localization.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_svg/svg.dart';
|
||||
import 'package:lottie/lottie.dart';
|
||||
import 'package:mohem_flutter_app/app_state/app_state.dart';
|
||||
import 'package:mohem_flutter_app/classes/colors.dart';
|
||||
import 'package:mohem_flutter_app/classes/consts.dart';
|
||||
import 'package:mohem_flutter_app/classes/lottie_consts.dart';
|
||||
import 'package:mohem_flutter_app/config/routes.dart';
|
||||
import 'package:mohem_flutter_app/extensions/int_extensions.dart';
|
||||
import 'package:mohem_flutter_app/extensions/string_extensions.dart';
|
||||
import 'package:mohem_flutter_app/extensions/widget_extensions.dart';
|
||||
import 'package:mohem_flutter_app/generated/locale_keys.g.dart';
|
||||
import 'package:mohem_flutter_app/models/marathon/question_model.dart';
|
||||
import 'package:mohem_flutter_app/ui/disclosure/disclosure_provider.dart';
|
||||
import 'package:mohem_flutter_app/ui/disclosure/widgets/custom_status_widget.dart';
|
||||
import 'package:mohem_flutter_app/ui/disclosure/widgets/disclosure_progress_container.dart';
|
||||
import 'package:mohem_flutter_app/ui/disclosure/widgets/disclosure_question_card.dart';
|
||||
import 'package:mohem_flutter_app/ui/disclosure/widgets/disclosure_question_card_builder.dart';
|
||||
import 'package:mohem_flutter_app/widgets/app_bar_widget.dart';
|
||||
import 'package:mohem_flutter_app/widgets/button/default_button.dart';
|
||||
import 'package:mohem_flutter_app/widgets/dialogs/confirm_dialog.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
class DisclosureScreen extends StatelessWidget {
|
||||
const DisclosureScreen({Key? key}) : super(key: key);
|
||||
|
||||
Widget getSuccessWidget({required int? gapType, required String? gapImage, required String? gapText}) {
|
||||
if (gapType == 1) {
|
||||
if (gapText == null) {
|
||||
return Image.asset(MyLottieConsts.congratsGif, height: 200);
|
||||
}
|
||||
return gapText.toText18(color: MyColors.darkTextColor, isCentered: true);
|
||||
}
|
||||
if (gapType == 0) {
|
||||
if (gapImage == null) {
|
||||
return Image.asset(MyLottieConsts.congratsGif, height: 200);
|
||||
}
|
||||
return Image.network(ApiConsts.marathonBaseUrlServices + gapImage, height: 200);
|
||||
}
|
||||
return Image.asset(MyLottieConsts.congratsGif, height: 200);
|
||||
}
|
||||
|
||||
Widget getDemoWinnerWidget(BuildContext context, {required DisclosureProvider provider}) {
|
||||
return provider.isUserOutOfGame
|
||||
? Column(
|
||||
children: <Widget>[
|
||||
Lottie.asset(MyLottieConsts.noWinnerLottie),
|
||||
Center(
|
||||
child: LocaleKeys.noWinner.tr().toText18(color: MyColors.grey3AColor, isCentered: true),
|
||||
),
|
||||
],
|
||||
)
|
||||
: Stack(
|
||||
children: <Widget>[
|
||||
Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: <Widget>[
|
||||
SizedBox(
|
||||
height: 50,
|
||||
child: Stack(
|
||||
children: <Widget>[
|
||||
Align(
|
||||
alignment: Alignment.center,
|
||||
child: SvgPicture.asset("assets/images/winner_ribbon.svg", height: 50),
|
||||
),
|
||||
Align(
|
||||
alignment: Alignment.center,
|
||||
child: LocaleKeys.winner.tr().toText32(color: MyColors.white, isBold: true, isCentered: true).paddingOnly(top: 07),
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
16.height,
|
||||
Column(
|
||||
children: <Widget>[
|
||||
displayLocalizedContent(
|
||||
isPhoneLangArabic: AppState().isArabic(context),
|
||||
selectedLanguage: provider.disclosureDetailsModel.selectedLanguage!,
|
||||
arabicContent: AppState().memberInformationList!.eMPLOYEEDISPLAYNAMEAr ?? "",
|
||||
englishContent: AppState().memberInformationList!.eMPLOYEEDISPLAYNAMEEn ?? "",
|
||||
).toText22(
|
||||
color: MyColors.grey3AColor,
|
||||
isCentered: true,
|
||||
),
|
||||
8.height,
|
||||
AppState().memberInformationList!.eMPLOYEENUMBER!.toText22(color: MyColors.grey57Color),
|
||||
],
|
||||
),
|
||||
60.height,
|
||||
if (provider.disclosureDetailsModel.sponsors != null && provider.disclosureDetailsModel.sponsors!.isNotEmpty) ...<Widget>[
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: <Widget>[
|
||||
"${LocaleKeys.sponsoredBy.tr()} ".toText14(color: MyColors.grey77Color),
|
||||
displayLocalizedContent(
|
||||
isPhoneLangArabic: AppState().isArabic(context),
|
||||
selectedLanguage: provider.disclosureDetailsModel.selectedLanguage!,
|
||||
englishContent: provider.disclosureDetailsModel.sponsors!.first.nameEn!,
|
||||
arabicContent: provider.disclosureDetailsModel.sponsors!.first.nameAr!,
|
||||
).toText14(
|
||||
color: MyColors.darkTextColor,
|
||||
isBold: true,
|
||||
),
|
||||
],
|
||||
),
|
||||
5.height,
|
||||
Image.network(
|
||||
ApiConsts.marathonBaseUrlServices + provider.disclosureDetailsModel.sponsors!.first.logo!,
|
||||
height: 50,
|
||||
width: 150,
|
||||
fit: BoxFit.contain,
|
||||
errorBuilder: (BuildContext context, Object exception, StackTrace? stackTrace) {
|
||||
return Image.asset("assets/images/logos/main_mohemm_logo.png", height: 50, width: 150);
|
||||
},
|
||||
)
|
||||
],
|
||||
],
|
||||
),
|
||||
Lottie.asset(MyLottieConsts.celebrate1Lottie),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
DisclosureProvider provider = context.watch<DisclosureProvider>();
|
||||
return WillPopScope(
|
||||
child: Scaffold(
|
||||
appBar: AppBarWidget(
|
||||
context,
|
||||
title: LocaleKeys.disclosure.tr(),
|
||||
onHomeTapped: () {
|
||||
if (provider.questionCardStatus == QuestionCardStatus.winnerFound) {
|
||||
provider.resetValues();
|
||||
provider.getDisclosureDetails();
|
||||
Navigator.of(context).popUntil(ModalRoute.withName(AppRoutes.dashboard));
|
||||
} else {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (BuildContext context) => ConfirmDialog(
|
||||
message: LocaleKeys.youWantToLeaveMarathon.tr(),
|
||||
onTap: () {
|
||||
provider.resetValues();
|
||||
provider.getDisclosureDetails();
|
||||
Navigator.of(context).popUntil(ModalRoute.withName(AppRoutes.dashboard));
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
},
|
||||
onBackTapped: () {
|
||||
if (provider.questionCardStatus == QuestionCardStatus.winnerFound) {
|
||||
provider.resetValues();
|
||||
provider.getDisclosureDetails();
|
||||
Navigator.of(context).popUntil(ModalRoute.withName(AppRoutes.dashboard));
|
||||
} else {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (BuildContext context) => ConfirmDialog(
|
||||
message: LocaleKeys.youWantToLeaveMarathon.tr(),
|
||||
onTap: () {
|
||||
provider.resetValues();
|
||||
Navigator.of(context).popUntil(ModalRoute.withName(AppRoutes.dashboard));
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
},
|
||||
),
|
||||
body: Column(
|
||||
children: <Widget>[
|
||||
ListView(
|
||||
shrinkWrap: true,
|
||||
children: <Widget>[
|
||||
10.height,
|
||||
if (provider.questionCardStatus == QuestionCardStatus.findingWinner)
|
||||
...<Widget>[]
|
||||
else if (provider.questionCardStatus == QuestionCardStatus.winnerFound)
|
||||
...<Widget>[]
|
||||
else ...<Widget>[
|
||||
DisclosureProgressContainer(provider: provider).paddingOnly(left: 21, right: 21),
|
||||
],
|
||||
DisclosureQuestionCardBuilder(
|
||||
onQuestion: (BuildContext context) => const DisclosureQuestionCard(),
|
||||
onCompleted: (BuildContext context) => DisclosureCustomStatusWidget(
|
||||
asset: Lottie.asset(MyLottieConsts.allQuestions, height: 200),
|
||||
title: LocaleKeys.congrats.tr().toText22(color: MyColors.greenColor),
|
||||
subTitle: LocaleKeys.allQuestionsCorrect.toText18(color: MyColors.darkTextColor, isCentered: true),
|
||||
),
|
||||
onCorrectAnswer: (BuildContext context) => DisclosureCustomStatusWidget(
|
||||
asset: getSuccessWidget(gapType: provider.gapTimeType, gapImage: provider.gapTimeImage, gapText: provider.gapTimeText),
|
||||
title: LocaleKeys.congrats.tr().toText22(color: MyColors.greenColor),
|
||||
subTitle: LocaleKeys.yourAnswerCorrect.tr().toText18(color: MyColors.darkTextColor, isCentered: true),
|
||||
),
|
||||
onWinner: (BuildContext context) => const SizedBox(),
|
||||
onWrongAnswer: (BuildContext context) => DisclosureCustomStatusWidget(
|
||||
asset: Image.asset(MyLottieConsts.wrongAnswerGif, height: 200),
|
||||
title: LocaleKeys.oops.tr().toText22(color: MyColors.redColor),
|
||||
subTitle: LocaleKeys.wrongAnswer.tr().toText18(color: MyColors.darkTextColor, isCentered: true),
|
||||
),
|
||||
onSkippedAnswer: (BuildContext context) => DisclosureCustomStatusWidget(
|
||||
asset: Image.asset(MyLottieConsts.wrongAnswerGif, height: 200),
|
||||
title: LocaleKeys.oops.tr().toText22(color: MyColors.redColor),
|
||||
subTitle: LocaleKeys.youMissedTheQuestion.tr().toText18(color: MyColors.darkTextColor, isCentered: true),
|
||||
),
|
||||
onFindingWinner: (BuildContext context) => DisclosureCustomStatusWidget(
|
||||
asset: Lottie.asset(MyLottieConsts.winnerLottie, height: 168, reverse: false, repeat: true),
|
||||
title: LocaleKeys.fingersCrossed.tr().toText22(color: MyColors.greenColor),
|
||||
subTitle: LocaleKeys.winnerSelectedRandomly.tr().toText18(color: MyColors.darkTextColor, isCentered: true),
|
||||
),
|
||||
questionCardStatus: provider.questionCardStatus,
|
||||
).paddingOnly(top: 12, left: 21, right: 21),
|
||||
// 50.height,
|
||||
],
|
||||
).expanded,
|
||||
DefaultButton(
|
||||
LocaleKeys.next.tr(),
|
||||
() {},
|
||||
).insideContainer,
|
||||
],
|
||||
),
|
||||
),
|
||||
onWillPop: () {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (BuildContext context) => ConfirmDialog(
|
||||
message: LocaleKeys.youWantToLeaveMarathon.tr(),
|
||||
onTap: () {
|
||||
provider.resetValues();
|
||||
Navigator.of(context).popUntil(ModalRoute.withName(AppRoutes.dashboard));
|
||||
},
|
||||
),
|
||||
);
|
||||
return Future<bool>.value(false);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,109 @@
|
||||
import 'package:easy_localization/easy_localization.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:lottie/lottie.dart';
|
||||
import 'package:mohem_flutter_app/classes/colors.dart';
|
||||
import 'package:mohem_flutter_app/classes/decorations_helper.dart';
|
||||
import 'package:mohem_flutter_app/classes/lottie_consts.dart';
|
||||
import 'package:mohem_flutter_app/config/routes.dart';
|
||||
import 'package:mohem_flutter_app/extensions/string_extensions.dart';
|
||||
import 'package:mohem_flutter_app/extensions/widget_extensions.dart';
|
||||
import 'package:mohem_flutter_app/generated/locale_keys.g.dart';
|
||||
import 'package:mohem_flutter_app/ui/disclosure/disclosure_provider.dart';
|
||||
import 'package:mohem_flutter_app/widgets/app_bar_widget.dart';
|
||||
import 'package:mohem_flutter_app/widgets/dialogs/confirm_dialog.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
class DisclosureWaitingScreen extends StatelessWidget {
|
||||
const DisclosureWaitingScreen({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
DisclosureProvider provider = context.watch<DisclosureProvider>();
|
||||
return WillPopScope(
|
||||
onWillPop: () {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (BuildContext context) => ConfirmDialog(
|
||||
message: LocaleKeys.youWantToLeaveMarathon.tr(),
|
||||
onTap: () {
|
||||
provider.resetValues();
|
||||
Navigator.of(context).popUntil(ModalRoute.withName(AppRoutes.dashboard));
|
||||
},
|
||||
),
|
||||
);
|
||||
return Future<bool>.value(false);
|
||||
},
|
||||
child: Scaffold(
|
||||
appBar: AppBarWidget(
|
||||
context,
|
||||
title: LocaleKeys.brainMarathon.tr(),
|
||||
onHomeTapped: () {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (BuildContext context) => ConfirmDialog(
|
||||
message: LocaleKeys.youWantToLeaveMarathon.tr(),
|
||||
onTap: () {
|
||||
provider.resetValues();
|
||||
Navigator.of(context).popUntil(ModalRoute.withName(AppRoutes.dashboard));
|
||||
},
|
||||
),
|
||||
);
|
||||
},
|
||||
onBackTapped: () {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (BuildContext context) => ConfirmDialog(
|
||||
message: LocaleKeys.youWantToLeaveMarathon.tr(),
|
||||
onTap: () {
|
||||
provider.resetValues();
|
||||
Navigator.of(context).popUntil(ModalRoute.withName(AppRoutes.dashboard));
|
||||
},
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
body: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: <Widget>[
|
||||
Container(
|
||||
width: double.infinity,
|
||||
margin: const EdgeInsets.all(21),
|
||||
decoration: MyDecorations.shadowDecoration,
|
||||
child: Stack(
|
||||
children: <Widget>[
|
||||
Align(
|
||||
child: Lottie.asset(MyLottieConsts.marathonWaiting, height: 200),
|
||||
),
|
||||
Align(
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: <Widget>[
|
||||
LocaleKeys.startingIn.tr().toText16(),
|
||||
(provider.totalSecondsToWaitForMarathon < 10 ? "0${provider.totalSecondsToWaitForMarathon.toString()}" : provider.totalSecondsToWaitForMarathon.toString()).toText18(color: provider.totalSecondsToWaitForMarathon < 5 ? MyColors.redColor : MyColors.black),
|
||||
],
|
||||
),
|
||||
),
|
||||
// Align(
|
||||
// child: Column(
|
||||
// mainAxisAlignment: MainAxisAlignment.end,
|
||||
// children: <Widget>[
|
||||
// InkWell(
|
||||
// onTap: () {
|
||||
// provider.callNextQuestionApi();
|
||||
// provider.timerToWaitForMarathon.cancel();
|
||||
// },
|
||||
// child: "Join Now".toText16(),
|
||||
// ).paddingOnly(bottom: 20),
|
||||
// ],
|
||||
// ),
|
||||
// ),
|
||||
],
|
||||
),
|
||||
).expanded,
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,176 @@
|
||||
import 'dart:ui' as ui;
|
||||
|
||||
import 'package:auto_size_text/auto_size_text.dart';
|
||||
import 'package:easy_localization/easy_localization.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_countdown_timer/current_remaining_time.dart';
|
||||
import 'package:flutter_countdown_timer/flutter_countdown_timer.dart';
|
||||
import 'package:mohem_flutter_app/classes/colors.dart';
|
||||
import 'package:mohem_flutter_app/generated/locale_keys.g.dart';
|
||||
import 'package:mohem_flutter_app/main.dart';
|
||||
import 'package:mohem_flutter_app/ui/disclosure/disclosure_provider.dart';
|
||||
|
||||
class DisclosureCountdownTimerForMainScreen extends StatelessWidget {
|
||||
final int timeToMarathon;
|
||||
final DisclosureProvider provider;
|
||||
|
||||
DisclosureCountdownTimerForMainScreen({
|
||||
Key? key,
|
||||
required this.provider,
|
||||
required this.timeToMarathon,
|
||||
}) : super(key: key);
|
||||
|
||||
final TextStyle styleTextHome = TextStyle(
|
||||
color: MyColors.white.withOpacity(0.45),
|
||||
fontStyle: FontStyle.italic,
|
||||
fontWeight: FontWeight.w800,
|
||||
letterSpacing: -0.4,
|
||||
);
|
||||
|
||||
final TextStyle styleDigitHome = TextStyle(
|
||||
height: 22 / 27,
|
||||
color: MyColors.white,
|
||||
fontSize: isTablet ? 30 : 15,
|
||||
fontStyle: FontStyle.italic,
|
||||
letterSpacing: -1.44,
|
||||
fontWeight: FontWeight.bold,
|
||||
);
|
||||
|
||||
final TextStyle styleTextMarathon = const TextStyle(
|
||||
fontSize: 10,
|
||||
fontStyle: FontStyle.normal,
|
||||
fontWeight: FontWeight.w600,
|
||||
color: MyColors.grey57Color,
|
||||
letterSpacing: -0.4,
|
||||
);
|
||||
|
||||
final TextStyle styleDigitMarathon = const TextStyle(
|
||||
height: 23 / 24,
|
||||
color: MyColors.darkTextColor,
|
||||
fontSize: 34,
|
||||
letterSpacing: -1.44,
|
||||
fontWeight: FontWeight.bold,
|
||||
);
|
||||
|
||||
Widget buildSeparator() {
|
||||
return AutoSizeText(
|
||||
" : ",
|
||||
maxFontSize: 24,
|
||||
minFontSize: 20,
|
||||
style: styleDigitHome,
|
||||
);
|
||||
}
|
||||
|
||||
Widget getTimeDigit(String text) {
|
||||
return AutoSizeText(
|
||||
text,
|
||||
maxFontSize: 24,
|
||||
minFontSize: 20,
|
||||
style: styleDigitHome,
|
||||
);
|
||||
}
|
||||
|
||||
Widget getTimeText(String text) {
|
||||
return AutoSizeText(
|
||||
text,
|
||||
minFontSize: 7,
|
||||
maxFontSize: 8,
|
||||
style: styleTextHome,
|
||||
);
|
||||
}
|
||||
|
||||
Widget buildEmptyWidget() {
|
||||
return Directionality(
|
||||
textDirection: ui.TextDirection.ltr,
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: <Widget>[
|
||||
Column(
|
||||
children: <Widget>[
|
||||
getTimeDigit("00"),
|
||||
getTimeText(LocaleKeys.days.tr()),
|
||||
],
|
||||
),
|
||||
buildSeparator(),
|
||||
Column(
|
||||
children: <Widget>[
|
||||
getTimeDigit("00"),
|
||||
getTimeText(LocaleKeys.hours.tr()),
|
||||
],
|
||||
),
|
||||
buildSeparator(),
|
||||
Column(
|
||||
children: <Widget>[
|
||||
getTimeDigit("00"),
|
||||
getTimeText(LocaleKeys.minutes.tr()),
|
||||
],
|
||||
),
|
||||
buildSeparator(),
|
||||
Column(
|
||||
children: <Widget>[
|
||||
getTimeDigit("00"),
|
||||
getTimeText(LocaleKeys.seconds.tr()),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget buildCountdownTimer(CurrentRemainingTime? time) {
|
||||
if (time == null) {
|
||||
return buildEmptyWidget();
|
||||
}
|
||||
|
||||
return Directionality(
|
||||
textDirection: ui.TextDirection.ltr,
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: <Widget>[
|
||||
Column(
|
||||
children: <Widget>[
|
||||
time.days == null ? getTimeDigit("00") : getTimeDigit(time.days! < 10 ? "0${time.days.toString()}" : time.days.toString()),
|
||||
getTimeText(LocaleKeys.days.tr()),
|
||||
],
|
||||
),
|
||||
buildSeparator(),
|
||||
Column(
|
||||
children: <Widget>[
|
||||
time.hours == null ? getTimeDigit("00") : getTimeDigit(time.hours! < 10 ? "0${time.hours.toString()}" : time.hours.toString()),
|
||||
getTimeText(LocaleKeys.hours.tr()),
|
||||
],
|
||||
),
|
||||
buildSeparator(),
|
||||
Column(
|
||||
children: <Widget>[
|
||||
time.min == null ? getTimeDigit("00") : getTimeDigit(time.min! < 10 ? "0${time.min.toString()}" : time.min.toString()),
|
||||
getTimeText(LocaleKeys.minutes.tr()),
|
||||
],
|
||||
),
|
||||
buildSeparator(),
|
||||
Column(
|
||||
children: <Widget>[
|
||||
time.sec == null ? getTimeDigit("00") : getTimeDigit(time.sec! < 10 ? "0${time.sec.toString()}" : time.sec.toString()),
|
||||
getTimeText(LocaleKeys.seconds.tr()),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return CountdownTimer(
|
||||
endTime: timeToMarathon,
|
||||
onEnd: null,
|
||||
widgetBuilder: (BuildContext context, CurrentRemainingTime? time) {
|
||||
return buildCountdownTimer(time);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,36 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:mohem_flutter_app/classes/decorations_helper.dart';
|
||||
import 'package:mohem_flutter_app/extensions/int_extensions.dart';
|
||||
|
||||
class DisclosureCustomStatusWidget extends StatelessWidget {
|
||||
final Widget asset;
|
||||
final Widget title;
|
||||
final Widget subTitle;
|
||||
|
||||
const DisclosureCustomStatusWidget({
|
||||
Key? key,
|
||||
required this.asset,
|
||||
required this.title,
|
||||
required this.subTitle,
|
||||
}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
width: double.infinity,
|
||||
height: 440,
|
||||
decoration: MyDecorations.shadowDecoration,
|
||||
padding: const EdgeInsets.symmetric(vertical: 20, horizontal: 20),
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: <Widget>[
|
||||
asset,
|
||||
50.height,
|
||||
title,
|
||||
10.height,
|
||||
subTitle,
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,556 @@
|
||||
// import 'dart:developer';
|
||||
// import 'dart:math' as math;
|
||||
//
|
||||
// import 'package:easy_localization/easy_localization.dart';
|
||||
// import 'package:flutter/foundation.dart';
|
||||
// import 'package:flutter/material.dart';
|
||||
// import 'package:flutter_svg/flutter_svg.dart';
|
||||
// import 'package:mohem_flutter_app/app_state/app_state.dart';
|
||||
// import 'package:mohem_flutter_app/classes/colors.dart';
|
||||
// import 'package:mohem_flutter_app/classes/decorations_helper.dart';
|
||||
// import 'package:mohem_flutter_app/classes/utils.dart';
|
||||
// import 'package:mohem_flutter_app/config/routes.dart';
|
||||
// import 'package:mohem_flutter_app/extensions/int_extensions.dart';
|
||||
// import 'package:mohem_flutter_app/extensions/string_extensions.dart';
|
||||
// import 'package:mohem_flutter_app/extensions/widget_extensions.dart';
|
||||
// import 'package:mohem_flutter_app/generated/locale_keys.g.dart';
|
||||
// import 'package:mohem_flutter_app/main.dart';
|
||||
// import 'package:mohem_flutter_app/ui/disclosure/disclosure_provider.dart';
|
||||
// import 'package:mohem_flutter_app/ui/disclosure/widgets/countdown_timer_main_screen.dart';
|
||||
// import 'package:provider/provider.dart';
|
||||
//
|
||||
// // It is used to pass a dummy time to test Marathon
|
||||
// int dummyTime = DateTime.now().millisecondsSinceEpoch + 8690;
|
||||
//
|
||||
// class DisclosureBanner extends StatelessWidget {
|
||||
// const DisclosureBanner({Key? key}) : super(key: key);
|
||||
//
|
||||
// Widget getUnPrivilegedMarathon(BuildContext context) {
|
||||
// return 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>[
|
||||
// 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)
|
||||
// ? Align(
|
||||
// alignment: Alignment.topRight,
|
||||
// child: SizedBox(
|
||||
// height: isTablet ? 30 : 20,
|
||||
// width: isTablet ? 45 : 35,
|
||||
// child: Transform.rotate(
|
||||
// angle: math.pi / 4.5,
|
||||
// child: Text(
|
||||
// LocaleKeys.brainMarathon.tr(),
|
||||
// textAlign: TextAlign.center,
|
||||
// maxLines: 2,
|
||||
// style: TextStyle(
|
||||
// color: MyColors.white,
|
||||
// fontWeight: FontWeight.bold,
|
||||
// fontSize: isTablet ? 8 : 6,
|
||||
// height: 1.2,
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
// ).paddingOnly(top: 5)
|
||||
// : Align(
|
||||
// alignment: Alignment.topLeft,
|
||||
// child: SizedBox(
|
||||
// height: isTablet ? 30 : 20,
|
||||
// width: isTablet ? 45 : 35,
|
||||
// child: Transform.rotate(
|
||||
// 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,
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
// ).paddingOnly(top: 5),
|
||||
// Container(
|
||||
// height: double.infinity,
|
||||
// width: double.infinity,
|
||||
// color: Colors.black.withOpacity(0.6),
|
||||
// child: const Icon(
|
||||
// Icons.lock_rounded,
|
||||
// color: MyColors.lightGreyIconColor,
|
||||
// ),
|
||||
// ),
|
||||
// ],
|
||||
// ),
|
||||
// );
|
||||
// }
|
||||
//
|
||||
// Widget getNoUpcomingMarathonWidget(BuildContext context) {
|
||||
// return 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>[
|
||||
// Column(
|
||||
// mainAxisAlignment: MainAxisAlignment.center,
|
||||
// crossAxisAlignment: CrossAxisAlignment.start,
|
||||
// mainAxisSize: MainAxisSize.min,
|
||||
// children: <Widget>[
|
||||
// AppState().isArabic(context) ? 0.height : 5.height,
|
||||
// Text(
|
||||
// LocaleKeys.noUpcoming.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,
|
||||
// ),
|
||||
// ),
|
||||
// Text(
|
||||
// LocaleKeys.youCanPlayDemo.tr(),
|
||||
// style: TextStyle(
|
||||
// fontSize: isTablet ? 20 : 11,
|
||||
// fontStyle: FontStyle.italic,
|
||||
// fontWeight: FontWeight.w600,
|
||||
// color: MyColors.white.withOpacity(0.83),
|
||||
// letterSpacing: -0.4,
|
||||
// ),
|
||||
// ),
|
||||
// ],
|
||||
// ).paddingOnly(
|
||||
// left: AppState().isArabic(context) ? 12 : 3,
|
||||
// right: AppState().isArabic(context) ? 3 : 12,
|
||||
// )
|
||||
// ],
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
// ],
|
||||
// ),
|
||||
// ),
|
||||
// AppState().isArabic(context)
|
||||
// ? Align(
|
||||
// alignment: Alignment.topRight,
|
||||
// child: SizedBox(
|
||||
// height: isTablet ? 30 : 20,
|
||||
// width: isTablet ? 45 : 35,
|
||||
// child: Transform.rotate(
|
||||
// angle: math.pi / 4.5,
|
||||
// child: Text(
|
||||
// LocaleKeys.brainMarathon.tr(),
|
||||
// textAlign: TextAlign.center,
|
||||
// maxLines: 2,
|
||||
// style: TextStyle(
|
||||
// color: MyColors.white,
|
||||
// fontWeight: FontWeight.bold,
|
||||
// fontSize: isTablet ? 8 : 6,
|
||||
// height: 1.2,
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
// ).paddingOnly(top: 5)
|
||||
// : Align(
|
||||
// alignment: Alignment.topLeft,
|
||||
// child: SizedBox(
|
||||
// height: isTablet ? 30 : 20,
|
||||
// width: isTablet ? 45 : 35,
|
||||
// child: Transform.rotate(
|
||||
// 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,
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
// ).paddingOnly(top: 5),
|
||||
// ],
|
||||
// ),
|
||||
// ).onPress(() {
|
||||
// Navigator.pushNamed(context, AppRoutes.marathonIntroScreen);
|
||||
// });
|
||||
// }
|
||||
//
|
||||
// @override
|
||||
// Widget build(BuildContext context) {
|
||||
// DisclosureProvider provider = context.read<DisclosureProvider>();
|
||||
// // if(provider.isUserWaiting) {
|
||||
// // provider.isUserWaiting = false;
|
||||
// // provider.getMarathonDetailsFromApi();
|
||||
// // }
|
||||
// return !provider.isPrivilegedWithMarathon
|
||||
// ? getUnPrivilegedMarathon(context)
|
||||
// : provider.isUpComingMarathon
|
||||
// ? 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>[
|
||||
// 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,
|
||||
// ),
|
||||
// ),
|
||||
// Flexible(
|
||||
// child: Text(
|
||||
// displayLocalizedContent(
|
||||
// isPhoneLangArabic: AppState().isArabic(context),
|
||||
// selectedLanguage: provider.marathonDetailModel.selectedLanguage ?? 0,
|
||||
// englishContent: provider.marathonDetailModel.titleEn ?? "",
|
||||
// arabicContent: provider.marathonDetailModel.titleAr ?? "",
|
||||
// ),
|
||||
// overflow: TextOverflow.ellipsis,
|
||||
// style: TextStyle(
|
||||
// fontStyle: FontStyle.italic,
|
||||
// fontSize: isTablet ? 30 : 19,
|
||||
// fontWeight: FontWeight.bold,
|
||||
// color: MyColors.white.withOpacity(0.83),
|
||||
// height: 32 / 22,
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
// isTablet ? 10.height : 3.height,
|
||||
// DisclosureCountdownTimerForMainScreen(
|
||||
// timeToMarathon: DateTime.parse(provider.marathonDetailModel.startTime!).millisecondsSinceEpoch,
|
||||
// provider: provider,
|
||||
// ),
|
||||
// ],
|
||||
// ).paddingOnly(
|
||||
// left: AppState().isArabic(context) ? 12 : 3,
|
||||
// right: AppState().isArabic(context) ? 3 : 12,
|
||||
// )
|
||||
// ],
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
// ],
|
||||
// ),
|
||||
// ),
|
||||
// AppState().isArabic(context)
|
||||
// ? Align(
|
||||
// alignment: Alignment.topRight,
|
||||
// child: SizedBox(
|
||||
// height: isTablet ? 30 : 20,
|
||||
// width: isTablet ? 45 : 35,
|
||||
// child: Transform.rotate(
|
||||
// angle: math.pi / 4.5,
|
||||
// child: Text(
|
||||
// LocaleKeys.brainMarathon.tr(),
|
||||
// textAlign: TextAlign.center,
|
||||
// maxLines: 2,
|
||||
// style: TextStyle(
|
||||
// color: MyColors.white,
|
||||
// fontWeight: FontWeight.bold,
|
||||
// fontSize: isTablet ? 8 : 6,
|
||||
// height: 1.2,
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
// ).paddingOnly(top: 5)
|
||||
// : Align(
|
||||
// alignment: Alignment.topLeft,
|
||||
// child: SizedBox(
|
||||
// height: isTablet ? 30 : 20,
|
||||
// width: isTablet ? 45 : 35,
|
||||
// child: Transform.rotate(
|
||||
// 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,
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
// ).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 > 5 && provider.marathonDetailModel.sponsors != null && provider.marathonDetailModel.sponsors!.isNotEmpty) {
|
||||
// Utils.showLoading(context);
|
||||
// // try {
|
||||
// // await provider.initializeVideoPlayer().then((_) {
|
||||
// // Utils.hideLoading(context);
|
||||
// // provider.startTimerForSponsorVideo();
|
||||
// // Navigator.pushNamed(context, AppRoutes.marathonSponsorVideoScreen);
|
||||
// // });
|
||||
// // } catch (e) {
|
||||
// // if (kDebugMode) {
|
||||
// // log("Error in VideoPlayer: ${e.toString()}");
|
||||
// // }
|
||||
// // Utils.hideLoading(context);
|
||||
// // Navigator.pushNamed(context, AppRoutes.marathonIntroScreen);
|
||||
// // }
|
||||
// } else {
|
||||
// Navigator.pushNamed(context, AppRoutes.marathonIntroScreen);
|
||||
// }
|
||||
// provider.updateLanguageAsPerMarathon(context, provider.isUpComingMarathon ? provider.marathonDetailModel : provider.demoMarathonDetailModel);
|
||||
// }),
|
||||
// )
|
||||
// : getNoUpcomingMarathonWidget(context);
|
||||
// }
|
||||
// }
|
||||
@ -0,0 +1,122 @@
|
||||
import 'package:easy_localization/easy_localization.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:mohem_flutter_app/app_state/app_state.dart';
|
||||
import 'package:mohem_flutter_app/classes/colors.dart';
|
||||
import 'package:mohem_flutter_app/classes/consts.dart';
|
||||
import 'package:mohem_flutter_app/classes/decorations_helper.dart';
|
||||
import 'package:mohem_flutter_app/extensions/int_extensions.dart';
|
||||
import 'package:mohem_flutter_app/extensions/string_extensions.dart';
|
||||
import 'package:mohem_flutter_app/extensions/widget_extensions.dart';
|
||||
import 'package:mohem_flutter_app/generated/locale_keys.g.dart';
|
||||
import 'package:mohem_flutter_app/models/disclosure/disclosure_details_model.dart';
|
||||
import 'package:mohem_flutter_app/ui/disclosure/disclosure_provider.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
class DisclosureDetailsCard extends StatelessWidget {
|
||||
final DisclosureDetailsModel disclosureDetailsCard;
|
||||
|
||||
const DisclosureDetailsCard({Key? key, required this.disclosureDetailsCard}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
width: double.infinity,
|
||||
decoration: MyDecorations.shadowDecoration,
|
||||
padding: const EdgeInsets.symmetric(vertical: 10, horizontal: 14),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: <Widget>[
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.end,
|
||||
children: [
|
||||
Container(
|
||||
decoration: BoxDecoration(color: MyColors.yellowColorII, borderRadius: BorderRadius.circular(100)),
|
||||
child: LocaleKeys.demo.tr().toText10(color: MyColors.white).paddingAll(4),
|
||||
),
|
||||
],
|
||||
),
|
||||
7.height,
|
||||
LocaleKeys.contestTopicAbout.tr().toText16(color: MyColors.grey77Color),
|
||||
displayLocalizedContent(
|
||||
isPhoneLangArabic: AppState().isArabic(context),
|
||||
selectedLanguage: disclosureDetailsCard.selectedLanguage ?? 0,
|
||||
englishContent: disclosureDetailsCard.titleEn ?? "",
|
||||
arabicContent: disclosureDetailsCard.titleAr ?? "",
|
||||
).toText20(color: MyColors.textMixColor, isBold: true),
|
||||
Row(
|
||||
children: <Widget>[
|
||||
Flexible(
|
||||
child: displayLocalizedContent(
|
||||
isPhoneLangArabic: AppState().isArabic(context),
|
||||
selectedLanguage: disclosureDetailsCard.selectedLanguage ?? 0,
|
||||
englishContent: disclosureDetailsCard.descEn ?? "",
|
||||
arabicContent: disclosureDetailsCard.descAr ?? "",
|
||||
).toText14(
|
||||
color: MyColors.grey77Color,
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
if (disclosureDetailsCard.sponsors != null && disclosureDetailsCard.sponsors!.isNotEmpty) ...<Widget>[
|
||||
5.height,
|
||||
disclosureDetailsCard.sponsors!.first.sponsorPrizes != null
|
||||
? Row(
|
||||
children: <Widget>[
|
||||
"${LocaleKeys.prize.tr()} ".toText16(color: MyColors.grey77Color),
|
||||
Expanded(
|
||||
child: SizedBox(
|
||||
height: 30,
|
||||
child: ListView.builder(
|
||||
scrollDirection: Axis.horizontal,
|
||||
shrinkWrap: true,
|
||||
itemCount: disclosureDetailsCard.sponsors!.first.sponsorPrizes!.length,
|
||||
itemBuilder: (BuildContext context, int index) {
|
||||
SponsorPrizes prizes = disclosureDetailsCard.sponsors!.first.sponsorPrizes![index];
|
||||
return Container(
|
||||
decoration: BoxDecoration(color: MyColors.backgroundColor, borderRadius: BorderRadius.circular(100), border: Border.all(color: MyColors.grey57Color.withOpacity(0.1))),
|
||||
child: displayLocalizedContent(
|
||||
isPhoneLangArabic: AppState().isArabic(context),
|
||||
selectedLanguage: disclosureDetailsCard.selectedLanguage ?? 0,
|
||||
englishContent: prizes.marathonPrizeEn ?? "",
|
||||
arabicContent: prizes.marathonPrizeAr ?? "",
|
||||
).toText16(color: MyColors.greenColor, isBold: true).paddingOnly(left: 5, right: 5),
|
||||
).paddingOnly(left: 5);
|
||||
},
|
||||
),
|
||||
),
|
||||
)
|
||||
],
|
||||
)
|
||||
: const SizedBox(),
|
||||
Row(
|
||||
children: <Widget>[
|
||||
"${LocaleKeys.sponsoredBy.tr()} ".toText16(color: MyColors.grey77Color),
|
||||
displayLocalizedContent(
|
||||
isPhoneLangArabic: AppState().isArabic(context),
|
||||
selectedLanguage: disclosureDetailsCard.selectedLanguage ?? 0,
|
||||
englishContent: disclosureDetailsCard.sponsors?.first.nameEn ?? "",
|
||||
arabicContent: disclosureDetailsCard.sponsors?.first.nameAr ?? "",
|
||||
).toText16(color: MyColors.darkTextColor, isBold: true),
|
||||
],
|
||||
),
|
||||
10.height,
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: <Widget>[
|
||||
Image.network(
|
||||
ApiConsts.marathonBaseUrlServices + disclosureDetailsCard.sponsors!.first.logo!,
|
||||
height: 50,
|
||||
width: 150,
|
||||
fit: BoxFit.contain,
|
||||
errorBuilder: (BuildContext context, Object exception, StackTrace? stackTrace) {
|
||||
return Image.asset("assets/images/logos/main_mohemm_logo.png", height: 50, width: 150);
|
||||
},
|
||||
)
|
||||
],
|
||||
),
|
||||
]
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,51 @@
|
||||
// ignore_for_file: always_specify_types
|
||||
|
||||
import 'package:easy_localization/easy_localization.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:mohem_flutter_app/classes/colors.dart';
|
||||
import 'package:mohem_flutter_app/extensions/widget_extensions.dart';
|
||||
import 'package:mohem_flutter_app/generated/locale_keys.g.dart';
|
||||
import 'package:mohem_flutter_app/ui/disclosure/disclosure_provider.dart';
|
||||
import 'package:mohem_flutter_app/widgets/button/default_button.dart';
|
||||
|
||||
class DisclosureFooter extends StatelessWidget {
|
||||
final DisclosureProvider provider;
|
||||
|
||||
const DisclosureFooter({Key? key, required this.provider}) : super(key: key);
|
||||
|
||||
Widget buildNoteForDemo() {
|
||||
return RichText(
|
||||
text: TextSpan(
|
||||
children: <InlineSpan>[
|
||||
TextSpan(
|
||||
text: LocaleKeys.note.tr(),
|
||||
style: const TextStyle(color: MyColors.darkTextColor, fontSize: 17, letterSpacing: -0.64, fontWeight: FontWeight.bold),
|
||||
),
|
||||
TextSpan(
|
||||
text: " " + LocaleKeys.demoMarathonNoteP1.tr(),
|
||||
style: const TextStyle(color: MyColors.grey77Color, fontSize: 17, letterSpacing: -0.64, fontWeight: FontWeight.w500),
|
||||
),
|
||||
TextSpan(
|
||||
text: " " + LocaleKeys.demoMarathonNoteP2.tr(),
|
||||
style: const TextStyle(color: MyColors.darkTextColor, fontSize: 17, fontWeight: FontWeight.bold),
|
||||
),
|
||||
TextSpan(
|
||||
text: " " + LocaleKeys.demoMarathonNoteP3.tr(),
|
||||
style: const TextStyle(color: MyColors.grey77Color, fontSize: 17, letterSpacing: -0.64, fontWeight: FontWeight.w500),
|
||||
)
|
||||
],
|
||||
),
|
||||
).paddingOnly(right: 21, left: 21, top: 11, bottom: 0);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
{
|
||||
return DefaultButton(
|
||||
LocaleKeys.joinDemoMarathon.tr(),
|
||||
() => provider.onJoinDemoMarathonPressed(context),
|
||||
color: MyColors.yellowColorII,
|
||||
).insideContainer;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,37 @@
|
||||
import 'package:easy_localization/easy_localization.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:mohem_flutter_app/classes/colors.dart';
|
||||
import 'package:mohem_flutter_app/extensions/string_extensions.dart';
|
||||
import 'package:mohem_flutter_app/generated/locale_keys.g.dart';
|
||||
|
||||
class DisclosureHeader extends StatelessWidget {
|
||||
const DisclosureHeader({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return SafeArea(
|
||||
child: Container(
|
||||
color: MyColors.kWhiteColor,
|
||||
width: double.infinity,
|
||||
height: 65,
|
||||
padding: const EdgeInsets.symmetric(horizontal: 25, vertical: 15),
|
||||
child: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.end,
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
LocaleKeys.brainMarathon.tr().toText24(isBold: true),
|
||||
IconButton(
|
||||
padding: EdgeInsets.zero,
|
||||
icon: const Icon(Icons.close, size: 28),
|
||||
color: MyColors.black,
|
||||
constraints: const BoxConstraints(),
|
||||
onPressed: () {
|
||||
Navigator.pop(context);
|
||||
},
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,122 @@
|
||||
import 'package:easy_localization/easy_localization.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:mohem_flutter_app/classes/colors.dart';
|
||||
import 'package:mohem_flutter_app/classes/decorations_helper.dart';
|
||||
import 'package:mohem_flutter_app/extensions/int_extensions.dart';
|
||||
import 'package:mohem_flutter_app/extensions/string_extensions.dart';
|
||||
import 'package:mohem_flutter_app/extensions/widget_extensions.dart';
|
||||
import 'package:mohem_flutter_app/generated/locale_keys.g.dart';
|
||||
import 'package:mohem_flutter_app/models/disclosure/disclosure_question_model.dart';
|
||||
import 'package:mohem_flutter_app/ui/disclosure/disclosure_provider.dart';
|
||||
|
||||
class DisclosureProgressContainer extends StatelessWidget {
|
||||
final DisclosureProvider provider;
|
||||
|
||||
const DisclosureProgressContainer({Key? key, required this.provider}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
width: double.infinity,
|
||||
decoration: MyDecorations.shadowDecoration,
|
||||
padding: const EdgeInsets.fromLTRB(13, 5, 13, 18),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: <Widget>[
|
||||
5.height,
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: <Widget>[
|
||||
Container(
|
||||
decoration: BoxDecoration(color: MyColors.greenColor, borderRadius: BorderRadius.circular(5)),
|
||||
padding: const EdgeInsets.symmetric(vertical: 5, horizontal: 8),
|
||||
child: "${provider.currentQuestionNumber.toString()} / ${provider.disclosureDetailsModel.totalQuestions.toString()} ${LocaleKeys.disclosure.tr()}".toText12(color: MyColors.white),
|
||||
),
|
||||
],
|
||||
),
|
||||
12.height,
|
||||
stepper(
|
||||
provider.currentQuestionNumber,
|
||||
provider.answerStatusesList,
|
||||
provider.disclosureDetailsModel.totalQuestions!,
|
||||
provider.isUserOutOfGame,
|
||||
),
|
||||
8.height,
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: <Widget>[
|
||||
"${provider.currentQuestionNumber == 1 ? 0 : (((provider.currentQuestionNumber - 1) / (provider.disclosureDetailsModel.totalQuestions!)) * 100).toInt()}% ${LocaleKeys.completed.tr()}".toText14(),
|
||||
provider.isUserOutOfGame ? LocaleKeys.youAreOutOfContest.tr().toText13(color: MyColors.redColor) : const SizedBox(),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Color getStepColor(DisclosureQuestionCardStatus status, bool isOutOfGame) {
|
||||
switch (status) {
|
||||
case DisclosureQuestionCardStatus.question:
|
||||
return MyColors.yellowColorII;
|
||||
case DisclosureQuestionCardStatus.wrongAnswer:
|
||||
return MyColors.lightGreyDeColor;
|
||||
case DisclosureQuestionCardStatus.correctAnswer:
|
||||
return MyColors.lightGreyDeColor;
|
||||
case DisclosureQuestionCardStatus.skippedAnswer:
|
||||
return MyColors.lightGreyDeColor;
|
||||
case DisclosureQuestionCardStatus.completed:
|
||||
return MyColors.lightGreyDeColor;
|
||||
case DisclosureQuestionCardStatus.findingWinner:
|
||||
return MyColors.lightGreyDeColor;
|
||||
case DisclosureQuestionCardStatus.winnerFound:
|
||||
return MyColors.lightGreyDeColor;
|
||||
}
|
||||
}
|
||||
|
||||
Widget stepper(int value, List<DisclosureQuestionCardStatus> statusesList, int totalQuestions, bool isOutOfGame) {
|
||||
return SizedBox(
|
||||
width: double.infinity,
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: <Widget>[
|
||||
for (int i = 0; i < totalQuestions; i++)
|
||||
if (value <= i)
|
||||
roundContainer(MyColors.lightGreyDeColor, i != 0)
|
||||
else
|
||||
roundContainer(
|
||||
getStepColor(statusesList[i], isOutOfGame),
|
||||
i != 0,
|
||||
)
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget roundContainer(Color color, bool isNeedLeftBorder) {
|
||||
if (isNeedLeftBorder) {
|
||||
return Row(
|
||||
children: <Widget>[
|
||||
Divider(
|
||||
thickness: 6,
|
||||
color: color,
|
||||
).expanded,
|
||||
Container(
|
||||
margin: EdgeInsets.zero,
|
||||
padding: EdgeInsets.zero,
|
||||
width: 10,
|
||||
height: 10,
|
||||
decoration: BoxDecoration(shape: BoxShape.circle, color: color, border: Border.all(color: color, width: 2)),
|
||||
),
|
||||
],
|
||||
).expanded;
|
||||
}
|
||||
|
||||
return Container(
|
||||
margin: EdgeInsets.zero,
|
||||
padding: EdgeInsets.zero,
|
||||
width: 10,
|
||||
height: 10,
|
||||
decoration: BoxDecoration(shape: BoxShape.circle, color: color, border: Border.all(color: color, width: 2)),
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,173 @@
|
||||
import 'package:appinio_swiper/appinio_swiper.dart';
|
||||
import 'package:easy_localization/easy_localization.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:lottie/lottie.dart';
|
||||
import 'package:mohem_flutter_app/app_state/app_state.dart';
|
||||
import 'package:mohem_flutter_app/classes/colors.dart';
|
||||
import 'package:mohem_flutter_app/classes/decorations_helper.dart';
|
||||
import 'package:mohem_flutter_app/classes/lottie_consts.dart';
|
||||
import 'package:mohem_flutter_app/classes/utils.dart';
|
||||
import 'package:mohem_flutter_app/extensions/string_extensions.dart';
|
||||
import 'package:mohem_flutter_app/extensions/widget_extensions.dart';
|
||||
import 'package:mohem_flutter_app/generated/locale_keys.g.dart';
|
||||
import 'package:mohem_flutter_app/models/disclosure/disclosure_question_model.dart';
|
||||
import 'package:mohem_flutter_app/ui/disclosure/disclosure_provider.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
class DisclosureQuestionCard extends StatelessWidget {
|
||||
const DisclosureQuestionCard({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
DisclosureProvider provider = context.read<DisclosureProvider>();
|
||||
return CupertinoPageScaffold(
|
||||
child: provider.cardContentList.isEmpty
|
||||
? Lottie.asset(MyLottieConsts.hourGlassLottie, height: 250).paddingOnly(top: 50)
|
||||
: SizedBox(
|
||||
height: MediaQuery.of(context).size.height * .45,
|
||||
width: double.infinity,
|
||||
child: AppinioSwiper(
|
||||
duration: const Duration(milliseconds: 400),
|
||||
padding: EdgeInsets.zero,
|
||||
isDisabled: true,
|
||||
controller: provider.swiperController,
|
||||
unswipe: (int index, AppinioSwiperDirection direction) {},
|
||||
onSwipe: (int index, AppinioSwiperDirection direction) {},
|
||||
cards: provider.cardContentList,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class DisclosureCardContent extends StatelessWidget {
|
||||
const DisclosureCardContent({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
DisclosureProvider provider = context.watch<DisclosureProvider>();
|
||||
return Container(
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
color: CupertinoColors.white,
|
||||
boxShadow: <BoxShadow>[
|
||||
BoxShadow(
|
||||
color: CupertinoColors.systemGrey.withOpacity(0.2),
|
||||
spreadRadius: 3,
|
||||
blurRadius: 7,
|
||||
offset: const Offset(0, 3),
|
||||
)
|
||||
],
|
||||
),
|
||||
alignment: Alignment.center,
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: <Widget>[
|
||||
Container(
|
||||
width: double.infinity,
|
||||
decoration: const BoxDecoration(
|
||||
borderRadius: BorderRadius.only(
|
||||
topLeft: Radius.circular(10),
|
||||
topRight: Radius.circular(10),
|
||||
),
|
||||
),
|
||||
child: Center(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 13, vertical: 15),
|
||||
child: Text(
|
||||
displayLocalizedContent(
|
||||
isPhoneLangArabic: AppState().isArabic(context),
|
||||
selectedLanguage: (provider.disclosureDetailsModel.selectedLanguage) ?? 0,
|
||||
englishContent: provider.currentQuestion.titleEn ?? "",
|
||||
arabicContent: provider.currentQuestion.titleAr ?? "",
|
||||
),
|
||||
style: const TextStyle(
|
||||
color: MyColors.darkTextColor,
|
||||
fontSize: 15,
|
||||
height: 21 / 14,
|
||||
fontWeight: FontWeight.w500,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
const DisclosureAnswerContent(),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class DisclosureAnswerContent extends StatelessWidget {
|
||||
const DisclosureAnswerContent({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
DisclosureProvider provider = context.watch<DisclosureProvider>();
|
||||
return Container(
|
||||
padding: const EdgeInsets.symmetric(vertical: 20, horizontal: 13),
|
||||
decoration: const BoxDecoration(
|
||||
color: MyColors.kWhiteColor,
|
||||
borderRadius: BorderRadius.only(
|
||||
bottomLeft: Radius.circular(10),
|
||||
bottomRight: Radius.circular(10),
|
||||
),
|
||||
),
|
||||
child: provider.currentQuestion.questionOptions != null
|
||||
? Row(
|
||||
children: List<Widget>.generate(
|
||||
provider.currentQuestion.questionOptions!.length,
|
||||
(int index) => Expanded(
|
||||
child: DisclosureAnswerTileForText(
|
||||
index: index,
|
||||
onAnswerTapped: () => provider.updateCurrentQuestionOptionStatus(status: DisclosureQuestionsOptionStatus.selected, selectedOptIndex: index, correctOptionIndex: -1), //
|
||||
).paddingAll(8),
|
||||
),
|
||||
),
|
||||
)
|
||||
: const SizedBox());
|
||||
}
|
||||
}
|
||||
|
||||
class DisclosureAnswerTileForText extends StatelessWidget {
|
||||
final int index;
|
||||
final Function() onAnswerTapped;
|
||||
|
||||
const DisclosureAnswerTileForText({Key? key, required this.index, required this.onAnswerTapped}) : super(key: key);
|
||||
|
||||
Color getAnswerTextColor(DisclosureQuestionsOptionStatus status) {
|
||||
switch (status) {
|
||||
case DisclosureQuestionsOptionStatus.correct:
|
||||
return MyColors.white;
|
||||
case DisclosureQuestionsOptionStatus.wrong:
|
||||
return MyColors.white;
|
||||
case DisclosureQuestionsOptionStatus.selected:
|
||||
return MyColors.white;
|
||||
case DisclosureQuestionsOptionStatus.unSelected:
|
||||
return MyColors.darkTextColor;
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
DisclosureProvider provider = context.watch<DisclosureProvider>();
|
||||
return InkWell(
|
||||
onTap: () {
|
||||
provider.isUserOutOfGame ? Utils.showToast(LocaleKeys.youAreOutOfContest.tr()) : onAnswerTapped();
|
||||
},
|
||||
child: Container(
|
||||
alignment: Alignment.centerLeft,
|
||||
decoration: MyDecorations.getAnswersContainerColorForDisclosure(provider.currentQuestion.questionOptions![index].optionStatus!),
|
||||
child: Center(
|
||||
child: displayLocalizedContent(
|
||||
isPhoneLangArabic: AppState().isArabic(context),
|
||||
selectedLanguage: (provider.disclosureDetailsModel.selectedLanguage) ?? 0,
|
||||
englishContent: provider.currentQuestion.questionOptions![index].titleEn ?? "",
|
||||
arabicContent: provider.currentQuestion.questionOptions![index].titleAr ?? "",
|
||||
).toText16(color: provider.isUserOutOfGame ? MyColors.darkTextColor : getAnswerTextColor(provider.currentQuestion.questionOptions![index].optionStatus!)).paddingOnly(top: 13, bottom: 13),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,51 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:mohem_flutter_app/models/disclosure/disclosure_question_model.dart';
|
||||
|
||||
class DisclosureQuestionCardBuilder extends StatelessWidget {
|
||||
final WidgetBuilder onQuestion;
|
||||
final WidgetBuilder onCompleted;
|
||||
final WidgetBuilder onWrongAnswer;
|
||||
final WidgetBuilder onCorrectAnswer;
|
||||
final WidgetBuilder onWinner;
|
||||
final WidgetBuilder onSkippedAnswer;
|
||||
final WidgetBuilder onFindingWinner;
|
||||
final DisclosureQuestionCardStatus questionCardStatus;
|
||||
|
||||
const DisclosureQuestionCardBuilder({
|
||||
Key? key,
|
||||
required this.onQuestion,
|
||||
required this.onCompleted,
|
||||
required this.onCorrectAnswer,
|
||||
required this.onWinner,
|
||||
required this.onSkippedAnswer,
|
||||
required this.onWrongAnswer,
|
||||
required this.onFindingWinner,
|
||||
required this.questionCardStatus,
|
||||
}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
switch (questionCardStatus) {
|
||||
case DisclosureQuestionCardStatus.question:
|
||||
return onQuestion(context);
|
||||
|
||||
case DisclosureQuestionCardStatus.wrongAnswer:
|
||||
return onWrongAnswer(context);
|
||||
|
||||
case DisclosureQuestionCardStatus.correctAnswer:
|
||||
return onCorrectAnswer(context);
|
||||
|
||||
case DisclosureQuestionCardStatus.completed:
|
||||
return onCompleted(context);
|
||||
|
||||
case DisclosureQuestionCardStatus.winnerFound:
|
||||
return onWinner(context);
|
||||
|
||||
case DisclosureQuestionCardStatus.findingWinner:
|
||||
return onFindingWinner(context);
|
||||
|
||||
case DisclosureQuestionCardStatus.skippedAnswer:
|
||||
return onSkippedAnswer(context);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,55 @@
|
||||
// import 'package:easy_localization/easy_localization.dart';
|
||||
// import 'package:flutter/material.dart';
|
||||
// import 'package:lottie/lottie.dart';
|
||||
// import 'package:mohem_flutter_app/app_state/app_state.dart';
|
||||
// import 'package:mohem_flutter_app/classes/colors.dart';
|
||||
// import 'package:mohem_flutter_app/classes/date_uitl.dart';
|
||||
// import 'package:mohem_flutter_app/classes/decorations_helper.dart';
|
||||
// import 'package:mohem_flutter_app/classes/lottie_consts.dart';
|
||||
// import 'package:mohem_flutter_app/extensions/string_extensions.dart';
|
||||
// import 'package:mohem_flutter_app/generated/locale_keys.g.dart';
|
||||
// import 'package:mohem_flutter_app/ui/disclosure/disclosure_provider.dart';
|
||||
// import 'package:mohem_flutter_app/ui/disclosure/widgets/countdown_timer_detail_screen.dart';
|
||||
//
|
||||
//
|
||||
// class DisclosureTimerCard extends StatelessWidget {
|
||||
// final int timeToMarathon;
|
||||
// final DisclosureProvider provider;
|
||||
//
|
||||
// const DisclosureTimerCard({
|
||||
// Key? key,
|
||||
// required this.provider,
|
||||
// required this.timeToMarathon,
|
||||
// }) : super(key: key);
|
||||
//
|
||||
// @override
|
||||
// Widget build(BuildContext context) {
|
||||
// return Container(
|
||||
// width: double.infinity,
|
||||
// decoration: MyDecorations.shadowDecoration,
|
||||
// padding: const EdgeInsets.symmetric(vertical: 18, horizontal: 14),
|
||||
// child: Column(
|
||||
// children: <Widget>[
|
||||
// Row(
|
||||
// children: <Widget>[
|
||||
// "${LocaleKeys.gameDate.tr()} ".toText16(color: MyColors.grey77Color),
|
||||
// DateUtil.getMonthDayYearDateFormatted(DateTime.parse(provider.marathonDetailModel.startTime!)).toText16(color: MyColors.darkTextColor, isBold: true),
|
||||
// ],
|
||||
// ),
|
||||
// Row(
|
||||
// children: <Widget>[
|
||||
// "${LocaleKeys.gameTime.tr()} ".toText16(color: MyColors.grey77Color),
|
||||
// DateUtil.formatDateToTimeLang(DateTime.parse(provider.marathonDetailModel.startTime!), AppState().isArabic(context)).toText16(color: MyColors.darkTextColor, isBold: true),
|
||||
// ],
|
||||
// ),
|
||||
// Lottie.asset(MyLottieConsts.hourGlassLottie, height: 200),
|
||||
// DisclosureCountdownTimerForDetailScreen(
|
||||
// // timeToMarathon: dummyTime,
|
||||
// timeToMarathon: timeToMarathon,
|
||||
// provider: provider,
|
||||
// ),
|
||||
// ],
|
||||
// ),
|
||||
// );
|
||||
// }
|
||||
// }
|
||||
Loading…
Reference in New Issue