Skip to content

Commit

Permalink
fix(nft-video): initial load height on iOS (#5580)
Browse files Browse the repository at this point in the history
### 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
  • Loading branch information
MuckT authored Jun 26, 2024
1 parent d3145ee commit 9d47dfc
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 9 deletions.
6 changes: 1 addition & 5 deletions src/navigator/Navigator.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -569,11 +569,7 @@ const nftScreens = (Navigator: typeof Stack) => (
<Navigator.Screen
name={Screens.NftsInfoCarousel}
component={NftsInfoCarousel}
options={{
...headerWithBackButton,
animation: 'slide_from_right',
animationDuration: 130,
}}
options={NftsInfoCarousel.navigationOptions as NativeStackNavigationOptions}
/>
</>
)
Expand Down
5 changes: 2 additions & 3 deletions src/nfts/NftMedia.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { useEffect, useState } from 'react'
import { Platform, View } from 'react-native'
import { View } from 'react-native'
import FastImage from 'react-native-fast-image'
import Video, { ResizeMode } from 'react-native-video'
import { NftEvents } from 'src/analytics/Events'
Expand Down Expand Up @@ -139,10 +139,9 @@ export default function NftMedia({
}}
key={`${nft.contractAddress}-${nft.tokenId}-${reloadAttempt}`}
style={{
height: Platform.OS === 'android' ? scaledHeight : height,
height: shouldAutoScaleHeight ? scaledHeight : height,
width: variables.width,
zIndex: 1, // Make sure the video player is in front of the loading skeleton
marginTop: 0,
}}
onLoad={({ naturalSize }) => {
const aspectRatio = naturalSize.width / naturalSize.height
Expand Down
20 changes: 19 additions & 1 deletion src/nfts/NftsInfoCarousel.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { useHeaderHeight } from '@react-navigation/elements'
import { NativeStackScreenProps } from '@react-navigation/native-stack'
import React, { useMemo, useState } from 'react'
import { useTranslation } from 'react-i18next'
Expand All @@ -6,6 +7,7 @@ import { SafeAreaView } from 'react-native-safe-area-context'
import Touchable from 'src/components/Touchable'
import ImageErrorIcon from 'src/icons/ImageErrorIcon'
import OpenLinkIcon from 'src/icons/OpenLinkIcon'
import { headerWithBackButton } from 'src/navigator/Headers'
import { navigate } from 'src/navigator/NavigationService'
import { Screens } from 'src/navigator/Screens'
import { StackParamList } from 'src/navigator/types'
Expand Down Expand Up @@ -106,6 +108,7 @@ export default function NftsInfoCarousel({ route }: Props) {
const { nfts, networkId } = route.params
const [activeNft, setActiveNft] = useState<Nft | null>(nfts[0] ?? null)
const { t } = useTranslation()
const headerHeight = useHeaderHeight()

const blockExplorerUri = useMemo(() => {
if (
Expand Down Expand Up @@ -161,7 +164,11 @@ export default function NftsInfoCarousel({ route }: Props) {
}

return (
<SafeAreaView edges={[]} style={styles.safeAreaView} testID="NftsInfoCarousel">
<SafeAreaView
style={[styles.safeAreaView, { paddingTop: headerHeight }]}
edges={[]}
testID="NftsInfoCarousel"
>
<ScrollView>
{/* Main Nft Video or Image */}
<NftMedia
Expand Down Expand Up @@ -233,6 +240,17 @@ export default function NftsInfoCarousel({ route }: Props) {
)
}

NftsInfoCarousel.navigationOptions = () => ({
...headerWithBackButton,
headerTransparent: true,
headerShown: true,
headerStyle: {
backgroundColor: 'transparent',
},
animation: 'slide_from_right',
animationDuration: 130,
})

const styles = StyleSheet.create({
attributeText: {
...fontStyles.regular,
Expand Down

0 comments on commit 9d47dfc

Please sign in to comment.