Revert "fix: KeyboardAvoidingView height when "Prefer Cross-Fade Transitions" is enabled (#34503)"

This reverts commit ec0049b008.
This commit is contained in:
Lorenzo Sciandra
2022-10-03 13:07:13 +01:00
parent a54ba33305
commit 9fd764388a
@@ -23,7 +23,6 @@ import type {
ViewLayoutEvent,
} from '../View/ViewPropTypes';
import type {KeyboardEvent, KeyboardEventCoordinates} from './Keyboard';
import AccessibilityInfo from '../AccessibilityInfo/AccessibilityInfo';
type Props = $ReadOnly<{|
...ViewProps,
@@ -72,24 +71,12 @@ class KeyboardAvoidingView extends React.Component<Props, State> {
this.viewRef = React.createRef();
}
async _relativeKeyboardHeight(
keyboardFrame: KeyboardEventCoordinates,
): Promise<number> {
_relativeKeyboardHeight(keyboardFrame: KeyboardEventCoordinates): number {
const frame = this._frame;
if (!frame || !keyboardFrame) {
return 0;
}
// On iOS when Prefer Cross-Fade Transitions is enabled, the keyboard position
// & height is reported differently (0 instead of Y position value matching height of frame)
if (
Platform.OS === 'ios' &&
keyboardFrame.screenY === 0 &&
(await AccessibilityInfo.prefersCrossFadeTransitions())
) {
return 0;
}
const keyboardY =
keyboardFrame.screenY - (this.props.keyboardVerticalOffset ?? 0);
@@ -103,7 +90,7 @@ class KeyboardAvoidingView extends React.Component<Props, State> {
this._updateBottomIfNecessary();
};
_onLayout = async (event: ViewLayoutEvent) => {
_onLayout = (event: ViewLayoutEvent) => {
const wasFrameNull = this._frame == null;
this._frame = event.nativeEvent.layout;
if (!this._initialFrameHeight) {
@@ -112,7 +99,7 @@ class KeyboardAvoidingView extends React.Component<Props, State> {
}
if (wasFrameNull) {
await this._updateBottomIfNecessary();
this._updateBottomIfNecessary();
}
if (this.props.onLayout) {
@@ -120,14 +107,14 @@ class KeyboardAvoidingView extends React.Component<Props, State> {
}
};
_updateBottomIfNecessary = async () => {
_updateBottomIfNecessary = () => {
if (this._keyboardEvent == null) {
this.setState({bottom: 0});
return;
}
const {duration, easing, endCoordinates} = this._keyboardEvent;
const height = await this._relativeKeyboardHeight(endCoordinates);
const height = this._relativeKeyboardHeight(endCoordinates);
if (this.state.bottom === height) {
return;