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

fix: offline indicator inside a keyboard avoiding view #30491

Merged
merged 7 commits into from
Oct 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/components/OfflineIndicator.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import PropTypes from 'prop-types';
import React from 'react';
import {View} from 'react-native';
import compose from '@libs/compose';
import stylePropTypes from '@styles/stylePropTypes';
import styles from '@styles/styles';
import * as StyleUtils from '@styles/StyleUtils';
import variables from '@styles/variables';
Expand All @@ -21,6 +22,9 @@ const propTypes = {
// eslint-disable-next-line react/forbid-prop-types
containerStyles: PropTypes.arrayOf(PropTypes.object),

/** Optional styles for the container */
style: stylePropTypes,

/** Is the window width narrow, like on a mobile device */
isSmallScreenWidth: PropTypes.bool.isRequired,

Expand All @@ -29,6 +33,7 @@ const propTypes = {

const defaultProps = {
containerStyles: [],
style: [],
};

const setStyles = (containerStyles, isSmallScreenWidth) => {
Expand Down
2 changes: 1 addition & 1 deletion src/components/ScreenWrapper/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ function ScreenWrapper({
}

// We always need the safe area padding bottom if we're showing the offline indicator since it is bottom-docked.
if (includeSafeAreaPaddingBottom || isOffline) {
if (includeSafeAreaPaddingBottom || (isOffline && shouldShowOfflineIndicator)) {
paddingStyle.paddingBottom = paddingBottom;
}

Expand Down
7 changes: 6 additions & 1 deletion src/pages/NewChatPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,14 @@ import {View} from 'react-native';
import {withOnyx} from 'react-native-onyx';
import _ from 'underscore';
import KeyboardAvoidingView from '@components/KeyboardAvoidingView';
import OfflineIndicator from '@components/OfflineIndicator';
import OptionsSelector from '@components/OptionsSelector';
import ScreenWrapper from '@components/ScreenWrapper';
import withLocalize, {withLocalizePropTypes} from '@components/withLocalize';
import withWindowDimensions, {windowDimensionsPropTypes} from '@components/withWindowDimensions';
import useDelayedInputFocus from '@hooks/useDelayedInputFocus';
import useNetwork from '@hooks/useNetwork';
import useWindowDimensions from '@hooks/useWindowDimensions';
import * as Browser from '@libs/Browser';
import compose from '@libs/compose';
import * as OptionsListUtils from '@libs/OptionsListUtils';
Expand Down Expand Up @@ -58,6 +60,7 @@ function NewChatPage({betas, isGroupChat, personalDetails, reports, translate, i
const [filteredUserToInvite, setFilteredUserToInvite] = useState();
const [selectedOptions, setSelectedOptions] = useState([]);
const {isOffline} = useNetwork();
const {isSmallScreenWidth} = useWindowDimensions();

const maxParticipantsReached = selectedOptions.length === CONST.REPORT.MAXIMUM_PARTICIPANTS;
const headerMessage = OptionsListUtils.getHeaderMessage(
Expand Down Expand Up @@ -218,7 +221,8 @@ function NewChatPage({betas, isGroupChat, personalDetails, reports, translate, i
return (
<ScreenWrapper
shouldEnableKeyboardAvoidingView={false}
includeSafeAreaPaddingBottom={false}
includeSafeAreaPaddingBottom={isOffline}
shouldShowOfflineIndicator={false}
includePaddingTop={false}
shouldEnableMaxHeight
testID={NewChatPage.displayName}
Expand Down Expand Up @@ -258,6 +262,7 @@ function NewChatPage({betas, isGroupChat, personalDetails, reports, translate, i
isLoadingNewOptions={isSearchingForReports}
/>
</View>
{isSmallScreenWidth && <OfflineIndicator />}
</KeyboardAvoidingView>
)}
</ScreenWrapper>
Expand Down
1 change: 1 addition & 0 deletions src/pages/NewChatSelectorPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ function NewChatSelectorPage(props) {
<ScreenWrapper
shouldEnableKeyboardAvoidingView={false}
includeSafeAreaPaddingBottom={false}
shouldShowOfflineIndicator={false}
shouldEnableMaxHeight
testID={NewChatSelectorPage.displayName}
>
Expand Down
9 changes: 8 additions & 1 deletion src/pages/workspace/WorkspaceNewRoomPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import _ from 'underscore';
import FullPageNotFoundView from '@components/BlockingViews/FullPageNotFoundView';
import Form from '@components/Form';
import KeyboardAvoidingView from '@components/KeyboardAvoidingView';
import OfflineIndicator from '@components/OfflineIndicator';
import RoomNameInput from '@components/RoomNameInput';
import ScreenWrapper from '@components/ScreenWrapper';
import Text from '@components/Text';
Expand All @@ -14,6 +15,8 @@ import ValuePicker from '@components/ValuePicker';
import withNavigationFocus from '@components/withNavigationFocus';
import useDelayedInputFocus from '@hooks/useDelayedInputFocus';
import useLocalize from '@hooks/useLocalize';
import useNetwork from '@hooks/useNetwork';
import useWindowDimensions from '@hooks/useWindowDimensions';
import compose from '@libs/compose';
import * as ErrorUtils from '@libs/ErrorUtils';
import Permissions from '@libs/Permissions';
Expand Down Expand Up @@ -73,6 +76,8 @@ const defaultProps = {

function WorkspaceNewRoomPage(props) {
const {translate} = useLocalize();
const {isOffline} = useNetwork();
const {isSmallScreenWidth} = useWindowDimensions();
const [visibility, setVisibility] = useState(CONST.REPORT.VISIBILITY.RESTRICTED);
const [policyID, setPolicyID] = useState(null);
const [writeCapability, setWriteCapability] = useState(CONST.REPORT.WRITE_CAPABILITIES.ALL);
Expand Down Expand Up @@ -170,7 +175,8 @@ function WorkspaceNewRoomPage(props) {
>
<ScreenWrapper
shouldEnableKeyboardAvoidingView={false}
includeSafeAreaPaddingBottom={false}
includeSafeAreaPaddingBottom={isOffline}
shouldShowOfflineIndicator={false}
includePaddingTop={false}
shouldEnablePickerAvoiding={false}
testID={WorkspaceNewRoomPage.displayName}
Expand Down Expand Up @@ -243,6 +249,7 @@ function WorkspaceNewRoomPage(props) {
</View>
<Text style={[styles.textLabel, styles.colorMuted]}>{visibilityDescription}</Text>
</Form>
{isSmallScreenWidth && <OfflineIndicator />}
</KeyboardAvoidingView>
)}
</ScreenWrapper>
Expand Down