From c57c22a58c1aecb51c7b666fdb18671e010e0bf8 Mon Sep 17 00:00:00 2001 From: haroon amjad Date: Sun, 29 Jun 2025 17:31:56 +0300 Subject: [PATCH 1/2] ERM Channel Text URL implemented --- lib/classes/consts.dart | 4 +- lib/models/itg/advertisement.dart | 4 + .../itg/its_add_screen_video_image.dart | 86 +++++++++++++++---- lib/ui/login/verify_last_login_screen.dart | 2 +- 4 files changed, 77 insertions(+), 19 deletions(-) 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/models/itg/advertisement.dart b/lib/models/itg/advertisement.dart index fb172ad..002f73d 100644 --- a/lib/models/itg/advertisement.dart +++ b/lib/models/itg/advertisement.dart @@ -1,6 +1,7 @@ class Advertisement { int? advertisementId; String? advertisementTitle; + String? advertisementTitleAr; int? durationInSeconds; bool? showDelete; dynamic acknowledgment; @@ -16,6 +17,7 @@ class Advertisement { Advertisement({ this.advertisementId, this.advertisementTitle, + this.advertisementTitleAr, this.durationInSeconds, this.showDelete, this.acknowledgment, @@ -34,6 +36,7 @@ class Advertisement { Advertisement.fromJson(Map json) { advertisementId = json['advertisementId']; advertisementTitle = json['advertisementTitle']; + advertisementTitleAr = json['advertisementTitleAr']; durationInSeconds = json['durationInSeconds']; showDelete = json['showDelete']; acknowledgment = json['acknowledgment']; @@ -63,6 +66,7 @@ class Advertisement { Map data = Map(); data['advertisementId'] = this.advertisementId; data['advertisementTitle'] = this.advertisementTitle; + data['advertisementTitleAr'] = this.advertisementTitleAr; data['durationInSeconds'] = this.durationInSeconds; data['showDelete'] = this.showDelete; data['acknowledgment'] = this.acknowledgment; 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 6e1358c..99911b9 100644 --- a/lib/ui/landing/itg/its_add_screen_video_image.dart +++ b/lib/ui/landing/itg/its_add_screen_video_image.dart @@ -11,8 +11,10 @@ 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/app_bar_widget.dart'; import 'package:mohem_flutter_app/widgets/button/default_button.dart'; import 'package:mohem_flutter_app/widgets/my_video_progress_indicator.dart'; +import 'package:url_launcher/url_launcher.dart'; import 'package:video_player/video_player.dart'; class ITGAdsScreen extends StatefulWidget { @@ -31,6 +33,8 @@ class _ITGAdsScreenState extends State { bool isAudio = false; String ext = ''; + bool isTextURL = false; + // late File imageFile; late String imageUrl; ads.Advertisement? advertisementData; @@ -45,23 +49,27 @@ class _ITGAdsScreenState extends State { late CountdownTimerController timerController; void checkFileType() { - String? rFile = advertisementData!.viewAttachFileColl!.first.base64String; - try { - rFile = advertisementData!.viewAttachFileColl!.where((element) => element.languageId == AppState().getLanguageID(context)).toList().first.base64String; - } catch (ex) {} - - String? rFileExt = advertisementData!.viewAttachFileColl!.first.fileName; - ext = "." + rFileExt!.split(".").last.toLowerCase(); - if (ext == ".png" || ext == ".jpg" || ext == ".jpeg" || ext == ".gif") { - // await processImage(); - imageUrl = rFile!; - isImage = true; + if (advertisementData!.viewAttachFileColl!.first.contentType!.toLowerCase() == "text") { + isTextURL = true; } else { - if (ext == ".aac") { - isAudio = true; + String? rFile = advertisementData!.viewAttachFileColl!.first.base64String; + try { + rFile = advertisementData!.viewAttachFileColl!.where((element) => element.languageId == AppState().getLanguageID(context)).toList().first.base64String; + } catch (ex) {} + + String? rFileExt = advertisementData!.viewAttachFileColl!.first.fileName; + ext = "." + rFileExt!.split(".").last.toLowerCase(); + if (ext == ".png" || ext == ".jpg" || ext == ".jpeg" || ext == ".gif") { + // await processImage(); + imageUrl = rFile!; + isImage = true; + } else { + if (ext == ".aac") { + isAudio = true; + } + isVideo = true; + _futureController = createVideoPlayer(rFile!); } - isVideo = true; - _futureController = createVideoPlayer(rFile!); } // advertisementData?.actionButtonsColl!.forEach((element) { @@ -132,7 +140,17 @@ class _ITGAdsScreenState extends State { timerController = CountdownTimerController(endTime: DateTime.now().millisecondsSinceEpoch + 1000 * videoDuration, onEnd: onTimerEnd); } return Scaffold( - backgroundColor: Colors.black, + backgroundColor: isTextURL ? Colors.white : Colors.black, + appBar: isTextURL + ? AppBar( + centerTitle: true, + automaticallyImplyLeading: false, + backgroundColor: Colors.white, + title: (AppState().isArabic(context) ? advertisementData!.advertisementTitleAr! : advertisementData!.advertisementTitleAr!).toText24(color: MyColors.darkTextColor, isBold: true), + + //advertisementData!.viewAttachFileColl!.first.base64String!.toText24(color: MyColors.darkTextColor, isBold: true), + ) + : null, body: Stack( children: [ if (isVideo) @@ -346,6 +364,42 @@ class _ITGAdsScreenState extends State { ], ), ), + if (isTextURL) + SingleChildScrollView( + padding: const EdgeInsets.all(21), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisSize: MainAxisSize.min, + children: [ + (AppState().isArabic(context) ? advertisementData!.viewAttachFileColl![0].base64String! : advertisementData!.viewAttachFileColl![1].base64String!) + .toText16(color: MyColors.darkTextColor), + 24.height, + ListView.separated( + itemCount: advertisementData!.actionButtonsColl?.length ?? 0, + separatorBuilder: (cxt, index) => 16.height, + shrinkWrap: true, + physics: const NeverScrollableScrollPhysics(), + padding: EdgeInsets.zero, + itemBuilder: (cxt, index) => DefaultButton( + AppState().isArabic(context) ? advertisementData!.actionButtonsColl![index].btnTextAr : advertisementData!.actionButtonsColl![index].btnTextEn, + () async { + if (advertisementData!.actionButtonsColl![index].actionValue.toLowerCase() == "skip") { + Navigator.pop(context); + } else { + Uri uri = Uri.parse(advertisementData!.actionButtonsColl![index].iconOrImage); + if (await canLaunchUrl(uri)) { + await launchUrl(uri); + Navigator.pop(context); + } else { + Utils.showToast('Could not launch'); + } + } + }, + ), + ), + ], + ), + ), ], ), ); diff --git a/lib/ui/login/verify_last_login_screen.dart b/lib/ui/login/verify_last_login_screen.dart index 1cdab8f..05b5c35 100644 --- a/lib/ui/login/verify_last_login_screen.dart +++ b/lib/ui/login/verify_last_login_screen.dart @@ -109,7 +109,7 @@ class _VerifyLastLoginScreenState extends State { Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, crossAxisAlignment: CrossAxisAlignment.center, - children: [LocaleKeys.lastLoginDetails.tr().toText16(), DateUtil.formatDateToDate(DateUtil.convertStringToDate(mobileLoginInfoListModel!.editedOn!), false).toText12()], + children: [LocaleKeys.lastLoginDetails.tr().toText16(), DateUtil.formatDateToDate(DateUtil.convertStringToDate(mobileLoginInfoListModel!.editedOn ?? DateTime.now().toString()), false).toText12()], ), Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, From dcbf7b386a611266bb251e829591ea87ddf85d93 Mon Sep 17 00:00:00 2001 From: haroon amjad Date: Mon, 7 Jul 2025 13:00:58 +0300 Subject: [PATCH 2/2] Survey link launch issue fixed, Updated to Stores VersionID 9.1 --- lib/ui/landing/itg/its_add_screen_video_image.dart | 13 ++++++++----- pubspec.yaml | 6 ++++-- 2 files changed, 12 insertions(+), 7 deletions(-) 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 99911b9..103fde1 100644 --- a/lib/ui/landing/itg/its_add_screen_video_image.dart +++ b/lib/ui/landing/itg/its_add_screen_video_image.dart @@ -387,12 +387,15 @@ class _ITGAdsScreenState extends State { Navigator.pop(context); } else { Uri uri = Uri.parse(advertisementData!.actionButtonsColl![index].iconOrImage); - if (await canLaunchUrl(uri)) { - await launchUrl(uri); - Navigator.pop(context); - } else { + // if (await canLaunchUrl(uri)) { + await launchUrl(uri, mode: LaunchMode.externalApplication).catchError((err) { + // print(err); Utils.showToast('Could not launch'); - } + }); + Navigator.pop(context); + // } else { + // Utils.showToast('Could not launch'); + // } } }, ), diff --git a/pubspec.yaml b/pubspec.yaml index f4f08b1..9f35f3b 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -16,8 +16,9 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev # In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion. # Read more about iOS versioning at # https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html -#version: 3.3.01+300040 -version: 3.6.3+300073 + +version: 3.6.6+300076 +#version: 3.8.999+2 environment: sdk: ">=2.16.0 <3.0.0" @@ -64,6 +65,7 @@ dependencies: geolocator: ^11.1.0 month_year_picker: ^0.2.0+1 month_picker_dialog_2: ^0.5.5 +# month_picker_dialog: ^6.2.3 # open_file: ^3.2.1 open_filex: ^4.4.0 wifi_iot: ^0.3.19+1