MM-16467 Fix iOS layout when playing a youtube video in landscape (#2926)

This commit is contained in:
Elias Nahum 2019-06-26 08:33:04 -04:00 committed by GitHub
parent fdb6cc6b2a
commit bef593c3cf
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 0 deletions

View file

@ -10,10 +10,13 @@ import {
Platform,
StyleSheet,
TouchableOpacity,
StatusBar,
} from 'react-native';
import {YouTubeStandaloneAndroid, YouTubeStandaloneIOS} from 'react-native-youtube';
import {intlShape} from 'react-intl';
import EventEmitter from 'mattermost-redux/utils/event_emitter';
import {TABLET_WIDTH} from 'app/components/sidebars/drawer_layout';
import PostAttachmentImage from 'app/components/post_attachment_image';
import ProgressiveImage from 'app/components/progressive_image';
@ -442,6 +445,7 @@ export default class PostBodyAdditionalContent extends PureComponent {
if (Platform.OS === 'ios') {
YouTubeStandaloneIOS.
playVideo(videoId, startTime).
then(this.playYouTubeVideoEnded).
catch(this.playYouTubeVideoError);
} else {
const {googleDeveloperKey} = this.props;
@ -459,6 +463,13 @@ export default class PostBodyAdditionalContent extends PureComponent {
}
};
playYouTubeVideoEnded = () => {
if (Platform.OS === 'ios') {
StatusBar.setHidden(false);
EventEmitter.emit('update_safe_area_view');
}
};
playYouTubeVideoError = (errorMessage) => {
const {formatMessage} = this.context.intl;

View file

@ -6,6 +6,8 @@ import PropTypes from 'prop-types';
import {Dimensions, Keyboard, NativeModules, View} from 'react-native';
import SafeArea from 'react-native-safe-area';
import EventEmitter from 'mattermost-redux/utils/event_emitter';
import {DeviceTypes} from 'app/constants';
import mattermostManaged from 'app/mattermost_managed';
@ -57,6 +59,7 @@ export default class SafeAreaIos extends PureComponent {
componentDidMount() {
Dimensions.addEventListener('change', this.getSafeAreaInsets);
EventEmitter.on('update_safe_area_view', this.getSafeAreaInsets);
this.keyboardDidShowListener = Keyboard.addListener('keyboardWillShow', this.keyboardWillShow);
this.keyboardDidHideListener = Keyboard.addListener('keyboardWillHide', this.keyboardWillHide);
this.getStatusBarHeight();
@ -65,6 +68,7 @@ export default class SafeAreaIos extends PureComponent {
componentWillUnmount() {
this.mounted = false;
Dimensions.removeEventListener('change', this.getSafeAreaInsets);
EventEmitter.off('update_safe_area_view', this.getSafeAreaInsets);
this.keyboardDidShowListener.remove();
this.keyboardDidHideListener.remove();
this.mounted = false;