|
|
|
|
@ -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');
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
|