-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Fix for Update Global Offline Indicator #10140
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
Merged
Merged
Changes from 15 commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
3e410ef
undo patch
jasperhuangg 4e2a6dc
merge main
jasperhuangg cc24e69
fix newchatpage white gap on android
jasperhuangg 2fa2b1a
merge main
jasperhuangg 1d4d368
remove unused
jasperhuangg af8e003
undo build.gradle changes
jasperhuangg 1c78fe2
change screenwrapper in ReportScreen to use height keyboardAvoidingVi…
jasperhuangg c292927
add android version of screenwrapper
jasperhuangg e86b23f
merge main and fix prop types
jasperhuangg fec4fbc
remove unused
jasperhuangg 9195a75
remove accidentally committed android emulator fix
jasperhuangg d69570b
remove unused
jasperhuangg c5fef4d
remove unused
jasperhuangg 0caf745
merge main
jasperhuangg 5a1a414
revert podfile
jasperhuangg 2518e21
fix styles with ReportActionCompose
jasperhuangg 4df147c
revert const change and fix desktop styles
jasperhuangg b68efca
style
jasperhuangg e0883bf
fix styling
jasperhuangg 80ba30d
fix linter error
jasperhuangg 41c7054
style
jasperhuangg File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,117 @@ | ||
import {KeyboardAvoidingView, View} from 'react-native'; | ||
import React from 'react'; | ||
import {SafeAreaInsetsContext} from 'react-native-safe-area-context'; | ||
import _ from 'underscore'; | ||
import {withOnyx} from 'react-native-onyx'; | ||
import CONST from '../../CONST'; | ||
import KeyboardShortcut from '../../libs/KeyboardShortcut'; | ||
import Navigation from '../../libs/Navigation/Navigation'; | ||
import onScreenTransitionEnd from '../../libs/onScreenTransitionEnd'; | ||
import * as StyleUtils from '../../styles/StyleUtils'; | ||
import styles from '../../styles/styles'; | ||
import HeaderGap from '../HeaderGap'; | ||
import KeyboardShortcutsModal from '../KeyboardShortcutsModal'; | ||
import OfflineIndicator from '../OfflineIndicator'; | ||
import compose from '../../libs/compose'; | ||
import withNavigation from '../withNavigation'; | ||
import withWindowDimensions from '../withWindowDimensions'; | ||
import ONYXKEYS from '../../ONYXKEYS'; | ||
import {withNetwork} from '../OnyxProvider'; | ||
import {propTypes, defaultProps} from './propTypes'; | ||
|
||
class BaseScreenWrapper extends React.Component { | ||
constructor(props) { | ||
super(props); | ||
|
||
this.state = { | ||
didScreenTransitionEnd: false, | ||
}; | ||
} | ||
|
||
componentDidMount() { | ||
const shortcutConfig = CONST.KEYBOARD_SHORTCUTS.ESCAPE; | ||
this.unsubscribeEscapeKey = KeyboardShortcut.subscribe(shortcutConfig.shortcutKey, () => { | ||
if (this.props.modal.willAlertModalBecomeVisible) { | ||
return; | ||
} | ||
|
||
Navigation.dismissModal(); | ||
}, shortcutConfig.descriptionKey, shortcutConfig.modifiers, true); | ||
|
||
this.unsubscribeTransitionEnd = onScreenTransitionEnd(this.props.navigation, () => { | ||
this.setState({didScreenTransitionEnd: true}); | ||
this.props.onTransitionEnd(); | ||
}); | ||
} | ||
|
||
componentWillUnmount() { | ||
if (this.unsubscribeEscapeKey) { | ||
this.unsubscribeEscapeKey(); | ||
} | ||
if (this.unsubscribeTransitionEnd) { | ||
this.unsubscribeTransitionEnd(); | ||
} | ||
} | ||
|
||
render() { | ||
return ( | ||
<SafeAreaInsetsContext.Consumer> | ||
{(insets) => { | ||
const {paddingTop, paddingBottom} = StyleUtils.getSafeAreaPadding(insets); | ||
const paddingStyle = {}; | ||
|
||
if (this.props.includePaddingTop) { | ||
paddingStyle.paddingTop = paddingTop; | ||
} | ||
|
||
// We always need the safe area padding bottom if we're showing the offline indicator since it is bottom-docked. | ||
if (this.props.includePaddingBottom || this.props.network.isOffline) { | ||
paddingStyle.paddingBottom = paddingBottom; | ||
} | ||
|
||
return ( | ||
<View | ||
style={[ | ||
...this.props.style, | ||
styles.flex1, | ||
paddingStyle, | ||
]} | ||
> | ||
<KeyboardAvoidingView style={[styles.w100, styles.h100]} behavior={this.props.keyboardAvoidingViewBehavior}> | ||
<HeaderGap /> | ||
{// If props.children is a function, call it to provide the insets to the children. | ||
_.isFunction(this.props.children) | ||
? this.props.children({ | ||
insets, | ||
didScreenTransitionEnd: this.state.didScreenTransitionEnd, | ||
}) | ||
: this.props.children | ||
} | ||
<KeyboardShortcutsModal /> | ||
{this.props.isSmallScreenWidth && this.props.network.isOffline && ( | ||
<View style={styles.chatItemComposeSecondaryRow}> | ||
<OfflineIndicator /> | ||
</View> | ||
)} | ||
</KeyboardAvoidingView> | ||
</View> | ||
); | ||
}} | ||
</SafeAreaInsetsContext.Consumer> | ||
); | ||
} | ||
} | ||
|
||
BaseScreenWrapper.propTypes = propTypes; | ||
BaseScreenWrapper.defaultProps = defaultProps; | ||
|
||
export default compose( | ||
withNavigation, | ||
withWindowDimensions, | ||
withOnyx({ | ||
modal: { | ||
key: ONYXKEYS.MODAL, | ||
}, | ||
}), | ||
withNetwork(), | ||
)(BaseScreenWrapper); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import React from 'react'; | ||
import BaseScreenWrapper from './BaseScreenWrapper'; | ||
import {defaultProps, propTypes} from './propTypes'; | ||
|
||
const ScreenWrapper = props => ( | ||
<BaseScreenWrapper | ||
// eslint-disable-next-line react/jsx-props-no-spreading | ||
{...props} | ||
keyboardAvoidingViewBehavior="height" | ||
> | ||
{props.children} | ||
</BaseScreenWrapper> | ||
); | ||
ScreenWrapper.propTypes = propTypes; | ||
ScreenWrapper.defaultProps = defaultProps; | ||
|
||
export default ScreenWrapper; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import React from 'react'; | ||
import BaseScreenWrapper from './BaseScreenWrapper'; | ||
import {defaultProps, propTypes} from './propTypes'; | ||
|
||
const ScreenWrapper = props => ( | ||
<BaseScreenWrapper | ||
// eslint-disable-next-line react/jsx-props-no-spreading | ||
{...props} | ||
> | ||
{props.children} | ||
</BaseScreenWrapper> | ||
); | ||
ScreenWrapper.propTypes = propTypes; | ||
ScreenWrapper.defaultProps = defaultProps; | ||
|
||
export default ScreenWrapper; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import PropTypes from 'prop-types'; | ||
|
||
const propTypes = { | ||
/** Array of additional styles to add */ | ||
style: PropTypes.arrayOf(PropTypes.object), | ||
|
||
/** Returns a function as a child to pass insets to or a node to render without insets */ | ||
children: PropTypes.oneOfType([ | ||
PropTypes.node, | ||
PropTypes.func, | ||
]).isRequired, | ||
|
||
/** Whether to include padding bottom */ | ||
includePaddingBottom: PropTypes.bool, | ||
|
||
/** Whether to include padding top */ | ||
includePaddingTop: PropTypes.bool, | ||
|
||
// Called when navigated Screen's transition is finished. | ||
onTransitionEnd: PropTypes.func, | ||
|
||
/** The behavior to pass to the KeyboardAvoidingView, requires some trial and error depending on the layout/devices used. | ||
* Search 'switch(behavior)' in ./node_modules/react-native/Libraries/Components/Keyboard/KeyboardAvoidingView.js for more context */ | ||
keyboardAvoidingViewBehavior: PropTypes.oneOf(['padding', 'height', 'position']), | ||
|
||
/** Details about any modals being used */ | ||
modal: PropTypes.shape({ | ||
/** Indicates when an Alert modal is about to be visible */ | ||
willAlertModalBecomeVisible: PropTypes.bool, | ||
}), | ||
}; | ||
|
||
const defaultProps = { | ||
style: [], | ||
includePaddingBottom: true, | ||
includePaddingTop: true, | ||
onTransitionEnd: () => {}, | ||
modal: {}, | ||
keyboardAvoidingViewBehavior: 'padding', | ||
}; | ||
|
||
export {propTypes, defaultProps}; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
FYI, this caused the regression in #10905 because the FAB (floating action button) also has a keyboardAvoidingView in it, so this caused the code to have nested keyboardAvoidingViews.