diff --git a/android/gradle.properties b/android/gradle.properties index 94adc3a..2260f45 100644 --- a/android/gradle.properties +++ b/android/gradle.properties @@ -1,3 +1,3 @@ -org.gradle.jvmargs=-Xmx1536M +org.gradle.jvmargs=-Xmx1836M android.useAndroidX=true android.enableJetifier=true diff --git a/assets/images/marathon_banner_bg.svg b/assets/images/marathon_banner_bg.svg index c047ef4..9053afc 100644 --- a/assets/images/marathon_banner_bg.svg +++ b/assets/images/marathon_banner_bg.svg @@ -1,86 +1,63 @@ - + - - - - - - - - - - - - - - - - - - - - - + - + - + - + - + - + - + - + - + - + - - - - + + + + + + + + + + + - - + + - + - - - + - - - - - - - + - - - + @@ -111,10 +88,10 @@ - + - + @@ -123,17 +100,17 @@ - + - + - + @@ -142,10 +119,10 @@ - + - + @@ -153,7 +130,7 @@ - + @@ -163,7 +140,7 @@ - + @@ -171,7 +148,7 @@ - + @@ -181,7 +158,7 @@ - + @@ -189,7 +166,7 @@ - + @@ -197,7 +174,7 @@ - + @@ -206,7 +183,7 @@ - + @@ -231,7 +208,7 @@ - + @@ -241,19 +218,19 @@ - + - + - + @@ -262,82 +239,59 @@ - - - - - - - - - - + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -346,10 +300,9 @@ - - + diff --git a/assets/langs/ar-SA.json b/assets/langs/ar-SA.json index 6c3d229..8a09315 100644 --- a/assets/langs/ar-SA.json +++ b/assets/langs/ar-SA.json @@ -469,6 +469,7 @@ "demoMarathonNoteP3": "قبل الوقت الفعلي.", "sponsoredBy": "برعاية:", "question": "سؤال", - "marathoners": "الماراثون" + "marathoners": "الماراثون", + "prize": "جائزة:" } \ No newline at end of file diff --git a/assets/langs/en-US.json b/assets/langs/en-US.json index c3ee52f..847d01b 100644 --- a/assets/langs/en-US.json +++ b/assets/langs/en-US.json @@ -469,5 +469,6 @@ "demoMarathonNoteP3": "before the actual time.", "sponsoredBy": "Sponsored By:", "question": "Question", - "marathoners": "Marathoners" + "marathoners": "Marathoners", + "prize": "Prize:" } \ No newline at end of file diff --git a/lib/classes/colors.dart b/lib/classes/colors.dart index 34c0188..e670bbc 100644 --- a/lib/classes/colors.dart +++ b/lib/classes/colors.dart @@ -32,6 +32,7 @@ class MyColors { static const Color yellowColor = Color(0xffF4E31C); static const Color orange = Color(0xFFCC9B14); static const Color yellowFavColor = Color(0xffEAC321); + static const Color yellowColorII = Color(0xffEAA118); static const Color backgroundBlackColor = Color(0xff202529); static const Color black = Color(0xff000000); static const Color white = Color(0xffffffff); diff --git a/lib/classes/decorations_helper.dart b/lib/classes/decorations_helper.dart index e3f368c..67139b8 100644 --- a/lib/classes/decorations_helper.dart +++ b/lib/classes/decorations_helper.dart @@ -2,7 +2,7 @@ import 'package:flutter/material.dart'; import 'package:mohem_flutter_app/classes/colors.dart'; class MyDecorations { - static Decoration shadowDecoration= BoxDecoration( + static Decoration shadowDecoration = BoxDecoration( color: MyColors.kWhiteColor, borderRadius: BorderRadius.circular(15), boxShadow: [ @@ -13,4 +13,10 @@ class MyDecorations { ), ], ); + + static Decoration answerContainerDecoration = BoxDecoration( + borderRadius: BorderRadius.circular(10), + color: MyColors.greyF7Color, + border: Border.all(width: 1, color: MyColors.lightGreyEFColor), + ); } diff --git a/lib/extensions/string_extensions.dart b/lib/extensions/string_extensions.dart index a9075c7..45e3293 100644 --- a/lib/extensions/string_extensions.dart +++ b/lib/extensions/string_extensions.dart @@ -10,19 +10,36 @@ extension CapExtension on String { String get allInCaps => this.toUpperCase(); - String get capitalizeFirstofEach => this.trim().length > 0 ? this.trim().toLowerCase().split(" ").map((str) => str.inCaps).join(" ") : ""; + String get capitalizeFirstofEach => this.trim().length > 0 + ? this.trim().toLowerCase().split(" ").map((str) => str.inCaps).join(" ") + : ""; } extension EmailValidator on String { Widget get toWidget => Text(this); - Widget toText10({Color? color, bool isBold = false, int? maxlines}) => Text( + Widget toText10( + {Color? color, + bool isBold = false, + int? maxlines, + FontStyle? fontStyle}) => + Text( this, //maxLines: maxlines, - style: TextStyle(fontSize: 10, fontWeight: isBold ? FontWeight.bold : FontWeight.w600, color: color ?? MyColors.darkTextColor, letterSpacing: -0.4), + style: TextStyle( + fontSize: 10, + fontStyle: fontStyle ?? FontStyle.normal, + fontWeight: isBold ? FontWeight.bold : FontWeight.w600, + color: color ?? MyColors.darkTextColor, + letterSpacing: -0.4), ); - Widget toText11({Color? color, FontWeight? weight, bool isUnderLine = false, bool isBold = false}) => Text( + Widget toText11( + {Color? color, + FontWeight? weight, + bool isUnderLine = false, + bool isBold = false}) => + Text( this, style: TextStyle( fontSize: 11, @@ -33,7 +50,13 @@ extension EmailValidator on String { ), ); - Widget toText12({Color? color, bool isUnderLine = false, bool isBold = false, bool isCenter = false, int maxLine = 0}) => Text( + Widget toText12( + {Color? color, + bool isUnderLine = false, + bool isBold = false, + bool isCenter = false, + int maxLine = 0}) => + Text( this, textAlign: isCenter ? TextAlign.center : null, maxLines: (maxLine > 0) ? maxLine : null, @@ -46,32 +69,57 @@ extension EmailValidator on String { ), ); - Widget toText12Auto({Color? color, bool isUnderLine = false, bool isBold = false, bool isCenter = false, int maxLine = 0}) => AutoSizeText( - this, - textAlign: isCenter ? TextAlign.center : null, - maxLines: (maxLine > 0) ? maxLine : null, - minFontSize: 8, - style: TextStyle( - fontSize: 12, - fontWeight: isBold ? FontWeight.bold : FontWeight.w600, - color: color ?? MyColors.darkTextColor, - letterSpacing: -0.72, - decoration: isUnderLine ? TextDecoration.underline : null, - ), - ); + Widget toText12Auto( + {Color? color, + bool isUnderLine = false, + bool isBold = false, + bool isCenter = false, + int maxLine = 0}) => + AutoSizeText( + this, + textAlign: isCenter ? TextAlign.center : null, + maxLines: (maxLine > 0) ? maxLine : null, + minFontSize: 8, + style: TextStyle( + fontSize: 12, + fontWeight: isBold ? FontWeight.bold : FontWeight.w600, + color: color ?? MyColors.darkTextColor, + letterSpacing: -0.72, + decoration: isUnderLine ? TextDecoration.underline : null, + ), + ); Widget toText13({Color? color, bool isUnderLine = false}) => Text( this, - style: TextStyle(fontSize: 13, fontWeight: FontWeight.w600, color: color ?? MyColors.darkTextColor, letterSpacing: -0.52, decoration: isUnderLine ? TextDecoration.underline : null), + style: TextStyle( + fontSize: 13, + fontWeight: FontWeight.w600, + color: color ?? MyColors.darkTextColor, + letterSpacing: -0.52, + decoration: isUnderLine ? TextDecoration.underline : null), ); - Widget toText14({Color? color, bool isBold = false, FontWeight? weight, int? maxlines}) => Text( + Widget toText14( + {Color? color, + bool isBold = false, + FontWeight? weight, + int? maxlines}) => + Text( this, maxLines: maxlines, - style: TextStyle(color: color ?? MyColors.darkTextColor, fontSize: 14, letterSpacing: -0.48, fontWeight: weight ?? (isBold ? FontWeight.bold : FontWeight.w600)), + style: TextStyle( + color: color ?? MyColors.darkTextColor, + fontSize: 14, + letterSpacing: -0.48, + fontWeight: weight ?? (isBold ? FontWeight.bold : FontWeight.w600)), ); - Widget toText16({Color? color, bool isUnderLine = false, bool isBold = false, int? maxlines}) => Text( + Widget toText16( + {Color? color, + bool isUnderLine = false, + bool isBold = false, + int? maxlines}) => + Text( this, maxLines: maxlines, style: TextStyle( @@ -85,51 +133,97 @@ extension EmailValidator on String { Widget toText17({Color? color, bool isBold = false}) => Text( this, - style: TextStyle(color: color ?? MyColors.darkTextColor, fontSize: 17, letterSpacing: -0.68, fontWeight: isBold ? FontWeight.bold : FontWeight.w600), + style: TextStyle( + color: color ?? MyColors.darkTextColor, + fontSize: 17, + letterSpacing: -0.68, + fontWeight: isBold ? FontWeight.bold : FontWeight.w600), ); Widget toText18({Color? color, bool isBold = false}) => Text( this, - style: TextStyle(fontSize: 18, fontWeight: isBold ? FontWeight.bold : FontWeight.w600, color: color ?? MyColors.darkTextColor, letterSpacing: -1.08), + style: TextStyle( + fontSize: 18, + fontWeight: isBold ? FontWeight.bold : FontWeight.w600, + color: color ?? MyColors.darkTextColor, + letterSpacing: -1.08), ); Widget toText19({Color? color, bool isBold = false}) => Text( - this, - style: TextStyle(fontSize: 19, fontWeight: isBold ? FontWeight.bold : FontWeight.w600, color: color ?? MyColors.darkTextColor, letterSpacing: -1.14), - ); + this, + style: TextStyle( + fontSize: 19, + fontWeight: isBold ? FontWeight.bold : FontWeight.w600, + color: color ?? MyColors.darkTextColor, + letterSpacing: -1.14), + ); Widget toText20({Color? color, bool isBold = false}) => Text( this, - style: TextStyle(fontSize: 20, fontWeight: isBold ? FontWeight.bold : FontWeight.w600, color: color ?? MyColors.darkTextColor, letterSpacing: -0.4), + style: TextStyle( + fontSize: 20, + fontWeight: isBold ? FontWeight.bold : FontWeight.w600, + color: color ?? MyColors.darkTextColor, + letterSpacing: -0.4), ); - Widget toText21({Color? color, bool isBold = false, FontWeight? weight, int? maxlines}) => Text( - this, - maxLines: maxlines, - style: TextStyle(color: color ?? MyColors.grey3AColor, fontSize: 21, letterSpacing: -0.31, fontWeight: weight ?? (isBold ? FontWeight.bold : FontWeight.w600)), - ); + Widget toText21( + {Color? color, + bool isBold = false, + FontWeight? weight, + int? maxlines}) => + Text( + this, + maxLines: maxlines, + style: TextStyle( + color: color ?? MyColors.grey3AColor, + fontSize: 21, + letterSpacing: -0.31, + fontWeight: weight ?? (isBold ? FontWeight.bold : FontWeight.w600)), + ); Widget toText22({Color? color, bool isBold = false}) => Text( this, - style: TextStyle(height: 1, color: color ?? MyColors.darkTextColor, fontSize: 22, letterSpacing: -1.44, fontWeight: isBold ? FontWeight.bold : FontWeight.w600), + style: TextStyle( + height: 1, + color: color ?? MyColors.darkTextColor, + fontSize: 22, + letterSpacing: -1.44, + fontWeight: isBold ? FontWeight.bold : FontWeight.w600), ); Widget toText24({Color? color, bool isBold = false}) => Text( this, - style: TextStyle(height: 23 / 24, color: color ?? MyColors.darkTextColor, fontSize: 24, letterSpacing: -1.44, fontWeight: isBold ? FontWeight.bold : FontWeight.w600), + style: TextStyle( + height: 23 / 24, + color: color ?? MyColors.darkTextColor, + fontSize: 24, + letterSpacing: -1.44, + fontWeight: isBold ? FontWeight.bold : FontWeight.w600), ); Widget toText32({Color? color, bool isBold = false}) => Text( this, - style: TextStyle(height: 32 / 32, color: color ?? MyColors.darkTextColor, fontSize: 32, letterSpacing: -1.92, fontWeight: isBold ? FontWeight.bold : FontWeight.w600), + style: TextStyle( + height: 32 / 32, + color: color ?? MyColors.darkTextColor, + fontSize: 32, + letterSpacing: -1.92, + fontWeight: isBold ? FontWeight.bold : FontWeight.w600), ); Widget toText44({Color? color, bool isBold = false}) => Text( this, - style: TextStyle(height: 32 / 32, color: color ?? MyColors.darkTextColor, fontSize: 44, letterSpacing: -2.64, fontWeight: isBold ? FontWeight.bold : FontWeight.w600), + style: TextStyle( + height: 32 / 32, + color: color ?? MyColors.darkTextColor, + fontSize: 44, + letterSpacing: -2.64, + fontWeight: isBold ? FontWeight.bold : FontWeight.w600), ); - Widget toSectionHeading({String upperHeading = "", String lowerHeading = ""}) { + Widget toSectionHeading( + {String upperHeading = "", String lowerHeading = ""}) { String upper = ""; String lower = ""; String heading = this; @@ -162,7 +256,9 @@ extension EmailValidator on String { } bool isValidEmail() { - return RegExp(r'^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$').hasMatch(this); + return RegExp( + r'^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$') + .hasMatch(this); } String toFormattedDate() { diff --git a/lib/generated/codegen_loader.g.dart b/lib/generated/codegen_loader.g.dart index 37e5d4e..e7c6880 100644 --- a/lib/generated/codegen_loader.g.dart +++ b/lib/generated/codegen_loader.g.dart @@ -467,10 +467,26 @@ class CodegenLoader extends AssetLoader{ "female": "Hello girl :) {}" } }, - "reset_locale": "Reset Language", + "reset_locale": "إعادة ضبط اللغة", "chat": "دردشة", "mychats": "دردشاتي", - "createNewChat": "Create New Chat" + "createNewChat": "إنشاء محادثة جديدة", + "brainMarathon": "ماراثون الدماغ", + "contestTopicAbout": "سيكون موضوع المسابقة حول:", + "gameDate": "تاريخ اللعبة:", + "gameTime": "وقت اللعب:", + "joinMarathon": "انضم إلى ماراثون", + "joinDemoMarathon": "انضم إلى الماراثون التجريبي", + "minutes": "الدقائق", + "seconds": "ثواني", + "note": "ملحوظة:", + "demoMarathonNoteP1": "يمكنك لعب ماراثون العرض لتتعلم كيف يعمل. يمكنك الانضمام إلى ماراثون", + "demoMarathonNoteP2": "خمس دقائق", + "demoMarathonNoteP3": "قبل الوقت الفعلي.", + "sponsoredBy": "برعاية:", + "question": "سؤال", + "marathoners": "الماراثون", + "prize": "جائزة:" }; static const Map en_US = { "mohemm": "Mohemm", @@ -928,7 +944,23 @@ static const Map en_US = { "reset_locale": "Reset Language", "chat": "Chat", "mychats": "My Chats", - "createNewChat": "Create New Chat" + "createNewChat": "Create New Chat", + "brainMarathon": "Brain Marathon", + "contestTopicAbout": "Contest Topic will be about:", + "gameDate": "Game Date:", + "gameTime": "Game Time:", + "joinMarathon": "Join Marathon", + "joinDemoMarathon": "Join Demo Marathon", + "minutes": "Minutes", + "seconds": "Seconds", + "note": "Note:", + "demoMarathonNoteP1": "You can play the demo Marathon to learn how it works. You can join the Marathon", + "demoMarathonNoteP2": "5 Minutes", + "demoMarathonNoteP3": "before the actual time.", + "sponsoredBy": "Sponsored By:", + "question": "Question", + "marathoners": "Marathoners", + "prize": "Prize:" }; static const Map> mapLocales = {"ar_SA": ar_SA, "en_US": en_US}; } diff --git a/lib/generated/locale_keys.g.dart b/lib/generated/locale_keys.g.dart index 03849d4..4d1ffb4 100644 --- a/lib/generated/locale_keys.g.dart +++ b/lib/generated/locale_keys.g.dart @@ -456,5 +456,6 @@ abstract class LocaleKeys { static const sponsoredBy = 'sponsoredBy'; static const question = 'question'; static const marathoners = 'marathoners'; + static const prize = 'prize'; } diff --git a/lib/models/marathon_question_model.dart b/lib/models/marathon_question_model.dart new file mode 100644 index 0000000..52f77b1 --- /dev/null +++ b/lib/models/marathon_question_model.dart @@ -0,0 +1,63 @@ +import 'package:flutter/cupertino.dart'; + +class DummyQuestionModel { + String? opt1; + String? opt2; + String? opt3; + + DummyQuestionModel({ + this.opt1, + this.opt2, + this.opt3, + }); +} + +final List answersDummyMap = [ + {"answer": "Jeddah"}, + {"answer": "Mecca"}, + {"answer": "Riyaadh"}, + {"answer": "Dammaam"}, +]; + +List questions = [ + DummyQuestionModel( + opt1: 'Riyadh 8', + opt2: 'Dammam', + opt3: 'Mecca', + ), + DummyQuestionModel( + opt1: 'Riyadh 7', + opt2: 'Dammam', + opt3: 'Mecca', + ), + DummyQuestionModel( + opt1: 'Riyadh 6', + opt2: 'Dammam', + opt3: 'Mecca', + ), + DummyQuestionModel( + opt1: 'Riyadh 5', + opt2: 'Dammam', + opt3: 'Mecca', + ), + DummyQuestionModel( + opt1: 'Riyadh 4', + opt2: 'Dammam', + opt3: 'Mecca', + ), + DummyQuestionModel( + opt1: 'Riyadh 3', + opt2: 'Dammam', + opt3: 'Mecca', + ), + DummyQuestionModel( + opt1: 'Riyadh 2', + opt2: 'Dammam', + opt3: 'Mecca', + ), + DummyQuestionModel( + opt1: 'Riyadh 1', + opt2: 'Dammam', + opt3: 'Mecca', + ), +]; diff --git a/lib/ui/landing/dashboard_screen.dart b/lib/ui/landing/dashboard_screen.dart index 68fa84e..7c78bc9 100644 --- a/lib/ui/landing/dashboard_screen.dart +++ b/lib/ui/landing/dashboard_screen.dart @@ -1,3 +1,4 @@ +import 'dart:async'; import 'dart:io'; import 'package:easy_localization/easy_localization.dart'; import 'package:flutter/material.dart'; @@ -45,8 +46,10 @@ class _DashboardScreenState extends State { @override void initState() { super.initState(); - data = Provider.of(context, listen: false); - _onRefresh(); + scheduleMicrotask(() { + data = Provider.of(context, listen: false); + _onRefresh(); + }); } @override @@ -361,8 +364,13 @@ class _DashboardScreenState extends State { ], ), ], - ).paddingOnly(left: 21, right: 21, top: 7), - MarathonBanner().paddingAll(20), + ).paddingOnly(left: 20, right: 20, top: 7), + MarathonBanner().paddingOnly( + left: 20, + right: 20, + top: 11, + bottom: 11, + ), ServicesWidget(), Container( width: double.infinity, @@ -370,8 +378,9 @@ class _DashboardScreenState extends State { decoration: BoxDecoration( color: Colors.white, borderRadius: const BorderRadius.only( - topRight: Radius.circular(50), - topLeft: Radius.circular(50)), + topRight: Radius.circular(50), + topLeft: Radius.circular(50), + ), border: Border.all( color: MyColors.lightGreyEDColor, width: 1), ), diff --git a/lib/ui/landing/widget/services_widget.dart b/lib/ui/landing/widget/services_widget.dart index a173e7c..854fa43 100644 --- a/lib/ui/landing/widget/services_widget.dart +++ b/lib/ui/landing/widget/services_widget.dart @@ -34,7 +34,7 @@ class ServicesWidget extends StatelessWidget { return data.isServicesMenusLoading ? whileLoading() : ListView.separated( - padding: const EdgeInsets.only(top: 21), + padding: const EdgeInsets.only(top: 0), itemBuilder: (context, parentIndex) { return Column( crossAxisAlignment: CrossAxisAlignment.start, diff --git a/lib/ui/marathon/marathon_intro_screen.dart b/lib/ui/marathon/marathon_intro_screen.dart index 9a88818..e1e3699 100644 --- a/lib/ui/marathon/marathon_intro_screen.dart +++ b/lib/ui/marathon/marathon_intro_screen.dart @@ -1,9 +1,5 @@ -import 'dart:async'; - 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:lottie/lottie.dart'; import 'package:mohem_flutter_app/classes/colors.dart'; import 'package:mohem_flutter_app/classes/decorations_helper.dart'; @@ -14,49 +10,49 @@ 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/marathon/marathon_provider.dart'; +import 'package:mohem_flutter_app/ui/marathon/widgets/countdown_timer.dart'; import 'package:mohem_flutter_app/ui/marathon/widgets/marathon_header.dart'; import 'package:mohem_flutter_app/widgets/button/default_button.dart'; import 'package:provider/provider.dart'; -final int dummyEndTime = DateTime.now().millisecondsSinceEpoch + 1000 * 10; +final int dummyEndTime = DateTime.now().millisecondsSinceEpoch + 1000 * 30; class MarathonIntroScreen extends StatelessWidget { const MarathonIntroScreen({Key? key}) : super(key: key); @override Widget build(BuildContext context) { + MarathonProvider provider = context.watch(); return Scaffold( - body: Consumer( - builder: (BuildContext context, MarathonProvider provider, _) { - return Stack( - children: [ - SingleChildScrollView( - child: Column( - children: [ - const MarathonHeader(), - 20.height, - const MarathonDetailsCard().paddingAll(15), - MarathonTimerCard( - provider: provider, - timeToMarathon: dummyEndTime, - ).paddingAll(15), - ], - ), - ), - Align( - alignment: Alignment.bottomCenter, - child: MarathonFooter(provider: provider), - ), - ], - ); - }, + body: Stack( + children: [ + SingleChildScrollView( + child: Column( + children: [ + const MarathonHeader(), + MarathonDetailsCard(provider: provider).paddingAll(15), + MarathonTimerCard( + provider: provider, + timeToMarathon: dummyEndTime, + ).paddingOnly(left: 15, right: 15, bottom: 15), + ], + ), + ), + Align( + alignment: Alignment.bottomCenter, + child: MarathonFooter(provider: provider), + ), + ], ), ); } } class MarathonDetailsCard extends StatelessWidget { - const MarathonDetailsCard({Key? key}) : super(key: key); + final MarathonProvider provider; + + const MarathonDetailsCard({Key? key, required this.provider}) + : super(key: key); @override Widget build(BuildContext context) { @@ -76,20 +72,45 @@ class MarathonDetailsCard extends StatelessWidget { .toText16(color: MyColors.grey77Color), "Saudi Arabia" .toText20(color: MyColors.textMixColor, isBold: true), - 10.height, - ], - ), - Row( - children: [ - LocaleKeys.gameDate.tr().toText16(color: MyColors.grey77Color), - " 10 Oct, 2022" - .toText16(color: MyColors.darkTextColor, isBold: true), - ], - ), - Row( - children: [ - LocaleKeys.gameTime.tr().toText16(color: MyColors.grey77Color), - " 3:00pm".toText16(color: MyColors.darkTextColor, isBold: true), + Row( + children: [ + Flexible( + child: + "Nam suscipit turpis in pharetra euismsdef. Duis rutrum at nulla id aliquam" + .toText16(color: MyColors.grey77Color), + ) + ], + ), + if (provider.itsMarathonTime) ...[ + 5.height, + Row( + children: [ + LocaleKeys.prize.tr().toText16(color: MyColors.grey77Color), + " LED 55\" Android TV" + .toText16(color: MyColors.greenColor, isBold: true), + ], + ), + Row( + children: [ + LocaleKeys.sponsoredBy + .tr() + .toText16(color: MyColors.grey77Color), + " Extra".toText16(color: MyColors.black, isBold: true), + ], + ), + 10.height, + Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Image.network( + "https://cdn.pixabay.com/photo/2014/08/27/07/53/blog-428950_1280.jpg", + height: 50, + fit: BoxFit.fill, + width: 120, + ) + ], + ), + ] ], ), ], @@ -116,10 +137,27 @@ class MarathonTimerCard extends StatelessWidget { padding: const EdgeInsets.symmetric(vertical: 20, horizontal: 20), child: Column( children: [ - Lottie.asset(MyLottieConsts.hourGlassLottie, height: 200), + Row( + children: [ + LocaleKeys.gameDate.tr().toText16(color: MyColors.grey77Color), + " 10 Oct, 2022" + .toText16(color: MyColors.darkTextColor, isBold: true), + ], + ), + Row( + children: [ + LocaleKeys.gameTime.tr().toText16(color: MyColors.grey77Color), + " 3:00pm".toText16(color: MyColors.darkTextColor, isBold: true), + ], + ), + Lottie.asset( + MyLottieConsts.hourGlassLottie, + height: 140, + ), BuildCountdownTimer( timeToMarathon: timeToMarathon, provider: provider, + screenFlag: 1, ), ], ), @@ -127,116 +165,6 @@ class MarathonTimerCard extends StatelessWidget { } } -class BuildCountdownTimer extends StatelessWidget { - final int timeToMarathon; - final MarathonProvider provider; - - const BuildCountdownTimer({ - Key? key, - required this.provider, - required this.timeToMarathon, - }) : super(key: key); - - Widget buildEmptyWidget() { - return Row( - mainAxisSize: MainAxisSize.min, - mainAxisAlignment: MainAxisAlignment.spaceEvenly, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Column( - children: [ - "00".toText32(), - LocaleKeys.days.tr().toText14(color: MyColors.grey57Color), - ], - ), - buildSeparator(), - Column( - children: [ - "00".toText32(), - LocaleKeys.hours.tr().toText14(color: MyColors.grey57Color), - ], - ), - buildSeparator(), - Column( - children: [ - "00".toText32(), - LocaleKeys.minutes.tr().toText14(color: MyColors.grey57Color), - ], - ), - buildSeparator(), - Column( - children: [ - "00".toText32(), - LocaleKeys.seconds.tr().toText14(color: MyColors.grey57Color), - ], - ), - ], - ); - } - - Widget buildSeparator() { - return " : ".toText32(); - } - - Widget buildCountdownTimer(CurrentRemainingTime? time) { - if (time == null) { - scheduleMicrotask(() { - provider.itsMarathonTime = true; - }); - return buildEmptyWidget(); - } - return Row( - mainAxisSize: MainAxisSize.min, - mainAxisAlignment: MainAxisAlignment.spaceEvenly, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Column( - children: [ - time.days == null - ? "00".toText32() - : time.days.toString().toText32(), - LocaleKeys.days.tr().toText14(color: MyColors.grey57Color), - ], - ), - buildSeparator(), - Column( - children: [ - time.hours == null - ? "00".toText32() - : time.hours.toString().toText32(), - LocaleKeys.hours.tr().toText14(color: MyColors.grey57Color), - ], - ), - buildSeparator(), - Column( - children: [ - time.min == null ? "00".toText32() : time.min.toString().toText32(), - LocaleKeys.minutes.tr().toText14(color: MyColors.grey57Color), - ], - ), - buildSeparator(), - Column( - children: [ - time.sec == null ? "00".toText32() : time.sec.toString().toText32(), - LocaleKeys.seconds.tr().toText14(color: MyColors.grey57Color), - ], - ), - ], - ); - } - - @override - Widget build(BuildContext context) { - return CountdownTimer( - endTime: timeToMarathon, - onEnd: null, - widgetBuilder: (BuildContext context, CurrentRemainingTime? time) { - return buildCountdownTimer(time); - }, - ); - } -} - class MarathonFooter extends StatelessWidget { final MarathonProvider provider; @@ -253,33 +181,36 @@ class MarathonFooter extends StatelessWidget { TextSpan( text: LocaleKeys.note.tr(), style: const TextStyle( - fontSize: 22, - fontWeight: FontWeight.bold, color: MyColors.darkTextColor, + fontSize: 17, + letterSpacing: -0.64, + fontWeight: FontWeight.bold, ), ), TextSpan( text: " " + LocaleKeys.demoMarathonNoteP1.tr(), style: const TextStyle( - color: MyColors.darkTextColor, - fontSize: 18, - fontWeight: FontWeight.w600, + color: MyColors.grey77Color, + fontSize: 17, + letterSpacing: -0.64, + fontWeight: FontWeight.w500, ), ), TextSpan( text: " " + LocaleKeys.demoMarathonNoteP2.tr(), style: const TextStyle( color: MyColors.darkTextColor, - fontSize: 20, + fontSize: 17, fontWeight: FontWeight.bold, ), ), TextSpan( text: " " + LocaleKeys.demoMarathonNoteP3.tr(), style: const TextStyle( - color: MyColors.darkTextColor, - fontSize: 18, - fontWeight: FontWeight.w600, + color: MyColors.grey77Color, + fontSize: 17, + letterSpacing: -0.64, + fontWeight: FontWeight.w500, ), ) ], @@ -298,13 +229,16 @@ class MarathonFooter extends StatelessWidget { ? DefaultButton( LocaleKeys.joinMarathon.tr(), () => Navigator.pushNamed(context, AppRoutes.marathonScreen), - ).insideContainer + ).insideContainer : Column( mainAxisSize: MainAxisSize.min, children: [ buildNoteForDemo(), - DefaultButton(LocaleKeys.joinDemoMarathon.tr(), () {}) - .insideContainer, + DefaultButton( + LocaleKeys.joinDemoMarathon.tr(), + () {}, + color: MyColors.yellowColorII, + ).insideContainer, ], ), ); diff --git a/lib/ui/marathon/marathon_provider.dart b/lib/ui/marathon/marathon_provider.dart index 444aa66..e185936 100644 --- a/lib/ui/marathon/marathon_provider.dart +++ b/lib/ui/marathon/marathon_provider.dart @@ -1,6 +1,11 @@ +import 'dart:async'; + +import 'package:appinio_swiper/appinio_swiper.dart'; import 'package:flutter/cupertino.dart'; class MarathonProvider extends ChangeNotifier { + final AppinioSwiperController swiperController = AppinioSwiperController(); + bool _itsMarathonTime = false; bool get itsMarathonTime => _itsMarathonTime; @@ -9,4 +14,29 @@ class MarathonProvider extends ChangeNotifier { _itsMarathonTime = value; notifyListeners(); } + + Timer timer = Timer.periodic(const Duration(seconds: 1), (Timer timer) {}); + int start = 20; + + void startTimer() { + start = 20; + const Duration oneSec = Duration(seconds: 1); + timer = Timer.periodic( + oneSec, + (Timer timer) { + if (start == 0) { + swiperController.swipeLeft(); + timer.cancel(); + } else { + start--; + } + notifyListeners(); + }, + ); + } + + void cancelTimer() { + timer.cancel(); + notifyListeners(); + } } diff --git a/lib/ui/marathon/marathon_screen.dart b/lib/ui/marathon/marathon_screen.dart index 6e22160..1d98f4b 100644 --- a/lib/ui/marathon/marathon_screen.dart +++ b/lib/ui/marathon/marathon_screen.dart @@ -1,3 +1,5 @@ +import 'dart:async'; + import 'package:easy_localization/easy_localization.dart'; import 'package:flutter/material.dart'; import 'package:mohem_flutter_app/classes/colors.dart'; @@ -6,7 +8,10 @@ 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/ui/marathon/marathon_provider.dart'; import 'package:mohem_flutter_app/ui/marathon/widgets/marathon_header.dart'; +import 'package:mohem_flutter_app/ui/marathon/widgets/question_card.dart'; +import 'package:provider/provider.dart'; import 'package:steps_indicator/steps_indicator.dart'; class MarathonScreen extends StatelessWidget { @@ -14,13 +19,16 @@ class MarathonScreen extends StatelessWidget { @override Widget build(BuildContext context) { + MarathonProvider provider = context.watch(); return Scaffold( body: SingleChildScrollView( child: Column( children: [ const MarathonHeader(), 21.height, - const MarathonProgressContainer().paddingOnly(left: 21, right: 21), + MarathonProgressContainer(provider: provider) + .paddingOnly(left: 21, right: 21), + QuestionCard(provider: provider), ], ), ), @@ -28,22 +36,47 @@ class MarathonScreen extends StatelessWidget { } } -class MarathonProgressContainer extends StatelessWidget { - const MarathonProgressContainer({Key? key}) : super(key: key); +class MarathonProgressContainer extends StatefulWidget { + final MarathonProvider provider; + + const MarathonProgressContainer({Key? key, required this.provider}) + : super(key: key); + + @override + State createState() => + _MarathonProgressContainerState(); +} + +class _MarathonProgressContainerState extends State { + final int totalQuestions = 10; + + final int currentQuestion = 04; + + @override + void initState() { + scheduleMicrotask(() { + widget.provider.startTimer(); + }); + super.initState(); + } - final int totalQuestions = 24; - final int currentQuestion = 20; + @override + void dispose() { + widget.provider.cancelTimer(); + super.dispose(); + } @override Widget build(BuildContext context) { return Container( width: double.infinity, decoration: MyDecorations.shadowDecoration, + padding: const EdgeInsets.symmetric(vertical: 15, horizontal: 20), child: Column( mainAxisSize: MainAxisSize.min, children: [ Row( - mainAxisAlignment: MainAxisAlignment.spaceEvenly, + mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Container( decoration: BoxDecoration( @@ -51,40 +84,41 @@ class MarathonProgressContainer extends StatelessWidget { borderRadius: BorderRadius.circular(12), ), padding: const EdgeInsets.symmetric(vertical: 5, horizontal: 8), - child: Flexible( - child: - "${currentQuestion.toString()} / ${totalQuestions.toString()} ${LocaleKeys.question.tr()}" - .toText12(color: MyColors.white), - ), - ), - Flexible( - child: "23 ${LocaleKeys.marathoners.tr()}".toText14(), - ), - Flexible( - child: "00:23".toText16(isBold: true), + child: + "${currentQuestion.toString()} / ${totalQuestions.toString()} ${LocaleKeys.question.tr()}" + .toText12(color: MyColors.white), ), + "23 ${LocaleKeys.marathoners.tr()}".toText14(), + "00:${widget.provider.start < 10 ? "0${widget.provider.start}" : widget.provider.start}" + .toText18(isBold: true), + ], + ), + 15.height, + const StepsIndicator( + lineLength: 23, + nbSteps: 10, + selectedStep: 6, + doneLineColor: MyColors.greenColor, + doneStepColor: MyColors.greenColor, + doneLineThickness: 6, + undoneLineThickness: 6, + selectedStepSize: 10, + unselectedStepSize: 10, + doneStepSize: 10, + selectedStepColorIn: MyColors.greenColor, + selectedStepColorOut: MyColors.greenColor, + unselectedStepColorIn: MyColors.lightGreyDeColor, + unselectedStepColorOut: MyColors.lightGreyDeColor, + undoneLineColor: MyColors.lightGreyDeColor, + enableLineAnimation: true, + enableStepAnimation: true, + ), + 12.height, + Row( + children: [ + "25% ${LocaleKeys.completed.tr()}".toText18(isBold: true), ], ), - 15.height, - const SizedBox( - width: double.infinity, - child: StepsIndicator( - nbSteps: 7, - selectedStep: 2, - doneLineColor: MyColors.greenColor, - doneStepColor: MyColors.greenColor, - doneLineThickness: 5, - undoneLineThickness: 5, - selectedStepSize: 10, - selectedStepColorIn: MyColors.greenColor, - selectedStepColorOut: MyColors.greenColor, - unselectedStepColorIn: MyColors.lightGreyDeColor, - unselectedStepColorOut: MyColors.lightGreyDeColor, - undoneLineColor: MyColors.lightGreyDeColor, - enableLineAnimation: true, - enableStepAnimation: true, - ), - ), ], ), ); diff --git a/lib/ui/marathon/widgets/countdown_timer.dart b/lib/ui/marathon/widgets/countdown_timer.dart new file mode 100644 index 0000000..4d551a2 --- /dev/null +++ b/lib/ui/marathon/widgets/countdown_timer.dart @@ -0,0 +1,240 @@ +import 'dart:async'; + +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/ui/marathon/marathon_provider.dart'; + +class BuildCountdownTimer extends StatelessWidget { + final int timeToMarathon; + final MarathonProvider provider; + final int screenFlag; + + const BuildCountdownTimer({ + Key? key, + required this.provider, + required this.timeToMarathon, + required this.screenFlag, + }) : super(key: key); + + final TextStyle styleTextHome = const TextStyle( + fontSize: 9, + color: MyColors.greyACColor, + fontStyle: FontStyle.italic, + fontWeight: FontWeight.w600, + letterSpacing: -0.4, + ); + + final TextStyle styleDigitHome = const TextStyle( + height: 23 / 24, + color: MyColors.white, + fontSize: 24, + 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: 32, + letterSpacing: -1.44, + fontWeight: FontWeight.bold, + ); + + Widget buildEmptyWidget() { + return Row( + mainAxisSize: MainAxisSize.min, + mainAxisAlignment: MainAxisAlignment.spaceEvenly, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Column( + children: [ + Text( + "00", + style: screenFlag == 0 ? styleDigitHome : styleDigitMarathon, + ), + Text( + LocaleKeys.days.tr(), + style: screenFlag == 0 ? styleTextHome : styleTextMarathon, + ), + ], + ), + buildSeparator(), + Column( + children: [ + Text( + "00", + style: screenFlag == 0 ? styleDigitHome : styleDigitMarathon, + ), + Text( + LocaleKeys.hours.tr(), + style: screenFlag == 0 ? styleTextHome : styleTextMarathon, + ), + ], + ), + buildSeparator(), + Column( + children: [ + Text( + "00", + style: screenFlag == 0 ? styleDigitHome : styleDigitMarathon, + ), + Text( + LocaleKeys.minutes.tr(), + style: screenFlag == 0 ? styleTextHome : styleTextMarathon, + ), + ], + ), + buildSeparator(), + Column( + children: [ + Text( + "00", + style: screenFlag == 0 ? styleDigitHome : styleDigitMarathon, + ), + Text( + LocaleKeys.seconds.tr(), + style: screenFlag == 0 ? styleTextHome : styleTextMarathon, + ), + ], + ), + ], + ); + } + + Widget buildSeparator() { + return Text( + " : ", + style: screenFlag == 0 ? styleDigitHome : styleDigitMarathon, + ); + } + + Widget buildCountdownTimer(CurrentRemainingTime? time) { + if (time == null) { + if (!provider.itsMarathonTime) { + scheduleMicrotask(() { + provider.itsMarathonTime = true; + }); + } + + return buildEmptyWidget(); + } + return Row( + mainAxisSize: MainAxisSize.min, + mainAxisAlignment: MainAxisAlignment.spaceEvenly, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Column( + children: [ + time.days == null + ? Text( + "00", + style: + screenFlag == 0 ? styleDigitHome : styleDigitMarathon, + ) + : Text( + time.days! < 10 + ? "0${time.days.toString()}" + : time.days.toString(), + style: + screenFlag == 0 ? styleDigitHome : styleDigitMarathon, + ), + Text( + LocaleKeys.days.tr(), + style: screenFlag == 0 ? styleTextHome : styleTextMarathon, + ), + ], + ), + buildSeparator(), + Column( + children: [ + time.hours == null + ? Text( + "00", + style: + screenFlag == 0 ? styleDigitHome : styleDigitMarathon, + ) + : Text( + time.hours! < 10 + ? "0${time.hours.toString()}" + : time.hours.toString(), + style: + screenFlag == 0 ? styleDigitHome : styleDigitMarathon, + ), + Text( + LocaleKeys.hours.tr(), + style: screenFlag == 0 ? styleTextHome : styleTextMarathon, + ), + ], + ), + buildSeparator(), + Column( + children: [ + time.min == null + ? Text( + "00", + style: + screenFlag == 0 ? styleDigitHome : styleDigitMarathon, + ) + : Text( + time.min! < 10 + ? "0${time.min.toString()}" + : time.min.toString(), + style: + screenFlag == 0 ? styleDigitHome : styleDigitMarathon, + ), + Text( + LocaleKeys.minutes.tr(), + style: screenFlag == 0 ? styleTextHome : styleTextMarathon, + ), + ], + ), + buildSeparator(), + Column( + children: [ + time.sec == null + ? Text( + "00", + style: + screenFlag == 0 ? styleDigitHome : styleDigitMarathon, + ) + : Text( + time.sec! < 10 + ? "0${time.sec.toString()}" + : time.sec.toString(), + style: + screenFlag == 0 ? styleDigitHome : styleDigitMarathon, + ), + Text( + LocaleKeys.seconds.tr(), + style: screenFlag == 0 ? styleTextHome : styleTextMarathon, + ), + ], + ), + ], + ); + } + + @override + Widget build(BuildContext context) { + return CountdownTimer( + endTime: timeToMarathon, + onEnd: null, + widgetBuilder: (BuildContext context, CurrentRemainingTime? time) { + return buildCountdownTimer(time); + }, + ); + } +} diff --git a/lib/ui/marathon/widgets/marathon_banner.dart b/lib/ui/marathon/widgets/marathon_banner.dart index 62711ae..081801d 100644 --- a/lib/ui/marathon/widgets/marathon_banner.dart +++ b/lib/ui/marathon/widgets/marathon_banner.dart @@ -1,21 +1,73 @@ +import 'package:easy_localization/easy_localization.dart'; import 'package:flutter/material.dart'; -import 'package:mohem_flutter_app/classes/decorations_helper.dart'; +import 'package:flutter_svg/flutter_svg.dart'; +import 'package:mohem_flutter_app/classes/colors.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/ui/marathon/marathon_intro_screen.dart'; +import 'package:mohem_flutter_app/ui/marathon/marathon_provider.dart'; +import 'package:mohem_flutter_app/ui/marathon/widgets/countdown_timer.dart'; +import 'package:provider/provider.dart'; class MarathonBanner extends StatelessWidget { const MarathonBanner({Key? key}) : super(key: key); @override Widget build(BuildContext context) { - return Container( - height: 88, - width: double.infinity, - decoration: MyDecorations.shadowDecoration, - child: Center( - child: "Banner Here".toText14(), - ), + MarathonProvider provider = context.read(); + return Stack( + children: [ + SvgPicture.asset( + "assets/images/marathon_banner_bg.svg", + fit: BoxFit.cover, + width: MediaQuery.of(context).size.width - 40, + ), + Row( + mainAxisAlignment: MainAxisAlignment.end, + children: [ + Column( + mainAxisAlignment: MainAxisAlignment.center, + mainAxisSize: MainAxisSize.min, + children: [ + 5.height, + Flexible( + child: const Text( + "Get Ready for the coming contest:", + style: TextStyle( + fontStyle: FontStyle.italic, + fontSize: 11, + fontWeight: FontWeight.w600, + color: MyColors.lightGreyEFColor, + letterSpacing: -0.4, + ), + ).paddingOnly(right: 12), + ), + const Flexible( + child: Text( + "Saudi Arabia", + style: TextStyle( + fontStyle: FontStyle.italic, + fontSize: 20, + fontWeight: FontWeight.bold, + color: MyColors.lightGreyEFColor, + // letterSpacing: -0.4, + ), + ), + ), + 5.height, + BuildCountdownTimer( + timeToMarathon: dummyEndTime, + provider: provider, + screenFlag: 0, + ), + ], + ) + ], + ).paddingOnly(right: 10), + ], ).onPress( () => Navigator.pushNamed(context, AppRoutes.marathonIntroScreen), ); diff --git a/lib/ui/marathon/widgets/marathon_header.dart b/lib/ui/marathon/widgets/marathon_header.dart index 1a5fe5c..4c9c539 100644 --- a/lib/ui/marathon/widgets/marathon_header.dart +++ b/lib/ui/marathon/widgets/marathon_header.dart @@ -9,24 +9,26 @@ class MarathonHeader extends StatelessWidget { @override Widget build(BuildContext context) { - return Container( - color: MyColors.kWhiteColor, - width: double.infinity, - height: 100, - 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), - ) - ], + 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), + ) + ], + ), ), ); } diff --git a/lib/ui/marathon/widgets/question_card.dart b/lib/ui/marathon/widgets/question_card.dart new file mode 100644 index 0000000..2530873 --- /dev/null +++ b/lib/ui/marathon/widgets/question_card.dart @@ -0,0 +1,315 @@ +import 'package:appinio_swiper/appinio_swiper.dart'; +import 'package:flutter/cupertino.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/models/marathon_question_model.dart'; +import 'package:mohem_flutter_app/ui/marathon/marathon_provider.dart'; +import 'package:provider/provider.dart'; + +class QuestionCard extends StatefulWidget { + final MarathonProvider provider; + + const QuestionCard({Key? key, required this.provider}) : super(key: key); + + @override + State createState() => _QuestionCardState(); +} + +class _QuestionCardState extends State { + final List questionCards = []; + + @override + void initState() { + _loadCards(); + super.initState(); + } + + void _loadCards() { + for (DummyQuestionModel question in questions) { + questionCards.add( + QuestionContent(question: question), + ); + } + } + + @override + Widget build(BuildContext context) { + return CupertinoPageScaffold( + child: SizedBox( + height: MediaQuery.of(context).size.height * 0.6, + width: double.infinity, + child: Consumer( + builder: (BuildContext context, MarathonProvider provider, _) { + return AppinioSwiper( + isDisabled: true, + controller: provider.swiperController, + unswipe: (int index, AppinioSwiperDirection direction) {}, + cards: questionCards, + onSwipe: (int index, AppinioSwiperDirection direction) { + if (direction == AppinioSwiperDirection.left){ + provider.startTimer(); + } + }, + ); + }, + ), + ), + ); + } +} + +class QuestionContent extends StatelessWidget { + final DummyQuestionModel question; + + const QuestionContent({ + Key? key, + required this.question, + }) : super(key: key); + + @override + Widget build(BuildContext context) { + return Container( + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(10), + color: CupertinoColors.white, + boxShadow: [ + BoxShadow( + color: CupertinoColors.systemGrey.withOpacity(0.2), + spreadRadius: 3, + blurRadius: 7, + offset: const Offset(0, 3), + ) + ], + ), + alignment: Alignment.center, + child: Column( + children: [ + Container( + height: 90, + width: double.infinity, + decoration: const BoxDecoration( + gradient: LinearGradient( + transform: GradientRotation(.83), + begin: Alignment.topRight, + end: Alignment.bottomLeft, + colors: [ + MyColors.gradiantEndColor, + MyColors.gradiantStartColor, + ], + ), + borderRadius: BorderRadius.only( + topLeft: Radius.circular(10), + topRight: Radius.circular(10), + ), + ), + child: const Center( + child: Text( + "What is the capital of Saudi Arabia?", + style: TextStyle( + color: Colors.white, + fontSize: 18, + fontWeight: FontWeight.w600, + ), + ), + ), + ), + AnswerContent(question: question), + ], + ), + ); + } +} + +class AnswerContent extends StatelessWidget { + final DummyQuestionModel question; + + const AnswerContent({Key? key, required this.question}) : super(key: key); + + @override + Widget build(BuildContext context) { + return Container( + padding: const EdgeInsets.all(15), + decoration: const BoxDecoration( + color: MyColors.kWhiteColor, + borderRadius: BorderRadius.only( + bottomLeft: Radius.circular(10), + bottomRight: Radius.circular(10), + ), + ), + child: Column( + mainAxisSize: MainAxisSize.min, + mainAxisAlignment: MainAxisAlignment.center, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + InkWell( + onTap: () {}, + child: Container( + height: 60, + width: MediaQuery.of(context).size.width - 75, + alignment: Alignment.centerLeft, + decoration: MyDecorations.answerContainerDecoration, + child: Center( + child: Text( + question.opt1!, + style: const TextStyle( + color: MyColors.darkTextColor, + fontWeight: FontWeight.bold, + fontSize: 18, + ), + ), + ), + ), + ), + const SizedBox(height: 15), + InkWell( + onTap: () {}, + child: Container( + height: 60, + width: MediaQuery.of(context).size.width - 75, + alignment: Alignment.centerLeft, + decoration: MyDecorations.answerContainerDecoration, + child: Center( + child: Text( + question.opt2!, + style: const TextStyle( + color: MyColors.darkTextColor, + fontWeight: FontWeight.bold, + fontSize: 18, + ), + ), + ), + ), + ), + const SizedBox(height: 15), + InkWell( + onTap: () {}, + child: Container( + height: 60, + width: MediaQuery.of(context).size.width - 75, + alignment: Alignment.centerLeft, + decoration: MyDecorations.answerContainerDecoration, + child: Center( + child: Text( + question.opt3!, + style: const TextStyle( + color: MyColors.darkTextColor, + fontWeight: FontWeight.bold, + fontSize: 18, + ), + ), + ), + ), + ), + const SizedBox(height: 15), + InkWell( + onTap: () {}, + child: Container( + height: 60, + width: MediaQuery.of(context).size.width - 75, + alignment: Alignment.centerLeft, + decoration: MyDecorations.answerContainerDecoration, + child: Center( + child: Text( + question.opt3!, + style: const TextStyle( + color: MyColors.darkTextColor, + fontWeight: FontWeight.bold, + fontSize: 18, + ), + ), + ), + ), + ), + ], + ), + ); + } +} + +//Column( +// mainAxisSize: MainAxisSize.min, +// mainAxisAlignment: MainAxisAlignment.center, +// crossAxisAlignment: CrossAxisAlignment.center, +// children: [ +// InkWell( +// onTap: () {}, +// child: Container( +// height: 60, +// width: MediaQuery.of(context).size.width - 75, +// alignment: Alignment.centerLeft, +// decoration: MyDecorations.answerContainerDecoration, +// child: Center( +// child: Text( +// question.opt1!, +// style: const TextStyle( +// color: MyColors.darkTextColor, +// fontWeight: FontWeight.bold, +// fontSize: 18, +// ), +// ), +// ), +// ), +// ), +// const SizedBox(height: 15), +// InkWell( +// onTap: () {}, +// child: Container( +// height: 60, +// width: MediaQuery.of(context).size.width - 75, +// alignment: Alignment.centerLeft, +// decoration: MyDecorations.answerContainerDecoration, +// child: Center( +// child: Text( +// question.opt2!, +// style: const TextStyle( +// color: MyColors.darkTextColor, +// fontWeight: FontWeight.bold, +// fontSize: 18, +// ), +// ), +// ), +// ), +// ), +// const SizedBox(height: 15), +// InkWell( +// onTap: () {}, +// child: Container( +// height: 60, +// width: MediaQuery.of(context).size.width - 75, +// alignment: Alignment.centerLeft, +// decoration: MyDecorations.answerContainerDecoration, +// child: Center( +// child: Text( +// question.opt3!, +// style: const TextStyle( +// color: MyColors.darkTextColor, +// fontWeight: FontWeight.bold, +// fontSize: 18, +// ), +// ), +// ), +// ), +// ), +// const SizedBox(height: 15), +// InkWell( +// onTap: () {}, +// child: Container( +// height: 60, +// width: MediaQuery.of(context).size.width - 75, +// alignment: Alignment.centerLeft, +// decoration: MyDecorations.answerContainerDecoration, +// child: Center( +// child: Text( +// question.opt3!, +// style: const TextStyle( +// color: MyColors.darkTextColor, +// fontWeight: FontWeight.bold, +// fontSize: 18, +// ), +// ), +// ), +// ), +// ), +// ], +// ), diff --git a/lib/ui/my_attendance/dynamic_screens/dynamic_input_screen.dart b/lib/ui/my_attendance/dynamic_screens/dynamic_input_screen.dart index 0a6c9d4..1c97b28 100644 --- a/lib/ui/my_attendance/dynamic_screens/dynamic_input_screen.dart +++ b/lib/ui/my_attendance/dynamic_screens/dynamic_input_screen.dart @@ -260,7 +260,7 @@ class _DynamicInputScreenState extends State { for (int i = 0; i < parentsList.length; i++) { for (int j = 0; j < (getEitDffStructureList?.length ?? 0); j++) { - if (getEitDffStructureList![j].sEGMENTNAME == parentsList[i].name) { + if (getEitDffStructureList![j].sEGMENTNAME == parentsList[i].opt1) { if (getEitDffStructureList![j].dISPLAYFLAG != "N") { if (getEitDffStructureList![j].vALIDATIONTYPE == "N") { String? idColName; diff --git a/lib/widgets/button/default_button.dart b/lib/widgets/button/default_button.dart index d572d0c..71de642 100644 --- a/lib/widgets/button/default_button.dart +++ b/lib/widgets/button/default_button.dart @@ -3,7 +3,12 @@ import 'package:flutter_svg/svg.dart'; import 'package:mohem_flutter_app/classes/colors.dart'; extension WithContainer on Widget { - Widget get insideContainer => Container(color: Colors.white, padding: const EdgeInsets.only(top: 16, bottom: 16, right: 21, left: 21), child: this); + Widget get insideContainer => Container( + color: Colors.white, + padding: + const EdgeInsets.only(top: 16, bottom: 16, right: 21, left: 21), + child: this, + ); } class DefaultButton extends StatelessWidget { @@ -19,8 +24,20 @@ class DefaultButton extends StatelessWidget { final int count; final List? colors; - DefaultButton(this.text, this.onPress, - {this.color, this.isTextExpanded = true, this.svgIcon, this.disabledColor, this.count = 0, this.textColor = Colors.white, this.iconData, this.fontSize, this.colors}); + const DefaultButton( + this.text, + this.onPress, { + Key? key, + this.color, + this.isTextExpanded = true, + this.svgIcon, + this.disabledColor, + this.count = 0, + this.textColor = Colors.white, + this.iconData, + this.fontSize, + this.colors, + }) : super(key: key); @override Widget build(BuildContext context) { @@ -31,29 +48,50 @@ class DefaultButton extends StatelessWidget { decoration: BoxDecoration( borderRadius: BorderRadius.circular(6.0), gradient: onPress == null - ? const LinearGradient(colors: [Color(0xffEAEAEA), Color(0xffEAEAEA)]) - : LinearGradient( - transform: GradientRotation(.83), - begin: Alignment.topRight, - end: Alignment.bottomLeft, - colors: colors ?? - [ - MyColors.gradiantEndColor, - MyColors.gradiantStartColor, - ]), + ? const LinearGradient( + colors: [ + Color(0xffEAEAEA), + Color(0xffEAEAEA), + ], + ) + : color == MyColors.yellowColorII + ? const LinearGradient( + colors: [ + MyColors.yellowColorII, + MyColors.yellowColorII, + ], + ) + : LinearGradient( + transform: const GradientRotation(.83), + begin: Alignment.topRight, + end: Alignment.bottomLeft, + colors: colors ?? + [ + MyColors.gradiantEndColor, + MyColors.gradiantStartColor, + ], + ), ), child: Row( mainAxisAlignment: MainAxisAlignment.center, - children: [ + children: [ if (iconData != null) Icon(iconData, color: textColor), - if (svgIcon != null) SvgPicture.asset(svgIcon ?? "", color: textColor), + if (svgIcon != null) + SvgPicture.asset(svgIcon ?? "", color: textColor), if (!isTextExpanded) Padding( - padding: EdgeInsets.only(left: (iconData ?? svgIcon) != null ? 6 : 0), + padding: EdgeInsets.only( + left: (iconData ?? svgIcon) != null ? 6 : 0, + ), child: Text( text, textAlign: TextAlign.center, - style: TextStyle(fontSize: fontSize ?? 16, fontWeight: FontWeight.w600, color: textColor, letterSpacing: -0.48), + style: TextStyle( + fontSize: fontSize ?? 16, + fontWeight: FontWeight.w600, + color: textColor, + letterSpacing: -0.48, + ), ), ), if (isTextExpanded) @@ -61,7 +99,12 @@ class DefaultButton extends StatelessWidget { child: Text( text, textAlign: TextAlign.center, - style: TextStyle(fontSize: fontSize ?? 16, fontWeight: FontWeight.w600, color: textColor, letterSpacing: -0.48), + style: TextStyle( + fontSize: fontSize ?? 16, + fontWeight: FontWeight.w600, + color: textColor, + letterSpacing: -0.48, + ), ), ), if (count > 0) @@ -72,11 +115,19 @@ class DefaultButton extends StatelessWidget { padding: const EdgeInsets.only(left: 5, right: 5), alignment: Alignment.center, height: 16, - decoration: BoxDecoration(borderRadius: BorderRadius.circular(10.0), color: Colors.white), + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(10.0), + color: Colors.white, + ), child: Text( "$count", textAlign: TextAlign.center, - style: const TextStyle(fontSize: 12, fontWeight: FontWeight.w700, color: Color(0xffD02127), letterSpacing: -0.6), + style: const TextStyle( + fontSize: 12, + fontWeight: FontWeight.w700, + color: Color(0xffD02127), + letterSpacing: -0.6, + ), ), ), )