react-native-actions-sheet icon indicating copy to clipboard operation
react-native-actions-sheet copied to clipboard

Padding bottom is overwritten by the libraries style

Open naderalfakesh opened this issue 3 years ago • 11 comments

<ActionSheetBase
  containerStyle={{
    ...styles.container,
    paddingBottom: insets.bottom,
    ...containerStyle,
    }}>
  {children}
</ActionSheetBase>

We are setting bottom padding with the value coming from safe area context on, I was able to solve this by wrapping content with a view and passing the padding to it. But I have one sheet that has a sticky button so it should be without bottom spacing but I cannot overwrite the padding.

Thanks for the great efforts, keep it up.

naderalfakesh avatar Dec 08 '21 11:12 naderalfakesh

Same problem, can't affect paddingBottom in containerStyle

theneekz avatar Feb 03 '22 16:02 theneekz

@theneekz Its not possible with the current mechanism of how the sheet works. Paddings are locked to a specific number. You can add padding to an inner view or render a <View/> at the bottom of your sheet and give it an height.

ammarahm-ed avatar Feb 03 '22 17:02 ammarahm-ed

That's what I've come to realize...thanks for clarifying. I would like to have the ActionSheet rise up from a different height (so that a bottom tabs navigator is still visible), which I also don't think is possible. This was one route I tried to get around that with a few other styling changes but I don't think it's possible to create the effect.

theneekz avatar Feb 03 '22 17:02 theneekz

As close as I can get it right now:

<ActionSheet
    containerStyle={{
        backgroundColor: 'transparent',
    }}
    indicatorStyle={{ backgroundColor: 'grey', top: 20, zIndex: 2 }} 
    ...
        <View 
            style={{ 
               marginBottom: tabBarHeight,
               paddingHorizontal: '5%',
               backgroundColor: 'white',
               borderTopWidth: 20,
               borderTopLeftRadius: 10,
               borderTopRightRadius: 10,
               borderTopColor: 'white',
            }}>
           ....

Screen Shot 2022-02-03 at 11 11 40 AM

theneekz avatar Feb 03 '22 17:02 theneekz

@theneekz I can see what you are trying to do here. The Sheet opens up in a Modal. So if the user cannot interact with the buttons in bottom tab, I think it will end up being a confusing UX. One way around that would be to render the tab at the same position inside the sheet. So when the Sheet opens up, the bottom tabs are in there and user can tap on them to close the sheet and navigate to the respective tab.

What you are trying to achieve here is possible with a Sheet that does not open in a Modal but in a View container.

ammarahm-ed avatar Feb 03 '22 17:02 ammarahm-ed

Thanks, that makes sense. I think rerendering the bottom tabs inside the modal is the only solution for using this library. There's no way to render this inside a View container right rather than a modal right?

theneekz avatar Feb 03 '22 17:02 theneekz

@theneekz Right not it won't be possible to do it.

ammarahm-ed avatar Feb 03 '22 18:02 ammarahm-ed

@ammarahm-ed on bottom there is a little padding between the Navigation Bar and the ActionSheet that can't be removed (on Android at least) - the black area is containerStyle with backgroundColor: 'black' of ActionSheet and the yellow area is my content.

unwanted_padding

mydesweb avatar May 09 '22 14:05 mydesweb

@mydesweb also facing the same issue. Did you manage to find a fix? Perhaps @ammarahm-ed can save the day 🙏 🙏

Screenshot 2022-06-01 at 12 01 14

Could we add support for a custom background color on this element? @ammarahm-ed

  <View style={{
                    height: 200,
                    backgroundColor: (containerStyle === null || containerStyle === void 0 ? void 0 : containerStyle.backgroundColor) || "#ffffff",
                    position: "absolute",
                    bottom: -195,
                    width: (containerStyle === null || containerStyle === void 0 ? void 0 : containerStyle.width) || "100%"
                }}/>

Using patch-package (https://www.npmjs.com/package/patch-package) with fix:

Screenshot 2022-06-01 at 15 53 44 Screenshot 2022-06-01 at 15 53 54

Allows you to change the color and and adjust the positioning to remove the background color bleeding issue:

Screenshot 2022-06-01 at 15 57 08

I have the same problem on Ios and Android platforms. I am sharing 2 screenshots and code blocks to elaborate on the subject.

Code:

<ActionSheet containerStyle={{backgroundColor: 'red'}}>
      <View style={{ width: '100%', height: 200, backgroundColor: 'green'}} />
<ActionSheet>

Screenshots:

Android Ios
image image

HyopeR avatar Aug 20 '22 17:08 HyopeR

I think I found the problem. There is a problem with the following part of the source code. At: https://github.com/ammarahm-ed/react-native-actions-sheet/blob/master/src/index.tsx


{overdrawEnabled ? (
    <Animated.View
        style={{
            height: overdrawSize,
            position: "absolute",
            bottom: -overdrawSize
            backgroundColor: props.containerStyle?.backgroundColor || "white",
            width: dimensions.width,
        }}
    />
) : null}

This is what this part looks like when it comes out of the package. Look at the bottom value.

<View style={{
        height: 200,
        backgroundColor: (containerStyle === null || containerStyle === void 0 ? void 0 : containerStyle.backgroundColor) || "#ffffff",
        position: "absolute",
        bottom: -195, // 5 pixels missing here. 
        width: (containerStyle === null || containerStyle === void 0 ? void 0 : containerStyle.width) || "100%"
    }}
/>

There is a problem in the part where the 'overdrawSize' value is given as negative. And the difference of 5 pixels creates the padding.

HyopeR avatar Aug 20 '22 18:08 HyopeR

@HyopeR The master branch has the unreleased version of the library. You must be using the older version. A new version will be out soon which fixes this. I will investigate this and see if this padding at bottom could be avoided completely.

ammarahm-ed avatar Aug 20 '22 19:08 ammarahm-ed

You can try installing the vnext branch but beware it has many breaking changes so its best to wait until i release v0.8.0

ammarahm-ed avatar Aug 20 '22 19:08 ammarahm-ed

This is fixed in v0.8.0. Will release today.

ammarahm-ed avatar Aug 21 '22 06:08 ammarahm-ed

Still facing this issue on v0.8.0. please help.

the pink area is containerStyle actionsheetSucks

actionsheetultrasucks

alwazqazi avatar Mar 28 '23 11:03 alwazqazi

Still facing this issue on v0.8.0. please help.

the pink area is containerStyle actionsheetSucks

actionsheetultrasucks

The same for me! Pls help!

MoRa2297 avatar May 29 '23 20:05 MoRa2297

Screenshot 2023-06-29 at 09 34 19

Still happening to me, there's an excess white background in the image. I'm using version 0.8.29.

Thanks.

adrian3ka avatar Jun 29 '23 02:06 adrian3ka

Happening to me as well

andrisole92 avatar Sep 14 '23 02:09 andrisole92