|  |  |  | @ -39,6 +39,12 @@ class _ITGAdsScreenState extends State<ITGAdsScreen> { | 
		
	
		
			
				|  |  |  |  |   String? masterID; | 
		
	
		
			
				|  |  |  |  |   int videoDuration = 0; | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  |   bool hasTimerEndedBool = false; | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  |   final ValueNotifier<bool> hasTimerEnded = ValueNotifier(false); | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  |   late CountdownTimerController timerController; | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  |   void checkFileType() async { | 
		
	
		
			
				|  |  |  |  |     String? rFile = advertisementData!.viewAttachFileColl!.first.base64String; | 
		
	
		
			
				|  |  |  |  |     String? rFileExt = advertisementData!.viewAttachFileColl!.first.fileName; | 
		
	
	
		
			
				
					|  |  |  | @ -56,6 +62,17 @@ class _ITGAdsScreenState extends State<ITGAdsScreen> { | 
		
	
		
			
				|  |  |  |  |     setState(() {}); | 
		
	
		
			
				|  |  |  |  |   } | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  |   void changeTimer(bool isTimerEnd) { | 
		
	
		
			
				|  |  |  |  |     hasTimerEndedBool = isTimerEnd; | 
		
	
		
			
				|  |  |  |  |     hasTimerEnded.value = !hasTimerEnded.value; | 
		
	
		
			
				|  |  |  |  |   } | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  |   void onTimerEnd() { | 
		
	
		
			
				|  |  |  |  |     changeTimer(true); | 
		
	
		
			
				|  |  |  |  |     timerController.disposeTimer(); | 
		
	
		
			
				|  |  |  |  |     timerController.dispose(); | 
		
	
		
			
				|  |  |  |  |   } | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  |   Future processImage(String encodedBytes) async { | 
		
	
		
			
				|  |  |  |  |     try { | 
		
	
		
			
				|  |  |  |  |       Uint8List decodedBytes = base64Decode(encodedBytes.split("base64,").last); | 
		
	
	
		
			
				
					|  |  |  | @ -69,18 +86,20 @@ class _ITGAdsScreenState extends State<ITGAdsScreen> { | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  |   Future<VideoPlayerController> 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); | 
		
	
		
			
				|  |  |  |  |       // 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(); | 
		
	
		
			
				|  |  |  |  |       await controller.setVolume(1.0); | 
		
	
		
			
				|  |  |  |  |       await controller.setLooping(false); | 
		
	
		
			
				|  |  |  |  |       return controller; | 
		
	
		
			
				|  |  |  |  |     } catch (e) { | 
		
	
		
			
				|  |  |  |  |       return VideoPlayerController.asset("dataSource"); | 
		
	
		
			
				|  |  |  |  |       print(e); | 
		
	
		
			
				|  |  |  |  |       return VideoPlayerController.network("https://apimohemmweb.cloudsolutions.com.sa/ErmAttachment/compressedvideo.mp4"); | 
		
	
		
			
				|  |  |  |  |     } | 
		
	
		
			
				|  |  |  |  |   } | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
	
		
			
				
					|  |  |  | @ -107,6 +126,7 @@ class _ITGAdsScreenState extends State<ITGAdsScreen> { | 
		
	
		
			
				|  |  |  |  |     if (advertisementData != null) { | 
		
	
		
			
				|  |  |  |  |       checkFileType(); | 
		
	
		
			
				|  |  |  |  |       videoDuration = advertisementData?.durationInSeconds ?? 0; | 
		
	
		
			
				|  |  |  |  |       timerController = CountdownTimerController(endTime: DateTime.now().millisecondsSinceEpoch + 1000 * videoDuration, onEnd: onTimerEnd); | 
		
	
		
			
				|  |  |  |  |     } | 
		
	
		
			
				|  |  |  |  |     return Scaffold( | 
		
	
		
			
				|  |  |  |  |       backgroundColor: Colors.black, | 
		
	
	
		
			
				
					|  |  |  | @ -131,24 +151,34 @@ class _ITGAdsScreenState extends State<ITGAdsScreen> { | 
		
	
		
			
				|  |  |  |  |                       ), | 
		
	
		
			
				|  |  |  |  |                       30.height, | 
		
	
		
			
				|  |  |  |  |                       CountdownTimer( | 
		
	
		
			
				|  |  |  |  |                         controller: timerController, | 
		
	
		
			
				|  |  |  |  |                         endTime: DateTime.now().millisecondsSinceEpoch + 1000 * videoDuration, | 
		
	
		
			
				|  |  |  |  |                         onEnd: null, | 
		
	
		
			
				|  |  |  |  |                         endWidget: "00:00:00".toText14(color: Colors.white, isBold: true), | 
		
	
		
			
				|  |  |  |  |                         endWidget: "00:00:00".toText16(color: Colors.white, isBold: true), | 
		
	
		
			
				|  |  |  |  |                         textStyle: const TextStyle(color: Colors.white, fontSize: 16, letterSpacing: -0.48, fontWeight: FontWeight.bold), | 
		
	
		
			
				|  |  |  |  |                       ), | 
		
	
		
			
				|  |  |  |  |                       50.height, | 
		
	
		
			
				|  |  |  |  |                       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); | 
		
	
		
			
				|  |  |  |  |                             Navigator.pop(context); | 
		
	
		
			
				|  |  |  |  |                           }); | 
		
	
		
			
				|  |  |  |  |                         } catch (ex) { | 
		
	
		
			
				|  |  |  |  |                           logger.wtf(ex); | 
		
	
		
			
				|  |  |  |  |                           Utils.handleException(ex, context, null); | 
		
	
		
			
				|  |  |  |  |                         } | 
		
	
		
			
				|  |  |  |  |                       }), | 
		
	
		
			
				|  |  |  |  |                       ValueListenableBuilder<bool>( | 
		
	
		
			
				|  |  |  |  |                           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); | 
		
	
		
			
				|  |  |  |  |                                     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); | 
		
	
	
		
			
				
					|  |  |  | 
 |