Skip to content

Commit

Permalink
Merge pull request #53686 from nkdengineer/fix/53444
Browse files Browse the repository at this point in the history
fix: Navigation bar shows purple color in offline mode
  • Loading branch information
MarioExpensify authored Dec 26, 2024
2 parents a05ae82 + 8286cc3 commit 499b61b
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions src/components/ScreenWrapper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import {PickerAvoidingView} from 'react-native-picker-select';
import type {EdgeInsets} from 'react-native-safe-area-context';
import useEnvironment from '@hooks/useEnvironment';
import useInitialDimensions from '@hooks/useInitialWindowDimensions';
import useNetwork from '@hooks/useNetwork';
import useResponsiveLayout from '@hooks/useResponsiveLayout';
import useStyledSafeAreaInsets from '@hooks/useStyledSafeAreaInsets';
import useTackInputFocus from '@hooks/useTackInputFocus';
Expand Down Expand Up @@ -158,7 +157,6 @@ function ScreenWrapper(
const {initialHeight} = useInitialDimensions();
const styles = useThemeStyles();
const {isDevelopment} = useEnvironment();
const {isOffline} = useNetwork();
const [didScreenTransitionEnd, setDidScreenTransitionEnd] = useState(false);
const maxHeight = shouldEnableMaxHeight ? windowHeight : undefined;
const minHeight = shouldEnableMinHeight && !Browser.isSafari() ? initialHeight : undefined;
Expand Down Expand Up @@ -244,18 +242,17 @@ function ScreenWrapper(
}

// We always need the safe area padding bottom if we're showing the offline indicator since it is bottom-docked.
const isSafeAreaBottomPaddingApplied = includeSafeAreaPaddingBottom || (isOffline && shouldShowOfflineIndicator);
if (isSafeAreaBottomPaddingApplied) {
if (includeSafeAreaPaddingBottom) {
paddingStyle.paddingBottom = paddingBottom;
}
if (isSafeAreaBottomPaddingApplied && ignoreInsetsConsumption) {
if (includeSafeAreaPaddingBottom && ignoreInsetsConsumption) {
paddingStyle.paddingBottom = unmodifiedPaddings.bottom;
}

const isAvoidingViewportScroll = useTackInputFocus(isFocused && shouldEnableMaxHeight && shouldAvoidScrollOnVirtualViewport && Browser.isMobileWebKit());
const contextValue = useMemo(
() => ({didScreenTransitionEnd, isSafeAreaTopPaddingApplied, isSafeAreaBottomPaddingApplied}),
[didScreenTransitionEnd, isSafeAreaBottomPaddingApplied, isSafeAreaTopPaddingApplied],
() => ({didScreenTransitionEnd, isSafeAreaTopPaddingApplied, isSafeAreaBottomPaddingApplied: includeSafeAreaPaddingBottom}),
[didScreenTransitionEnd, includeSafeAreaPaddingBottom, isSafeAreaTopPaddingApplied],
);

return (
Expand Down Expand Up @@ -297,7 +294,14 @@ function ScreenWrapper(
}
{isSmallScreenWidth && shouldShowOfflineIndicator && (
<>
<OfflineIndicator style={offlineIndicatorStyle} />
<OfflineIndicator
style={[offlineIndicatorStyle]}
containerStyles={
includeSafeAreaPaddingBottom
? [styles.offlineIndicatorMobile]
: [styles.offlineIndicatorMobile, {paddingBottom: paddingBottom + styles.offlineIndicatorMobile.paddingBottom}]
}
/>
{/* Since import state is tightly coupled to the offline state, it is safe to display it when showing offline indicator */}
<ImportedStateIndicator />
</>
Expand Down

0 comments on commit 499b61b

Please sign in to comment.