Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions examples/consentmanager/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# @contentpass/examples-consentmanager

## 0.0.10

### Patch Changes

- Updated dependencies
- @contentpass/react-native-contentpass-ui@0.8.1

## 0.0.9

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion examples/consentmanager/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@contentpass/examples-consentmanager",
"version": "0.0.9",
"version": "0.0.10",
"main": "index.ts",
"scripts": {
"start": "expo start",
Expand Down
6 changes: 6 additions & 0 deletions packages/react-native-contentpass-ui/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# @contentpass/react-native-contentpass-ui

## 0.8.1

### Patch Changes

- Keep the first-layer footer above the Android system navigation bar so the privacy-policy link stays tappable.

## 0.8.0

### Minor Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/react-native-contentpass-ui/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@contentpass/react-native-contentpass-ui",
"version": "0.8.0",
"version": "0.8.1",
"description": "Contentpass React Native UI Components",
"source": "./src/index.tsx",
"main": "./lib/commonjs/index.js",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,20 @@
import {
ActivityIndicator,
AppState,
Dimensions,
Modal,
Platform,
Pressable,
StatusBar,
StyleSheet,
Text,
useWindowDimensions,
View,
} from 'react-native';
import { WebView, type WebViewMessageEvent } from 'react-native-webview';
import type { ContentpassLayerEvents } from './ContentpassLayerEvents';
import buildFirstLayerUrl from './buildFirstLayerUrl';
import { getAndroidOverlayNavigationBarInset } from './ContentpassLayerAndroidInset';
import {
canReachLayerUrl,
getLayerLoadErrorCopy,
Expand Down Expand Up @@ -38,6 +43,20 @@

export const LOAD_END_READY_FALLBACK_MS = 500;

function useAndroidOverlayNavigationBarInset(): number {
const window = useWindowDimensions();

if (Platform.OS !== 'android') {
return 0;
}

return getAndroidOverlayNavigationBarInset({
windowHeight: window.height,
screenHeight: Dimensions.get('screen').height,
statusBarHeight: StatusBar.currentHeight ?? 0,
});
}

export function layerReadyReducer(
ready: boolean,
action: LayerReadyAction
Expand Down Expand Up @@ -257,6 +276,8 @@
vendorCount: number;
locale?: string;
}) {
const androidOverlayNavigationBarInset =
useAndroidOverlayNavigationBarInset();
const cacheNonce = useState(() => String(++firstLayerMountNonce))[0];
const firstLayerUrl = useMemo(() => {
return buildFirstLayerUrl({
Expand Down Expand Up @@ -400,7 +421,7 @@
}

try {
const popupUrl = new URL(url, baseUrl);

Check warning on line 424 in packages/react-native-contentpass-ui/src/components/ContentpassLayer.tsx

View workflow job for this annotation

GitHub Actions / lint

'popupUrl' is already declared in the upper scope on line 304 column 10

if (!POPUP_URL_PROTOCOLS.has(popupUrl.protocol)) {
console.warn('Unable to open popup with unsupported URL', url);
Expand Down Expand Up @@ -499,7 +520,14 @@
}

return (
<View style={styles.container}>
<View
style={[
styles.container,
androidOverlayNavigationBarInset > 0 && {
paddingBottom: androidOverlayNavigationBarInset,
},
]}
>
<WebView
key={reloadNonce}
source={{ uri: layerUrl }}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
// Copyright 2026 Content Pass GmbH. All Rights Reserved.

import {
ANDROID_NAVIGATION_BAR_HEIGHT_DP,
getAndroidOverlayNavigationBarInset,
} from './ContentpassLayerAndroidInset';

describe('getAndroidOverlayNavigationBarInset', () => {
it('pads when the window is edge-to-edge', () => {
expect(
getAndroidOverlayNavigationBarInset({
windowHeight: 800,
screenHeight: 800,
statusBarHeight: 24,
})
).toBe(ANDROID_NAVIGATION_BAR_HEIGHT_DP);
});

it('does not pad when the window already excludes the navigation bar', () => {
expect(
getAndroidOverlayNavigationBarInset({
windowHeight: 728,
screenHeight: 800,
statusBarHeight: 24,
})
).toBe(0);
});

it('does not pad when only the navigation bar is reserved', () => {
expect(
getAndroidOverlayNavigationBarInset({
windowHeight: 752,
screenHeight: 800,
statusBarHeight: 24,
})
).toBe(0);
});

it('pads when the status bar is reserved but the navigation bar overlays', () => {
expect(
getAndroidOverlayNavigationBarInset({
windowHeight: 776,
screenHeight: 800,
statusBarHeight: 24,
})
).toBe(ANDROID_NAVIGATION_BAR_HEIGHT_DP);
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// Copyright 2026 Content Pass GmbH. All Rights Reserved.

export const ANDROID_NAVIGATION_BAR_HEIGHT_DP = 48;

export function getAndroidOverlayNavigationBarInset({
windowHeight,
screenHeight,
statusBarHeight,
}: {
windowHeight: number;
screenHeight: number;
statusBarHeight: number;
}): number {
const reservedHeight = screenHeight - windowHeight;

// The RN window is already shorter than the screen, so the WebView does
// not sit under the navigation bar.
if (reservedHeight > statusBarHeight + 1) {
return 0;
}

return ANDROID_NAVIGATION_BAR_HEIGHT_DP;
}
Loading