diff --git a/lib/api/dashboard_api_client.dart b/lib/api/dashboard_api_client.dart index 95631a9..5126f6d 100644 --- a/lib/api/dashboard_api_client.dart +++ b/lib/api/dashboard_api_client.dart @@ -199,17 +199,17 @@ class DashboardApiClient { }, url, postParams); } -// Future setAdvertisementViewed(String masterID, int advertisementId) async { -// String url = "${ApiConsts.cocRest}Mohemm_ITG_UpdateAdvertisementAsViewed"; -// -// Map postParams = { -// "ItgNotificationMasterId": masterID, -// "ItgAdvertisement": {"advertisementId": advertisementId, "acknowledgment": true} //Mobile Id -// }; -// postParams.addAll(AppState().postParamsJson); -// return await ApiClient().postJsonForObject((json) { -// // ItgMainRes responseData = ItgMainRes.fromJson(json); -// return json; -// }, url, postParams); -// } +Future setAdvertisementViewed(String masterID, int advertisementId) async { + String url = "${ApiConsts.cocRest}Mohemm_ITG_UpdateAdvertisementAsViewed"; + + Map postParams = { + "ItgNotificationMasterId": masterID, + "ItgAdvertisement": {"advertisementId": advertisementId, "acknowledgment": true} //Mobile Id + }; + postParams.addAll(AppState().postParamsJson); + return await ApiClient().postJsonForObject((json) { + // ItgMainRes responseData = ItgMainRes.fromJson(json); + return json; + }, url, postParams); +} } diff --git a/lib/classes/utils.dart b/lib/classes/utils.dart index 3368f83..076e8ab 100644 --- a/lib/classes/utils.dart +++ b/lib/classes/utils.dart @@ -226,6 +226,7 @@ class Utils { return BoxDecoration( color: background, border: Border.all( + width: 1, // color: background // <--- border width here ), diff --git a/lib/ui/landing/dashboard_screen.dart b/lib/ui/landing/dashboard_screen.dart index ed064ac..1de8913 100644 --- a/lib/ui/landing/dashboard_screen.dart +++ b/lib/ui/landing/dashboard_screen.dart @@ -16,7 +16,6 @@ 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/models/offers_and_discounts/get_offers_list.dart'; import 'package:mohem_flutter_app/provider/chat_provider_model.dart'; import 'package:mohem_flutter_app/provider/dashboard_provider_model.dart'; @@ -143,10 +142,47 @@ class _DashboardScreenState extends State with WidgetsBindingOb data.fetchMenuEntries(); data.getCategoryOffersListAPI(context); marathonProvider.getMarathonDetailsFromApi(); + if(isFromInit) { + checkERMChannel(); + } if (!cProvider.disbaleChatForThisUser && !isFromInit) checkHubCon(); _refreshController.refreshCompleted(); } + void checkERMChannel() { + data.getITGNotification().then((val) { + if (val!.result!.data != null) { + print("-------------------- Survey ----------------------------"); + if (val.result!.data!.notificationType == "Survey") { + Navigator.pushNamed(context, AppRoutes.survey, arguments: val.result!.data); + } else { + print("------------------------------------------- Ads --------------------"); + DashboardApiClient().getAdvertisementDetail(val.result!.data!.notificationMasterId ?? "").then( + (value) { + if (value!.mohemmItgResponseItem!.statusCode == 200) { + if (value.mohemmItgResponseItem!.result!.data != null) { + Navigator.pushNamed(context, AppRoutes.advertisement, arguments: { + "masterId": val.result!.data!.notificationMasterId, + "advertisement": value.mohemmItgResponseItem!.result!.data!.advertisement, + }); + // Navigator.push( + // context, + // MaterialPageRoute( + // builder: (BuildContext context) => ITGAdsScreen( + // addMasterId: val.result!.data!.notificationMasterId!, + // advertisement: value.mohemmItgResponseItem!.result!.data!.advertisement!, + // ), + // ), + // ); + } + } + }, + ); + } + } + }); + } + @override Widget build(BuildContext context) { return Scaffold( diff --git a/lib/ui/landing/itg/its_add_screen_video_image.dart b/lib/ui/landing/itg/its_add_screen_video_image.dart index bcb9ed4..d5fe237 100644 --- a/lib/ui/landing/itg/its_add_screen_video_image.dart +++ b/lib/ui/landing/itg/its_add_screen_video_image.dart @@ -2,10 +2,15 @@ import 'dart:convert'; import 'dart:io' as Io; import 'dart:io'; import 'dart:typed_data'; + import 'package:flutter/material.dart'; -import 'package:just_audio/just_audio.dart'; +import 'package:flutter_countdown_timer/index.dart'; import 'package:mohem_flutter_app/api/dashboard_api_client.dart'; import 'package:mohem_flutter_app/classes/colors.dart'; +import 'package:mohem_flutter_app/classes/utils.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/main.dart'; import 'package:mohem_flutter_app/models/itg/advertisement.dart' as ads; import 'package:path_provider/path_provider.dart'; @@ -29,6 +34,7 @@ class _ITGAdsScreenState extends State { ads.Advertisement? advertisementData; dynamic data; String? masterID; + int videoDuration = 0; void checkFileType() async { String? rFile = advertisementData!.viewAttachFileColl!.first.base64String; @@ -42,7 +48,7 @@ class _ITGAdsScreenState extends State { _futureController = createVideoPlayer(rFile!); } setState(() {}); - initTimer(); + // initTimer(); } Future processImage(String encodedBytes) async { @@ -76,7 +82,7 @@ class _ITGAdsScreenState extends State { void initTimer() { Future.delayed(const Duration(seconds: 5), () { skip = true; - setState(() {}); + // setState(() {}); }); } @@ -93,9 +99,11 @@ class _ITGAdsScreenState extends State { if (masterID == null) masterID = data["masterId"]; if (advertisementData != null) { checkFileType(); + videoDuration = advertisementData?.durationInSeconds ?? 0; + print("VIDEO DURATION: $videoDuration"); } - // double height = MediaQuery.of(context).size.height * .25; return Scaffold( + backgroundColor: Colors.black, body: Stack( children: [ if (isVideo) @@ -104,11 +112,50 @@ class _ITGAdsScreenState extends State { builder: (BuildContext context, AsyncSnapshot snapshot) { if (snapshot.connectionState == ConnectionState.done && snapshot.data != null) { _controller = snapshot.data as VideoPlayerController; - return Positioned.fill( - child: AspectRatio( - aspectRatio: _controller.value.aspectRatio, - child: VideoPlayer(_controller), - ), + return Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Center( + child: AspectRatio( + aspectRatio: _controller.value.aspectRatio, + child: VideoPlayer(_controller), + ), + ), + 30.height, + CountdownTimer( + endTime: DateTime.now().millisecondsSinceEpoch + 1000 * videoDuration, + onEnd: null, + endWidget: "00:00:00".toText14(color: Colors.white, isBold: true), + textStyle: const TextStyle(color: Colors.white, fontSize: 16, letterSpacing: -0.48, fontWeight: FontWeight.bold), + ), + 50.height, + Container(padding: const EdgeInsets.all(16), decoration: Utils.containerRadius(MyColors.white, 10), child: const Icon(Icons.thumb_up, color: MyColors.gradiantEndColor)) + .onPress(() { + try { + DashboardApiClient().setAdvertisementViewed(masterID!, advertisementData!.advertisementId!).then((value) { + logger.d(value); + Navigator.pop(context); + }); + } catch (ex) { + logger.wtf(ex); + Utils.handleException(ex, context, null); + } + }), + // DefaultButton(LocaleKeys.home.tr(), () async { + // DashboardApiClient().setAdvertisementViewed(masterID!, advertisementData!.advertisementId!).then((value) { + // logger.d(value); + // }); + // }).paddingOnly(left: 50, right: 50) + + // ElevatedButton( + // onPressed: () async { + // // DashboardApiClient().setAdvertisementViewed(widget.addMasterId, widget.advertisement!.advertisementId!).then((value) { + // // logger.d(value); + // // }); + // }, + // child: const Text("Go To Dashboard"), + // ) + ], ); } else { return const Center( @@ -118,15 +165,7 @@ class _ITGAdsScreenState extends State { }, ), if (isImage) Image.file(imageFile), - if (skip) - ElevatedButton( - onPressed: () async { - // DashboardApiClient().setAdvertisementViewed(widget.addMasterId, widget.advertisement!.advertisementId!).then((value) { - // logger.d(value); - // }); - }, - child: const Text("Go To Dashboard"), - ) + // if (skip) ], ), );