Skip to content

Commit

Permalink
added force full screen
Browse files Browse the repository at this point in the history
  • Loading branch information
kosmydel committed Jan 11, 2024
1 parent fb57764 commit 2921f1a
Show file tree
Hide file tree
Showing 6 changed files with 55 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import type ForceFullScreenViewProps from './types';

function ForceFullScreenView({children}: ForceFullScreenViewProps) {
return children;
}

ForceFullScreenView.displayName = 'ForceFullScreenView';

export default ForceFullScreenView;
18 changes: 18 additions & 0 deletions src/components/BlockingViews/ForceFullScreenView/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import React from 'react';
import {View} from 'react-native';
import useThemeStyles from '@hooks/useThemeStyles';
import type ForceFullScreenViewProps from './types';

function ForceFullScreenView({children, forceFullPage = false}: ForceFullScreenViewProps) {
const styles = useThemeStyles();

if (forceFullPage) {
return <View style={forceFullPage && styles.forcedBlockingViewContainer}>{children}</View>;
}

return children;
}

ForceFullScreenView.displayName = 'ForceFullScreenViewProps';

export default ForceFullScreenView;
7 changes: 7 additions & 0 deletions src/components/BlockingViews/ForceFullScreenView/types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import type ChildrenProps from '@src/types/utils/ChildrenProps';

type ForceFullScreenViewProps = ChildrenProps & {
forceFullPage?: boolean;
};

export default ForceFullScreenViewProps;
9 changes: 7 additions & 2 deletions src/components/BlockingViews/FullPageNotFoundView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import variables from '@styles/variables';
import type {TranslationPaths} from '@src/languages/types';
import ROUTES from '@src/ROUTES';
import BlockingView from './BlockingView';
import ForceFullScreenView from './ForceFullScreenView';

type FullPageNotFoundViewProps = {
/** Child elements */
Expand Down Expand Up @@ -37,6 +38,9 @@ type FullPageNotFoundViewProps = {

/** Function to call when pressing the navigation link */
onLinkPress: () => void;

/** Whether we should force the full page view */
forceFullPage?: boolean;
};

// eslint-disable-next-line rulesdir/no-negated-variables
Expand All @@ -50,13 +54,14 @@ function FullPageNotFoundView({
shouldShowLink = true,
shouldShowBackButton = true,
onLinkPress = () => Navigation.dismissModal(),
forceFullPage = false,
}: FullPageNotFoundViewProps) {
const styles = useThemeStyles();
const {translate} = useLocalize();

if (shouldShow) {
return (
<>
<ForceFullScreenView forceFullPage={forceFullPage}>
<HeaderWithBackButton
onBackButtonPress={onBackButtonPress}
shouldShowBackButton={shouldShowBackButton}
Expand All @@ -73,7 +78,7 @@ function FullPageNotFoundView({
onLinkPress={onLinkPress}
/>
</View>
</>
</ForceFullScreenView>
);
}

Expand Down
6 changes: 5 additions & 1 deletion src/pages/workspace/WorkspacePageWithSections.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,8 @@ function WorkspacePageWithSections({
const {isSmallScreenWidth} = useWindowDimensions();
const firstRender = useRef(true);

const goBack = () => Navigation.goBack(ROUTES.SETTINGS_WORKSPACES);

useEffect(() => {
// Because isLoading is false before merging in Onyx, we need firstRender ref to display loading page as well before isLoading is change to true
firstRender.current = false;
Expand All @@ -137,9 +139,11 @@ function WorkspacePageWithSections({
shouldShowOfflineIndicatorInWideScreen={shouldShowOfflineIndicatorInWideScreen}
>
<FullPageNotFoundView
onBackButtonPress={() => Navigation.goBack(ROUTES.SETTINGS_WORKSPACES)}
onBackButtonPress={goBack}
onLinkPress={goBack}
shouldShow={_.isEmpty(policy) || !PolicyUtils.isPolicyAdmin(policy) || PolicyUtils.isPendingDeletePolicy(policy)}
subtitleKey={_.isEmpty(policy) ? undefined : 'workspace.common.notAuthorized'}
forceFullPage
>
<HeaderWithBackButton
title={headerText}
Expand Down
9 changes: 9 additions & 0 deletions src/styles/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2296,6 +2296,15 @@ const styles = (theme: ThemeColors) =>
paddingBottom: variables.contentHeaderHeight,
},

forcedBlockingViewContainer: {
...positioning.pFixed,
top: 0,
left: 0,
right: 0,
bottom: 0,
backgroundColor: theme.appBG,
},

defaultModalContainer: {
backgroundColor: theme.componentBG,
borderColor: theme.transparent,
Expand Down

0 comments on commit 2921f1a

Please sign in to comment.