Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

presentation="modal" not working on android #1650

Open
Kotpes opened this issue Dec 1, 2022 · 62 comments · May be fixed by #1974
Open

presentation="modal" not working on android #1650

Kotpes opened this issue Dec 1, 2022 · 62 comments · May be fixed by #1974
Assignees
Labels
Platform: Android This issue is specific to Android Repro provided A reproduction with a snack or repo is provided

Comments

@Kotpes
Copy link

Kotpes commented Dec 1, 2022

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

@github-actions github-actions bot added Repro provided A reproduction with a snack or repo is provided Platform: Android This issue is specific to Android labels Dec 1, 2022
@kkafar kkafar self-assigned this Dec 2, 2022
@lokeshdangi
Copy link

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

@jaredly
Copy link

jaredly commented Feb 8, 2023

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.

@muteshi
Copy link

muteshi commented Feb 14, 2023

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

@jsvelte
Copy link

jsvelte commented Mar 1, 2023

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

@mustafaDabah
Copy link

Is there anyone solved this issue ??

@PranavRanjithKumar
Copy link

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

@kkafar
Copy link
Member

kkafar commented Mar 22, 2023

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.

@0xQuokka
Copy link

hey, @kkafar did you find the solution 😛 ?

@zackify
Copy link

zackify commented May 30, 2023

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

@iraybi
Copy link

iraybi commented Jun 14, 2023

Any solution yet?

@titicarabina
Copy link

anything on this?

@GanongLS
Copy link

let's change to use flutter.

@atultiwaree
Copy link

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

@nitesh-kumar-gupta
Copy link

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

@rojingharooni
Copy link

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>

@izyspania
Copy link

Any update on this?

@MahbubMorshed
Copy link

working perfectly

@sinonodd
Copy link

Still not working

1 similar comment
@gaufranc
Copy link

Still not working

@DarlonHenrique
Copy link

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

@atultiwaree
Copy link

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

@sergiosrtd
Copy link

still not working

@Minkeun-Yun
Copy link

add the below in screenOptions
: animation:"slide_from_bottom"

@Paulods0
Copy link

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

@izyspania
Copy link

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.

@JulioMacedo0
Copy link

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."

@mubarakshow
Copy link

mubarakshow commented Dec 20, 2023

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

Changing from modal to transparentModal worked for me.
@Paulods0 @izyspania

{
   presentation: "transparentModal"
}

@fukemy
Copy link

fukemy commented Jan 12, 2024

ModalSlideFromBottomIOS worked but the screen still show in fullscreen, any solution?

@rafael-mingossi
Copy link

ModalSlideFromBottomIOS worked but the screen still show in fullscreen, any solution?

Mine is working well not covering full screen. I am using createStackNavigator (non native) and screenOptions={{presentation: 'modal'}} I created a separated group for modal presentations by using <"StackName".Group screenOptions={{presentation: 'modal'}}>, hope that works

@fukemy
Copy link

fukemy commented Jan 12, 2024

Mine is working well not covering full screen. I am using createStackNavigator (non native) and screenOptions={{presentation: 'modal'}} I created a separated group for modal presentations by using <"StackName".Group screenOptions={{presentation: 'modal'}}>, hope that works

thanks, but I native-stack is better performance, so I dont want to use non-native

@rafael-mingossi
Copy link

Mine is working well not covering full screen. I am using createStackNavigator (non native) and screenOptions={{presentation: 'modal'}} I created a separated group for modal presentations by using <"StackName".Group screenOptions={{presentation: 'modal'}}>, hope that works

thanks, but I native-stack is better performance, so I dont want to use non-native

Yeah, your are right, but with Native unfortunately it won't work, I hope they fix that.

@eidan66
Copy link

eidan66 commented Feb 1, 2024

