feat: ship Wave 5-6 multi-surface hygiene, optimization, and bug fixes
This commit is contained in:
parent
01ef3293cf
commit
66b6b45ba9
399 changed files with 17828 additions and 11330 deletions
|
|
@ -4,6 +4,7 @@ import {
|
|||
BannerAd,
|
||||
BannerAdSize,
|
||||
} from 'react-native-google-mobile-ads'
|
||||
import { useResponsiveLayout } from '@d3ro/ui-native'
|
||||
import { useMobileAds } from '../lib/mobile-ads-context'
|
||||
import { useMobilePreferences } from '../lib/preferences-context'
|
||||
import { ThemeText } from '../theme/themed-components'
|
||||
|
|
@ -16,10 +17,12 @@ export default function FreeTierBanner(): React.ReactElement | null {
|
|||
const { t } = useI18n()
|
||||
const ads = useMobileAds()
|
||||
const { palette } = useMobilePreferences()
|
||||
const { bannerSlotMinHeight } = useResponsiveLayout()
|
||||
const [loaded, setLoaded] = useState(false)
|
||||
const [failed, setFailed] = useState(false)
|
||||
const [retryAttempt, setRetryAttempt] = useState(0)
|
||||
const [retryKey, setRetryKey] = useState(0)
|
||||
const [measuredHeight, setMeasuredHeight] = useState(0)
|
||||
|
||||
useEffect(() => {
|
||||
setLoaded(false)
|
||||
|
|
@ -28,6 +31,10 @@ export default function FreeTierBanner(): React.ReactElement | null {
|
|||
setRetryKey(0)
|
||||
}, [ads.bannerUnitId])
|
||||
|
||||
useEffect(() => {
|
||||
setMeasuredHeight(0)
|
||||
}, [ads.bannerUnitId, ads.eligible, bannerSlotMinHeight])
|
||||
|
||||
useEffect(() => {
|
||||
if (!failed || !ads.bannerUnitId) return undefined
|
||||
const delay = Math.min(
|
||||
|
|
@ -45,11 +52,20 @@ export default function FreeTierBanner(): React.ReactElement | null {
|
|||
|
||||
if (!ads.eligible) return null
|
||||
|
||||
const reservedMinHeight = Math.max(bannerSlotMinHeight, measuredHeight)
|
||||
|
||||
return (
|
||||
<View
|
||||
onLayout={(event) => {
|
||||
const nextHeight = Math.round(event.nativeEvent.layout.height)
|
||||
if (nextHeight > measuredHeight) {
|
||||
setMeasuredHeight(nextHeight)
|
||||
}
|
||||
}}
|
||||
style={[
|
||||
styles.slot,
|
||||
{
|
||||
minHeight: reservedMinHeight,
|
||||
backgroundColor: palette.bg.inset,
|
||||
borderTopColor: palette.border.subtle,
|
||||
},
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue