ammarahm-ed / react-native-actions-sheet

A Cross Platform(Android, iOS & Web) ActionSheet with a flexible api, native performance and zero dependency code for react native. Create anything you want inside ActionSheet.
https://rnas.vercel.app
MIT License
1.42k stars 119 forks source link

How to limit max expanded height? #322

Closed z1haze closed 5 months ago

z1haze commented 7 months ago

How do you prevent a sheet from going beyond a max height or snap point? I have tried setting a snap point to 75 for example, but it will allow me to expand it even further, if there is content in the view large enough. The preference would be to set a limit for the max height and have the scroll view handle the overflow.

Here is an example of difference in functionality between platforms. We do not like the ios behavior of how it will up into the status bar. it should behave like android does

image
YeeWan0217 commented 7 months ago

have same problem too

justinmwarner commented 6 months ago

Not sure if you tried, but passing in snapPoints={[80]} sets the height to 80%. This works on my end at least.

YeeWan0217 commented 6 months ago

@justinmwarner Thank you for the solution, my solution is set the style of ScrollView in ActionSheet with maxHeight: Platform.OS == 'ios' ? Dimensions.get('window').height * 0.3 : Dimensions.get('window').height * 0.4,. But I do like your solution.

eisodev commented 6 months ago

https://rnas.vercel.app/guides/safearea

Isn't the drawUnderStatusbar={false} supposed to solve this problem? That prop does nothing for me it seems.

Version 0.8.21

ammarahm-ed commented 5 months ago

This will be fixed in #330

You can set the maxHeight on containerStyle prop btw for now.

z1haze commented 5 months ago

Not sure if you tried, but passing in snapPoints={[80]} sets the height to 80%. This works on my end at least.

Read the op issue. It mentions using snap points and it does not fix the issue. Your test case I imagine does not have enough content in it to see the actual issue...

ammarahm-ed commented 5 months ago

Not sure if you tried, but passing in snapPoints={[80]} sets the height to 80%. This works on my end at least.

Read the op issue. It mentions using snap points and it does not fix the issue. Your test case I imagine does not have enough content in it to see the actual issue...

You can't limit max height with snap points, you can however using maxHeight on containerStyle to do it. Snap points are used to snap to a certain section of sheet, the sheet will always open to 100% of its actual height based on the content.

blazk0 commented 3 months ago

Using maxHeight to containerStyle doesn't work on version 0.9.3

leymytel commented 1 month ago

@blazk0 did you find any solutions or workarounds for this issue?

My workaround is to set the maxHeight like this:

<ActionSheet>
      <View style={{ maxHeight: MAX_SHEET_HEIGHT }}>
         <ScrollView contentContainerStyle={styles.contentContainer}>
             ...
         </ScrollView>
     </View>
</ActionSheet>