diff --git a/client/react-native/common/components/App.js b/client/react-native/common/components/App.js index 93211b024d..777e525461 100644 --- a/client/react-native/common/components/App.js +++ b/client/react-native/common/components/App.js @@ -17,6 +17,7 @@ import { AppNavigator } from './Navigator/AppNavigator' import { RelayContext } from '../relay' import { UpdateContext } from '../update' import * as KeyboardContext from '../helpers/KeyboardContext' +import Mousetrap from 'mousetrap' const { CoreModule } = NativeModules @@ -160,6 +161,15 @@ export default class App extends PureComponent { }) .catch(() => {}) + if (Platform.OS === 'web') { + if (this._showQuickSwitch === undefined) { + this._showQuickSwitch = () => this.showQuickSwitch() + } + + Mousetrap.prototype.stopCallback = () => {} + Mousetrap.bind(['command+k', 'ctrl+k', 'command+t', 'ctrl+t'], this._showQuickSwitch) + } + this.setState({ loading: false }) } @@ -169,6 +179,15 @@ export default class App extends PureComponent { if (this._handleOpenURL !== undefined) { Linking.removeEventListener('url', this._handleOpenURL) } + + if (Platform.OS === 'web') { + Mousetrap.unbind(['command+k', 'ctrl+k'], this._showQuickSwitch) + } + } + + showQuickSwitch () { + NavigationService.navigate('modal/chats/switcher') + return false } _onLanguageChange = ({ language } = {}) => { diff --git a/client/react-native/common/components/Library/ModalScreen.js b/client/react-native/common/components/Library/ModalScreen.js index 4d85aa3af1..28f58996a0 100644 --- a/client/react-native/common/components/Library/ModalScreen.js +++ b/client/react-native/common/components/Library/ModalScreen.js @@ -1,102 +1,127 @@ import { StackActions, withNavigation } from 'react-navigation' -import { View } from 'react-native' +import { + View, + Platform, + TouchableOpacity, +} from 'react-native' import React from 'react' import Loader from './Loader' import Button from './Button' import colors from '../../constants/colors' -const ModalScreen = props => { - const { - children, - navigation, - loading, - showDismiss, - width, - footer, - ...otherProps - } = props +class ModalScreen extends React.PureComponent { + componentDidMount () { + if (Platform.OS === 'web') { + if (this._keyboardListener === undefined) { + this._keyboardListener = (e) => this.keyboardListener(e) + } + window.addEventListener('keyup', this._keyboardListener) + } + } - const beforeDismiss = navigation.getParam('beforeDismiss') + componentWillUnmount () { + window.removeEventListener('keyup', this._keyboardListener) + } - return ( - <> - { + const { + children, + loading, + showDismiss, + width, + footer, + ...otherProps + } = this.props + + return ( + <> + - - - {!loading ? ( - + }} onPress={() => (this.props.showDismiss || this.props.keyboardDismiss) && this.dismiss()}> + + {!loading ? ( + - {showDismiss ? ( + + {showDismiss ? ( + +