You've already forked joplin
mirror of
https://github.com/laurent22/joplin.git
synced 2025-08-13 22:12:50 +02:00
Fixed list scroll position
This commit is contained in:
@@ -33,6 +33,7 @@ class NoteListComponent extends Component {
|
|||||||
items: [],
|
items: [],
|
||||||
selectedItemIds: [],
|
selectedItemIds: [],
|
||||||
};
|
};
|
||||||
|
this.rootRef_ = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
filterNotes(notes) {
|
filterNotes(notes) {
|
||||||
@@ -65,6 +66,11 @@ class NoteListComponent extends Component {
|
|||||||
this.setState({
|
this.setState({
|
||||||
dataSource: this.state.dataSource.cloneWithRows(this.filterNotes(newProps.items)),
|
dataSource: this.state.dataSource.cloneWithRows(this.filterNotes(newProps.items)),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Make sure scroll position is reset when switching from one folder to another or to a tag list.
|
||||||
|
if (this.rootRef_ && newProps.notesSource != this.props.notesSource) {
|
||||||
|
this.rootRef_.scrollTo({ x: 0, y: 0, animated: false });
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
@@ -73,6 +79,7 @@ class NoteListComponent extends Component {
|
|||||||
if (this.state.dataSource.getRowCount()) {
|
if (this.state.dataSource.getRowCount()) {
|
||||||
return (
|
return (
|
||||||
<ListView
|
<ListView
|
||||||
|
ref={(ref) => this.rootRef_ = ref}
|
||||||
dataSource={this.state.dataSource}
|
dataSource={this.state.dataSource}
|
||||||
renderRow={(note) => {
|
renderRow={(note) => {
|
||||||
return <NoteItem note={note}/>
|
return <NoteItem note={note}/>
|
||||||
@@ -89,7 +96,10 @@ class NoteListComponent extends Component {
|
|||||||
|
|
||||||
const NoteList = connect(
|
const NoteList = connect(
|
||||||
(state) => {
|
(state) => {
|
||||||
return { items: state.notes };
|
return {
|
||||||
|
items: state.notes,
|
||||||
|
notesSource: state.notesSource,
|
||||||
|
};
|
||||||
}
|
}
|
||||||
)(NoteListComponent)
|
)(NoteListComponent)
|
||||||
|
|
||||||
|
@@ -181,11 +181,13 @@ class ScreenHeaderComponent extends Component {
|
|||||||
function saveButton(styles, onPress, disabled, show) {
|
function saveButton(styles, onPress, disabled, show) {
|
||||||
if (!show) return null;
|
if (!show) return null;
|
||||||
|
|
||||||
|
const title = disabled ? _('Saved') : _('Save');
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<TouchableOpacity onPress={onPress} disabled={disabled}>
|
<TouchableOpacity onPress={onPress} disabled={disabled}>
|
||||||
<View style={disabled ? styles.saveButtonDisabled : styles.saveButton}>
|
<View style={disabled ? styles.saveButtonDisabled : styles.saveButton}>
|
||||||
{ disabled && <Icon name='md-checkmark' style={styles.saveButtonIcon} /> }
|
{ disabled && <Icon name='md-checkmark' style={styles.saveButtonIcon} /> }
|
||||||
<Text style={styles.saveButtonText}>Save</Text>
|
<Text style={styles.saveButtonText}>{title}</Text>
|
||||||
</View>
|
</View>
|
||||||
</TouchableOpacity>
|
</TouchableOpacity>
|
||||||
);
|
);
|
||||||
|
Reference in New Issue
Block a user