Skip to content

Commit

Permalink
Merge pull request #26873 from ishpaul777/ishpaul777/fix-IllustratedH…
Browse files Browse the repository at this point in the history
…eader-Overscroll-spacer-safari

fix overscroll spacer in safari
  • Loading branch information
roryabraham authored Sep 15, 2023
2 parents 1ec7186 + a55003d commit d9f35a3
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 5 deletions.
20 changes: 15 additions & 5 deletions src/components/IllustratedHeaderPageLayout.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import * as StyleUtils from '../styles/StyleUtils';
import useWindowDimensions from '../hooks/useWindowDimensions';
import FixedFooter from './FixedFooter';
import useNetwork from '../hooks/useNetwork';
import * as Browser from '../libs/Browser';

const propTypes = {
...headerWithBackButtonPropTypes,
Expand Down Expand Up @@ -39,14 +40,16 @@ const defaultProps = {
};

function IllustratedHeaderPageLayout({backgroundColor, children, illustration, footer, overlayContent, ...propsToPassToHeader}) {
const {windowHeight} = useWindowDimensions();
const {isOffline} = useNetwork();
const {isSmallScreenWidth, windowHeight} = useWindowDimensions();
const appBGColor = StyleUtils.getBackgroundColorStyle(themeColors.appBG);

return (
<ScreenWrapper
style={[StyleUtils.getBackgroundColorStyle(backgroundColor)]}
shouldEnablePickerAvoiding={false}
includeSafeAreaPaddingBottom={false}
offlineIndicatorStyle={[StyleUtils.getBackgroundColorStyle(themeColors.appBG)]}
offlineIndicatorStyle={[appBGColor]}
>
{({safeAreaPaddingBottomStyle}) => (
<>
Expand All @@ -56,12 +59,19 @@ function IllustratedHeaderPageLayout({backgroundColor, children, illustration, f
titleColor={backgroundColor === themeColors.appBG ? undefined : themeColors.textColorfulBackground}
iconFill={backgroundColor === themeColors.appBG ? undefined : themeColors.iconColorfulBackground}
/>
<View style={[styles.flex1, StyleUtils.getBackgroundColorStyle(themeColors.appBG), !isOffline ? safeAreaPaddingBottomStyle : {}]}>
<View style={[styles.flex1, appBGColor, !isOffline ? safeAreaPaddingBottomStyle : {}]}>
{/* Safari on ios/mac has a bug where overscrolling the page scrollview shows green the background color. This is a workaround to fix that. https://github.com/Expensify/App/issues/23422 */}
{Browser.isSafari() && (
<View style={[styles.dualColorOverscrollSpacer]}>
<View style={[styles.flex1, StyleUtils.getBackgroundColorStyle(backgroundColor)]} />
<View style={[isSmallScreenWidth ? styles.flex1 : styles.flex3, appBGColor]} />
</View>
)}
<ScrollView
contentContainerStyle={safeAreaPaddingBottomStyle}
showsVerticalScrollIndicator={false}
>
<View style={styles.overscrollSpacer(backgroundColor, windowHeight)} />
{!Browser.isSafari() && <View style={styles.overscrollSpacer(backgroundColor, windowHeight)} />}
<View style={[styles.alignItemsCenter, styles.justifyContentEnd, StyleUtils.getBackgroundColorStyle(backgroundColor)]}>
<Lottie
source={illustration}
Expand All @@ -71,7 +81,7 @@ function IllustratedHeaderPageLayout({backgroundColor, children, illustration, f
/>
{overlayContent && overlayContent()}
</View>
<View style={[styles.pt5]}>{children}</View>
<View style={[styles.pt5, appBGColor]}>{children}</View>
</ScrollView>
{!_.isNull(footer) && <FixedFooter>{footer}</FixedFooter>}
</View>
Expand Down
9 changes: 9 additions & 0 deletions src/styles/styles.js
Original file line number Diff line number Diff line change
Expand Up @@ -3757,6 +3757,15 @@ const styles = (theme) => ({
right: 0,
}),

dualColorOverscrollSpacer: {
position: 'absolute',
top: 0,
left: 0,
width: '100%',
height: '100%',
zIndex: -1,
},

willChangeTransform: {
willChange: 'transform',
},
Expand Down

0 comments on commit d9f35a3

Please sign in to comment.