Skip to content

Use native KeyboardAvoidingView component everywhere #11586

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 25 commits into from
Oct 28, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
8d7a65e
Remove our custom keyboard avoiding view
tgolen Sep 28, 2022
4e3b445
Rename the FAB component so I know what it is
tgolen Sep 29, 2022
a075139
Increase the max keys count
tgolen Sep 29, 2022
9cb2e89
Fix component's display name
tgolen Sep 29, 2022
fe96e1e
Consolidate floating action button into a single component with a key…
tgolen Sep 29, 2022
d4a832d
Remove unused component
tgolen Sep 29, 2022
e470677
Change default behavior for padding or else the floatingActionButton …
tgolen Sep 29, 2022
709758a
Make the login keyboard avoiding view more clean
tgolen Sep 29, 2022
73608be
Remove unused import
tgolen Sep 29, 2022
7a13d7f
Use the proper HOC for including insets
tgolen Sep 30, 2022
a93a104
Fix some whitespace
tgolen Sep 30, 2022
1232c66
Dont' forget to display the children! THINK OF THE CHILDREN!!!!
tgolen Sep 30, 2022
9b19892
Merge branch 'main' into tgolen-animatedkeyboard
tgolen Oct 4, 2022
1052f4f
Merge branch 'main' into tgolen-animatedkeyboard
tgolen Oct 12, 2022
4285663
Stop sending empty string as keyboard avoiding behavior to fix propTy…
tgolen Oct 12, 2022
c856e8e
Remove unused import
tgolen Oct 13, 2022
d73d240
Remove our weird keyboard thing on the login page
tgolen Oct 13, 2022
a0a1ead
Cleanup an unnecessary variable
tgolen Oct 13, 2022
5cdbed9
Put back the safe area insets
tgolen Oct 13, 2022
99682bc
Merge branch 'main' into tgolen-animatedkeyboard
tgolen Oct 14, 2022
731bc69
Remove extra line break
tgolen Oct 14, 2022
fd15d80
Clean up components for sign in page graphics
tgolen Oct 14, 2022
9a9310e
Fix styles on login page
tgolen Oct 14, 2022
fb62d8c
Apply wrapper styles to variable instead of single component
tgolen Oct 18, 2022
0f3f363
Merge branch 'main' into tgolen-animatedkeyboard
tgolen Oct 23, 2022
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
11 changes: 0 additions & 11 deletions src/components/FAB/fabPropTypes.js

This file was deleted.

18 changes: 0 additions & 18 deletions src/components/FAB/index.ios.js

This file was deleted.

3 changes: 0 additions & 3 deletions src/components/FAB/index.js

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,23 +1,33 @@
import React, {PureComponent} from 'react';
import {
Pressable, Animated, Easing,
Pressable, Animated, Easing, KeyboardAvoidingView,
} from 'react-native';
import Icon from '../Icon';
import * as Expensicons from '../Icon/Expensicons';
import styles from '../../styles/styles';
import * as StyleUtils from '../../styles/StyleUtils';
import themeColors from '../../styles/themes/default';
import fabPropTypes from './fabPropTypes';
import Tooltip from '../Tooltip';
import withLocalize from '../withLocalize';
import PropTypes from 'prop-types';
import Icon from './Icon';
import * as Expensicons from './Icon/Expensicons';
import styles from '../styles/styles';
import * as StyleUtils from '../styles/StyleUtils';
import themeColors from '../styles/themes/default';
import Tooltip from './Tooltip';
import withLocalize, {withLocalizePropTypes} from './withLocalize';

const AnimatedIcon = Animated.createAnimatedComponent(Icon);
AnimatedIcon.displayName = 'AnimatedIcon';

const AnimatedPressable = Animated.createAnimatedComponent(Pressable);
AnimatedPressable.displayName = 'AnimatedPressable';

