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

Make sure title height is correct with multi line text

This commit is contained in:
Laurent Cozic 2017-07-31 17:56:14 +00:00
parent 4761606330
commit 229fc4ed2e
2 changed files with 29 additions and 5 deletions

View File

@ -90,8 +90,8 @@ android {
applicationId "net.cozic.joplin"
minSdkVersion 16
targetSdkVersion 22
versionCode 36
versionName "0.9.23"
versionCode 37
versionName "0.9.24"
ndk {
abiFilters "armeabi-v7a", "x86"
}

View File

@ -48,6 +48,7 @@ const styleObject = {
};
styleObject.titleContainer = {
flex: 0,
flexDirection: 'row',
paddingLeft: globalStyle.marginLeft,
paddingRight: globalStyle.marginRight,
@ -76,6 +77,7 @@ class NoteScreenComponent extends BaseScreenComponent {
lastSavedNote: null,
isLoading: true,
resources: {},
titleTextInputHeight: 20,
};
this.saveButtonHasBeenShown_ = false;
@ -275,6 +277,11 @@ class NoteScreenComponent extends BaseScreenComponent {
await this.saveOneProperty('todo_completed', checked ? time.unixMs() : 0);
}
titleTextInput_contentSizeChange(event) {
let height = event.nativeEvent.contentSize.height;
this.setState({ titleTextInputHeight: height });
}
render() {
if (this.state.isLoading) {
return (
@ -344,6 +351,25 @@ class NoteScreenComponent extends BaseScreenComponent {
const titleContainerStyle = isTodo ? styles.titleContainerTodo : styles.titleContainer;
const titleTextInputStyle = Object.assign({}, styleObject.titleTextInput);
titleTextInputStyle.height = this.state.titleTextInputHeight;
const titleComp = (
<View style={titleContainerStyle}>
{ isTodo && <Checkbox checked={!!Number(note.todo_completed)} onChange={(checked) => { this.todoCheckbox_change(checked) }} /> }
<TextInput
onContentSizeChange={(event) => this.titleTextInput_contentSizeChange(event)}
autoFocus={isNew}
multiline={true}
underlineColorAndroid="#ffffff00"
autoCapitalize="sentences"
style={titleTextInputStyle}
value={note.title}
onChangeText={(text) => this.title_changeText(text)}
/>
</View>
);
return (
<View style={this.styles().screen}>
<ScreenHeader
@ -377,9 +403,7 @@ class NoteScreenComponent extends BaseScreenComponent {
saveButtonDisabled={saveButtonDisabled}
onSaveButtonPress={() => this.saveNoteButton_press()}
/>
<View style={titleContainerStyle}>
{ isTodo && <Checkbox checked={!!Number(note.todo_completed)} onChange={(checked) => { this.todoCheckbox_change(checked) }} /> }<TextInput autoFocus={isNew} underlineColorAndroid="#ffffff00" autoCapitalize="sentences" style={styles.titleTextInput} value={note.title} onChangeText={(text) => this.title_changeText(text)} />
</View>
{ titleComp }
{ bodyComponent }
{ actionButtonComp }
{ this.state.showNoteMetadata && <Text style={{ paddingLeft: globalStyle.marginLeft, paddingRight: globalStyle.marginRight, }}>{this.state.noteMetadata}</Text> }