react-native-screens icon indicating copy to clipboard operation
react-native-screens copied to clipboard

presentation="modal" not working on android

Open Kotpes opened this issue 1 year ago • 71 comments

Description

Having set presentation="modal" for a screen has no effect on that screen on Android (still opens full screen view)

<Stack.Screen name="ComponentName" component={Component} options={() => ({
        presentation: 'modal'
})} />

Works as expected on iOS.

Steps to reproduce

  1. Add presentation="modal" to a screen options
  2. See that it has no effect on android (still opens the full screen view) - see the snack attached

Snack or a link to a repository

https://snack.expo.dev/gg56CATOS

Screens version

6.6.1

React Native version

0.69.0

Platforms

Android

JavaScript runtime

Hermes

Workflow

React Native (without Expo)

Architecture

Paper (Old Architecture)

Build type

No response

Device

No response

Device model

No response

Acknowledgements

Yes

Kotpes avatar Dec 01 '22 12:12 Kotpes

was facing the same issue. seems like native-stack has some issue with "modal" but 'containedTransparentModal' was working. "modal" works fine if we switch to a normal stack navigator

lokeshdangi avatar Dec 21 '22 14:12 lokeshdangi

Yeah it looks like it's just not implemented? 🤔 weird that the documentation says

modal, containedModal, fullScreenModal, formSheet will use Screen.StackPresentation.MODAL.

when MODAL is essentially ignored in the android code.

react-native-screens on main ➜ rg MODAL android
android/src/main/java/com/swmansion/rnscreens/Screen.kt
240:        PUSH, MODAL, TRANSPARENT_MODAL

android/src/main/java/com/swmansion/rnscreens/ScreenViewManager.kt
58:                Screen.StackPresentation.MODAL
60:                Screen.StackPresentation.TRANSPARENT_MODAL

android/src/main/java/com/swmansion/rnscreens/ScreenStack.kt
90:        var visibleBottom: ScreenStackFragment? = null // this is only set if newTop has TRANSPARENT_MODAL presentation mode
328:            fragment.screen.stackPresentation === Screen.StackPresentation.TRANSPARENT_MODAL

Given that Screen's are backed by androidx Fragments, I expect the fix will be to have modal screens inherit from DialogFragment.

jaredly avatar Feb 08 '23 17:02 jaredly

Also facing the same issue. Do we have a work around for this for android?

muteshi avatar Feb 14 '23 03:02 muteshi

I'm facing the same issue. It's not working in android 💯

jsvelte avatar Mar 01 '23 12:03 jsvelte

Is there anyone solved this issue ??

mustafaDabah avatar Mar 04 '23 19:03 mustafaDabah

Yes it is not working. Can anyone suggest a workaround?

PranavRanjithKumar avatar Mar 22 '23 18:03 PranavRanjithKumar

Hi, sorry for late response!

There is likely no workaround, because as @jaredly reported, indeed Android modal view are effectively not implemented. I recently started looking into it while attempting to implement bottom-sheets for Android -- and unfortunately there are some technical reasons why it is the case and Android modals were left behind. It looks that documentation is indeed misleading, sorry! Once I'll open PR with support for modals & I'll try to remember to link it here so you can track progress.

kkafar avatar Mar 22 '23 19:03 kkafar

hey, @kkafar did you find the solution 😛 ?

0xQuokka avatar May 17 '23 05:05 0xQuokka

6 months and the docs still say this presentation works on android and ios. Would appreciate any update :)

zackify avatar May 30 '23 19:05 zackify

Any solution yet?

iraybi avatar Jun 14 '23 02:06 iraybi

anything on this?

titicarabina avatar Jun 22 '23 01:06 titicarabina

let's change to use flutter.

GanongLS avatar Jun 25 '23 11:06 GanongLS

I think we should try to use animation API provided by Stack as an alternative to it

atultiwaree avatar Jun 26 '23 08:06 atultiwaree

use import {createStackNavigator} from "@react-navigation/stack"; instead of import {createNativeStackNavigator} from "@react-navigation/native-stack"; working for both Android and IOS

nitesh-kumar-gupta avatar Jul 05 '23 17:07 nitesh-kumar-gupta

after upgrading to react navigation V6 this code worked for me:

<Stack.Group screenOptions={{ presentation: 'modal' }}>

    <Stack.Screen name="ComponentName" component={Component} options={() => ({
            presentation: 'modal'
    })} />

</Stack.Group>

rojingharooni avatar Jul 05 '23 22:07 rojingharooni

Any update on this?

izyspania avatar Aug 06 '23 20:08 izyspania

working perfectly

MahbubMorshed avatar Aug 09 '23 18:08 MahbubMorshed

Still not working

sinonodd avatar Sep 21 '23 16:09 sinonodd

Still not working

gaufranc avatar Sep 21 '23 19:09 gaufranc

day 28 of september, Expo Router V2 and SDK 49, and still not working on android

DarlonHenrique avatar Sep 29 '23 02:09 DarlonHenrique

It's been a so long, Tag "Zuck" now. 😬

atultiwaree avatar Sep 29 '23 11:09 atultiwaree

still not working

sergiosrtd avatar Oct 05 '23 03:10 sergiosrtd

add the below in screenOptions : animation:"slide_from_bottom"

Minkeun-Yun avatar Oct 11 '23 01:10 Minkeun-Yun

I want to make the previous screen appear a little bit in the current screen

Paulods0 avatar Oct 12 '23 19:10 Paulods0

I want to make the previous screen appear a little bit in the current screen

I want the same but i dont think is intended to work that way on android from what ive seen.

izyspania avatar Oct 16 '23 08:10 izyspania

I'm using "expo": "~49.0.13", and I'm facing the same issue on Android. The Expo documentation has examples saying it should work, but I can't get it to work."

JulioMacedo0 avatar Oct 16 '23 12:10 JulioMacedo0

I have tried tons of things and still its not working on android

radhey007 avatar Oct 19 '23 06:10 radhey007

Let's be honest I've been receiving emails through it everytime. This will not gonna fix the issue. Please close it!

jsvelte avatar Oct 19 '23 09:10 jsvelte

Let's be honest I've been receiving emails through it everytime. This will not gonna fix the issue. Please close it!

<Stack.Group screenOptions={{ presentation: 'modal',animation:"slide_from_bottom" }}> <Stack.Screen name="Shopp" component={Panier} options={{ title: ' Shopp', presentation: 'modal', }} /> </Stack.Group>

valdydev avatar Oct 24 '23 05:10 valdydev

finally this is worked

`import { TransitionPresets } from '@react-navigation/stack';

<Stack.Screen name="Profile" component={Profile} options={{ title: 'Profile', ...TransitionPresets.ModalSlideFromBottomIOS, }} />;`

The currently available transitions are:

  • SlideFromRightIOS
  • ModalSlideFromBottomIOS
  • ModalPresentationIOS
  • FadeFromBottomAndroid
  • RevealFromBottomAndroid
  • ScaleFromCenterAndroid
  • DefaultTransition
  • ModalTransition

All of these are the standard transitions provided by iOS and Android

mshaheerz avatar Nov 22 '23 13:11 mshaheerz