class FAB extends PureComponent {
const propTypes = {
// Callback to fire on request to toggle the FloatingActionButton
onPress: PropTypes.func.isRequired,

// Current state (active or not active) of the component
isActive: PropTypes.bool.isRequired,

...withLocalizePropTypes,
};

class FloatingActionButton extends PureComponent {
constructor(props) {
super(props);
this.animatedValue = new Animated.Value(props.isActive ? 1 : 0);
Expand Down Expand Up @@ -63,22 +73,25 @@ class FAB extends PureComponent {
});

return (
<Tooltip absolute text={this.props.translate('common.new')}>
<AnimatedPressable
accessibilityLabel={this.props.accessibilityLabel}
accessibilityRole={this.props.accessibilityRole}
onPress={this.props.onPress}
style={[
styles.floatingActionButton,
StyleUtils.getAnimatedFABStyle(rotate, backgroundColor),
]}
>
<AnimatedIcon src={Expensicons.Plus} fill={fill} />
</AnimatedPressable>
</Tooltip>
<KeyboardAvoidingView behavior="padding">
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was a mistake to add because it created duplicate keyboard avoiding views. This was caught in the issue here: #10905

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The other one is in BaseScreenWrapper

<Tooltip absolute text={this.props.translate('common.new')}>
<AnimatedPressable
accessibilityLabel={this.props.accessibilityLabel}
accessibilityRole={this.props.accessibilityRole}
onPress={this.props.onPress}
style={[
styles.floatingActionButton,
StyleUtils.getAnimatedFABStyle(rotate, backgroundColor),
]}
>
<AnimatedIcon src={Expensicons.Plus} fill={fill} />
</AnimatedPressable>
</Tooltip>
</KeyboardAvoidingView>
);
}
}

FAB.propTypes = fabPropTypes;
export default withLocalize(FAB);
FloatingActionButton.propTypes = propTypes;

export default withLocalize(FloatingActionButton);
28 changes: 0 additions & 28 deletions src/components/KeyboardAvoidingView/index.ios.js

This file was deleted.

18 changes: 0 additions & 18 deletions src/components/KeyboardAvoidingView/index.js

This file was deleted.

