Skip to content

Commit 9d47dfc

Browse files
authored
fix(nft-video): initial load height on iOS (#5580)
### Description Follow up to #5566 where iOS's initial load of iOS could obscure the full screen controls. This also cleans up the navigation options and moves them into `src/nfts/NftsInfoCarousel.tsx`. | iOS Before | iOS After | | ----- | ----- | | <video src="https://github.com/valora-inc/wallet/assets/26950305/f884e901-31d4-42e8-b2f7-b1b6dacb07ca" /> | <video src="https://github.com/valora-inc/wallet/assets/26950305/b55776a9-7e37-42fa-a261-e4e2d95bbb97" /> | ### Test plan - [x] Tested locally on iOS - [x] Tested locally on Android ### Related issues - N/A ### Backwards compatibility Yes ### Network scalability N/A
1 parent d3145ee commit 9d47dfc

File tree

3 files changed

+22
-9
lines changed

3 files changed

+22
-9
lines changed

src/navigator/Navigator.tsx

+1-5
Original file line numberDiff line numberDiff line change
@@ -569,11 +569,7 @@ const nftScreens = (Navigator: typeof Stack) => (
569569
<Navigator.Screen
570570
name={Screens.NftsInfoCarousel}
571571
component={NftsInfoCarousel}
572-
options={{
573-
...headerWithBackButton,
574-
animation: 'slide_from_right',
575-
animationDuration: 130,
576-
}}
572+
options={NftsInfoCarousel.navigationOptions as NativeStackNavigationOptions}
577573
/>
578574
</>
579575
)

src/nfts/NftMedia.tsx

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React, { useEffect, useState } from 'react'
2-
import { Platform, View } from 'react-native'
2+
import { View } from 'react-native'
33
import FastImage from 'react-native-fast-image'
44
import Video, { ResizeMode } from 'react-native-video'
55
import { NftEvents } from 'src/analytics/Events'
@@ -139,10 +139,9 @@ export default function NftMedia({
139139
}}
140140
key={`${nft.contractAddress}-${nft.tokenId}-${reloadAttempt}`}
141141
style={{
142-
height: Platform.OS === 'android' ? scaledHeight : height,
142+
height: shouldAutoScaleHeight ? scaledHeight : height,
143143
width: variables.width,
144144
zIndex: 1, // Make sure the video player is in front of the loading skeleton
145-
marginTop: 0,
146145
}}
147146
onLoad={({ naturalSize }) => {
148147
const aspectRatio = naturalSize.width / naturalSize.height

src/nfts/NftsInfoCarousel.tsx

+19-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { useHeaderHeight } from '@react-navigation/elements'
12
import { NativeStackScreenProps } from '@react-navigation/native-stack'
23
import React, { useMemo, useState } from 'react'
34
import { useTranslation } from 'react-i18next'
@@ -6,6 +7,7 @@ import { SafeAreaView } from 'react-native-safe-area-context'
67
import Touchable from 'src/components/Touchable'
78
import ImageErrorIcon from 'src/icons/ImageErrorIcon'
89
import OpenLinkIcon from 'src/icons/OpenLinkIcon'
10+
import { headerWithBackButton } from 'src/navigator/Headers'
911
import { navigate } from 'src/navigator/NavigationService'
1012
import { Screens } from 'src/navigator/Screens'
1113
import { StackParamList } from 'src/navigator/types'
@@ -106,6 +108,7 @@ export default function NftsInfoCarousel({ route }: Props) {
106108
const { nfts, networkId } = route.params
107109
const [activeNft, setActiveNft] = useState<Nft | null>(nfts[0] ?? null)
108110
const { t } = useTranslation()
111+
const headerHeight = useHeaderHeight()
109112

110113
const blockExplorerUri = useMemo(() => {
111114
if (
@@ -161,7 +164,11 @@ export default function NftsInfoCarousel({ route }: Props) {
161164
}
162165

163166
return (
164-
<SafeAreaView edges={[]} style={styles.safeAreaView} testID="NftsInfoCarousel">
167+
<SafeAreaView
168+
style={[styles.safeAreaView, { paddingTop: headerHeight }]}
169+
edges={[]}
170+
testID="NftsInfoCarousel"
171+
>
165172
<ScrollView>
166173
{/* Main Nft Video or Image */}
167174
<NftMedia
@@ -233,6 +240,17 @@ export default function NftsInfoCarousel({ route }: Props) {
233240
)
234241
}
235242

243+
NftsInfoCarousel.navigationOptions = () => ({
244+
...headerWithBackButton,
245+
headerTransparent: true,
246+
headerShown: true,
247+
headerStyle: {
248+
backgroundColor: 'transparent',
249+
},
250+
animation: 'slide_from_right',
251+
animationDuration: 130,
252+
})
253+
236254
const styles = StyleSheet.create({
237255
attributeText: {
238256
...fontStyles.regular,

0 commit comments

Comments
 (0)