mirror of
https://github.com/timepill/timepill-app.git
synced 2025-04-30 09:59:31 +08:00
评论,ok绷图标放进列表,大于0时显示数字。
修复bug: 1. 创建日记本过期日期选择问题 2. 写日记没有日记本提示
This commit is contained in:
parent
fda030567e
commit
ce3dbde712
4 changed files with 86 additions and 44 deletions
|
@ -22,7 +22,7 @@ export default class DateInput extends Component {
|
|||
|
||||
this.updateDate();
|
||||
this.state = {
|
||||
date: this.formatDate(this.nowDate)
|
||||
date: this.minDate
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -36,11 +36,11 @@ export default class DateInput extends Component {
|
|||
this.nowDate = now();
|
||||
let nowMSec = this.nowDate.getTime();
|
||||
|
||||
let minExpiredMSec = 7 * 24 * 3600000; // at least 7 days to expire
|
||||
let minExpiredMSec = 8 * 24 * 3600000; // at least 7 days to expire
|
||||
let minExpiredDate = new Date(nowMSec + minExpiredMSec);
|
||||
this.minDate = this.formatDate(minExpiredDate);
|
||||
|
||||
let maxExpiredMSec = 3650 * 24 * 3600000; // at most 10 years to expire
|
||||
let maxExpiredMSec = 364 * 24 * 3600000; // at most 1 years to expire
|
||||
let maxExpireDate = new Date(nowMSec + maxExpiredMSec);
|
||||
this.maxDate = this.formatDate(maxExpireDate);
|
||||
}
|
||||
|
|
|
@ -16,13 +16,15 @@ export default class DiaryIconComment extends Component {
|
|||
}
|
||||
|
||||
render() {
|
||||
return this.state.count > 0 ? (
|
||||
return (
|
||||
<View style={localStyle.wrap}>
|
||||
<Ionicons name="ios-text-outline" size={18}
|
||||
style={localStyle.icon} />
|
||||
<Text style={localStyle.text}>{this.state.count}</Text>
|
||||
<Text style={localStyle.text}>
|
||||
{this.state.count > 0 ? this.state.count : ''}
|
||||
</Text>
|
||||
</View>
|
||||
) : null;
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -80,12 +80,16 @@ export default class DiaryIconOkB extends Component {
|
|||
style={localStyle.icon}
|
||||
/>
|
||||
|
||||
<Text style={[localStyle.text, {
|
||||
color: !this.state.active
|
||||
? Color.inactiveText
|
||||
: Color.primary
|
||||
}]}
|
||||
>{this.state.count > 0 ? this.state.count : ''}</Text>
|
||||
{
|
||||
this.state.count > 0 ?
|
||||
<Text style={[localStyle.text, {
|
||||
color: !this.state.active
|
||||
? Color.inactiveText
|
||||
: Color.primary
|
||||
}]}
|
||||
>{this.state.count}</Text>
|
||||
: null
|
||||
}
|
||||
</View>
|
||||
</TouchableOpacity>
|
||||
);
|
||||
|
@ -101,8 +105,7 @@ const localStyle = StyleSheet.create({
|
|||
icon: {
|
||||
width: 18,
|
||||
height: 18,
|
||||
marginLeft: 4,
|
||||
marginRight: 1
|
||||
marginLeft: 4
|
||||
},
|
||||
text: {
|
||||
fontSize: 15,
|
||||
|
|
|
@ -13,6 +13,7 @@ import {
|
|||
DeviceEventEmitter,
|
||||
Alert,
|
||||
Image,
|
||||
InteractionManager,
|
||||
SafeAreaView
|
||||
} from 'react-native';
|
||||
import {Navigation} from 'react-native-navigation';
|
||||
|
@ -105,8 +106,25 @@ export default class WritePage extends Component {
|
|||
}
|
||||
|
||||
componentDidMount() {
|
||||
this.loadNotebook();
|
||||
this.contentInput.focus();
|
||||
this.loadNotebook().then(notebookCount => {
|
||||
if(notebookCount > 0) {
|
||||
setTimeout(() => {
|
||||
this.contentInput.focus();
|
||||
}, 500);
|
||||
|
||||
} else {
|
||||
Alert.alert('提示', '没有可用日记本,无法写日记',[
|
||||
{text: '取消', onPress: () => {}},
|
||||
{text: '创建一个', onPress: () => {
|
||||
Navigation.push(this.props.componentId, {
|
||||
component: {
|
||||
name: 'NotebookEdit'
|
||||
}
|
||||
});
|
||||
}}
|
||||
]);
|
||||
}
|
||||
});
|
||||
|
||||
this.notebookListener = DeviceEventEmitter.addListener(Event.updateNotebooks, (param) => {
|
||||
this.loadNotebook(true);
|
||||
|
@ -120,12 +138,6 @@ export default class WritePage extends Component {
|
|||
openModal() {
|
||||
this.contentInput.blur();
|
||||
this.setState({modalVisible: true});
|
||||
|
||||
if(this.state.notebooks.length == 0) {
|
||||
Alert.alert('提示', '没有可用日记本,无法写日记', [
|
||||
{text: '确定', onPress: () => {}}
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
closeModal(showKeyboard = true, callback) {
|
||||
|
@ -185,29 +197,27 @@ export default class WritePage extends Component {
|
|||
});
|
||||
}
|
||||
|
||||
loadNotebook(resetTargetbook = false) {
|
||||
Api.getSelfNotebooks()
|
||||
.then(notebooks => {
|
||||
if (!notebooks || !notebooks.filter) {
|
||||
notebooks = [];
|
||||
}
|
||||
async loadNotebook(resetTargetbook = false) {
|
||||
let notebooks = await Api.getSelfNotebooks();
|
||||
if(!notebooks || !notebooks.filter) {
|
||||
notebooks = [];
|
||||
}
|
||||
|
||||
let unExpiredBooks = notebooks.filter(it => !it.isExpired);
|
||||
if (unExpiredBooks.length > 0) {
|
||||
let st = {
|
||||
notebooks: unExpiredBooks
|
||||
}
|
||||
let unExpiredBooks = notebooks.filter(it => !it.isExpired);unExpiredBooks=[];
|
||||
if(unExpiredBooks && unExpiredBooks.length > 0) {
|
||||
let st = {
|
||||
notebooks: unExpiredBooks
|
||||
}
|
||||
|
||||
if (resetTargetbook || this.state.targetbookId == 0) {
|
||||
st.targetbookId = unExpiredBooks[0].id;
|
||||
st.targetbookSubject = unExpiredBooks[0].subject;
|
||||
}
|
||||
if(resetTargetbook || this.state.targetbookId == 0) {
|
||||
st.targetbookId = unExpiredBooks[0].id;
|
||||
st.targetbookSubject = unExpiredBooks[0].subject;
|
||||
}
|
||||
|
||||
this.setState(st);
|
||||
}
|
||||
this.setState(st);
|
||||
}
|
||||
|
||||
})
|
||||
.catch((err) => { console.error(err) })
|
||||
return unExpiredBooks && unExpiredBooks.length > 0 ? unExpiredBooks.length : 0;
|
||||
}
|
||||
|
||||
_onPickPhoto() {
|
||||
|
@ -262,6 +272,29 @@ export default class WritePage extends Component {
|
|||
return;
|
||||
}
|
||||
|
||||
if(this.state.targetbookId == 0) {
|
||||
if(this.state.notebooks.length == 0) {
|
||||
this.contentInput.blur();
|
||||
Alert.alert('提示', '没有可用日记本,无法写日记',[
|
||||
{text: '取消', onPress: () => {}},
|
||||
{text: '创建一个', onPress: () => {
|
||||
Navigation.push(this.props.componentId, {
|
||||
component: {
|
||||
name: 'NotebookEdit'
|
||||
}
|
||||
});
|
||||
}}
|
||||
]);
|
||||
|
||||
} else {
|
||||
Alert.alert('提示', '选择一个日记本先',[
|
||||
{text: '确定', onPress: () => this.openModal()}
|
||||
]);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
let photoUri = this.state.photoUri;
|
||||
let topic = this.props.topic ? 1 : 0;
|
||||
|
||||
|
@ -431,9 +464,13 @@ export default class WritePage extends Component {
|
|||
|
||||
<Animated.View style={{height: this.state.fadeAnimHeight, backgroundColor: '#fff'}}>
|
||||
<View style={localStyle.modalBanner}>
|
||||
<TouchableOpacity onPress={this._onCreateNotebook.bind(this)} style={localStyle.modalButton}>
|
||||
<Text style={localStyle.modalButtonText}>新添</Text>
|
||||
</TouchableOpacity>
|
||||
{
|
||||
!this.diary ?
|
||||
<TouchableOpacity onPress={this._onCreateNotebook.bind(this)} style={localStyle.modalButton}>
|
||||
<Text style={localStyle.modalButtonText}>新添</Text>
|
||||
</TouchableOpacity> : <Text/>
|
||||
}
|
||||
|
||||
<Text style={{padding: 10, color: Color.text}}>选择日记本</Text>
|
||||
<TouchableOpacity onPress={this.closeModal.bind(this)} style={localStyle.modalButton}>
|
||||
<Text style={localStyle.modalButtonText}>取消</Text>
|
||||
|
|
Loading…
Reference in a new issue