@@ -2,6 +2,7 @@ import 'package:defyx_vpn/core/data/local/secure_storage/secure_storage.dart';
22import 'package:defyx_vpn/core/data/local/secure_storage/secure_storage_const.dart' ;
33import 'package:flutter_timezone/flutter_timezone.dart' ;
44import 'package:flutter_riverpod/flutter_riverpod.dart' ;
5+ import 'package:flutter/foundation.dart' ;
56import 'dart:math' ;
67
78class AdvertiseDirector {
@@ -11,15 +12,22 @@ class AdvertiseDirector {
1112
1213 static Future <bool > shouldUseInternalAds (WidgetRef ref) async {
1314 final String currentTimeZone = await FlutterTimezone .getLocalTimezone ();
15+ debugPrint ('📍 Ad Manager - Current Timezone: $currentTimeZone ' );
1416
1517 final adversies =
1618 await ref.read (secureStorageProvider).readMap (apiAvertiseKey);
1719
1820 if (adversies['api_advertise' ] != null ) {
1921 final advertiseMap = adversies['api_advertise' ] as Map <String , dynamic >;
20- return advertiseMap.containsKey (currentTimeZone);
22+ final hasInternalAds = advertiseMap.containsKey (currentTimeZone);
23+ debugPrint ('📍 Ad Manager - Has internal ads for timezone: $hasInternalAds ' );
24+ if (hasInternalAds) {
25+ debugPrint ('📍 Ad Manager - Available timezones: ${advertiseMap .keys .toList ()}' );
26+ }
27+ return hasInternalAds;
2128 }
2229
30+ debugPrint ('📍 Ad Manager - No advertise data found' );
2331 return false ;
2432 }
2533
@@ -35,6 +43,7 @@ class AdvertiseDirector {
3543
3644 static Future <Map <String , String >> getRandomCustomAd (WidgetRef ref) async {
3745 final String currentTimeZone = await FlutterTimezone .getLocalTimezone ();
46+ debugPrint ('📍 Ad Manager - Getting ad for timezone: $currentTimeZone ' );
3847
3948 final adversies =
4049 await ref.read (secureStorageProvider).readMap (apiAvertiseKey);
@@ -43,21 +52,27 @@ class AdvertiseDirector {
4352 final advertiseMap = adversies['api_advertise' ] as Map <String , dynamic >;
4453 if (advertiseMap.containsKey (currentTimeZone)) {
4554 final adsData = advertiseMap[currentTimeZone] as List <dynamic >;
55+ debugPrint ('📍 Ad Manager - Found ${adsData .length } ads for timezone' );
4656 if (adsData.isNotEmpty) {
4757 final random = Random ();
4858 final randomIndex = random.nextInt (adsData.length);
4959 final selectedAd = adsData[randomIndex] as List <dynamic >;
5060
5161 if (selectedAd.length >= 2 ) {
62+ debugPrint ('📍 Ad Manager - Selected ad #$randomIndex ' );
5263 return {
5364 'imageUrl' : selectedAd[0 ] as String ,
5465 'clickUrl' : selectedAd[1 ] as String ,
5566 };
5667 }
5768 }
69+ } else {
70+ debugPrint ('📍 Ad Manager - No ads for timezone: $currentTimeZone ' );
71+ debugPrint ('📍 Ad Manager - Available timezones: ${advertiseMap .keys .toList ()}' );
5872 }
5973 }
6074
75+ debugPrint ('📍 Ad Manager - Returning empty ad' );
6176 // Return empty map - UI will handle showing "No ads available"
6277 return {'imageUrl' : '' , 'clickUrl' : '' };
6378 }
0 commit comments