Skip to content

Commit

Permalink
fix(tvospictureinpicture): fix picture in picture sample screen on tvOS
Browse files Browse the repository at this point in the history
  • Loading branch information
rolandkakonyi committed Nov 24, 2023
1 parent 1d2d6c0 commit 4da61e3
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
### Fixed

- Android: `PlayerView` destroys attached `Player` instance on destroy. `Player` lifecycle must be handled on the creation side
- tvOS: Picture in Picture sample screen has unwanted padding

## [0.14.0] (2023-11-14)

Expand Down
12 changes: 8 additions & 4 deletions example/src/screens/BasicPictureInPicture.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { useCallback, useEffect, useState } from 'react';
import { Button, Platform, StyleSheet } from 'react-native';
import { Button, Platform, StyleSheet, View, ViewProps } from 'react-native';
import { useFocusEffect } from '@react-navigation/native';
import {
Event,
Expand Down Expand Up @@ -116,9 +116,9 @@ export default function BasicPictureInPicture({
[]
);

const ContainerView = Platform.isTV ? View : SafeAreaContainer;
return (
<SafeAreaView
edges={Platform.isTV ? [] : ['bottom', 'left', 'right']}
<ContainerView
style={
// On Android, we need to remove the padding from the container when in PiP mode.
Platform.OS === 'android' && isInPictureInPicture
Expand All @@ -137,10 +137,14 @@ export default function BasicPictureInPicture({
onPictureInPictureExit={onPictureInPictureExitEvent}
onPictureInPictureExited={onEvent}
/>
</SafeAreaView>
</ContainerView>
);
}

function SafeAreaContainer(props: ViewProps): JSX.Element {
return <SafeAreaView edges={['bottom', 'left', 'right']} {...props} />;
}

const styles = StyleSheet.create({
container: {
flex: 1,
Expand Down

0 comments on commit 4da61e3

Please sign in to comment.