mirror of
https://github.com/timepill/timepill-app.git
synced 2025-04-30 09:59:31 +08:00
修复bug:
1. 点击底栏‘首页’和‘关注’时,若列表已置顶,则刷新列表 2. 日记编辑页的编辑框默认选中态
This commit is contained in:
parent
4cf622c40d
commit
654fc227d1
3 changed files with 47 additions and 14 deletions
|
@ -53,6 +53,15 @@ export default class DiaryList extends Component {
|
|||
}
|
||||
|
||||
scrollToTop() {
|
||||
if(!this.scrollY) {
|
||||
this.scrollY = 0;
|
||||
}
|
||||
|
||||
if(this.scrollY <= 10) {
|
||||
this.refresh();
|
||||
return;
|
||||
}
|
||||
|
||||
this.list.scrollToOffset({
|
||||
offset: 0
|
||||
});
|
||||
|
@ -263,6 +272,10 @@ export default class DiaryList extends Component {
|
|||
|
||||
onEndReachedThreshold={2}
|
||||
onEndReached={this.state.hasMore ? this.loadMore.bind(this) : null}
|
||||
|
||||
onScroll={(event) => {
|
||||
this.scrollY = event.nativeEvent.contentOffset.y;
|
||||
}}
|
||||
>
|
||||
</FlatList>
|
||||
|
||||
|
|
|
@ -52,10 +52,20 @@ export default class FollowPage extends Component {
|
|||
});
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
this.bottomTabEventListener = Navigation.events().registerBottomTabSelectedListener(
|
||||
({ selectedTabIndex, unselectedTabIndex }) => {
|
||||
if(selectedTabIndex == unselectedTabIndex && selectedTabIndex == 1) {
|
||||
this.diaryList.scrollToTop();
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
render() {
|
||||
return (
|
||||
<View style={localStyle.wrap}>
|
||||
<DiaryList ref={(r) => this.list = r}
|
||||
<DiaryList ref={(r) => this.diaryList = r}
|
||||
dataSource={this.dataSource}
|
||||
{...this.props}
|
||||
|
||||
|
|
|
@ -100,6 +100,7 @@ export default class WritePage extends Component {
|
|||
|
||||
componentDidMount() {
|
||||
this.loadNotebook();
|
||||
this.contentInput.focus();
|
||||
|
||||
this.notebookListener = DeviceEventEmitter.addListener(Event.updateNotebooks, (param) => {
|
||||
this.loadNotebook(true);
|
||||
|
@ -111,6 +112,7 @@ export default class WritePage extends Component {
|
|||
}
|
||||
|
||||
openModal() {
|
||||
this.contentInput.blur();
|
||||
this.setState({modalVisible: true});
|
||||
|
||||
if(this.state.notebooks.length == 0) {
|
||||
|
@ -120,15 +122,14 @@ export default class WritePage extends Component {
|
|||
}
|
||||
}
|
||||
|
||||
closeModal(showKeyboard = true) {
|
||||
this.contentInput.blur();
|
||||
closeModal(showKeyboard = true, callback) {
|
||||
Animated.parallel([
|
||||
Animated.timing(
|
||||
this.state.fadeAnimOpacity,
|
||||
{
|
||||
toValue: 0,
|
||||
duration: 350,
|
||||
easing: Easing.out(Easing.cubic)
|
||||
easing: Easing.out(Easing.linear)
|
||||
}
|
||||
),
|
||||
Animated.timing(
|
||||
|
@ -136,27 +137,36 @@ export default class WritePage extends Component {
|
|||
{
|
||||
toValue: 0,
|
||||
duration: 350,
|
||||
easing: Easing.out(Easing.cubic)
|
||||
easing: Easing.out(Easing.linear)
|
||||
}
|
||||
)
|
||||
]).start(({finished}) => {
|
||||
this.setState({modalVisible: false});
|
||||
if(!finished) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.setState({modalVisible: false}, () => {
|
||||
setTimeout(() => {
|
||||
if(showKeyboard) {
|
||||
setTimeout(() => this.contentInput.focus(), 100);
|
||||
this.contentInput.focus()
|
||||
} else {
|
||||
if(typeof callback == 'function') {
|
||||
callback();
|
||||
}
|
||||
}
|
||||
}, 100);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
_onCreateNotebook() {
|
||||
this.closeModal(false);
|
||||
this.closeModal(false, () => {
|
||||
Navigation.push(this.props.componentId, {
|
||||
component: {
|
||||
name: 'NotebookEdit'
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
_onNotebookSelected(notebook) {
|
||||
|
|
Loading…
Reference in a new issue