import 'dart:math' as math; import 'package:easy_localization/easy_localization.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/date_uitl.dart'; import 'package:mohem_flutter_app/classes/decorations_helper.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/provider/dashboard_provider_model.dart'; import 'package:mohem_flutter_app/ui/marathon/marathon_provider.dart'; import 'package:mohem_flutter_app/ui/marathon/widgets/countdown_timer_main_screen.dart'; import 'package:mohem_flutter_app/widgets/glowy_borders/glowy_borders.dart'; import 'package:provider/provider.dart'; int dummyTime = DateTime.now().millisecondsSinceEpoch + 8690; class EventActivityBanner extends StatelessWidget { const EventActivityBanner({Key? key}) : super(key: key); 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: [ 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: [ 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: [ Column( mainAxisAlignment: MainAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.start, mainAxisSize: MainAxisSize.min, children: [ 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) { DashboardProviderModel dashboardProvider = context.read(); return SizedBox( // decoration: BoxDecoration( // color: MyColors.kWhiteColor, // borderRadius: BorderRadius.circular(8), // boxShadow: [ // BoxShadow( // color: const Color(0xff000000).withOpacity(.05), // blurRadius: 26, // offset: const Offset(0, -3), // ), // ], // ), height: isTablet ? MediaQuery.of(context).size.height * 0.17 : MediaQuery.of(context).size.height * 0.11, child: AnimatedGradientBorder( borderSize: 3, stretchAlongAxis: true, animationTime: 2, stretchAxis: Axis.vertical, gradientColors: const [ Color(0xff0E5A64), Color(0xff0E5A64), Color(0xff0E5A64), Color(0xff91C481), ], borderRadius: BorderRadius.circular(10), child: Container( decoration: BoxDecoration( color: const Color(0xff0E5A64), borderRadius: BorderRadius.circular(8), ), // height: isTablet ? MediaQuery.of(context).size.height * 0.17 : MediaQuery.of(context).size.height * 0.11, child: Stack( children: [ // Transform( // alignment: Alignment.center, // // transform: Matrix4.rotationY( // // AppState().isArabic(context) ? math.pi : 0, // // ), // child: // AppState().isArabic(context) ? Positioned( left: -15, top: -10, child: Transform.rotate( angle: 10, child: SizedBox( child: SvgPicture.asset( "assets/images/light_bulb.svg"), ), ), ) : Positioned( right: 0, top: 10, child: Opacity( opacity: .5, child: SvgPicture.asset( "assets/images/light_bulb.svg", ), )), SizedBox( width: double.infinity, height: double.infinity, child: Row( children: [ Expanded( flex: 3, child: Image.network( dashboardProvider.eventActivity?.shortImageURL ?? "", fit: BoxFit.cover, key: UniqueKey() ).paddingAll(5)), Expanded( flex: AppState().isArabic(context) ? 4 : 5, child: SizedBox( width: double.infinity, height: double.infinity, child: Row( mainAxisAlignment: MainAxisAlignment.start, children: [ Column( mainAxisAlignment: MainAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.start, mainAxisSize: MainAxisSize.min, children: [ AppState().isArabic(context) ? 0.height : 5.height, Flexible( child: Text( displayLocalizedContent( isPhoneLangArabic: AppState().isArabic(context), selectedLanguage: 3, englishContent: dashboardProvider.eventActivity?.titleEn ?? "", arabicContent: dashboardProvider.eventActivity?.titleAr ?? "", ), overflow: TextOverflow.ellipsis, style: TextStyle( fontStyle: FontStyle.italic, fontSize: isTablet ? 25 : 16, fontWeight: FontWeight.bold, color: MyColors.white, height: 32 / 24, ), ), ), Text( displayLocalizedContent( isPhoneLangArabic: AppState().isArabic(context), selectedLanguage: 3, englishContent: dashboardProvider.eventActivity?.shortDescEn ?? "", arabicContent: dashboardProvider.eventActivity?.shortDescAr ?? "", ), style: TextStyle( fontSize: isTablet ? 20 : 11, fontStyle: FontStyle.italic, fontWeight: FontWeight.w600, color: MyColors.white, letterSpacing: -0.5, ), ), isTablet ? 15.height : 10.height, CountdownTimerForMainScreen( timeToMarathon: DateUtil.convertStringToDateMarathon(dashboardProvider.eventActivity!.startOn!).millisecondsSinceEpoch, provider: context.read(), isEvent: true, ), ], ).paddingOnly( left: AppState().isArabic(context) ? 12 : 3, right: AppState().isArabic(context) ? 3 : 12, ) ], ), ), ), ], ), ), !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 = DateUtil.convertStringToDateMarathon(dashboardProvider.eventActivity!.startOn!).difference(DateTime.now()).inMinutes; // if (remainingTimeInMinutes < 0) { Navigator.pushNamed(context, AppRoutes.activityScreen); //} // provider.updateLanguageAsPerMarathon(context, provider.isUpComingMarathon ? provider.marathonDetailModel : provider.demoMarathonDetailModel); })), ), ); } }