3 changes: 1 addition & 2 deletions src/components/PDFView/index.native.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import React, {Component} from 'react';
import {TouchableWithoutFeedback, View} from 'react-native';
import {TouchableWithoutFeedback, View, KeyboardAvoidingView} from 'react-native';
import PDF from 'react-native-pdf';
import styles from '../../styles/styles';
import * as StyleUtils from '../../styles/StyleUtils';
import FullScreenLoadingIndicator from '../FullscreenLoadingIndicator';
import KeyboardAvoidingView from '../KeyboardAvoidingView';
import PDFPasswordForm from './PDFPasswordForm';
import * as pdfViewPropTypes from './pdfViewPropTypes';
import compose from '../../libs/compose';
Expand Down
5 changes: 2 additions & 3 deletions src/pages/home/ReportScreen.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react';
import {withOnyx} from 'react-native-onyx';
import PropTypes from 'prop-types';
import {Platform, View} from 'react-native';
import {View} from 'react-native';
import lodashGet from 'lodash/get';
import _ from 'underscore';
import {Freeze} from 'react-freeze';
Expand Down Expand Up @@ -216,7 +216,7 @@ class ReportScreen extends React.Component {
const reportID = getReportID(this.props.route);
const addWorkspaceRoomOrChatPendingAction = lodashGet(this.props.report, 'pendingFields.addWorkspaceRoom') || lodashGet(this.props.report, 'pendingFields.createChat');
const addWorkspaceRoomOrChatErrors = lodashGet(this.props.report, 'errorFields.addWorkspaceRoom') || lodashGet(this.props.report, 'errorFields.createChat');
const screenWrapperStyle = [styles.appContent, {marginTop: this.state.viewportOffsetTop}];
const screenWrapperStyle = [styles.appContent, styles.flex1, {marginTop: this.state.viewportOffsetTop}];
return (
<Freeze
freeze={this.props.isSmallScreenWidth && this.props.isDrawerOpen}
Expand All @@ -231,7 +231,6 @@ class ReportScreen extends React.Component {
>
<ScreenWrapper
style={screenWrapperStyle}
keyboardAvoidingViewBehavior={Platform.OS === 'android' ? '' : 'padding'}
>
<FullPageNotFoundView
shouldShow={!this.props.report.reportID}
Expand Down
4 changes: 2 additions & 2 deletions src/pages/home/sidebar/SidebarScreen/BaseSidebarScreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import PropTypes from 'prop-types';
import styles from '../../../../styles/styles';
import SidebarLinks from '../SidebarLinks';
import PopoverMenu from '../../../../components/PopoverMenu';
import FAB from '../../../../components/FAB';
import FloatingActionButton from '../../../../components/FloatingActionButton';
import ScreenWrapper from '../../../../components/ScreenWrapper';
import Navigation from '../../../../libs/Navigation/Navigation';
import ROUTES from '../../../../ROUTES';
Expand Down Expand Up @@ -117,7 +117,7 @@ class BaseSidebarScreen extends Component {
isDrawerOpen={this.props.isDrawerOpen}
reportIDFromRoute={this.props.reportIDFromRoute}
/>
<FAB
<FloatingActionButton
accessibilityLabel={this.props.translate('sidebarScreen.fabNewChat')}
accessibilityRole="button"
isActive={this.state.isCreateMenuActive}
Expand Down
13 changes: 7 additions & 6 deletions src/pages/settings/AddSecondaryLoginPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,13 +90,14 @@ class AddSecondaryLoginPage extends Component {

render() {
return (
<ScreenWrapper onTransitionEnd={() => {
if (!this.phoneNumberInputRef) {
return;
}
<ScreenWrapper
onTransitionEnd={() => {
if (!this.phoneNumberInputRef) {
return;
}

this.phoneNumberInputRef.focus();
}}
this.phoneNumberInputRef.focus();
}}
>
<HeaderWithCloseButton
title={this.props.translate(this.formType === CONST.LOGIN_TYPE.PHONE
Expand Down

This file was deleted.

This file was deleted.

11 changes: 5 additions & 6 deletions src/pages/signin/SignInPageLayout/SignInPageContent.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import React from 'react';
import {ScrollView, View} from 'react-native';
import {ScrollView, View, KeyboardAvoidingView} from 'react-native';
import PropTypes from 'prop-types';
import {withSafeAreaInsets} from 'react-native-safe-area-context';
import styles from '../../../styles/styles';
import * as StyleUtils from '../../../styles/StyleUtils';
import variables from '../../../styles/variables';
import ExpensifyCashLogo from '../../../components/ExpensifyCashLogo';
import Text from '../../../components/Text';
Expand All @@ -12,9 +11,9 @@ import withLocalize, {withLocalizePropTypes} from '../../../components/withLocal
import SignInPageForm from '../../../components/SignInPageForm';
import compose from '../../../libs/compose';
import scrollViewContentContainerStyles from './signInPageStyles';
import LoginKeyboardAvoidingView from './LoginKeyboardAvoidingView';
import withKeyboardState from '../../../components/withKeyboardState';
import withWindowDimensions, {windowDimensionsPropTypes} from '../../../components/withWindowDimensions';
import * as StyleUtils from '../../../styles/StyleUtils';

const propTypes = {
/** The children to show inside the layout */
Expand Down Expand Up @@ -58,9 +57,9 @@ const SignInPageContent = props => (
props.isSmallScreenWidth ? styles.ph5 : styles.ph4,
]}
>
<LoginKeyboardAvoidingView
<KeyboardAvoidingView
behavior="position"
contentContainerStyle={[
style={[
props.isSmallScreenWidth ? styles.signInPageNarrowContentMargin : {},
!props.isMediumScreenWidth || (props.isMediumScreenWidth && props.windowHeight < variables.minHeightToShowGraphics) ? styles.signInPageWideLeftContentMargin : {},
styles.mb3,
Expand All @@ -87,7 +86,7 @@ const SignInPageContent = props => (
</Text>
)}
{props.children}
</LoginKeyboardAvoidingView>
</KeyboardAvoidingView>
</SignInPageForm>
<View style={[styles.mb5, styles.alignSelfCenter, styles.ph5]}>
<TermsAndLicenses />
Expand Down
33 changes: 33 additions & 0 deletions src/pages/signin/SignInPageLayout/SignInPageGraphics.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import {Pressable} from 'react-native';
import React from 'react';
import _ from 'underscore';
import styles from '../../../styles/styles';
import * as StyleUtils from '../../../styles/StyleUtils';
import * as Link from '../../../libs/actions/Link';
import SVGImage from '../../../components/SVGImage';

const backgroundStyle = StyleUtils.getLoginPagePromoStyle();

const SignInPageGraphics = () => (
<Pressable
style={[
styles.flex1,
StyleUtils.getBackgroundColorStyle(backgroundStyle.backgroundColor),
]}
onPress={() => {
Link.openExternalLink(backgroundStyle.redirectUri);
}}
disabled={_.isEmpty(backgroundStyle.redirectUri)}
>
<SVGImage
width="100%"
height="100%"
src={backgroundStyle.backgroundImageUri}
resizeMode="contain"
/>
</Pressable>
);

SignInPageGraphics.displayName = 'SignInPageGraphics';

export default SignInPageGraphics;
Loading