diff --git a/app/components/post_draft/__snapshots__/post_draft.test.js.snap b/app/components/post_draft/__snapshots__/post_draft.test.js.snap index ec56930b5..211869f0a 100644 --- a/app/components/post_draft/__snapshots__/post_draft.test.js.snap +++ b/app/components/post_draft/__snapshots__/post_draft.test.js.snap @@ -304,6 +304,8 @@ exports[`PostDraft Should render the DraftInput 1`] = ` onEndEditing={[Function]} onFocus={[Function]} onPaste={[Function]} + onPressIn={[Function]} + onPressOut={[Function]} onResponderGrant={[Function]} onResponderMove={[Function]} onResponderRelease={[Function]} diff --git a/app/components/post_draft/post_input/__snapshots__/post_input.test.js.snap b/app/components/post_draft/post_input/__snapshots__/post_input.test.js.snap index 8db89e74e..95a9b5955 100644 --- a/app/components/post_draft/post_input/__snapshots__/post_input.test.js.snap +++ b/app/components/post_draft/post_input/__snapshots__/post_input.test.js.snap @@ -13,6 +13,8 @@ exports[`PostInput should match, full snapshot 1`] = ` onChangeText={[Function]} onEndEditing={[Function]} onPaste={[Function]} + onPressIn={[Function]} + onPressOut={[Function]} onSelectionChange={[Function]} placeholder="Write to Test Channel" placeholderTextColor="rgba(63,67,80,0.5)" diff --git a/app/components/post_draft/post_input/post_input.js b/app/components/post_draft/post_input/post_input.js index 841ada04e..b1df1dbb7 100644 --- a/app/components/post_draft/post_input/post_input.js +++ b/app/components/post_draft/post_input/post_input.js @@ -4,7 +4,7 @@ import PropTypes from 'prop-types'; import React, {PureComponent} from 'react'; import {intlShape} from 'react-intl'; -import {Alert, AppState, findNodeHandle, Keyboard, NativeModules, Platform} from 'react-native'; +import {Alert, AppState, DeviceEventEmitter, findNodeHandle, Keyboard, NativeModules, Platform} from 'react-native'; import {NavigationTypes} from '@constants'; import DEVICE from '@constants/device'; @@ -285,6 +285,18 @@ export default class PostInput extends PureComponent { } } + onPressIn = () => { + if (Platform.OS === 'ios') { + DeviceEventEmitter.emit(NavigationTypes.DRAWER, 'locked-closed'); + } + }; + + onPressOut = () => { + if (Platform.OS === 'ios') { + DeviceEventEmitter.emit(NavigationTypes.DRAWER, 'unlocked'); + } + }; + render() { const {formatMessage} = this.context.intl; const {testID, channelDisplayName, screenId, isLandscape, theme} = this.props; @@ -318,6 +330,8 @@ export default class PostInput extends PureComponent { autoCompleteType='off' keyboardAppearance={getKeyboardAppearanceFromTheme(theme)} screenId={screenId} + onPressIn={this.onPressIn} + onPressOut={this.onPressOut} /> ); } diff --git a/app/components/sidebars/drawer_layout/index.tsx b/app/components/sidebars/drawer_layout/index.tsx index 3004b546d..ab8abe0a0 100644 --- a/app/components/sidebars/drawer_layout/index.tsx +++ b/app/components/sidebars/drawer_layout/index.tsx @@ -1,9 +1,12 @@ // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. // See LICENSE.txt for license information. -import React from 'react'; +import React, {useEffect, useState} from 'react'; +import {DeviceEventEmitter, EventSubscription, Platform} from 'react-native'; import {useSafeAreaInsets} from 'react-native-safe-area-context'; +import NavigationTypes from '@constants/navigation'; + import DrawerLayout from './drawer_layout'; export const DRAWER_INITIAL_OFFSET = 40; @@ -30,11 +33,23 @@ interface DrawerLayoutAdapterProps { const DrawerLayoutAdapter = (props: DrawerLayoutAdapterProps) => { const insets = useSafeAreaInsets(); const horizontal = insets.left + insets.right; + const [drawerLockMode, setDrawerLockMode] = useState(props.drawerLockMode || 'unlocked'); + + useEffect(() => { + let listener: EventSubscription | undefined; + if (Platform.OS === 'ios') { + listener = DeviceEventEmitter.addListener(NavigationTypes.DRAWER, (value) => { + setDrawerLockMode(value); + }); + } + + return () => listener?.remove(); + }); return (