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() {
|
scrollToTop() {
|
||||||
|
if(!this.scrollY) {
|
||||||
|
this.scrollY = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(this.scrollY <= 10) {
|
||||||
|
this.refresh();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
this.list.scrollToOffset({
|
this.list.scrollToOffset({
|
||||||
offset: 0
|
offset: 0
|
||||||
});
|
});
|
||||||
|
@ -263,6 +272,10 @@ export default class DiaryList extends Component {
|
||||||
|
|
||||||
onEndReachedThreshold={2}
|
onEndReachedThreshold={2}
|
||||||
onEndReached={this.state.hasMore ? this.loadMore.bind(this) : null}
|
onEndReached={this.state.hasMore ? this.loadMore.bind(this) : null}
|
||||||
|
|
||||||
|
onScroll={(event) => {
|
||||||
|
this.scrollY = event.nativeEvent.contentOffset.y;
|
||||||
|
}}
|
||||||
>
|
>
|
||||||
</FlatList>
|
</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() {
|
render() {
|
||||||
return (
|
return (
|
||||||
<View style={localStyle.wrap}>
|
<View style={localStyle.wrap}>
|
||||||
<DiaryList ref={(r) => this.list = r}
|
<DiaryList ref={(r) => this.diaryList = r}
|
||||||
dataSource={this.dataSource}
|
dataSource={this.dataSource}
|
||||||
{...this.props}
|
{...this.props}
|
||||||
|
|
||||||
|
|
|
@ -100,6 +100,7 @@ export default class WritePage extends Component {
|
||||||
|
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
this.loadNotebook();
|
this.loadNotebook();
|
||||||
|
this.contentInput.focus();
|
||||||
|
|
||||||
this.notebookListener = DeviceEventEmitter.addListener(Event.updateNotebooks, (param) => {
|
this.notebookListener = DeviceEventEmitter.addListener(Event.updateNotebooks, (param) => {
|
||||||
this.loadNotebook(true);
|
this.loadNotebook(true);
|
||||||
|
@ -111,6 +112,7 @@ export default class WritePage extends Component {
|
||||||
}
|
}
|
||||||
|
|
||||||
openModal() {
|
openModal() {
|
||||||
|
this.contentInput.blur();
|
||||||
this.setState({modalVisible: true});
|
this.setState({modalVisible: true});
|
||||||
|
|
||||||
if(this.state.notebooks.length == 0) {
|
if(this.state.notebooks.length == 0) {
|
||||||
|
@ -120,15 +122,14 @@ export default class WritePage extends Component {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
closeModal(showKeyboard = true) {
|
closeModal(showKeyboard = true, callback) {
|
||||||
this.contentInput.blur();
|
|
||||||
Animated.parallel([
|
Animated.parallel([
|
||||||
Animated.timing(
|
Animated.timing(
|
||||||
this.state.fadeAnimOpacity,
|
this.state.fadeAnimOpacity,
|
||||||
{
|
{
|
||||||
toValue: 0,
|
toValue: 0,
|
||||||
duration: 350,
|
duration: 350,
|
||||||
easing: Easing.out(Easing.cubic)
|
easing: Easing.out(Easing.linear)
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
Animated.timing(
|
Animated.timing(
|
||||||
|
@ -136,27 +137,36 @@ export default class WritePage extends Component {
|
||||||
{
|
{
|
||||||
toValue: 0,
|
toValue: 0,
|
||||||
duration: 350,
|
duration: 350,
|
||||||
easing: Easing.out(Easing.cubic)
|
easing: Easing.out(Easing.linear)
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
]).start(({finished}) => {
|
]).start(({finished}) => {
|
||||||
this.setState({modalVisible: false});
|
|
||||||
if(!finished) {
|
if(!finished) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.setState({modalVisible: false}, () => {
|
||||||
|
setTimeout(() => {
|
||||||
if(showKeyboard) {
|
if(showKeyboard) {
|
||||||
setTimeout(() => this.contentInput.focus(), 100);
|
this.contentInput.focus()
|
||||||
|
} else {
|
||||||
|
if(typeof callback == 'function') {
|
||||||
|
callback();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}, 100);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
_onCreateNotebook() {
|
_onCreateNotebook() {
|
||||||
this.closeModal(false);
|
this.closeModal(false, () => {
|
||||||
Navigation.push(this.props.componentId, {
|
Navigation.push(this.props.componentId, {
|
||||||
component: {
|
component: {
|
||||||
name: 'NotebookEdit'
|
name: 'NotebookEdit'
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
_onNotebookSelected(notebook) {
|
_onNotebookSelected(notebook) {
|
||||||
|
|
Loading…
Reference in a new issue