Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hybrid app android fragment v2 #56145

Prev Previous commit
Next Next commit
fix status bar on travel page
  • Loading branch information
war-in authored and jnowakow committed Jan 31, 2025
commit 0b1755b649659b117527eb575cc32964866e2fd8
3 changes: 3 additions & 0 deletions src/components/ScreenWrapper.tsx
Original file line number Diff line number Diff line change
@@ -5,6 +5,7 @@ import type {StyleProp, ViewStyle} from 'react-native';
import {Keyboard, NativeModules, PanResponder, View} from 'react-native';
import {PickerAvoidingView} from 'react-native-picker-select';
import type {EdgeInsets} from 'react-native-safe-area-context';
import CustomStatusBarAndBackgroundContext from '@components/CustomStatusBarAndBackground/CustomStatusBarAndBackgroundContext';
import useEnvironment from '@hooks/useEnvironment';
import useInitialDimensions from '@hooks/useInitialWindowDimensions';
import useResponsiveLayout from '@hooks/useResponsiveLayout';
@@ -152,6 +153,7 @@ function ScreenWrapper(
const {windowHeight} = useWindowDimensions(shouldUseCachedViewportHeight);
// since Modals are drawn in separate native view hierarchy we should always add paddings
const ignoreInsetsConsumption = !useContext(ModalContext).default;
const {setRootStatusBarEnabled} = useContext(CustomStatusBarAndBackgroundContext);

// We need to use isSmallScreenWidth instead of shouldUseNarrowLayout for a case where we want to show the offline indicator only on small screens
// eslint-disable-next-line rulesdir/prefer-shouldUseNarrowLayout-instead-of-isSmallScreenWidth
@@ -171,6 +173,7 @@ function ScreenWrapper(

UNSTABLE_usePreventRemove(shouldReturnToOldDot, () => {
NativeModules.HybridAppModule?.closeReactNativeApp(false, false);
setRootStatusBarEnabled(false);
});

const panResponder = useRef(
8 changes: 7 additions & 1 deletion src/libs/actions/Travel.ts
Original file line number Diff line number Diff line change
@@ -114,7 +114,12 @@ function provisionDomain(domain: string) {
Navigation.navigate(ROUTES.TRAVEL_TCS.getRoute(domain));
}

function bookATrip(translate: LocaleContextProps['translate'], setCtaErrorMessage: Dispatch<SetStateAction<string>>, ctaErrorMessage = ''): void {
function bookATrip(
translate: LocaleContextProps['translate'],
setCtaErrorMessage: Dispatch<SetStateAction<string>>,
setRootStatusBarEnabled: (isEnabled: boolean) => void,
ctaErrorMessage = '',
): void {
if (!activePolicyID) {
return;
}
@@ -138,6 +143,7 @@ function bookATrip(translate: LocaleContextProps['translate'], setCtaErrorMessag

Log.info('[HybridApp] Returning to OldDot after opening TravelDot');
NativeModules.HybridAppModule.closeReactNativeApp(false, false);
setRootStatusBarEnabled(false);
})
?.catch(() => {
setCtaErrorMessage(translate('travel.errorMessage'));
5 changes: 4 additions & 1 deletion src/pages/OnboardingEmployees/BaseOnboardingEmployees.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import React, {useMemo, useState} from 'react';
import React, {useContext, useMemo, useState} from 'react';
import {NativeModules} from 'react-native';
import {useOnyx} from 'react-native-onyx';
import Button from '@components/Button';
import CustomStatusBarAndBackgroundContext from '@components/CustomStatusBarAndBackground/CustomStatusBarAndBackgroundContext';
import FormHelpMessage from '@components/FormHelpMessage';
import HeaderWithBackButton from '@components/HeaderWithBackButton';
import ScreenWrapper from '@components/ScreenWrapper';
@@ -34,6 +35,7 @@ function BaseOnboardingEmployees({shouldUseNativeStyles, route}: BaseOnboardingE
const [onboardingPolicyID] = useOnyx(ONYXKEYS.ONBOARDING_POLICY_ID);
const [onboardingAdminsChatReportID] = useOnyx(ONYXKEYS.ONBOARDING_ADMINS_CHAT_REPORT_ID);
const [allPolicies] = useOnyx(ONYXKEYS.COLLECTION.POLICY);
const {setRootStatusBarEnabled} = useContext(CustomStatusBarAndBackgroundContext);

const paidGroupPolicy = Object.values(allPolicies ?? {}).find(PolicyUtils.isPaidGroupPolicy);

@@ -106,6 +108,7 @@ function BaseOnboardingEmployees({shouldUseNativeStyles, route}: BaseOnboardingE
}

NativeModules.HybridAppModule.closeReactNativeApp(false, true);
setRootStatusBarEnabled(false);
}}
pressOnEnter
/>
6 changes: 4 additions & 2 deletions src/pages/Search/EmptySearchView.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import React, {useMemo, useState} from 'react';
import React, {useContext, useMemo, useState} from 'react';
import {Linking, View} from 'react-native';
import {useOnyx} from 'react-native-onyx';
import type {OnyxCollection} from 'react-native-onyx';
import ConfirmModal from '@components/ConfirmModal';
import CustomStatusBarAndBackgroundContext from '@components/CustomStatusBarAndBackground/CustomStatusBarAndBackgroundContext';
import DotIndicatorMessage from '@components/DotIndicatorMessage';
import EmptyStateComponent from '@components/EmptyStateComponent';
import type {FeatureListItem} from '@components/FeatureList';
@@ -60,6 +61,7 @@ function EmptySearchView({type, hasResults}: EmptySearchViewProps) {
const shouldRedirectToExpensifyClassic = useMemo(() => {
return areAllGroupPoliciesExpenseChatDisabled((allPolicies as OnyxCollection<Policy>) ?? {});
}, [allPolicies]);
const {setRootStatusBarEnabled} = useContext(CustomStatusBarAndBackgroundContext);

const [ctaErrorMessage, setCtaErrorMessage] = useState('');

@@ -133,7 +135,7 @@ function EmptySearchView({type, hasResults}: EmptySearchViewProps) {
buttons: [
{
buttonText: translate('search.searchResults.emptyTripResults.buttonText'),
buttonAction: () => bookATrip(translate, setCtaErrorMessage, ctaErrorMessage),
buttonAction: () => bookATrip(translate, setCtaErrorMessage, setRootStatusBarEnabled, ctaErrorMessage),
success: true,
},
],
6 changes: 4 additions & 2 deletions src/pages/Travel/ManageTrips.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React, {useState} from 'react';
import React, {useContext, useState} from 'react';
import {Linking, View} from 'react-native';
import {useOnyx} from 'react-native-onyx';
import CustomStatusBarAndBackgroundContext from '@components/CustomStatusBarAndBackground/CustomStatusBarAndBackgroundContext';
import type {FeatureListItem} from '@components/FeatureList';
import FeatureList from '@components/FeatureList';
import FullScreenLoadingIndicator from '@components/FullscreenLoadingIndicator';
@@ -34,6 +35,7 @@ function ManageTrips() {
const {translate} = useLocalize();
const [activePolicyID] = useOnyx(ONYXKEYS.NVP_ACTIVE_POLICY_ID);
const policy = usePolicy(activePolicyID);
const {setRootStatusBarEnabled} = useContext(CustomStatusBarAndBackgroundContext);

const [ctaErrorMessage, setCtaErrorMessage] = useState('');

@@ -55,7 +57,7 @@ function ManageTrips() {
ctaText={translate('travel.bookTravel')}
ctaAccessibilityLabel={translate('travel.bookTravel')}
onCtaPress={() => {
bookATrip(translate, setCtaErrorMessage, ctaErrorMessage);
bookATrip(translate, setCtaErrorMessage, setRootStatusBarEnabled, ctaErrorMessage);
}}
ctaErrorMessage={ctaErrorMessage}
illustration={LottieAnimations.TripsEmptyState}