1
0
mirror of https://github.com/laurent22/joplin.git synced 2024-12-24 10:27:10 +02:00

Merge pull request #111 from marcosvega91/fix_scroll_note_keyboard

Fix scroll note keyboard on IOS
This commit is contained in:
Laurent Cozic 2018-01-08 16:45:58 +00:00 committed by GitHub
commit b99146ed7f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,5 +1,5 @@
const React = require('react'); const Component = React.Component;
const { Platform, Keyboard, BackHandler, View, Button, TextInput, WebView, Text, StyleSheet, Linking, Image } = require('react-native');
const { Platform, Keyboard, BackHandler, View, Button, TextInput, WebView, Text, StyleSheet, Linking, Image,KeyboardAvoidingView } = require('react-native');
const { connect } = require('react-redux');
const { uuid } = require('lib/uuid.js');
const { Log } = require('lib/log.js');
@ -51,6 +51,7 @@ class NoteScreenComponent extends BaseScreenComponent {
isLoading: true,
titleTextInputHeight: 20,
alarmDialogShown: false,
heightBumpView:0
};
// iOS doesn't support multiline text fields properly so disable it
@ -148,6 +149,11 @@ class NoteScreenComponent extends BaseScreenComponent {
await shared.initState(this);
this.refreshNoteMetadata();
if(Platform.OS === 'ios'){
this.keyboardDidShowListener = Keyboard.addListener('keyboardDidShow', this._keyboardDidShow.bind(this));
this.keyboardDidHideListener = Keyboard.addListener('keyboardDidHide', this._keyboardDidHide.bind(this));
}
}
refreshNoteMetadata(force = null) {
@ -156,6 +162,23 @@ class NoteScreenComponent extends BaseScreenComponent {
componentWillUnmount() {
BackButtonService.removeHandler(this.backHandler);
if(Platform.OS === 'ios'){
this.keyboardDidShowListener.remove();
this.keyboardDidHideListener.remove();
}
}
_keyboardDidShow () {
this.setState({
heightBumpView:30
})
}
_keyboardDidHide () {
this.setState({
heightBumpView:0
})
}
title_changeText(text) {
@ -522,7 +545,7 @@ class NoteScreenComponent extends BaseScreenComponent {
);
return (
<View style={this.rootStyle(this.props.theme).root}>
<KeyboardAvoidingView behavior= {(Platform.OS === 'ios')? "padding" : null} style={this.rootStyle(this.props.theme).root}>
<ScreenHeader
folderPickerOptions={{
enabled: true,
@ -558,7 +581,8 @@ class NoteScreenComponent extends BaseScreenComponent {
/>
<DialogBox ref={dialogbox => { this.dialogbox = dialogbox }}/>
</View>
<View style={{ height: this.state.heightBumpView }} />
</KeyboardAvoidingView>
);
}