From 45cd51c398278f466ec702ea971fe00fb4bad0b0 Mon Sep 17 00:00:00 2001 From: youssef eddibili Date: Mon, 23 Dec 2024 01:19:55 +0100 Subject: [PATCH] feat: adaptive banner with container width and adaptive height --- RNGoogleMobileAdsExample/App.tsx | 121 ++++--- ...iveGoogleMobileAdsBannerAdViewManager.java | 58 +++- .../ReactNativeGoogleMobileAdsCommon.java | 52 ++- .../common/ReactNativeAdView.java | 42 +++ .../RNGoogleMobileAdsBannerComponent.h | 4 + .../RNGoogleMobileAdsBannerComponent.m | 57 +++- .../RNGoogleMobileAdsBannerView.h | 2 + .../RNGoogleMobileAdsBannerView.mm | 78 +++-- .../RNGoogleMobileAdsBannerViewManager.mm | 2 + .../RNGoogleMobileAdsCommon.h | 4 +- .../RNGoogleMobileAdsCommon.mm | 29 +- src/ads/BaseAd.tsx | 299 ++++++++++-------- ...oogleMobileAdsBannerViewNativeComponent.ts | 1 + src/types/BannerAdProps.ts | 5 + 14 files changed, 518 insertions(+), 236 deletions(-) diff --git a/RNGoogleMobileAdsExample/App.tsx b/RNGoogleMobileAdsExample/App.tsx index de6ab97d..3eb8dc58 100644 --- a/RNGoogleMobileAdsExample/App.tsx +++ b/RNGoogleMobileAdsExample/App.tsx @@ -1,4 +1,4 @@ -import React, {useEffect, useRef} from 'react'; +import React, { useEffect, useRef } from 'react'; import { Button, Platform, @@ -8,7 +8,7 @@ import { Text, View, } from 'react-native'; -import {Test, TestRegistry, TestResult, TestRunner, TestType} from 'jet'; +import { Test, TestRegistry, TestResult, TestRunner, TestType } from 'jet'; import MobileAds, { type PaidEvent, @@ -44,7 +44,7 @@ class AppOpenTest implements Test { constructor() { // Current no way in jet-next to re-render on async completion or to delay render? But still can log it - this.adListener = appOpen.addAdEventsListener(({type, payload}) => { + this.adListener = appOpen.addAdEventsListener(({ type, payload }) => { console.log(`${Platform.OS} app open ad event: ${type}`); if (type === AdEventType.PAID) { console.log(payload); @@ -119,7 +119,7 @@ class InterstitialTest implements Test { constructor() { // Current no way in jet-next to re-render on async completion or to delay render? But still can log it - this.adListener = interstitial.addAdEventsListener(({type, payload}) => { + this.adListener = interstitial.addAdEventsListener(({ type, payload }) => { console.log(`${Platform.OS} interstitial ad event: ${type}`); if (type === AdEventType.PAID) { console.log('Paid', payload); @@ -182,12 +182,64 @@ class InterstitialTest implements Test { } } +class BannerContainer extends React.Component<{ bannerAdSize: string }, { enableContainerAdaptiveMode: boolean }> { + state = { + enableContainerAdaptiveMode: true + } + bannerRef = React.createRef(); + + + render(): React.ReactNode { + return ( + <> + + { + console.log( + `Paid: ${event.value} ${event.currency} (precision ${RevenuePrecisions[event.precision] + }})`, + ); + }} + /> + +