-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Inset the full screen modal used for workspaces on large devices #3887
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
Changes from all commits
29761f4
8ad161a
67a6c14
208dd34
ed7d06d
6315c42
684d5b2
8de4c56
703a063
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| import React from 'react'; | ||
| import {View} from 'react-native'; | ||
| import styles from '../styles/styles'; | ||
|
|
||
| const CardOverlay = () => <View style={styles.cardOverlay} />; | ||
|
|
||
| export default CardOverlay; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -65,6 +65,8 @@ import Timers from '../../Timers'; | |
| import ValidateLoginNewWorkspacePage from '../../../pages/ValidateLoginNewWorkspacePage'; | ||
| import ValidateLogin2FANewWorkspacePage from '../../../pages/ValidateLogin2FANewWorkspacePage'; | ||
| import WorkspaceSettingsDrawerNavigator from './WorkspaceSettingsDrawerNavigator'; | ||
| import spacing from '../../../styles/utilities/spacing'; | ||
| import CardOverlay from '../../../components/CardOverlay'; | ||
| import defaultScreenOptions from './defaultScreenOptions'; | ||
|
|
||
| Onyx.connect({ | ||
|
|
@@ -253,10 +255,14 @@ class AuthScreens extends React.Component { | |
| }; | ||
| const fullscreenModalScreenOptions = { | ||
| ...commonModalScreenOptions, | ||
| cardStyle: {...styles.fullscreenCard}, | ||
| cardStyle: { | ||
| ...styles.fullscreenCard, | ||
| padding: this.props.isSmallScreenWidth ? spacing.p0.padding : spacing.p5.padding, | ||
| }, | ||
| cardStyleInterpolator: props => modalCardStyleInterpolator(this.props.isSmallScreenWidth, true, props), | ||
| cardOverlayEnabled: false, | ||
| cardOverlayEnabled: !this.props.isSmallScreenWidth, | ||
| isFullScreenModal: true, | ||
| cardOverlay: CardOverlay, | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sould it make more sense just to have cardOverlay: <View style={styles.cardOverlay} />,Why have an entirely different file for something that is only used in this one place?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We could move it to the AuthScreen but, we would still need to pass it as |
||
| }; | ||
|
|
||
| return ( | ||
|
|
@@ -279,6 +285,7 @@ class AuthScreens extends React.Component { | |
| // prevent unnecessary scrolling | ||
| cardStyle: { | ||
| overflow: 'hidden', | ||
| height: '100%', | ||
| }, | ||
| }} | ||
| component={MainDrawerNavigator} | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,6 +2,7 @@ import React from 'react'; | |
| import _ from 'underscore'; | ||
| import PropTypes from 'prop-types'; | ||
| import {createDrawerNavigator} from '@react-navigation/drawer'; | ||
| import {View} from 'react-native'; | ||
| import styles, {getNavigationDrawerStyle, getNavigationDrawerType} from '../../../styles/styles'; | ||
| import withWindowDimensions, {windowDimensionsPropTypes} from '../../../components/withWindowDimensions'; | ||
|
|
||
|
|
@@ -22,38 +23,51 @@ const propTypes = { | |
| /** Drawer content Component */ | ||
| drawerContent: PropTypes.elementType.isRequired, | ||
|
|
||
| /** If it's the main screen, don't wrap the content even if it's a full screen modal. */ | ||
| isMainScreen: PropTypes.bool, | ||
|
|
||
| /** Window Dimensions props */ | ||
| ...windowDimensionsPropTypes, | ||
| }; | ||
| const Drawer = createDrawerNavigator(); | ||
|
|
||
| const BaseDrawerNavigator = props => ( | ||
| <Drawer.Navigator | ||
| defaultStatus={props.isSmallScreenWidth ? 'open' : 'closed'} | ||
| sceneContainerStyle={styles.navigationSceneContainer} | ||
| drawerContent={props.drawerContent} | ||
| screenOptions={{ | ||
| cardStyle: styles.navigationScreenCardStyle, | ||
| headerShown: false, | ||
| drawerType: getNavigationDrawerType(props.isSmallScreenWidth), | ||
| drawerStyle: getNavigationDrawerStyle( | ||
| props.windowWidth, | ||
| props.windowHeight, | ||
| props.isSmallScreenWidth, | ||
| ), | ||
| swipeEdgeWidth: 500, | ||
| }} | ||
| > | ||
| {_.map(props.screens, screen => ( | ||
| <Drawer.Screen | ||
| key={screen.name} | ||
| name={screen.name} | ||
| component={screen.component} | ||
| initialParams={screen.initialParams} | ||
| /> | ||
| ))} | ||
| </Drawer.Navigator> | ||
| ); | ||
| const BaseDrawerNavigator = (props) => { | ||
| const content = ( | ||
| <Drawer.Navigator | ||
| defaultStatus={props.isSmallScreenWidth ? 'open' : 'closed'} | ||
| sceneContainerStyle={styles.navigationSceneContainer} | ||
| drawerContent={props.drawerContent} | ||
| screenOptions={{ | ||
| cardStyle: styles.navigationScreenCardStyle, | ||
| headerShown: false, | ||
| drawerType: getNavigationDrawerType(props.isSmallScreenWidth), | ||
| drawerStyle: getNavigationDrawerStyle( | ||
| props.isSmallScreenWidth, | ||
| ), | ||
| swipeEdgeWidth: 500, | ||
| }} | ||
| > | ||
| {_.map(props.screens, screen => ( | ||
| <Drawer.Screen | ||
| key={screen.name} | ||
| name={screen.name} | ||
| component={screen.component} | ||
| initialParams={screen.initialParams} | ||
| /> | ||
| ))} | ||
| </Drawer.Navigator> | ||
| ); | ||
|
|
||
| if (!props.isMainScreen && !props.isSmallScreenWidth) { | ||
| return ( | ||
| <View style={styles.navigationSceneFullScreenWrapper}> | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could we change only the styles passed to
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That's what I tried first, and I found that the sceneContainerStyle targets a different UI component. Adding the View wrapper was necessary because it was the only way to wrap the Drawer and the Screen contents and apply the rounded corners to them.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Got it. Does having the extra <View style={props.isSmallScreenWidth ? styles.navigationSceneFullScreenWrapper : undefined}>
... other stuff
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also no worries if there is no way to keep all the JSX together. I think it's just easier to parse without the |
||
| {content} | ||
| </View> | ||
| ); | ||
| } | ||
|
|
||
| return content; | ||
| }; | ||
|
|
||
| BaseDrawerNavigator.propTypes = propTypes; | ||
| BaseDrawerNavigator.displayName = 'BaseDrawerNavigator'; | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -54,6 +54,7 @@ const MainDrawerNavigator = (props) => { | |
| initialParams, | ||
| }, | ||
| ]} | ||
| isMainScreen | ||
| /> | ||
| ); | ||
| }; | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1551,6 +1551,12 @@ const styles = { | |
| height: '100%', | ||
| }, | ||
|
|
||
| navigationSceneFullScreenWrapper: { | ||
|
joelbettner marked this conversation as resolved.
|
||
| borderRadius: variables.componentBorderRadiusCard, | ||
| overflow: 'hidden', | ||
| height: '100%', | ||
| }, | ||
|
|
||
| invisible: { | ||
| position: 'absolute', | ||
| opacity: 0, | ||
|
|
@@ -1855,6 +1861,22 @@ const styles = { | |
| ...whiteSpace.noWrap, | ||
| }, | ||
|
|
||
| cardOverlay: { | ||
| backgroundColor: themeColors.modalBackdrop, | ||
| position: 'absolute', | ||
| top: 0, | ||
| left: 0, | ||
| width: '100%', | ||
| height: '100%', | ||
| opacity: 0.5, | ||
| }, | ||
|
|
||
| communicationsLinkIcon: { | ||
| right: -36, | ||
| top: 0, | ||
| bottom: 0, | ||
| }, | ||
|
|
||
| shortTermsRow: { | ||
| flexDirection: 'row', | ||
| padding: 12, | ||
|
|
@@ -1999,20 +2021,18 @@ function getSafeAreaMargins(insets) { | |
| /** | ||
| * Return navigation menu styles. | ||
| * | ||
| * @param {Number} windowWidth | ||
| * @param {Number} windowHeight | ||
| * @param {Boolean} isSmallScreenWidth | ||
| * @returns {Object} | ||
| */ | ||
| function getNavigationDrawerStyle(windowWidth, windowHeight, isSmallScreenWidth) { | ||
| function getNavigationDrawerStyle(isSmallScreenWidth) { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Out of curiosity, is this change just clean up or were the non relative width/height causing some issue?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yep, the non-relative values were causing issues after I added the spacing around the modal (essentially, the modal wasn't respecting the parent's right and bottom padding), so I ended up making all the sizes relative to fix the issue. An alternative to this was subtracting
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Got it, thanks. I think maybe in this case it would be good to add that context in a comment since a future change could undo that and the reasoning for these values is not very clear.
That does sound more complicated. |
||
| return isSmallScreenWidth | ||
| ? { | ||
| width: windowWidth, | ||
| height: windowHeight, | ||
| width: '100%', | ||
| height: '100%', | ||
| borderColor: themeColors.border, | ||
| } | ||
| : { | ||
| height: windowHeight, | ||
| height: '100%', | ||
| width: variables.sideBarWidth, | ||
| borderRightColor: themeColors.border, | ||
| }; | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since
styles.cardOverlayis being added below and has the following styles:and
styles.fullscreenCardhas the following styles:why do we need to add
...styles.fullscreenCardhere? Won't all these styles be included incardOverlay?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
cardOverlayis for the backdrop of the modal, and thefullscreenCardis for the content that appears on top of the backdrop. These styles are for two different components, hence the need for the two different styles.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was just wondering if the styles would be inherited. In any case, if the
cardOverlaycomponent might be used elsewhere, it makes sense to pass the styles along and not rely on inheritence.