Skip to content

Commit

Permalink
(BSR) fix(venueMap): filters modal presentation
Browse files Browse the repository at this point in the history
  • Loading branch information
mmeissonnier-pass committed Dec 1, 2024
1 parent 250d322 commit 97946ad
Show file tree
Hide file tree
Showing 8 changed files with 106 additions and 18 deletions.
3 changes: 3 additions & 0 deletions __mocks__/@react-navigation/stack.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,6 @@ const Navigator: React.FC<PropsWithChildren> = ({ children }) => {
const Screen = () => null

export const createStackNavigator = () => ({ Navigator, Screen })

export const TransitionPresets = {}
export const TransitionSpecs = { TransitionIOSSpec: { config: {} } }
35 changes: 20 additions & 15 deletions src/features/navigation/RootNavigator/RootNavigator.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import { useAuthContext } from 'features/auth/context/AuthContext'
import { PrivacyPolicy } from 'features/cookies/pages/PrivacyPolicy'
import { useCurrentRoute } from 'features/navigation/helpers/useCurrentRoute'
import { AccessibleTabBar } from 'features/navigation/RootNavigator/Header/AccessibleTabBar'
import { ROOT_NAVIGATOR_SCREEN_OPTIONS } from 'features/navigation/RootNavigator/navigationOptions'
import { RootScreenNames } from 'features/navigation/RootNavigator/types'
import { useInitialScreen } from 'features/navigation/RootNavigator/useInitialScreenConfig'
import { withWebWrapper } from 'features/navigation/RootNavigator/withWebWrapper'
Expand All @@ -22,33 +21,39 @@ import { LoadingPage } from 'ui/components/LoadingPage'
import { QuickAccess } from 'ui/web/link/QuickAccess'

import { determineAccessibilityRole } from './determineAccessibilityRole'
import { FILTERS_MODAL_NAV_OPTIONS } from './filtersModalNavOptions'
import { Header } from './Header/Header'
import { ROOT_NAVIGATOR_SCREEN_OPTIONS } from './navigationOptions'
import { RootScreens } from './screens'
import { RootStack } from './Stack'

const isWeb = Platform.OS === 'web'

const RootStackNavigator = withWebWrapper(
({ initialRouteName }: { initialRouteName: RootScreenNames }) => {
const { top } = useSafeAreaInsets()

return (
<IconFactoryProvider>
<RootStack.Navigator
initialRouteName={initialRouteName}
screenOptions={ROOT_NAVIGATOR_SCREEN_OPTIONS}>
{isWeb ? null : (
<RootStack.Screen
name="VenueMapFiltersStackNavigator"
component={VenueMapFiltersStackNavigator}
options={{
presentation: 'modal',
...FILTERS_MODAL_NAV_OPTIONS,
cardStyle: {
marginTop: top,
borderTopLeftRadius: 20,
borderTopRightRadius: 20,
},
}}
/>
)}

{RootScreens}
<RootStack.Screen
name="VenueMapFiltersStackNavigator"
component={VenueMapFiltersStackNavigator}
options={{
presentation: 'modal',
cardStyle:
Platform.OS === 'android'
? {
marginTop: top,
}
: undefined,
}}
/>
</RootStack.Navigator>
</IconFactoryProvider>
)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import { FILTERS_MODAL_NAV_OPTIONS } from './filtersModalNavOptions'

describe('filtersModalNavOptions', () => {
it('should return screen options', () => {
const { cardStyleInterpolator } = FILTERS_MODAL_NAV_OPTIONS

expect(FILTERS_MODAL_NAV_OPTIONS).toBeDefined()
expect(
cardStyleInterpolator?.({
index: 0,
closing: {},
inverted: 1,
insets: { top: 0, left: 0, bottom: 0, right: 0 },
swiping: false,
current: { progress: { interpolate: jest.fn().mockImplementation(() => 1) } },
layouts: { screen: { height: 300, width: 300 } },
})
).toMatchObject({
overlayStyle: {
backgroundColor: 'black',
opacity: 1,
},
cardStyle: {
transform: [
{
translateY: 1,
},
],
},
})
})
})
34 changes: 34 additions & 0 deletions src/features/navigation/RootNavigator/filtersModalNavOptions.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import { StackNavigationOptions, TransitionPresets, TransitionSpecs } from '@react-navigation/stack'

export const FILTERS_MODAL_NAV_OPTIONS: StackNavigationOptions = {
...TransitionPresets.ModalSlideFromBottomIOS,
cardOverlayEnabled: true,
transitionSpec: {
open: {
animation: 'spring',
config: { ...TransitionSpecs.TransitionIOSSpec.config, mass: 2, damping: 83 },
},
close: { ...TransitionSpecs.BottomSheetSlideOutSpec },
},
cardStyleInterpolator: ({ current, layouts }) => ({
overlayStyle: {
backgroundColor: 'black',
opacity: current.progress.interpolate({
inputRange: [0, 1],
outputRange: [0, 0.7],
extrapolate: 'clamp',
}),
},
cardStyle: {
transform: [
{
translateY: current.progress.interpolate({
inputRange: [0, 1],
outputRange: [layouts.screen.height, 0],
extrapolate: 'clamp',
}),
},
],
},
}),
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import React from 'react'

import { render } from 'tests/utils'

import { VenueMapFiltersStackNavigator } from './VenueMapFiltersStackNavigator'

describe('VenueMapFiltersStackNavigator', () => {
it('should render correctly', () => {
render(<VenueMapFiltersStackNavigator />)

expect(true).toBe(true)
})
})
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@ import React from 'react'
import { VenueMapFiltersStack } from 'features/navigation/VenueMapFiltersStackNavigator/VenueMapFiltersStack'
import { VenueMapFiltersList } from 'features/venueMap/components/VenueMapFiltersList/VenueMapFiltersList'
import { VenueMapTypeFilter } from 'features/venueMap/components/VenueMapTypeFilter/VenueMapTypeFilter'
import { useWhiteStatusBar } from 'libs/hooks/useWhiteStatusBar'

export const VenueMapFiltersStackNavigator = () => {
useWhiteStatusBar()
return (
<VenueMapFiltersStack.Navigator
screenOptions={{
Expand Down
3 changes: 0 additions & 3 deletions src/features/search/components/SearchCustomModalHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { useTheme } from 'styled-components'
import styled from 'styled-components/native'

import { AccessibilityRole } from 'libs/accessibilityRole/accessibilityRole'
import { useWhiteStatusBar } from 'libs/hooks/useWhiteStatusBar'
import { styledButton } from 'ui/components/buttons/styledButton'
import { BackButton } from 'ui/components/headers/BackButton'
import { CloseButton } from 'ui/components/headers/CloseButton'
Expand All @@ -29,8 +28,6 @@ export const SearchCustomModalHeader: React.FC<Props> = ({
shouldDisplayCloseButton,
onClose,
}) => {
useWhiteStatusBar()

const { top } = useCustomSafeInsets()
const { isDesktopViewport } = useTheme()
const headerHeight = getSpacing(18) + (isDesktopViewport ? top : 0)
Expand Down
2 changes: 2 additions & 0 deletions src/ui/components/modals/AppModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {
Platform,
ScrollView,
ScrollViewProps,
StatusBar,
useWindowDimensions,
ViewProps,
} from 'react-native'
Expand Down Expand Up @@ -231,6 +232,7 @@ export const AppModal: FunctionComponent<Props> = ({
onSwipeComplete={onSwipe}
swipeDirection={swipeDirection}
propagateSwipe={propagateSwipe}>
<StatusBar barStyle="light-content" translucent />
<ModalContainer
height={maxHeight ? undefined : modalContainerHeight}
testID="modalContainer"
Expand Down

0 comments on commit 97946ad

Please sign in to comment.