From 6e3fc55fde6d49b465e28209dbf653d72f49e4b4 Mon Sep 17 00:00:00 2001 From: Sikander Saleem Date: Tue, 4 Feb 2025 11:06:03 +0300 Subject: [PATCH] event activity added - cont --- lib/api/dashboard_api_client.dart | 10 + lib/classes/consts.dart | 4 +- lib/classes/date_uitl.dart | 2 +- lib/models/dashboard/event_activity.dart | 77 +++ lib/models/generic_response_model.dart | 5 + lib/provider/dashboard_provider_model.dart | 28 +- lib/ui/landing/dashboard_screen.dart | 11 + lib/ui/landing/event_activity_banner.dart | 578 +++++++++++++++++++ lib/widgets/glowy_borders/glowy_borders.dart | 150 +++++ 9 files changed, 859 insertions(+), 6 deletions(-) create mode 100644 lib/models/dashboard/event_activity.dart create mode 100644 lib/ui/landing/event_activity_banner.dart create mode 100644 lib/widgets/glowy_borders/glowy_borders.dart diff --git a/lib/api/dashboard_api_client.dart b/lib/api/dashboard_api_client.dart index bc0fece..89e7d48 100644 --- a/lib/api/dashboard_api_client.dart +++ b/lib/api/dashboard_api_client.dart @@ -105,6 +105,16 @@ class DashboardApiClient { }, url, postParams); } + Future getEventActivity() async { + String url = "${ApiConsts.erpRest}Get_EventActivity"; + Map postParams = {"P_SELECTED_RESP_ID": -999, "P_MENU_TYPE": "E"}; + postParams.addAll(AppState().postParamsJson); + return await ApiClient().postJsonForObject((json) { + GenericResponseModel responseData = GenericResponseModel.fromJson(json); + return responseData; + }, url, postParams); + } + //Mark Attendance Future markAttendance({String lat = "0", String? long = "0", required int pointType, String nfcValue = "", bool isGpsRequired = false, String QRValue = "", String payrollCode = ""}) async { String url = "${ApiConsts.swpRest}AuthenticateAndSwipeUserSupportNFC"; diff --git a/lib/classes/consts.dart b/lib/classes/consts.dart index fea9b75..c2772b8 100644 --- a/lib/classes/consts.dart +++ b/lib/classes/consts.dart @@ -9,9 +9,9 @@ class ApiConsts { // static String baseUrl = "https://webservices.hmg.com"; // PreProd // static String baseUrl = "https://hmgwebservices.com"; // Live server - static String baseUrl = "https://mohemm.hmg.com"; // New Live server + // static String baseUrl = "https://mohemm.hmg.com"; // New Live server // - // static String baseUrl = "https://uat.hmgwebservices.com"; // UAT ser343622ver + static String baseUrl = "https://uat.hmgwebservices.com"; // UAT ser343622ver // static String baseUrl = "http://10.20.200.111:1010/"; // static String baseUrl = "https://webservices.hmg.com"; // PreProd diff --git a/lib/classes/date_uitl.dart b/lib/classes/date_uitl.dart index e27843c..53b6525 100644 --- a/lib/classes/date_uitl.dart +++ b/lib/classes/date_uitl.dart @@ -7,7 +7,7 @@ class DateUtil { /// static DateTime convertStringToDateMarathon(String date) { - // /Date(1585774800000+0300)/ + // return DateTime(2025, 2, 5); if (date != null) { const start = "/Date("; const end = "+0300)"; diff --git a/lib/models/dashboard/event_activity.dart b/lib/models/dashboard/event_activity.dart new file mode 100644 index 0000000..e7e821c --- /dev/null +++ b/lib/models/dashboard/event_activity.dart @@ -0,0 +1,77 @@ +class EventActivityList { + EventActivityList({ + required this.id, + required this.titleEn, + required this.titleAr, + required this.shortDescEn, + required this.shortDescAr, + required this.longDescEn, + required this.longDescAr, + required this.url, + required this.startOn, + required this.endOn, + required this.channel, + required this.isActive, + required this.createdBy, + required this.createdOn, + required this.modifiedBy, + required this.modifiedOn, + }); + + final int? id; + final String? titleEn; + final String? titleAr; + final String? shortDescEn; + final String? shortDescAr; + final String? longDescEn; + final String? longDescAr; + final String? url; + final String? startOn; + final String? endOn; + final int? channel; + final bool? isActive; + final int? createdBy; + final String? createdOn; + final String? modifiedBy; + final String? modifiedOn; + + factory EventActivityList.fromJson(Map json) { + return EventActivityList( + id: json["ID"], + titleEn: json["TitleEn"], + titleAr: json["TitleAr"], + shortDescEn: json["ShortDescEn"], + shortDescAr: json["ShortDescAr"], + longDescEn: json["LongDescEn"], + longDescAr: json["LongDescAr"], + url: json["URL"], + startOn: json["StartOn"], + endOn: json["EndOn"], + channel: json["Channel"], + isActive: json["IsActive"], + createdBy: json["CreatedBy"], + createdOn: json["CreatedOn"], + modifiedBy: json["ModifiedBy"], + modifiedOn: json["ModifiedOn"], + ); + } + + Map toJson() => { + "ID": id, + "TitleEn": titleEn, + "TitleAr": titleAr, + "ShortDescEn": shortDescEn, + "ShortDescAr": shortDescAr, + "LongDescEn": longDescEn, + "LongDescAr": longDescAr, + "URL": url, + "StartOn": startOn, + "EndOn": endOn, + "Channel": channel, + "IsActive": isActive, + "CreatedBy": createdBy, + "CreatedOn": createdOn, + "ModifiedBy": modifiedBy, + "ModifiedOn": modifiedOn, + }; +} diff --git a/lib/models/generic_response_model.dart b/lib/models/generic_response_model.dart index e87c3e0..ba48836 100644 --- a/lib/models/generic_response_model.dart +++ b/lib/models/generic_response_model.dart @@ -1,6 +1,7 @@ import 'package:mohem_flutter_app/models/add_att_success_list_model.dart'; import 'package:mohem_flutter_app/models/add_attachment_list_model.dart'; import 'package:mohem_flutter_app/models/basic_member_information_model.dart'; +import 'package:mohem_flutter_app/models/dashboard/event_activity.dart'; import 'package:mohem_flutter_app/models/dashboard/get_accrual_balances_list_model.dart'; import 'package:mohem_flutter_app/models/dashboard/get_attendance_tracking_list_model.dart'; import 'package:mohem_flutter_app/models/dashboard/get_open_missing_swipes_list_model.dart'; @@ -214,6 +215,7 @@ class GenericResponseModel { List? getItemTypesList; List? getLookupValuesList; List? getMenuEntriesList; + List? getEventActivityList; List? getMoItemHistoryList; List? getMoNotificationBodyList; List? getNotificationButtonsList; @@ -487,6 +489,7 @@ class GenericResponseModel { this.getItemTypesList, this.getLookupValuesList, this.getMenuEntriesList, + this.getEventActivityList, this.getMoItemHistoryList, this.getMoNotificationBodyList, this.getNotificationButtonsList, @@ -974,6 +977,7 @@ class GenericResponseModel { getItemTypesList = json['GetItemTypesList']; getLookupValuesList = json['GetLookupValuesList']; getMenuEntriesList = json["GetMenuEntriesList"] == null ? null : List.from(json["GetMenuEntriesList"].map((x) => GetMenuEntriesList.fromJson(x))); + getEventActivityList = json["EventActivityList"] == null ? null : List.from(json["EventActivityList"].map((x) => EventActivityList.fromJson(x))); if (json['GetMoItemHistoryList'] != null) { getMoItemHistoryList = []; json['GetMoItemHistoryList'].forEach((v) { @@ -1630,6 +1634,7 @@ class GenericResponseModel { data['GetItemTypesList'] = this.getItemTypesList; data['GetLookupValuesList'] = this.getLookupValuesList; data['GetMenuEntriesList'] = this.getMenuEntriesList; + data['EventActivityList'] = this.getEventActivityList; if (this.getMoItemHistoryList != null) { data['GetMoItemHistoryList'] = this.getMoItemHistoryList!.map((v) => v.toJson()).toList(); } diff --git a/lib/provider/dashboard_provider_model.dart b/lib/provider/dashboard_provider_model.dart index e3f6511..9b57133 100644 --- a/lib/provider/dashboard_provider_model.dart +++ b/lib/provider/dashboard_provider_model.dart @@ -9,6 +9,7 @@ import 'package:mohem_flutter_app/config/routes.dart'; import 'package:mohem_flutter_app/generated/locale_keys.g.dart'; import 'package:mohem_flutter_app/main.dart'; import 'package:mohem_flutter_app/models/dashboard/drawer_menu_item_model.dart'; +import 'package:mohem_flutter_app/models/dashboard/event_activity.dart'; import 'package:mohem_flutter_app/models/dashboard/get_accrual_balances_list_model.dart'; import 'package:mohem_flutter_app/models/dashboard/get_attendance_tracking_list_model.dart'; import 'package:mohem_flutter_app/models/dashboard/get_open_notifications_list.dart'; @@ -20,7 +21,6 @@ import 'package:mohem_flutter_app/models/dashboard/mohemm_itg_pending_task_respo import 'package:mohem_flutter_app/models/generic_response_model.dart'; import 'package:mohem_flutter_app/models/itg/itg_response_model.dart'; import 'package:mohem_flutter_app/models/offers_and_discounts/get_offers_list.dart'; -import 'package:mohem_flutter_app/ui/landing/dashboard_screen.dart'; import 'package:mohem_flutter_app/widgets/dialogs/confirm_dialog.dart'; /// Mix-in [DiagnosticableTreeMixin] to have access to [debugFillProperties] for the devtool @@ -50,9 +50,12 @@ class DashboardProviderModel with ChangeNotifier, DiagnosticableTreeMixin { //Menu Entries bool isServicesMenusLoading = true; + bool isEventLoadingLoading = true; List? homeMenus; List? getMenuEntriesList; + EventActivityList? eventActivity; + //Offers And Discounts bool isOffersLoading = true; List getOffersList = []; @@ -99,6 +102,7 @@ class DashboardProviderModel with ChangeNotifier, DiagnosticableTreeMixin { ticketBalance = 0; isServicesMenusLoading = true; + isEventLoadingLoading = true; homeMenus = null; getMenuEntriesList = null; isOffersLoading = true; @@ -253,10 +257,28 @@ class DashboardProviderModel with ChangeNotifier, DiagnosticableTreeMixin { notifyListeners(); } catch (ex) { // Utils.hideLoading(context); - getOffersList=[]; + getOffersList = []; isOffersLoading = false; notifyListeners(); - // Utils.handleException(ex, context, null); + // Utils.handleException(ex, context, null); + } + } + + void fetchEventActivity() async { + try { + GenericResponseModel? genericResponseModel = await DashboardApiClient().getEventActivity(); + List eventList = (genericResponseModel!.getEventActivityList ?? []); + if (eventList.isNotEmpty) { + eventActivity = eventList.first; + } + + isEventLoadingLoading = false; + notifyListeners(); + } catch (ex) { + logger.wtf(ex); + isEventLoadingLoading = false; + notifyListeners(); + Utils.handleException(ex, null, null); } } diff --git a/lib/ui/landing/dashboard_screen.dart b/lib/ui/landing/dashboard_screen.dart index 4448ad1..67e748c 100644 --- a/lib/ui/landing/dashboard_screen.dart +++ b/lib/ui/landing/dashboard_screen.dart @@ -21,6 +21,7 @@ import 'package:mohem_flutter_app/models/offers_and_discounts/get_offers_list.da import 'package:mohem_flutter_app/models/privilege_list_model.dart'; import 'package:mohem_flutter_app/provider/chat_provider_model.dart'; import 'package:mohem_flutter_app/provider/dashboard_provider_model.dart'; +import 'package:mohem_flutter_app/ui/landing/event_activity_banner.dart'; import 'package:mohem_flutter_app/ui/landing/widget/app_drawer.dart'; import 'package:mohem_flutter_app/ui/landing/widget/menus_widget.dart'; import 'package:mohem_flutter_app/ui/landing/widget/services_widget.dart'; @@ -149,6 +150,7 @@ class _DashboardScreenState extends State with WidgetsBindingOb data.fetchMissingSwipe(context); data.fetchLeaveTicketBalance(context, DateTime.now()); data.fetchMenuEntries(); + data.fetchEventActivity(); data.getCategoryOffersListAPI(context); marathonProvider.getMarathonDetailsFromApi(); marathonProvider.getMarathonTutorial(); @@ -420,6 +422,7 @@ class _DashboardScreenState extends State with WidgetsBindingOb ), ], ).paddingOnly(left: 21, right: 21, top: 7, bottom: 21), + eventActivityWidget(context), Consumer(builder: (BuildContext context, DashboardProviderModel model, Widget? child) { if (!model.isOffersLoading && model.getOffersList.isEmpty) { return const SizedBox(); @@ -706,6 +709,14 @@ class _DashboardScreenState extends State with WidgetsBindingOb ); } + Widget eventActivityWidget(BuildContext context) { + return (context.watch().isEventLoadingLoading) + ? const MarathonBannerShimmer().paddingOnly(left: 21, right: 21, bottom: 21, top: 0) + : context.watch().eventActivity == null + ? const SizedBox() + : const EventActivityBanner().paddingOnly(left: 21, right: 21, bottom: 21, top: 0); + } + void navigateToDetails(OffersListModel offersListModelObj) { List getOffersDetailList = []; getOffersDetailList.clear(); diff --git a/lib/ui/landing/event_activity_banner.dart b/lib/ui/landing/event_activity_banner.dart new file mode 100644 index 0000000..83c58dd --- /dev/null +++ b/lib/ui/landing/event_activity_banner.dart @@ -0,0 +1,578 @@ +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'; + +// It is used to pass a dummy time to test Marathon +int dummyTime = DateTime.now().millisecondsSinceEpoch + 8690; + +class EventActivityBanner extends StatelessWidget { + const EventActivityBanner({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: [ + // 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.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: [ + 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 Container( + // 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: 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.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: 3, + englishContent: dashboardProvider.eventActivity?.titleEn ?? "", + arabicContent: dashboardProvider.eventActivity?.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, + CountdownTimerForMainScreen( + timeToMarathon: DateUtil.convertStringToDateMarathon(dashboardProvider.eventActivity!.startOn!).millisecondsSinceEpoch, + provider: context.read(), + ), + ], + ).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(dashboardProvider.eventActivity!.startOn!).difference(DateTime.now()).inMinutes; + // if (remainingTimeInMinutes > 5 && dashboardProvider.eventActivity.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); + })), + ), + ); + } +} diff --git a/lib/widgets/glowy_borders/glowy_borders.dart b/lib/widgets/glowy_borders/glowy_borders.dart new file mode 100644 index 0000000..ffdc31b --- /dev/null +++ b/lib/widgets/glowy_borders/glowy_borders.dart @@ -0,0 +1,150 @@ +library glowy_borderspertino.dart; + +import 'dart:math' as math; + +import 'package:flutter/cupertino.dart'; +import 'package:mohem_flutter_app/classes/colors.dart'; + +class AnimatedGradientBorder extends StatefulWidget { + const AnimatedGradientBorder( + {Key? key, + required this.child, + required this.gradientColors, + required this.borderRadius, + this.animationTime, + this.borderSize, + this.animationProgress, + this.stretchAlongAxis = false, + this.stretchAxis = Axis.horizontal}); + + final Widget child; + final double? borderSize; + final List gradientColors; + final BorderRadiusGeometry borderRadius; + final int? animationTime; + final double? animationProgress; + final bool stretchAlongAxis; + final Axis stretchAxis; + + @override + State createState() => AnimatedGradientState(); +} + +class AnimatedGradientState extends State with SingleTickerProviderStateMixin { + late AnimationController _controller; + late Animation _angleAnimation; + + @override + void initState() { + super.initState(); + _controller = AnimationController(vsync: this, duration: Duration(seconds: widget.animationTime ?? 2)); + _controller.addListener(() => setState(() {})); + _angleAnimation = Tween(begin: 0.1, end: 2 * math.pi).animate(_controller); + if (widget.animationProgress != null) { + _controller.forward(); + } else { + _controller.repeat(); + } + } + + @override + void dispose() { + _controller.dispose(); + super.dispose(); + } + + @override + void didUpdateWidget(covariant AnimatedGradientBorder oldWidget) { + super.didUpdateWidget(oldWidget); + double? animateTo = widget.animationProgress; + if (animateTo != null) { + _controller.animateTo(animateTo); + } else { + _controller.repeat(); + } + } + + @override + Widget build(BuildContext context) { + double? negativeMargin = -1.0 * (widget.borderSize ?? 0); + return Container( + padding: EdgeInsets.all(widget.borderSize ?? 0), + clipBehavior: Clip.hardEdge, + decoration: BoxDecoration( + color: MyColors.kWhiteColor, + borderRadius: BorderRadius.circular(10), + boxShadow: [ + BoxShadow( + color: const Color(0xff000000).withOpacity(.05), + blurRadius: 26, + offset: const Offset(0, -3), + ), + ], + ), + child: Stack(alignment: Alignment.center, clipBehavior: Clip.none, children: [ + Positioned( + top: negativeMargin, + left: negativeMargin, + right: negativeMargin, + bottom: negativeMargin, + child: AnimatedGradientContainer( + gradientColors: widget.gradientColors, + borderRadius: widget.borderRadius, + gradientAngle: _angleAnimation.value, + )), + widget.child, + // BackdropFilter( + // filter: ImageFilter.blur(sigmaX: widget.glowSize ?? 0, sigmaY: widget.glowSize ?? 0), + // child: Stack( + // alignment: Alignment.center, + // clipBehavior: Clip.none, + // children: [ + // Positioned( + // top: negativeMargin, + // right: negativeMargin, + // left: negativeMargin, + // bottom: negativeMargin, + // child: AnimatedGradientContainer( + // gradientColors: widget.gradientColors, + // borderRadius: widget.borderRadius, + // gradientAngle: _angleAnimation.value, + // )), + // if (widget.stretchAlongAxis) + // SizedBox( + // width: widget.stretchAxis == Axis.horizontal ? double.infinity : null, + // height: widget.stretchAxis == Axis.vertical ? double.infinity : null, + // child: widget.child, + // ) + // else + // widget.child, + // ], + // ), + // ), + ]), + ); + } +} + +class AnimatedGradientContainer extends StatelessWidget { + const AnimatedGradientContainer({Key? key, required this.gradientColors, required this.gradientAngle, required this.borderRadius}); + + final List gradientColors; + final double gradientAngle; + final BorderRadiusGeometry borderRadius; + + @override + Widget build(BuildContext context) { + return Container( + decoration: BoxDecoration( + borderRadius: borderRadius, + gradient: SweepGradient( + colors: [...gradientColors, ...gradientColors.reversed], stops: _generateColorStops([...gradientColors, ...gradientColors.reversed]), transform: GradientRotation(gradientAngle)))); + } + + List _generateColorStops(List colors) { + return colors.asMap().entries.map((entry) { + double percentageStop = entry.key / colors.length; + return percentageStop; + }).toList(); + } +}