ERM Channel Text URL implemented

master
haroon amjad 4 months ago
parent aaa4f13493
commit c57c22a58c

@ -9,9 +9,9 @@ class ApiConsts {
// static String baseUrl = "https://webservices.hmg.com"; // PreProd // static String baseUrl = "https://webservices.hmg.com"; // PreProd
// static String baseUrl = "https://hmgwebservices.com"; // Live server // 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 = "http://10.20.200.111:1010/";
// static String baseUrl = "https://webservices.hmg.com"; // PreProd // static String baseUrl = "https://webservices.hmg.com"; // PreProd

@ -1,6 +1,7 @@
class Advertisement { class Advertisement {
int? advertisementId; int? advertisementId;
String? advertisementTitle; String? advertisementTitle;
String? advertisementTitleAr;
int? durationInSeconds; int? durationInSeconds;
bool? showDelete; bool? showDelete;
dynamic acknowledgment; dynamic acknowledgment;
@ -16,6 +17,7 @@ class Advertisement {
Advertisement({ Advertisement({
this.advertisementId, this.advertisementId,
this.advertisementTitle, this.advertisementTitle,
this.advertisementTitleAr,
this.durationInSeconds, this.durationInSeconds,
this.showDelete, this.showDelete,
this.acknowledgment, this.acknowledgment,
@ -34,6 +36,7 @@ class Advertisement {
Advertisement.fromJson(Map<String, dynamic> json) { Advertisement.fromJson(Map<String, dynamic> json) {
advertisementId = json['advertisementId']; advertisementId = json['advertisementId'];
advertisementTitle = json['advertisementTitle']; advertisementTitle = json['advertisementTitle'];
advertisementTitleAr = json['advertisementTitleAr'];
durationInSeconds = json['durationInSeconds']; durationInSeconds = json['durationInSeconds'];
showDelete = json['showDelete']; showDelete = json['showDelete'];
acknowledgment = json['acknowledgment']; acknowledgment = json['acknowledgment'];
@ -63,6 +66,7 @@ class Advertisement {
Map<String, dynamic> data = Map<String, dynamic>(); Map<String, dynamic> data = Map<String, dynamic>();
data['advertisementId'] = this.advertisementId; data['advertisementId'] = this.advertisementId;
data['advertisementTitle'] = this.advertisementTitle; data['advertisementTitle'] = this.advertisementTitle;
data['advertisementTitleAr'] = this.advertisementTitleAr;
data['durationInSeconds'] = this.durationInSeconds; data['durationInSeconds'] = this.durationInSeconds;
data['showDelete'] = this.showDelete; data['showDelete'] = this.showDelete;
data['acknowledgment'] = this.acknowledgment; data['acknowledgment'] = this.acknowledgment;

@ -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/extensions/widget_extensions.dart';
import 'package:mohem_flutter_app/main.dart'; import 'package:mohem_flutter_app/main.dart';
import 'package:mohem_flutter_app/models/itg/advertisement.dart' as ads; 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/button/default_button.dart';
import 'package:mohem_flutter_app/widgets/my_video_progress_indicator.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'; import 'package:video_player/video_player.dart';
class ITGAdsScreen extends StatefulWidget { class ITGAdsScreen extends StatefulWidget {
@ -31,6 +33,8 @@ class _ITGAdsScreenState extends State<ITGAdsScreen> {
bool isAudio = false; bool isAudio = false;
String ext = ''; String ext = '';
bool isTextURL = false;
// late File imageFile; // late File imageFile;
late String imageUrl; late String imageUrl;
ads.Advertisement? advertisementData; ads.Advertisement? advertisementData;
@ -45,23 +49,27 @@ class _ITGAdsScreenState extends State<ITGAdsScreen> {
late CountdownTimerController timerController; late CountdownTimerController timerController;
void checkFileType() { void checkFileType() {
String? rFile = advertisementData!.viewAttachFileColl!.first.base64String; if (advertisementData!.viewAttachFileColl!.first.contentType!.toLowerCase() == "text") {
try { isTextURL = true;
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 { } else {
if (ext == ".aac") { String? rFile = advertisementData!.viewAttachFileColl!.first.base64String;
isAudio = true; 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) { // advertisementData?.actionButtonsColl!.forEach((element) {
@ -132,7 +140,17 @@ class _ITGAdsScreenState extends State<ITGAdsScreen> {
timerController = CountdownTimerController(endTime: DateTime.now().millisecondsSinceEpoch + 1000 * videoDuration, onEnd: onTimerEnd); timerController = CountdownTimerController(endTime: DateTime.now().millisecondsSinceEpoch + 1000 * videoDuration, onEnd: onTimerEnd);
} }
return Scaffold( 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( body: Stack(
children: [ children: [
if (isVideo) if (isVideo)
@ -346,6 +364,42 @@ class _ITGAdsScreenState extends State<ITGAdsScreen> {
], ],
), ),
), ),
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');
}
}
},
),
),
],
),
),
], ],
), ),
); );

@ -109,7 +109,7 @@ class _VerifyLastLoginScreenState extends State<VerifyLastLoginScreen> {
Row( Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween, mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.center, 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( Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween, mainAxisAlignment: MainAxisAlignment.spaceBetween,

Loading…
Cancel
Save