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 · 71 comments · May be fixed by #1974
Open

presentation="modal" not working on android #1650

Kotpes opened this issue Dec 1, 2022 · 71 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."

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

@00ricardo
Copy link

I'll recommend to use presentation: "transparentModal" instead. It worked for me.

@mpanac
Copy link

mpanac commented Jun 7, 2024

Please fix this issue with presentation: modal on android.
For iOS there are no issues but on android i cannot make it work. Thanks!

@brenosimonetti
Copy link

any updates?

@phoneticallySAARTHaK
Copy link

phoneticallySAARTHaK commented Jun 15, 2024

Reading through the comments,

PR: #2045 is in progress

Workarounds:

  1. Use Stack Navigator - with these screenOptions, and cardStyle to set its height

  2. Bottom sheet

@doyunnn
Copy link

doyunnn commented Jun 19, 2024

I'm using @react-navigation/native-stack "^6.9.13" and below props should work.

{
  presentation: Platform.select({
    ios: 'transparentModal',
    android: 'containedTransparentModal',
  }),
  animation: 'slide_from_bottom',
  animationDuration: 100,
}

@mapleroyal
Copy link

Still not working on android.

@karimelsaidy
Copy link

still not working

@kkafar
Copy link
Member

kkafar commented Jun 26, 2024

Hey, I'm limiting conversation cause:

  1. "still not working" comments do not bring anything to the discussion,
  2. I've already mentioned that you can track progress on feat!: iOS custom detents & Android form sheets #2045 (comment link),
  3. actually useful information gets lost in ton on "still not working" comments.

@software-mansion software-mansion locked as spam and limited conversation to collaborators Jun 26, 2024
@kkafar
Copy link
Member

kkafar commented Jun 26, 2024

And also let me update you on the status of

It is quite a big PR with tons of new logic introduced to the library, also bringing some breaking changes to the API - I'm actively progressing through the review & patching rough edges, but I wouldn't be surprised if it took even few more weeks to get the necessary approvals.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
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.