Any update on this problem? :(
react-navigation/stack didn't work also.

@wujekbizon
Copy link

so with "expo": "~50.0.5", and "expo-router": "~3.4.6", it's still not working , shame because docs saying differently

@ExarchDB
Copy link

ExarchDB commented Feb 7, 2024

Well over a year and still what most would call a key facility is non functional. What, do they all use iphones or what?

@vikrant699
Copy link

I am having the same issue, my app heavily relies on modal to work correctly. Is there any kind of communication regarding this being in the pipeline to be fixed?

@ser-emejia
Copy link

My workaround using expo:


import Constants from 'expo-constants';

    <View
      style={{
        flex: 1,
        paddingTop: IS_ANDROID ? Constants.statusBarHeight : 0,
      }}>
      
      //...

    </View>

@qaezrun
Copy link

qaezrun commented Apr 1, 2024

any updates?

@Khalidzo
Copy link

Khalidzo commented Apr 1, 2024

Please this info should be included in expo docs, since this is causing confusion for many of us.

@jonanpogi
Copy link

presentation=modal is still not working for bot ios and android

@suryanshsingh2001
Copy link

presentation=modal is still not working for bot ios and android

Same

@eric-everbright
Copy link

eric-everbright commented Apr 3, 2024

looks like a few things could happen here for a way forward:

  1. issue gets fixed (looking unlikely on a timeframe suitable for any of us with in-progress projects)
  2. update docs
  3. some kind of console warning if used on android
    ===
    as for my project, just living with the push navigation for now, unfortunately, and had to figure out a hack to hide the bottom navigation bar, because the purpose of the modal presentation was so that the presented flow was apart from the root navigation

@suryanshsingh2001
Copy link

suryanshsingh2001 commented Apr 3, 2024

looks like a few things could happen here for a way forward:

  1. issue gets fixed (looking unlikely on a timeframe suitable for any of us with in-progress projects)
  2. update docs
  3. some kind of console warning if used on android

    as for my project, just living with the push navigation for now, unfortunately, and had to figure out a hack to hide the bottom navigation bar, because the purpose of the modal presentation was so that the presented flow was apart from the root navigation

You are absolutely right !. I am thinking of using this instead
react-native-bottom-sheet

@ArtyEmsee
Copy link

looks like a few things could happen here for a way forward:

  1. issue gets fixed (looking unlikely on a timeframe suitable for any of us with in-progress projects)
  2. update docs
  3. some kind of console warning if used on android

    as for my project, just living with the push navigation for now, unfortunately, and had to figure out a hack to hide the bottom navigation bar, because the purpose of the modal presentation was so that the presented flow was apart from the root navigation

You are absolutely right !. I am thinking of using this instead react-native-bottom-sheet

With the plan being to host the sheets inside of your routes?

@suryanshsingh2001
Copy link

suryanshsingh2001 commented Apr 8, 2024

looks like a few things could happen here for a way forward:

  1. issue gets fixed (looking unlikely on a timeframe suitable for any of us with in-progress projects)
  2. update docs
  3. some kind of console warning if used on android

    as for my project, just living with the push navigation for now, unfortunately, and had to figure out a hack to hide the bottom navigation bar, because the purpose of the modal presentation was so that the presented flow was apart from the root navigation

You are absolutely right !. I am thinking of using this instead react-native-bottom-sheet

With the plan being to host the sheets inside of your routes?

No, just using them like a modal.

@suryanshsingh2001
Copy link

suryanshsingh2001 commented Apr 19, 2024

Hey, I just found a temporary workaround for this for android, if you want modal to be a bit of away from screen like IOS version, just add these screen options and you are good to go.

 <Stack.Group screenOptions={({navigation}) => ({
          ...TransitionPresets.ModalSlideFromBottomIOS,
          gestureEnabled: true,
          presentation: "modal",
          cardStyle: {marginTop: 10, borderTopStartRadius: 20, borderTopEndRadius: 20}

        })}>

@AnkushSarkar10
Copy link

damn

@m-emre-yalcin
Copy link

i wish the modal screen supported on android

@T30-H0
Copy link

T30-H0 commented May 10, 2024

they all use iPhones only 😥 .

@kkafar
Copy link
Member

kkafar commented May 10, 2024

Hey hey: you can track this PR: #2045 for progress in the matter. It's finally entering review process.

@atultiwaree
Copy link

Hey hey: you can track this PR: #2045 for progress in the matter. It's finally entering review process.

Finally 😅

@suryanshsingh2001
Copy link

Hey hey: you can track this PR: #2045 for progress in the matter. It's finally entering review process.

Nice.

@YosefOberlander
Copy link

YosefOberlander commented May 26, 2024

This works on android and IOS.
presentation: 'modal', gestureEnabled: true, ...(Platform.OS === 'android' && TransitionPresets.ModalPresentationIOS),

<ListStackNavigator.Group screenOptions={{ presentation: 'modal', gestureEnabled: true, ...(Platform.OS === 'android' && TransitionPresets.ModalPresentationIOS), }}> <ListStackNavigator.Screen name="NewList" component={NewList} options={{ headerShown: false, }} /> </ListStackNavigator.Group>

@atultiwaree
Copy link

This works on android.
presentation: 'modal', gestureEnabled: true, ...(Platform.OS === 'android' && TransitionPresets.ModalPresentationIOS),

<ListStackNavigator.Group screenOptions={{ presentation: 'modal', gestureEnabled: true, ...(Platform.OS === 'android' && TransitionPresets.ModalPresentationIOS), }}> <ListStackNavigator.Screen name="NewList" component={NewList} options={{ headerShown: false, }} /> </ListStackNavigator.Group>
Will it work on iOS??

@YosefOberlander
Copy link

@atultiwaree Yes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Platform: Android This issue is specific to Android Repro provided A reproduction with a snack or repo is provided
Projects
None yet
Development

Successfully merging a pull request may close this issue.