mirror of
https://github.com/timepill/timepill-app.git
synced 2025-04-30 09:59:31 +08:00
退出写日记页面增加提示 & 优化写日记页面打开逻辑
This commit is contained in:
parent
2bc456dadd
commit
d159650186
2 changed files with 53 additions and 57 deletions
|
@ -23,57 +23,47 @@ export default class EmptyPage extends Component {
|
||||||
|
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
this.navigationEventListener = Navigation.events().bindComponent(this);
|
this.navigationEventListener = Navigation.events().bindComponent(this);
|
||||||
|
this.bottomTabEventListener = Navigation.events().registerBottomTabSelectedListener(({ selectedTabIndex, unselectedTabIndex }) => {
|
||||||
|
if(selectedTabIndex === 2) {
|
||||||
|
Navigation.showModal({
|
||||||
|
stack: {
|
||||||
|
children: [{
|
||||||
|
component: {
|
||||||
|
name: 'Write',
|
||||||
|
passProps: {
|
||||||
|
text: 'stack with one child'
|
||||||
|
},
|
||||||
|
bottomTabs: {
|
||||||
|
visible: false,
|
||||||
|
|
||||||
|
// hide bottom tab for android
|
||||||
|
drawBehind: true,
|
||||||
|
animate: true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}]
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
setTimeout(() => {
|
||||||
|
Navigation.mergeOptions(this.props.componentId, {
|
||||||
|
bottomTabs: {
|
||||||
|
currentTabIndex: unselectedTabIndex
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}, 1000)
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
componentWillUnmount() {
|
componentWillUnmount() {
|
||||||
this.navigationEventListener.remove();
|
this.navigationEventListener.remove();
|
||||||
|
this.bottomTabEventListener.remove();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
componentDidAppear() {
|
componentDidAppear() {
|
||||||
let forword = true;
|
|
||||||
if(this.state.from == 'write') {
|
|
||||||
forword = false;
|
|
||||||
this.setState({from: ''});
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!forword) {
|
|
||||||
|
|
||||||
Navigation.mergeOptions(this.props.componentId, {
|
|
||||||
bottomTabs: {
|
|
||||||
currentTabIndex: 4
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
} else {
|
|
||||||
Navigation.push(this.props.componentId, {
|
|
||||||
component: {
|
|
||||||
name: 'Write',
|
|
||||||
options: {
|
|
||||||
animations: {
|
|
||||||
push: {
|
|
||||||
enabled: false
|
|
||||||
},
|
|
||||||
pop: {
|
|
||||||
enabled: false
|
|
||||||
}
|
|
||||||
},
|
|
||||||
bottomTabs: {
|
|
||||||
visible: false,
|
|
||||||
|
|
||||||
// hide bottom tab for android
|
|
||||||
drawBehind: true,
|
|
||||||
animate: true
|
|
||||||
}
|
|
||||||
},
|
|
||||||
passProps: {
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -81,23 +81,19 @@ export default class WritePage extends Component {
|
||||||
navigationButtonPressed({buttonId}) {
|
navigationButtonPressed({buttonId}) {
|
||||||
if(buttonId == 'cancel') {
|
if(buttonId == 'cancel') {
|
||||||
|
|
||||||
if(this.diary || this.topic) {
|
if(this.state.content.length > 0) {
|
||||||
Navigation.pop(this.props.componentId);
|
Alert.alert('提示', '日记还没保存,退出将删除日记内容', [
|
||||||
|
{
|
||||||
} else {
|
text: '取消', onPress: () => {}
|
||||||
Navigation.setStackRoot(this.props.componentId, {
|
},
|
||||||
component: {
|
{
|
||||||
name: 'Empty',
|
text: '删除并退出', onPress: () => {
|
||||||
options: {
|
this.closePage();
|
||||||
bottomTabs: {
|
|
||||||
visible: true
|
|
||||||
}
|
|
||||||
},
|
|
||||||
passProps: {
|
|
||||||
from: 'write'
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
]);
|
||||||
|
} else {
|
||||||
|
this.closePage();
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if(buttonId == 'save') {
|
} else if(buttonId == 'save') {
|
||||||
|
@ -105,6 +101,16 @@ export default class WritePage extends Component {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
closePage() {
|
||||||
|
this.contentInput.blur();
|
||||||
|
if (this.diary || this.topic) {
|
||||||
|
Navigation.pop(this.props.componentId);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
Navigation.dismissModal(this.props.componentId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
this.loadNotebook().then(notebookCount => {
|
this.loadNotebook().then(notebookCount => {
|
||||||
if(notebookCount > 0) {
|
if(notebookCount > 0) {
|
||||||
|
|
Loading…
Reference in a new issue