-
Notifications
You must be signed in to change notification settings - Fork 112
presentation: 'modal' does't work for Stack in Android #640
Comments
The Modal presentation in iOS is iOS only. <JsStack.Screen
key={name}
name={name}
options={{
...TransitionPresets.ModalPresentationIOS,
presentation: 'modal'
}}
/> |
To clarify, use JS stack: import {
// Import the creation function
createStackNavigator,
// Import the types
StackNavigationOptions,
} from "@react-navigation/stack";
import { withLayoutContext } from "expo-router";
const { Navigator } = createStackNavigator();
// This can be used like `<JsStack />`
export const JsStack = withLayoutContext<
StackNavigationOptions,
typeof Navigator
>(Navigator); Then import { TransitionPresets } from '@react-navigation/stack';
// Later ...
<JsStack name="..." options={{
...TransitionPresets.ModalPresentationIOS,
presentation: 'modal'
}}> |
Any chance this could be implemented directly with Expo-Router, without using JsStack? When using JsStack, one has to use different option names ( |
It would be better to be able use it with just presentation: "modal", rather than weird workaround |
@EvanBacon how can I do it with Expo v2 and SDK 49, I'm getting dependency conflict |
The modal does not close on Android when I swipe it down |
yes, agree. @EvanBacon any chance for this? |
@EvanBacon the solution you provide, do not make the android have the same result of IOS, it's keep the Android Version having the same result as before, actually I'm in expo router v2 and expo 49
I'm using Expo Go to test it in a physical iPhone 7 with IOS 15.7.6, and it's working fine My expo go version on android is 2.29.8 that's my code piece in my app/_layout.tsx
and that's the code I'm using to provide the JsStack:
the same code you provide above |
Hi @EvanBacon, |
If you add gestureEnabled: true to the options the swipe down works for me on Android |
@EvanBacon We have used provided example in a typescript project and we get a type error for the withLayoutContext function that it expects 4 type arguments not 2, it works if the ignore the typescript error but it is not a really nice solution imo. So it would be great if it would be possible to have the modal work on android with expo-router directly so we could skip this workaround💪 |
Hi, I'm with the same issue. I have tried to use |
I don't think pinging the guy again and again is going to help get this issue resolved. From the Material UI documentation, it looks like Android simply doesn't support swipeable full-screen dialogs the same way iOS has. So there simply isn't any solution other than to implement your own with the JSStack navigator, like shown already. More information can be found here. |
Reference the implementation of withLayoutContext. You can customise import {
createMaterialBottomTabNavigator,
MaterialBottomTabNavigationEventMap,
MaterialBottomTabNavigationOptions,
} from 'react-native-paper/react-navigation'
import { NavigationState, ParamListBase } from '@react-navigation/native'
import { withLayoutContext } from 'expo-router'
const { Navigator } = createMaterialBottomTabNavigator()
export const MaterialBottomTabs = withLayoutContext<
MaterialBottomTabNavigationOptions,
typeof Navigator,
NavigationState<ParamListBase>,
MaterialBottomTabNavigationEventMap
>(Navigator) |
I want to use native stack not js stack, any solution? |
@fukemy Android does not support modal screens, so no. The only solution is to emulate the iOS behavior with JS stack. Check my comment above. |
Is this still so for expo router 3? |
I think so |
Any luck ? I am also having the same issue. |
Try changing your app/_layout.tsx: <JsStack>
<Stack.Screen name="(tabs)" options={{ headerShown: false }} />
<JsStack.Screen
name="filters"
options={{
...TransitionPresets.ModalPresentationIOS,
presentation: "modal",
gestureEnabled: true,
}}
/>
</JsStack> This worked for me |
|
The expo team should update the docs then, i´ve been trying to see how to solve it just because the docs say it supports android
|
I was getting the same typescript error and you literally saved me with that! Thanks, man! |
You should update the expo router docs. It is really misleading. It mentioned that android is supported when clearly it's not.. and instead developers lead to using this workaround instead. |
someone created an iOS Modal Sheet Animation for Android. It may be very useful and people may be interested. I would love to know what you guys think about it. |
We tried using the JS Stack solution, but our modal is around 3 nested navigators deep.. The IOS modal displays over all of the nested navigator headers but the JSStack modal only displays within the parent stack.. Has anyone encountered / solved this? |
Thanks to everyone!. Working fine on my end. Specifically to: @EvanBacon and @tittobreno |
I find this still clunky on Android and even worse on Web so instead I use Tamagui's Sheet component. Works well on all 3 platforms |
For anyone who tried the jstack with expo router, is it a stable setup? |
I used |
Which package manager are you using? (Yarn is recommended)
yarn
Summary
On android modal screen looks like simplify screen, but on IoS everything is fine
Minimal reproducible example
`
<Stack.Screen
mode="modal"
name="myModal"
screenOptions={{headerShown: true, presentation: 'modal'}}
/>
`
The text was updated successfully, but these errors were encountered: