Skip to content

Commit 3477a29

Browse files
authored
Merge pull request Expensify#60438 from margelo/@chrispader/fix-start-chat-page-offline-indicator
fix: Make offline indicator opaque by default, fix offline indicator on "New Room" page and minor Edge-to-Edge Bottom safe area fix
2 parents 1d48288 + b63d080 commit 3477a29

9 files changed

Lines changed: 29 additions & 24 deletions

File tree

src/components/NavigationBar/index.android.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import {useMemo} from 'react';
22
import {View} from 'react-native';
3+
import useNetwork from '@hooks/useNetwork';
34
import useSafeAreaPaddings from '@hooks/useSafeAreaPaddings';
45
import useStyleUtils from '@hooks/useStyleUtils';
56
import useThemeStyles from '@hooks/useThemeStyles';
@@ -10,11 +11,12 @@ function NavigationBar() {
1011
const styles = useThemeStyles();
1112
const StyleUtils = useStyleUtils();
1213
const {insets, paddingBottom} = useSafeAreaPaddings();
14+
const {isOffline} = useNetwork();
1315

1416
const navigationBarType = useMemo(() => StyleUtils.getNavigationBarType(insets), [StyleUtils, insets]);
1517
const isSoftKeyNavigation = navigationBarType === CONST.NAVIGATION_BAR_TYPE.SOFT_KEYS;
1618

17-
return isSoftKeyNavigation ? <View style={[styles.navigationBarBG, styles.stickToBottom, {height: paddingBottom}]} /> : null;
19+
return isSoftKeyNavigation ? <View style={[isOffline ? styles.appBG : styles.translucentNavigationBarBG, styles.stickToBottom, {height: paddingBottom}]} /> : null;
1820
}
1921
NavigationBar.displayName = 'NavigationBar';
2022

src/components/OfflineIndicator.tsx

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,9 @@ type OfflineIndicatorProps = {
2020

2121
/** Whether to add bottom safe area padding to the view. */
2222
addBottomSafeAreaPadding?: boolean;
23-
24-
/** Whether to make the indicator translucent. */
25-
isTranslucent?: boolean;
2623
};
2724

28-
function OfflineIndicator({style, containerStyles: containerStylesProp, addBottomSafeAreaPadding = false, isTranslucent = false}: OfflineIndicatorProps) {
25+
function OfflineIndicator({style, containerStyles: containerStylesProp, addBottomSafeAreaPadding = false}: OfflineIndicatorProps) {
2926
const theme = useTheme();
3027
const styles = useThemeStyles();
3128
const {translate} = useLocalize();
@@ -42,7 +39,7 @@ function OfflineIndicator({style, containerStyles: containerStylesProp, addBotto
4239
}
4340

4441
return (
45-
<View style={[containerStyles, isTranslucent && styles.navigationBarBG, styles.flexRow, styles.alignItemsCenter, style]}>
42+
<View style={[containerStyles, styles.flexRow, styles.alignItemsCenter, style]}>
4643
<Icon
4744
fill={theme.icon}
4845
src={Expensicons.OfflineCloud}

src/components/ScreenWrapper.tsx

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ function ScreenWrapper(
180180
enableEdgeToEdgeBottomSafeAreaPadding: enableEdgeToEdgeBottomSafeAreaPaddingProp,
181181
shouldMobileOfflineIndicatorStickToBottom: shouldMobileOfflineIndicatorStickToBottomProp,
182182
shouldKeyboardOffsetBottomSafeAreaPadding: shouldKeyboardOffsetBottomSafeAreaPaddingProp,
183-
isOfflineIndicatorTranslucent: isOfflineIndicatorTranslucentProp,
183+
isOfflineIndicatorTranslucent = false,
184184
}: ScreenWrapperProps,
185185
ref: ForwardedRef<View>,
186186
) {
@@ -201,7 +201,7 @@ function ScreenWrapper(
201201
const {setRootStatusBarEnabled} = useContext(CustomStatusBarAndBackgroundContext);
202202
const {initialURL} = useContext(InitialURLContext);
203203

204-
const [isSingleNewDotEntry] = useOnyx(ONYXKEYS.IS_SINGLE_NEW_DOT_ENTRY);
204+
const [isSingleNewDotEntry] = useOnyx(ONYXKEYS.IS_SINGLE_NEW_DOT_ENTRY, {canBeMissing: true});
205205

206206
// When the `enableEdgeToEdgeBottomSafeAreaPadding` prop is explicitly set, we enable edge-to-edge mode.
207207
const isUsingEdgeToEdgeMode = enableEdgeToEdgeBottomSafeAreaPaddingProp !== undefined;
@@ -210,7 +210,6 @@ function ScreenWrapper(
210210
// We enable all of these flags by default, if we are using edge-to-edge mode.
211211
const shouldMobileOfflineIndicatorStickToBottom = shouldMobileOfflineIndicatorStickToBottomProp ?? isUsingEdgeToEdgeMode;
212212
const shouldKeyboardOffsetBottomSafeAreaPadding = shouldKeyboardOffsetBottomSafeAreaPaddingProp ?? isUsingEdgeToEdgeMode;
213-
const isOfflineIndicatorTranslucent = isOfflineIndicatorTranslucentProp ?? isUsingEdgeToEdgeMode;
214213

215214
// We disable legacy bottom safe area padding handling, if we are using edge-to-edge mode.
216215
const includeSafeAreaPaddingBottom = isUsingEdgeToEdgeMode ? false : includeSafeAreaPaddingBottomProp;
@@ -362,16 +361,16 @@ function ScreenWrapper(
362361
* This style applies the background color of the mobile offline indicator.
363362
* When there is not bottom content, and the device either has soft keys or is offline,
364363
* the background style is applied.
365-
* By default, the background color of the mobile offline indicator is translucent.
366-
* If `isOfflineIndicatorTranslucent` is set to true, an opaque background color is applied.
364+
* By default, the background color of the mobile offline indicator is opaque.
365+
* If `isOfflineIndicatorTranslucent` is set to true, a translucent background color is applied.
367366
*/
368367
const mobileOfflineIndicatorBackgroundStyle = useMemo(() => {
369-
const showOfflineIndicatorBackground = !extraContent && (isSoftKeyNavigation || isOffline);
368+
const showOfflineIndicatorBackground = !extraContent && isOffline;
370369
if (!showOfflineIndicatorBackground) {
371370
return undefined;
372371
}
373-
return isOfflineIndicatorTranslucent ? styles.navigationBarBG : styles.appBG;
374-
}, [extraContent, isOffline, isOfflineIndicatorTranslucent, isSoftKeyNavigation, styles.appBG, styles.navigationBarBG]);
372+
return isOfflineIndicatorTranslucent ? styles.translucentNavigationBarBG : styles.appBG;
373+
}, [extraContent, isOffline, isOfflineIndicatorTranslucent, styles.appBG, styles.translucentNavigationBarBG]);
375374

376375
/** In edge-to-edge mode, we always want to apply the bottom safe area padding to the mobile offline indicator. */
377376
const hasMobileOfflineIndicatorBottomSafeAreaPadding = isUsingEdgeToEdgeMode ? enableEdgeToEdgeBottomSafeAreaPadding : !includeSafeAreaPaddingBottom;

src/pages/workspace/WorkspaceNewRoomPage.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import useActiveWorkspace from '@hooks/useActiveWorkspace';
1717
import useAutoFocusInput from '@hooks/useAutoFocusInput';
1818
import useBottomSafeSafeAreaPaddingStyle from '@hooks/useBottomSafeSafeAreaPaddingStyle';
1919
import useLocalize from '@hooks/useLocalize';
20+
import useResponsiveLayout from '@hooks/useResponsiveLayout';
2021
import useSafeAreaInsets from '@hooks/useSafeAreaInsets';
2122
import useThemeStyles from '@hooks/useThemeStyles';
2223
import {addErrorMessage} from '@libs/ErrorUtils';
@@ -43,6 +44,7 @@ function WorkspaceNewRoomPage() {
4344
const [activePolicyID] = useOnyx(ONYXKEYS.NVP_ACTIVE_POLICY_ID, {canBeMissing: false});
4445
// We need to use isSmallScreenWidth instead of shouldUseNarrowLayout to show offline indicator on small screen only
4546
// eslint-disable-next-line rulesdir/prefer-shouldUseNarrowLayout-instead-of-isSmallScreenWidth
47+
const {isSmallScreenWidth} = useResponsiveLayout();
4648
const {top} = useSafeAreaInsets();
4749
const [visibility, setVisibility] = useState<ValueOf<typeof CONST.REPORT.VISIBILITY>>(CONST.REPORT.VISIBILITY.RESTRICTED);
4850
const [writeCapability, setWriteCapability] = useState<ValueOf<typeof CONST.REPORT.WRITE_CAPABILITIES>>(CONST.REPORT.WRITE_CAPABILITIES.ALL);
@@ -234,6 +236,7 @@ function WorkspaceNewRoomPage() {
234236
onSubmit={submit}
235237
enabledWhenOffline
236238
addBottomSafeAreaPadding
239+
addOfflineIndicatorBottomSafeAreaPadding={isSmallScreenWidth}
237240
>
238241
<View style={styles.mb5}>
239242
<InputWrapper

src/pages/workspace/expensifyCard/WorkspaceExpensifyCardBankAccounts.tsx

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import LottieAnimations from '@components/LottieAnimations';
1313
import MenuItem from '@components/MenuItem';
1414
import ScreenWrapper from '@components/ScreenWrapper';
1515
import Text from '@components/Text';
16+
import useBottomSafeSafeAreaPaddingStyle from '@hooks/useBottomSafeSafeAreaPaddingStyle';
1617
import useLocalize from '@hooks/useLocalize';
1718
import useThemeStyles from '@hooks/useThemeStyles';
1819
import useWorkspaceAccountID from '@hooks/useWorkspaceAccountID';
@@ -37,14 +38,14 @@ type WorkspaceExpensifyCardBankAccountsProps = PlatformStackScreenProps<Settings
3738
function WorkspaceExpensifyCardBankAccounts({route}: WorkspaceExpensifyCardBankAccountsProps) {
3839
const {translate} = useLocalize();
3940
const styles = useThemeStyles();
40-
const [bankAccountsList] = useOnyx(ONYXKEYS.BANK_ACCOUNT_LIST);
41+
const [bankAccountsList] = useOnyx(ONYXKEYS.BANK_ACCOUNT_LIST, {canBeMissing: false});
4142

4243
const policyID = route?.params?.policyID;
4344

4445
const workspaceAccountID = useWorkspaceAccountID(policyID);
4546

46-
const [cardBankAccountMetadata] = useOnyx(`${ONYXKEYS.COLLECTION.EXPENSIFY_CARD_BANK_ACCOUNT_METADATA}${workspaceAccountID}`);
47-
const [cardOnWaitlist] = useOnyx(`${ONYXKEYS.COLLECTION.NVP_EXPENSIFY_ON_CARD_WAITLIST}${policyID}`);
47+
const [cardBankAccountMetadata] = useOnyx(`${ONYXKEYS.COLLECTION.EXPENSIFY_CARD_BANK_ACCOUNT_METADATA}${workspaceAccountID}`, {canBeMissing: true});
48+
const [cardOnWaitlist] = useOnyx(`${ONYXKEYS.COLLECTION.NVP_EXPENSIFY_ON_CARD_WAITLIST}${policyID}`, {canBeMissing: true});
4849

4950
const getVerificationState = () => {
5051
if (cardOnWaitlist) {
@@ -102,6 +103,8 @@ function WorkspaceExpensifyCardBankAccounts({route}: WorkspaceExpensifyCardBankA
102103
const verificationState = getVerificationState();
103104
const isInVerificationState = !!verificationState;
104105

106+
const bottomSafeAreaPaddingStyle = useBottomSafeSafeAreaPaddingStyle({addBottomSafeAreaPadding: true});
107+
105108
const renderVerificationStateView = () => {
106109
switch (verificationState) {
107110
case CONST.EXPENSIFY_CARD.VERIFICATION_STATE.LOADING:
@@ -114,6 +117,7 @@ function WorkspaceExpensifyCardBankAccounts({route}: WorkspaceExpensifyCardBankA
114117
animationWebStyle={styles.loadingVBAAnimationWeb}
115118
subtitleStyle={styles.textLabelSupporting}
116119
containerStyle={styles.pb20}
120+
addBottomSafeAreaPadding
117121
/>
118122
);
119123
case CONST.EXPENSIFY_CARD.VERIFICATION_STATE.ON_WAITLIST:
@@ -131,7 +135,7 @@ function WorkspaceExpensifyCardBankAccounts({route}: WorkspaceExpensifyCardBankA
131135
success
132136
large
133137
text={translate('workspace.expensifyCard.goToConcierge')}
134-
style={[styles.m5]}
138+
style={[styles.m5, bottomSafeAreaPaddingStyle]}
135139
pressOnEnter
136140
onPress={() => Navigation.navigate(ROUTES.CONCIERGE)}
137141
/>
@@ -152,7 +156,7 @@ function WorkspaceExpensifyCardBankAccounts({route}: WorkspaceExpensifyCardBankA
152156
success
153157
large
154158
text={translate('workspace.expensifyCard.gotIt')}
155-
style={[styles.m5]}
159+
style={[styles.m5, bottomSafeAreaPaddingStyle]}
156160
pressOnEnter
157161
onPress={() => {
158162
Navigation.dismissModal();

src/styles/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5659,8 +5659,8 @@ const styles = (theme: ThemeColors) =>
56595659
borderRadius: variables.componentBorderRadiusNormal,
56605660
},
56615661

5662-
navigationBarBG: {
5663-
backgroundColor: theme.navigationBarBackgroundColor,
5662+
translucentNavigationBarBG: {
5663+
backgroundColor: theme.translucentNavigationBarBackgroundColor,
56645664
},
56655665

56665666
stickToBottom: {

src/styles/theme/themes/dark.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ const darkTheme = {
154154

155155
statusBarStyle: CONST.STATUS_BAR_STYLE.LIGHT_CONTENT,
156156
navigationBarButtonsStyle: CONST.NAVIGATION_BAR_BUTTONS_STYLE.LIGHT,
157-
navigationBarBackgroundColor: `${colors.productDark100}CD`, // CD is 80% opacity (80% of 0xFF)
157+
translucentNavigationBarBackgroundColor: `${colors.productDark100}CD`, // CD is 80% opacity (80% of 0xFF)
158158
colorScheme: CONST.COLOR_SCHEME.DARK,
159159
} satisfies ThemeColors;
160160

src/styles/theme/themes/light.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ const lightTheme = {
154154

155155
statusBarStyle: CONST.STATUS_BAR_STYLE.DARK_CONTENT,
156156
navigationBarButtonsStyle: CONST.NAVIGATION_BAR_BUTTONS_STYLE.DARK,
157-
navigationBarBackgroundColor: `${colors.productLight100}CD`, // CD is 80% opacity (80% of 0xFF)
157+
translucentNavigationBarBackgroundColor: `${colors.productLight100}CD`, // CD is 80% opacity (80% of 0xFF)
158158
colorScheme: CONST.COLOR_SCHEME.LIGHT,
159159
} satisfies ThemeColors;
160160

src/styles/theme/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ type ThemeColors = {
109109
// e.g. the StatusBar displays either "light-content" or "dark-content" based on the theme
110110
statusBarStyle: StatusBarStyle;
111111
navigationBarButtonsStyle: NavBarButtonStyle;
112-
navigationBarBackgroundColor: Color;
112+
translucentNavigationBarBackgroundColor: Color;
113113
colorScheme: ColorScheme;
114114
};
115115

0 commit comments

Comments
 (0)