mirror of
https://github.com/timepill/timepill-app.git
synced 2025-04-30 09:59:31 +08:00
1. 首页,关注,我的日记列表增加ok绷图标,可点/可取消
This commit is contained in:
parent
d137b41c74
commit
239c7bc790
12 changed files with 212 additions and 65 deletions
Before Width: | Height: | Size: 5.6 KiB After Width: | Height: | Size: 5.6 KiB |
|
@ -7,6 +7,8 @@ import Color from '../../style/color';
|
||||||
import UserIcon from '../userIcon';
|
import UserIcon from '../userIcon';
|
||||||
import Photo from '../photo';
|
import Photo from '../photo';
|
||||||
|
|
||||||
|
import DiaryIconComment from './diaryIconComment';
|
||||||
|
import DiaryIconOkB from './diaryIconOkB';
|
||||||
import DiaryAction from './diaryAction';
|
import DiaryAction from './diaryAction';
|
||||||
|
|
||||||
|
|
||||||
|
@ -16,9 +18,10 @@ export default class DiaryBrief extends Component {
|
||||||
super(props);
|
super(props);
|
||||||
|
|
||||||
this.diary = props.diary;
|
this.diary = props.diary;
|
||||||
|
this.diary.isExpired = props.isExpired || false;
|
||||||
this.editable = props.editable || false;
|
this.editable = props.editable || false;
|
||||||
|
|
||||||
this.showField = ['icon', 'userName', 'subject', 'createdTime'];
|
this.showField = ['userIcon', 'userName', 'subject', 'createdTime'];
|
||||||
if(props.showField && props.showField.length > 0) {
|
if(props.showField && props.showField.length > 0) {
|
||||||
this.showField = props.showField
|
this.showField = props.showField
|
||||||
}
|
}
|
||||||
|
@ -42,7 +45,7 @@ export default class DiaryBrief extends Component {
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<View style={[localStyle.box, this.props.style]}>
|
<View style={[localStyle.box, this.props.style]}>
|
||||||
{(user && user.iconUrl && this.show('icon'))
|
{(user && user.iconUrl && this.show('userIcon'))
|
||||||
? <UserIcon iconUrl={user.iconUrl} onPress={this.props.onUserIconPress}></UserIcon> : null}
|
? <UserIcon iconUrl={user.iconUrl} onPress={this.props.onUserIconPress}></UserIcon> : null}
|
||||||
|
|
||||||
<View style={localStyle.body}>
|
<View style={localStyle.body}>
|
||||||
|
@ -72,16 +75,13 @@ export default class DiaryBrief extends Component {
|
||||||
<Photo uri={diary.photoThumbUrl} onPress={this.props.onPhotoPress}></Photo>
|
<Photo uri={diary.photoThumbUrl} onPress={this.props.onPhotoPress}></Photo>
|
||||||
|
|
||||||
<View style={localStyle.actionBar}>
|
<View style={localStyle.actionBar}>
|
||||||
{
|
<View style={localStyle.icons}>
|
||||||
diary.comment_count > 0
|
<DiaryIconComment count={diary.comment_count}></DiaryIconComment>
|
||||||
? <View style={localStyle.commentIconBox}>
|
<DiaryIconOkB diaryId={diary.id}
|
||||||
<Ionicons name="ios-text-outline" size={18}
|
count={diary.like_count}
|
||||||
color={Color.inactiveText}
|
active={diary.liked}
|
||||||
style={localStyle.buttonIcon} />
|
clickable={!diary.isExpired}></DiaryIconOkB>
|
||||||
<Text style={localStyle.commentIconText}>{diary.comment_count}</Text>
|
|
||||||
</View>
|
</View>
|
||||||
: null
|
|
||||||
}
|
|
||||||
<View style={{flex: 1}} />
|
<View style={{flex: 1}} />
|
||||||
{
|
{
|
||||||
this.editable
|
this.editable
|
||||||
|
@ -143,19 +143,11 @@ const localStyle = StyleSheet.create({
|
||||||
marginTop: 10,
|
marginTop: 10,
|
||||||
justifyContent: 'space-between'
|
justifyContent: 'space-between'
|
||||||
},
|
},
|
||||||
|
icons: {
|
||||||
|
flexDirection: 'row'
|
||||||
|
},
|
||||||
moreIcon: {
|
moreIcon: {
|
||||||
paddingVertical: 5,
|
paddingVertical: 5,
|
||||||
paddingHorizontal: 5
|
paddingHorizontal: 5
|
||||||
},
|
|
||||||
commentIconBox: {
|
|
||||||
flexDirection: "row"
|
|
||||||
},
|
|
||||||
buttonIcon: {
|
|
||||||
marginRight: 8,
|
|
||||||
marginLeft: 2
|
|
||||||
},
|
|
||||||
commentIconIext: {
|
|
||||||
fontSize: 15,
|
|
||||||
color: Color.inactiveText
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
42
src/component/diary/diaryIconComment.js
Normal file
42
src/component/diary/diaryIconComment.js
Normal file
|
@ -0,0 +1,42 @@
|
||||||
|
import React, {Component} from 'react';
|
||||||
|
import {StyleSheet, Text, View, Image, TouchableOpacity} from 'react-native';
|
||||||
|
import Ionicons from 'react-native-vector-icons/Ionicons';
|
||||||
|
|
||||||
|
import Color from '../../style/color';
|
||||||
|
|
||||||
|
|
||||||
|
export default class DiaryIconComment extends Component {
|
||||||
|
|
||||||
|
constructor(props) {
|
||||||
|
super(props);
|
||||||
|
|
||||||
|
this.state = {
|
||||||
|
count: props.count || 0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
render() {
|
||||||
|
return this.state.count > 0 ? (
|
||||||
|
<View style={localStyle.wrap}>
|
||||||
|
<Ionicons name="ios-text-outline" size={18}
|
||||||
|
style={localStyle.icon} />
|
||||||
|
<Text style={localStyle.text}>{this.state.count}</Text>
|
||||||
|
</View>
|
||||||
|
) : null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const localStyle = StyleSheet.create({
|
||||||
|
wrap: {
|
||||||
|
flexDirection: 'row',
|
||||||
|
marginRight: 6
|
||||||
|
},
|
||||||
|
icon: {
|
||||||
|
marginLeft: 2,
|
||||||
|
marginRight: 4
|
||||||
|
},
|
||||||
|
text: {
|
||||||
|
fontSize: 15,
|
||||||
|
color: Color.inactiveText
|
||||||
|
}
|
||||||
|
});
|
97
src/component/diary/diaryIconOkB.js
Normal file
97
src/component/diary/diaryIconOkB.js
Normal file
|
@ -0,0 +1,97 @@
|
||||||
|
import React, {Component} from 'react';
|
||||||
|
import {StyleSheet, Text, View, Image, TouchableOpacity} from 'react-native';
|
||||||
|
|
||||||
|
import Color from '../../style/color';
|
||||||
|
import Api from '../../util/api';
|
||||||
|
import Msg from '../../util/msg';
|
||||||
|
|
||||||
|
|
||||||
|
export default class DiaryIconOkB extends Component {
|
||||||
|
|
||||||
|
constructor(props) {
|
||||||
|
super(props);
|
||||||
|
|
||||||
|
this.state = {
|
||||||
|
diaryId: props.diaryId || null,
|
||||||
|
count: props.count || 0,
|
||||||
|
active: props.active || false,
|
||||||
|
clickable: props.clickable && true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
onPress() {
|
||||||
|
if(!this.state.clickable) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
let count = this.state.count;
|
||||||
|
let isActive = this.state.active;
|
||||||
|
|
||||||
|
if(!isActive) {
|
||||||
|
Api.likeDiary(this.state.diaryId)
|
||||||
|
.then(re => {
|
||||||
|
this.setState({
|
||||||
|
count: count + 1,
|
||||||
|
active: true
|
||||||
|
})
|
||||||
|
})
|
||||||
|
.catch(e => {
|
||||||
|
Msg.showMsg('操作失败');
|
||||||
|
})
|
||||||
|
.done();
|
||||||
|
|
||||||
|
} else {
|
||||||
|
Api.cancelLikeDiary(this.state.diaryId)
|
||||||
|
.then(re => {
|
||||||
|
this.setState({
|
||||||
|
count: count - 1,
|
||||||
|
active: false
|
||||||
|
})
|
||||||
|
})
|
||||||
|
.catch(e => {
|
||||||
|
Msg.showMsg('操作失败');
|
||||||
|
})
|
||||||
|
.done();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
render() {
|
||||||
|
return (
|
||||||
|
<TouchableOpacity onPress={this.onPress.bind(this)}>
|
||||||
|
<View style={localStyle.wrap}>
|
||||||
|
<Image
|
||||||
|
source={
|
||||||
|
!this.state.active
|
||||||
|
? require('../../img/ok-beng1.png')
|
||||||
|
: require('../../img/ok-beng2.png')
|
||||||
|
}
|
||||||
|
style={localStyle.icon}
|
||||||
|
/>
|
||||||
|
|
||||||
|
<Text style={[localStyle.icon, {
|
||||||
|
color: !this.state.active
|
||||||
|
? Color.inactiveText
|
||||||
|
: Color.primary
|
||||||
|
}]}
|
||||||
|
>{this.state.count}</Text>
|
||||||
|
</View>
|
||||||
|
</TouchableOpacity>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const localStyle = StyleSheet.create({
|
||||||
|
wrap: {
|
||||||
|
flexDirection: 'row',
|
||||||
|
marginRight: 6
|
||||||
|
},
|
||||||
|
icon: {
|
||||||
|
width: 18,
|
||||||
|
height: 18,
|
||||||
|
marginLeft: 2,
|
||||||
|
marginRight: 4
|
||||||
|
},
|
||||||
|
text: {
|
||||||
|
fontSize: 15
|
||||||
|
}
|
||||||
|
});
|
|
@ -200,7 +200,7 @@ export default class DiaryList extends Component {
|
||||||
data={this.state.diaries}
|
data={this.state.diaries}
|
||||||
|
|
||||||
keyExtractor={(item, index) => {
|
keyExtractor={(item, index) => {
|
||||||
return item.id + item.updated + item.comment_count;
|
return item.id + item.updated + item.comment_count + item.like_count;
|
||||||
}}
|
}}
|
||||||
|
|
||||||
renderItem={({item}) => {
|
renderItem={({item}) => {
|
||||||
|
|
|
@ -81,7 +81,6 @@ export default class NotebookDiaryList extends Component {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log('format result:', result);
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -177,7 +176,13 @@ export default class NotebookDiaryList extends Component {
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
return this.notebook ? (
|
if(!this.notebook) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
let isExpired = this.notebook.isExpired;
|
||||||
|
|
||||||
|
return (
|
||||||
<View style={localStyle.container}>
|
<View style={localStyle.container}>
|
||||||
<SectionList
|
<SectionList
|
||||||
|
|
||||||
|
@ -187,8 +192,9 @@ export default class NotebookDiaryList extends Component {
|
||||||
|
|
||||||
renderItem={(rowData) => {
|
renderItem={(rowData) => {
|
||||||
return (<Touchable onPress={() => this._onDiaryPress(rowData.item)}>
|
return (<Touchable onPress={() => this._onDiaryPress(rowData.item)}>
|
||||||
<DiaryBrief diary={rowData.item}
|
<DiaryBrief diary={rowData.item} isExpired={isExpired}
|
||||||
showField={['createdTime']}>
|
showField={['createdTime']}>
|
||||||
|
}
|
||||||
</DiaryBrief>
|
</DiaryBrief>
|
||||||
</Touchable>);
|
</Touchable>);
|
||||||
}}
|
}}
|
||||||
|
@ -225,7 +231,7 @@ export default class NotebookDiaryList extends Component {
|
||||||
/>
|
/>
|
||||||
</View>
|
</View>
|
||||||
|
|
||||||
) : null;
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
BIN
src/img/ok-beng1.png
Normal file
BIN
src/img/ok-beng1.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 618 B |
BIN
src/img/ok-beng2.png
Normal file
BIN
src/img/ok-beng2.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.4 KiB |
|
@ -11,7 +11,7 @@ import Api from '../util/api';
|
||||||
import Token from '../util/token';
|
import Token from '../util/token';
|
||||||
import Event from '../util/event';
|
import Event from '../util/event';
|
||||||
import Color from '../style/color';
|
import Color from '../style/color';
|
||||||
import UpdateInfo from '../updateInfo';
|
import UpdateInfo from '../about/updateInfo';
|
||||||
|
|
||||||
|
|
||||||
export default class AboutPage extends Component {
|
export default class AboutPage extends Component {
|
||||||
|
@ -48,7 +48,7 @@ export default class AboutPage extends Component {
|
||||||
return (
|
return (
|
||||||
<View style={{flex: 1, backgroundColor: 'white'}}>
|
<View style={{flex: 1, backgroundColor: 'white'}}>
|
||||||
<View style={{flex: 1, padding: 15, alignItems: 'center', paddingTop: 80}}>
|
<View style={{flex: 1, padding: 15, alignItems: 'center', paddingTop: 80}}>
|
||||||
<Image source={require('../Icon.png')}
|
<Image source={require('../about/Icon.png')}
|
||||||
style={{width: 128, height: 128, borderRadius: 28, borderWidth: 1, borderColor:"#d9d9d9"}} />
|
style={{width: 128, height: 128, borderRadius: 28, borderWidth: 1, borderColor:"#d9d9d9"}} />
|
||||||
<Text style={{paddingTop: 20, paddingBottom: 60}}>版本: {Api.VERSION}{label}</Text>
|
<Text style={{paddingTop: 20, paddingBottom: 60}}>版本: {Api.VERSION}{label}</Text>
|
||||||
<Text style={{color: Color.inactiveText}}>{this.state.news.date} 更新日志</Text>
|
<Text style={{color: Color.inactiveText}}>{this.state.news.date} 更新日志</Text>
|
||||||
|
|
|
@ -2,10 +2,11 @@ import React, {Component} from 'react';
|
||||||
import {StyleSheet, Text, View} from 'react-native';
|
import {StyleSheet, Text, View} from 'react-native';
|
||||||
import {Navigation} from 'react-native-navigation';
|
import {Navigation} from 'react-native-navigation';
|
||||||
|
|
||||||
import Api from '../util/api'
|
import Api from '../util/api';
|
||||||
import {Icon} from '../style/icon'
|
import {Icon} from '../style/icon';
|
||||||
|
import Color from '../style/color';
|
||||||
|
|
||||||
import DiaryList from '../component/diary/diaryList'
|
import DiaryList from '../component/diary/diaryList';
|
||||||
import FollowDiaryData from '../dataLoader/followDiaryData';
|
import FollowDiaryData from '../dataLoader/followDiaryData';
|
||||||
|
|
||||||
|
|
||||||
|
@ -28,7 +29,7 @@ export default class FollowPage extends Component {
|
||||||
id: 'followIcon',
|
id: 'followIcon',
|
||||||
icon: Icon.followIcon,
|
icon: Icon.followIcon,
|
||||||
|
|
||||||
color: '#aaa' // android
|
color: Color.primary // android
|
||||||
}]
|
}]
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -68,7 +69,7 @@ const localStyle = StyleSheet.create({
|
||||||
wrap: {
|
wrap: {
|
||||||
flex: 1,
|
flex: 1,
|
||||||
backgroundColor: '#fff',
|
backgroundColor: '#fff',
|
||||||
paddingTop: 20
|
paddingTop: 1
|
||||||
},
|
},
|
||||||
header: {
|
header: {
|
||||||
paddingLeft: 20,
|
paddingLeft: 20,
|
||||||
|
|
|
@ -260,6 +260,41 @@ async function deleteDiary(id) {
|
||||||
return call('DELETE', '/diaries/' + id);
|
return call('DELETE', '/diaries/' + id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function addDiary(bookId, content, photoUri = null, join_topic = null) {
|
||||||
|
if(!photoUri) {
|
||||||
|
return call('POST', '/notebooks/' + bookId + '/diaries', {
|
||||||
|
content,
|
||||||
|
join_topic
|
||||||
|
});
|
||||||
|
|
||||||
|
} else {
|
||||||
|
return upload('POST', '/notebooks/' + bookId + '/diaries', {
|
||||||
|
content,
|
||||||
|
join_topic,
|
||||||
|
photo: {
|
||||||
|
uri: photoUri,
|
||||||
|
name: 'image.jpg',
|
||||||
|
type: 'image/jpg'
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function updateDiary(id, bookId, content) {
|
||||||
|
return call('PUT', '/diaries/' + id, {
|
||||||
|
content,
|
||||||
|
notebook_id: bookId
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
async function likeDiary(id) {
|
||||||
|
return callV2('PUT', '/like/diaries/' + id);
|
||||||
|
}
|
||||||
|
|
||||||
|
async function cancelLikeDiary(id) {
|
||||||
|
return callV2('DELETE', '/like/diaries/' + id);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
async function updateNotebookCover(bookId, photoUri) {
|
async function updateNotebookCover(bookId, photoUri) {
|
||||||
return upload('POST', `/notebooks/${bookId}/cover`, {
|
return upload('POST', `/notebooks/${bookId}/cover`, {
|
||||||
|
@ -292,33 +327,6 @@ async function deleteNotebook(id) {
|
||||||
return call('DELETE', '/notebooks/' + id)
|
return call('DELETE', '/notebooks/' + id)
|
||||||
}
|
}
|
||||||
|
|
||||||
async function addDiary(bookId, content, photoUri = null, join_topic = null) {
|
|
||||||
if(!photoUri) {
|
|
||||||
return call('POST', '/notebooks/' + bookId + '/diaries', {
|
|
||||||
content,
|
|
||||||
join_topic
|
|
||||||
});
|
|
||||||
|
|
||||||
} else {
|
|
||||||
return upload('POST', '/notebooks/' + bookId + '/diaries', {
|
|
||||||
content,
|
|
||||||
join_topic,
|
|
||||||
photo: {
|
|
||||||
uri: photoUri,
|
|
||||||
name: 'image.jpg',
|
|
||||||
type: 'image/jpg'
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
async function updateDiary(id, bookId, content) {
|
|
||||||
return call('PUT', '/diaries/' + id, {
|
|
||||||
content,
|
|
||||||
notebook_id: bookId
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
async function report(user_id, diary_id) {
|
async function report(user_id, diary_id) {
|
||||||
return call('POST', '/reports/', {
|
return call('POST', '/reports/', {
|
||||||
|
@ -494,6 +502,10 @@ export default {
|
||||||
|
|
||||||
getDiary,
|
getDiary,
|
||||||
deleteDiary,
|
deleteDiary,
|
||||||
|
addDiary,
|
||||||
|
updateDiary,
|
||||||
|
likeDiary,
|
||||||
|
cancelLikeDiary,
|
||||||
|
|
||||||
getDiaryComments,
|
getDiaryComments,
|
||||||
deleteComment,
|
deleteComment,
|
||||||
|
@ -516,9 +528,6 @@ export default {
|
||||||
updateNotebook,
|
updateNotebook,
|
||||||
deleteNotebook,
|
deleteNotebook,
|
||||||
|
|
||||||
addDiary,
|
|
||||||
updateDiary,
|
|
||||||
|
|
||||||
report,
|
report,
|
||||||
feedback
|
feedback
|
||||||
}
|
}
|
Loading…
Reference in a new issue