elCaribe app - customization and branding

This commit is contained in:
2025-12-12 19:09:42 -04:00
parent 9e5d0d8ebf
commit ba7deac9f3
402 changed files with 31833 additions and 0 deletions

View File

@@ -0,0 +1,58 @@
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:google_mobile_ads/google_mobile_ads.dart';
import 'package:news/cubits/appSystemSettingCubit.dart';
const AdRequest request = AdRequest(
//static
keywords: <String>['foo', 'bar'],
contentUrl: 'http://foo.com/bar.html',
nonPersonalizedAds: true,
);
RewardedAd? rewardedAd;
int _numRewardedLoadAttempts = 0;
int maxFailedLoadAttempts = 3;
void createGoogleRewardedAd(BuildContext context) {
if (context.read<AppConfigurationCubit>().rewardId() != "") {
RewardedAd.load(
adUnitId: context.read<AppConfigurationCubit>().rewardId()!,
request: request,
rewardedAdLoadCallback: RewardedAdLoadCallback(
onAdLoaded: (RewardedAd ad) {
rewardedAd = ad;
_numRewardedLoadAttempts = 0;
},
onAdFailedToLoad: (LoadAdError error) {
rewardedAd = null;
_numRewardedLoadAttempts += 1;
if (_numRewardedLoadAttempts <= maxFailedLoadAttempts) {
createGoogleRewardedAd(context);
}
},
));
}
}
void showGoogleRewardedAd(BuildContext context) {
if (context.read<AppConfigurationCubit>().rewardId() != "") {
if (rewardedAd == null) {
return;
}
rewardedAd!.fullScreenContentCallback = FullScreenContentCallback(
onAdShowedFullScreenContent: (RewardedAd ad) => debugPrint('ad onAdShowedFullScreenContent.'),
onAdDismissedFullScreenContent: (RewardedAd ad) {
ad.dispose();
createGoogleRewardedAd(context);
},
onAdFailedToShowFullScreenContent: (RewardedAd ad, AdError error) {
ad.dispose();
createGoogleRewardedAd(context);
},
);
rewardedAd!.setImmersiveMode(true);
rewardedAd!.show(onUserEarnedReward: (AdWithoutView ad, RewardItem reward) {});
rewardedAd = null;
}
}

View File

@@ -0,0 +1,23 @@
import 'package:flutter/foundation.dart';
import 'package:unity_ads_plugin/unity_ads_plugin.dart';
void loadUnityRewardAd(String placementId) {
UnityAds.load(placementId: placementId, onComplete: (placementId) {}, onFailed: (placementId, error, message) {});
}
void showUnityRewardAds(String placementId) {
UnityAds.showVideoAd(
placementId: placementId,
onComplete: (placementId) {
loadUnityRewardAd(placementId);
},
onFailed: (placementId, error, message) {
loadUnityRewardAd(placementId);
},
onStart: (placementId) => debugPrint('Video Ad $placementId started'),
onClick: (placementId) => debugPrint('Video Ad $placementId click'),
onSkipped: (placementId) {
loadUnityRewardAd(placementId);
},
);
}