Skip to content

Commit

Permalink
fix: padding in scrollview bottomsheet
Browse files Browse the repository at this point in the history
  • Loading branch information
Shivam25092001 committed Dec 25, 2024
1 parent 54f2284 commit ac8c410
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 20 deletions.
42 changes: 39 additions & 3 deletions src/components/common/CustomView.res
Original file line number Diff line number Diff line change
Expand Up @@ -68,14 +68,50 @@ module Wrapper = {
let make = (~onModalClose, ~width=100.->pct, ~children=React.null) => {
let {bgColor} = ThemebasedStyle.useThemeBasedStyle()

<Animated.ScrollView
let defaultHeight = 25.
let navigationBarHeight = React.useMemo(() => {
if Platform.os !== #android {
defaultHeight
} else {
let screenHeight = Dimensions.get(#screen).height
let windowHeight = Dimensions.get(#window).height
let statusBarHeight = StatusBar.currentHeight
let navigationHeight = screenHeight -. windowHeight -. statusBarHeight
Math.min(75., Math.max(0., navigationHeight) +. defaultHeight)
}
}, [])

let windowHeight = Dimensions.get(#window).height
let maxScrollViewHeight = windowHeight *. 0.95
let (isScrollable, setIsScrollable) = React.useState(_ => false)

<ScrollView
onLayout={event => {
let height = event.nativeEvent.layout.height
if height > maxScrollViewHeight {
setIsScrollable(_ => true)
} else {
setIsScrollable(_ => false)
}
}}
contentContainerStyle={viewStyle(
~paddingBottom=isScrollable ? (navigationBarHeight +. 15.)->dp : navigationBarHeight->dp,
(),
)}
keyboardShouldPersistTaps={#handled}
style={array([
viewStyle(~flexGrow=1., ~width, ~minHeight=250.->dp, ~padding=20.->dp, ()),
viewStyle(
~flexGrow=1.,
~width,
~minHeight=250.->dp,
~paddingHorizontal=20.->dp,
~paddingTop=20.->dp,
(),
),
bgColor,
])}>
<ModalHeader onModalClose />
children
</Animated.ScrollView>
</ScrollView>
}
}
2 changes: 0 additions & 2 deletions src/components/elements/ConfirmButton.res
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ let make = (
~paymentMethod: string,
~paymentExperience=?,
~errorText=None,
~bottomSpace=0.,
) => {
let (nativeProp, _) = React.useContext(NativePropContext.nativePropContext)
let (allApiData, _) = React.useContext(AllApiDataContext.allApiDataContext)
Expand Down Expand Up @@ -35,6 +34,5 @@ let make = (
: localeObject.payNowButton
}}
/>}
{bottomSpace > 0. ? <Space height={bottomSpace} /> : React.null}
</>
}
11 changes: 0 additions & 11 deletions src/routes/FullScreenSheetWrapper.res
Original file line number Diff line number Diff line change
Expand Up @@ -52,16 +52,6 @@ let make = (~children) => {
None
}, [loading])

let navigationBarHeight = React.useMemo(() => {
if Platform.os !== #android {
0.
} else {
let screenHeight = Dimensions.get(#screen).height
let windowHeight = Dimensions.get(#window).height
screenHeight -. windowHeight
}
}, [])

<View
style={viewStyle(
~flex=1.,
Expand All @@ -80,7 +70,6 @@ let make = (~children) => {
<CustomView onDismiss=onModalClose>
<CustomView.Wrapper onModalClose>
{children}
<Space height={navigationBarHeight} />
</CustomView.Wrapper>
</CustomView>
</Animated.View>
Expand Down
5 changes: 1 addition & 4 deletions src/routes/GlobalConfirmButton.res
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,5 @@ open ReactNative

@react.component
let make = (~confirmButtonDataRef) => {
<View>
{confirmButtonDataRef}
<Space />
</View>
<View> {confirmButtonDataRef} </View>
}

0 comments on commit ac8c410

Please sign in to comment.