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.updateDate();
|
||||||
this.state = {
|
this.state = {
|
||||||
date: this.formatDate(this.nowDate)
|
date: this.minDate
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -36,11 +36,11 @@ export default class DateInput extends Component {
|
||||||
this.nowDate = now();
|
this.nowDate = now();
|
||||||
let nowMSec = this.nowDate.getTime();
|
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);
|
let minExpiredDate = new Date(nowMSec + minExpiredMSec);
|
||||||
this.minDate = this.formatDate(minExpiredDate);
|
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);
|
let maxExpireDate = new Date(nowMSec + maxExpiredMSec);
|
||||||
this.maxDate = this.formatDate(maxExpireDate);
|
this.maxDate = this.formatDate(maxExpireDate);
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,13 +16,15 @@ export default class DiaryIconComment extends Component {
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
return this.state.count > 0 ? (
|
return (
|
||||||
<View style={localStyle.wrap}>
|
<View style={localStyle.wrap}>
|
||||||
<Ionicons name="ios-text-outline" size={18}
|
<Ionicons name="ios-text-outline" size={18}
|
||||||
style={localStyle.icon} />
|
style={localStyle.icon} />
|
||||||
<Text style={localStyle.text}>{this.state.count}</Text>
|
<Text style={localStyle.text}>
|
||||||
|
{this.state.count > 0 ? this.state.count : ''}
|
||||||
|
</Text>
|
||||||
</View>
|
</View>
|
||||||
) : null;
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -80,12 +80,16 @@ export default class DiaryIconOkB extends Component {
|
||||||
style={localStyle.icon}
|
style={localStyle.icon}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
{
|
||||||
|
this.state.count > 0 ?
|
||||||
<Text style={[localStyle.text, {
|
<Text style={[localStyle.text, {
|
||||||
color: !this.state.active
|
color: !this.state.active
|
||||||
? Color.inactiveText
|
? Color.inactiveText
|
||||||
: Color.primary
|
: Color.primary
|
||||||
}]}
|
}]}
|
||||||
>{this.state.count > 0 ? this.state.count : ''}</Text>
|
>{this.state.count}</Text>
|
||||||
|
: null
|
||||||
|
}
|
||||||
</View>
|
</View>
|
||||||
</TouchableOpacity>
|
</TouchableOpacity>
|
||||||
);
|
);
|
||||||
|
@ -101,8 +105,7 @@ const localStyle = StyleSheet.create({
|
||||||
icon: {
|
icon: {
|
||||||
width: 18,
|
width: 18,
|
||||||
height: 18,
|
height: 18,
|
||||||
marginLeft: 4,
|
marginLeft: 4
|
||||||
marginRight: 1
|
|
||||||
},
|
},
|
||||||
text: {
|
text: {
|
||||||
fontSize: 15,
|
fontSize: 15,
|
||||||
|
|
|
@ -13,6 +13,7 @@ import {
|
||||||
DeviceEventEmitter,
|
DeviceEventEmitter,
|
||||||
Alert,
|
Alert,
|
||||||
Image,
|
Image,
|
||||||
|
InteractionManager,
|
||||||
SafeAreaView
|
SafeAreaView
|
||||||
} from 'react-native';
|
} from 'react-native';
|
||||||
import {Navigation} from 'react-native-navigation';
|
import {Navigation} from 'react-native-navigation';
|
||||||
|
@ -105,8 +106,25 @@ export default class WritePage extends Component {
|
||||||
}
|
}
|
||||||
|
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
this.loadNotebook();
|
this.loadNotebook().then(notebookCount => {
|
||||||
|
if(notebookCount > 0) {
|
||||||
|
setTimeout(() => {
|
||||||
this.contentInput.focus();
|
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.notebookListener = DeviceEventEmitter.addListener(Event.updateNotebooks, (param) => {
|
||||||
this.loadNotebook(true);
|
this.loadNotebook(true);
|
||||||
|
@ -120,12 +138,6 @@ export default class WritePage extends Component {
|
||||||
openModal() {
|
openModal() {
|
||||||
this.contentInput.blur();
|
this.contentInput.blur();
|
||||||
this.setState({modalVisible: true});
|
this.setState({modalVisible: true});
|
||||||
|
|
||||||
if(this.state.notebooks.length == 0) {
|
|
||||||
Alert.alert('提示', '没有可用日记本,无法写日记', [
|
|
||||||
{text: '确定', onPress: () => {}}
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
closeModal(showKeyboard = true, callback) {
|
closeModal(showKeyboard = true, callback) {
|
||||||
|
@ -185,15 +197,14 @@ export default class WritePage extends Component {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
loadNotebook(resetTargetbook = false) {
|
async loadNotebook(resetTargetbook = false) {
|
||||||
Api.getSelfNotebooks()
|
let notebooks = await Api.getSelfNotebooks();
|
||||||
.then(notebooks => {
|
|
||||||
if(!notebooks || !notebooks.filter) {
|
if(!notebooks || !notebooks.filter) {
|
||||||
notebooks = [];
|
notebooks = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
let unExpiredBooks = notebooks.filter(it => !it.isExpired);
|
let unExpiredBooks = notebooks.filter(it => !it.isExpired);unExpiredBooks=[];
|
||||||
if (unExpiredBooks.length > 0) {
|
if(unExpiredBooks && unExpiredBooks.length > 0) {
|
||||||
let st = {
|
let st = {
|
||||||
notebooks: unExpiredBooks
|
notebooks: unExpiredBooks
|
||||||
}
|
}
|
||||||
|
@ -206,8 +217,7 @@ export default class WritePage extends Component {
|
||||||
this.setState(st);
|
this.setState(st);
|
||||||
}
|
}
|
||||||
|
|
||||||
})
|
return unExpiredBooks && unExpiredBooks.length > 0 ? unExpiredBooks.length : 0;
|
||||||
.catch((err) => { console.error(err) })
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_onPickPhoto() {
|
_onPickPhoto() {
|
||||||
|
@ -262,6 +272,29 @@ export default class WritePage extends Component {
|
||||||
return;
|
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 photoUri = this.state.photoUri;
|
||||||
let topic = this.props.topic ? 1 : 0;
|
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'}}>
|
<Animated.View style={{height: this.state.fadeAnimHeight, backgroundColor: '#fff'}}>
|
||||||
<View style={localStyle.modalBanner}>
|
<View style={localStyle.modalBanner}>
|
||||||
|
{
|
||||||
|
!this.diary ?
|
||||||
<TouchableOpacity onPress={this._onCreateNotebook.bind(this)} style={localStyle.modalButton}>
|
<TouchableOpacity onPress={this._onCreateNotebook.bind(this)} style={localStyle.modalButton}>
|
||||||
<Text style={localStyle.modalButtonText}>新添</Text>
|
<Text style={localStyle.modalButtonText}>新添</Text>
|
||||||
</TouchableOpacity>
|
</TouchableOpacity> : <Text/>
|
||||||
|
}
|
||||||
|
|
||||||
<Text style={{padding: 10, color: Color.text}}>选择日记本</Text>
|
<Text style={{padding: 10, color: Color.text}}>选择日记本</Text>
|
||||||
<TouchableOpacity onPress={this.closeModal.bind(this)} style={localStyle.modalButton}>
|
<TouchableOpacity onPress={this.closeModal.bind(this)} style={localStyle.modalButton}>
|
||||||
<Text style={localStyle.modalButtonText}>取消</Text>
|
<Text style={localStyle.modalButtonText}>取消</Text>
|
||||||
|
|
Loading…
Reference in a new issue