[FIX] UIKit Modal: Weird behavior on Android Tablet (#1742)
This commit is contained in:
parent
85dfe1b970
commit
777cb28a6f
29
app/index.js
29
app/index.js
|
@ -1,5 +1,7 @@
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { View, Linking, BackHandler } from 'react-native';
|
import {
|
||||||
|
View, Linking, BackHandler, ScrollView
|
||||||
|
} from 'react-native';
|
||||||
import { createAppContainer, createSwitchNavigator } from 'react-navigation';
|
import { createAppContainer, createSwitchNavigator } from 'react-navigation';
|
||||||
import { createStackNavigator } from 'react-navigation-stack';
|
import { createStackNavigator } from 'react-navigation-stack';
|
||||||
import { createDrawerNavigator } from 'react-navigation-drawer';
|
import { createDrawerNavigator } from 'react-navigation-drawer';
|
||||||
|
@ -34,7 +36,7 @@ import { ThemeContext } from './theme';
|
||||||
import RocketChat, { THEME_PREFERENCES_KEY } from './lib/rocketchat';
|
import RocketChat, { THEME_PREFERENCES_KEY } from './lib/rocketchat';
|
||||||
import { MIN_WIDTH_SPLIT_LAYOUT } from './constants/tablet';
|
import { MIN_WIDTH_SPLIT_LAYOUT } from './constants/tablet';
|
||||||
import {
|
import {
|
||||||
isTablet, isSplited, isIOS, setWidth, supportSystemTheme
|
isTablet, isSplited, isIOS, setWidth, supportSystemTheme, isAndroid
|
||||||
} from './utils/deviceInfo';
|
} from './utils/deviceInfo';
|
||||||
import { KEY_COMMAND } from './commands';
|
import { KEY_COMMAND } from './commands';
|
||||||
import Tablet, { initTabletNav } from './tablet';
|
import Tablet, { initTabletNav } from './tablet';
|
||||||
|
@ -479,6 +481,24 @@ class CustomModalStack extends React.Component {
|
||||||
const pageSheetViews = ['AttachmentView'];
|
const pageSheetViews = ['AttachmentView'];
|
||||||
const pageSheet = pageSheetViews.includes(getActiveRouteName(navigation.state));
|
const pageSheet = pageSheetViews.includes(getActiveRouteName(navigation.state));
|
||||||
|
|
||||||
|
const androidProps = isAndroid && {
|
||||||
|
style: { marginBottom: 0 }
|
||||||
|
};
|
||||||
|
|
||||||
|
let content = (
|
||||||
|
<View style={[sharedStyles.modal, pageSheet ? sharedStyles.modalPageSheet : sharedStyles.modalFormSheet]}>
|
||||||
|
<ModalSwitch navigation={navigation} screenProps={{ ...screenProps, closeModal: this.closeModal }} />
|
||||||
|
</View>
|
||||||
|
);
|
||||||
|
|
||||||
|
if (isAndroid) {
|
||||||
|
content = (
|
||||||
|
<ScrollView overScrollMode='never'>
|
||||||
|
{content}
|
||||||
|
</ScrollView>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Modal
|
<Modal
|
||||||
useNativeDriver
|
useNativeDriver
|
||||||
|
@ -487,10 +507,9 @@ class CustomModalStack extends React.Component {
|
||||||
onBackdropPress={closeModal}
|
onBackdropPress={closeModal}
|
||||||
hideModalContentWhileAnimating
|
hideModalContentWhileAnimating
|
||||||
avoidKeyboard
|
avoidKeyboard
|
||||||
|
{...androidProps}
|
||||||
>
|
>
|
||||||
<View style={[sharedStyles.modal, pageSheet ? sharedStyles.modalPageSheet : sharedStyles.modalFormSheet]}>
|
{content}
|
||||||
<ModalSwitch navigation={navigation} screenProps={{ ...screenProps, closeModal: this.closeModal }} />
|
|
||||||
</View>
|
|
||||||
</Modal>
|
</Modal>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -118,6 +118,17 @@ class ModalBlockView extends React.Component {
|
||||||
EventEmitter.addEventListener(viewId, this.handleUpdate);
|
EventEmitter.addEventListener(viewId, this.handleUpdate);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
shouldComponentUpdate(nextProps, nextState) {
|
||||||
|
if (!isEqual(nextProps, this.props)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (!isEqual(nextState, this.state)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
componentDidUpdate(prevProps) {
|
componentDidUpdate(prevProps) {
|
||||||
const { navigation } = this.props;
|
const { navigation } = this.props;
|
||||||
const oldData = prevProps.navigation.getParam('data', {});
|
const oldData = prevProps.navigation.getParam('data', {});
|
||||||
|
|
Loading…
Reference in New Issue