diff --git a/android/build.gradle b/android/build.gradle index 7991b9d..dc67123 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -1,5 +1,5 @@ buildscript { - ext.kotlin_version = '1.6.0' + ext.kotlin_version = '1.7.20' repositories { google() mavenCentral() diff --git a/lib/api/dashboard_api_client.dart b/lib/api/dashboard_api_client.dart index dfa4801..544ba71 100644 --- a/lib/api/dashboard_api_client.dart +++ b/lib/api/dashboard_api_client.dart @@ -201,13 +201,15 @@ class DashboardApiClient { }, url, postParams); } - Future setAdvertisementViewed(String masterID, int advertisementId) async { + Future setAdvertisementViewed(String masterID, int advertisementId, String ackValue) async { String url = "${ApiConsts.cocRest}Mohemm_ITG_UpdateAdvertisementAsViewed"; Map postParams = { "ItgNotificationMasterId": masterID, "EmployeeNumber": AppState().memberInformationList!.eMPLOYEENUMBER.toString(), - "ItgAdvertisement": {"advertisementId": advertisementId, "acknowledgment": true} //Mobile Id + "ItgAdvertisementId": advertisementId, + "ItgAcknowledgment": ackValue, + // "ItgAdvertisement": {"ItgAdvertisementId": advertisementId, "ItgAcknowledgment": ackValue} //Mobile Id }; postParams.addAll(AppState().postParamsJson); return await ApiClient().postJsonForObject((json) { diff --git a/lib/models/itg/advertisement.dart b/lib/models/itg/advertisement.dart index 598a248..96f4037 100644 --- a/lib/models/itg/advertisement.dart +++ b/lib/models/itg/advertisement.dart @@ -10,6 +10,9 @@ class Advertisement { this.pageSize, this.pageNo, this.languageId, + this.isOptional, + this.skipButtonTextEn, + this.skipButtonTextAr, }); final int? advertisementId; @@ -22,6 +25,9 @@ class Advertisement { final dynamic pageSize; final dynamic pageNo; final dynamic languageId; + final bool? isOptional; + final String? skipButtonTextEn; + final String? skipButtonTextAr; factory Advertisement.fromJson(Map json) => Advertisement( advertisementId: json["advertisementId"] == null ? null : json["advertisementId"], @@ -34,6 +40,9 @@ class Advertisement { pageSize: json["pageSize"], pageNo: json["pageNo"], languageId: json["languageId"], + isOptional: json["isOptional"] == null ? null : json["isOptional"], + skipButtonTextEn: json["skipBtnTextEn"] == null ? null : json["skipBtnTextEn"], + skipButtonTextAr: json["skipBtnTextAr"] == null ? null : json["skipBtnTextAr"], ); Map toJson() => { 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 160f773..1e280d8 100644 --- a/lib/ui/landing/itg/its_add_screen_video_image.dart +++ b/lib/ui/landing/itg/its_add_screen_video_image.dart @@ -7,6 +7,7 @@ import 'package:flutter/material.dart'; import 'package:flutter_countdown_timer/index.dart'; import 'package:lottie/lottie.dart'; import 'package:mohem_flutter_app/api/dashboard_api_client.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/lottie_consts.dart'; import 'package:mohem_flutter_app/classes/utils.dart'; @@ -15,6 +16,7 @@ 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:mohem_flutter_app/widgets/button/default_button.dart'; import 'package:path_provider/path_provider.dart'; import 'package:video_player/video_player.dart'; @@ -86,11 +88,6 @@ class _ITGAdsScreenState extends State { Future createVideoPlayer(String encodedBytes) async { try { - // Uint8List decodedBytes = base64Decode(encodedBytes.split("base64,").last); - // Directory appDocumentsDirectory = await getApplicationDocumentsDirectory(); // 1 - // File file = Io.File("${appDocumentsDirectory.path}/myAdsVideo.mp4"); - // file.writeAsBytesSync(decodedBytes); - // VideoPlayerController controller = VideoPlayerController.file(file); VideoPlayerController controller = VideoPlayerController.network(advertisementData!.viewAttachFileColl!.first.base64String!); await controller.initialize(); await controller.play(); @@ -113,8 +110,6 @@ class _ITGAdsScreenState extends State { @override void dispose() { if (_controller != null) _controller.dispose(); - // player.stop(); - // player.dispose(); super.dispose(); } @@ -158,41 +153,54 @@ class _ITGAdsScreenState extends State { ), 50.height, ValueListenableBuilder( - valueListenable: hasTimerEnded, - builder: (context, val, child) { - if (hasTimerEndedBool) { - return 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); + valueListenable: hasTimerEnded, + builder: (context, val, child) { + if (hasTimerEndedBool) { + return Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Container( + padding: const EdgeInsets.all(16), decoration: Utils.containerRadius(MyColors.white, 10), child: const Icon(Icons.thumb_up, color: MyColors.gradiantEndColor)) + .onPress(() { + try { Navigator.pop(context); - }); - } catch (ex) { - logger.wtf(ex); - Utils.handleException(ex, context, null); - } - }); - } else { - return Container(); - } - }), - - // 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"), - // ) + DashboardApiClient().setAdvertisementViewed(masterID!, advertisementData!.advertisementId!, "Like").then((value) { + logger.d(value); + }); + } catch (ex) { + logger.wtf(ex); + Utils.handleException(ex, context, null); + } + }), + 20.width, + Container( + padding: const EdgeInsets.all(16), decoration: Utils.containerRadius(MyColors.white, 10), child: const Icon(Icons.thumb_down, color: MyColors.gradiantEndColor)) + .onPress(() { + try { + Navigator.pop(context); + DashboardApiClient().setAdvertisementViewed(masterID!, advertisementData!.advertisementId!, "Dislike").then((value) { + logger.d(value); + }); + } catch (ex) { + logger.wtf(ex); + Utils.handleException(ex, context, null); + } + }), + ], + ); + } else { + return Container(); + } + }, + ), + 20.height, + if (advertisementData?.isOptional ?? false) + DefaultButton(AppState().isArabic(context) ? advertisementData?.skipButtonTextAr ?? "Skip" : advertisementData?.skipButtonTextEn ?? "Skip", () async { + Navigator.pop(context); + DashboardApiClient().setAdvertisementViewed(masterID!, advertisementData!.advertisementId!, "Skip").then((value) { + logger.d(value); + }); + }).paddingOnly(left: 100, right: 100) ], ); } else { @@ -212,9 +220,9 @@ class _ITGAdsScreenState extends State { 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) { + Navigator.pop(context); + DashboardApiClient().setAdvertisementViewed(masterID!, advertisementData!.advertisementId!, "Like").then((value) { logger.d(value); - Navigator.pop(context); }); } catch (ex) { logger.wtf(ex);