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://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

@ -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<String, dynamic> 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<String, dynamic> data = Map<String, dynamic>();
data['advertisementId'] = this.advertisementId;
data['advertisementTitle'] = this.advertisementTitle;
data['advertisementTitleAr'] = this.advertisementTitleAr;
data['durationInSeconds'] = this.durationInSeconds;
data['showDelete'] = this.showDelete;
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/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<ITGAdsScreen> {
bool isAudio = false;
String ext = '';
bool isTextURL = false;
// late File imageFile;
late String imageUrl;
ads.Advertisement? advertisementData;
@ -45,6 +49,9 @@ class _ITGAdsScreenState extends State<ITGAdsScreen> {
late CountdownTimerController timerController;
void checkFileType() {
if (advertisementData!.viewAttachFileColl!.first.contentType!.toLowerCase() == "text") {
isTextURL = true;
} else {
String? rFile = advertisementData!.viewAttachFileColl!.first.base64String;
try {
rFile = advertisementData!.viewAttachFileColl!.where((element) => element.languageId == AppState().getLanguageID(context)).toList().first.base64String;
@ -63,6 +70,7 @@ class _ITGAdsScreenState extends State<ITGAdsScreen> {
isVideo = true;
_futureController = createVideoPlayer(rFile!);
}
}
// advertisementData?.actionButtonsColl!.forEach((element) {
advertisementData?.actionButtonsColl!.removeWhere((element1) => element1.actionButtonId == advertisementData?.skipButtonId);
@ -132,7 +140,17 @@ class _ITGAdsScreenState extends State<ITGAdsScreen> {
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<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(
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,

Loading…
Cancel
Save