mirror of
https://github.com/timepill/timepill-app.git
synced 2025-04-30 18:09:31 +08:00
Compare commits
1 commit
7d1feea76c
...
792c29864d
Author | SHA1 | Date | |
---|---|---|---|
|
792c29864d |
17 changed files with 153 additions and 519 deletions
|
@ -1,131 +0,0 @@
|
||||||
import React, {Component} from 'react';
|
|
||||||
import {StyleSheet, Text, View, InteractionManager, FlatList, Alert} from 'react-native';
|
|
||||||
import {Navigation} from 'react-native-navigation';
|
|
||||||
import Ionicons from 'react-native-vector-icons/Ionicons';
|
|
||||||
|
|
||||||
import Touchable from '../touchable';
|
|
||||||
import Color from '../../style/color';
|
|
||||||
import Api from '../../util/api';
|
|
||||||
|
|
||||||
import UserIcon from '../userIcon';
|
|
||||||
import Loading from '../loading';
|
|
||||||
import {ListFooterEnd} from '../listFooter';
|
|
||||||
|
|
||||||
|
|
||||||
export default class BlockUserList extends Component {
|
|
||||||
|
|
||||||
constructor(props) {
|
|
||||||
super(props);
|
|
||||||
this.state = {
|
|
||||||
users: [],
|
|
||||||
isLoading: true
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
componentDidMount() {
|
|
||||||
InteractionManager.runAfterInteractions(() => {
|
|
||||||
this.refresh();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
_onDeletePress(user) {
|
|
||||||
Alert.alert('提示', '确定解除屏蔽?', [
|
|
||||||
{text: '确定', style: 'destructive', onPress: () => {
|
|
||||||
Api.deleteUserBlock(user.id)
|
|
||||||
.then(() => {
|
|
||||||
let filterUsers = this.state.users.filter((it) => it.id !== user.id);
|
|
||||||
this.setState({
|
|
||||||
users: filterUsers
|
|
||||||
});
|
|
||||||
})
|
|
||||||
.catch(e => {
|
|
||||||
Alert.alert('解除屏蔽失败');
|
|
||||||
});
|
|
||||||
}},
|
|
||||||
{text: '取消', onPress: () => {}}
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
|
|
||||||
refresh() {
|
|
||||||
Api.getBlockUsers()
|
|
||||||
.then(data => {
|
|
||||||
if (data) {
|
|
||||||
this.setState({
|
|
||||||
users: data.users || [],
|
|
||||||
});
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.catch(e => {
|
|
||||||
console.log('block user error:', e);
|
|
||||||
})
|
|
||||||
.finally(() => {
|
|
||||||
this.setState({
|
|
||||||
isLoading: false
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
render() {
|
|
||||||
if (this.state.isLoading) {
|
|
||||||
return <Loading visible={this.state.isLoading}></Loading>;
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
|
||||||
<View style={localStyle.container}>
|
|
||||||
<FlatList style={localStyle.list}
|
|
||||||
|
|
||||||
data={this.state.users}
|
|
||||||
|
|
||||||
keyExtractor={(item, index) => {
|
|
||||||
return item.id ? item.id.toString() : index;
|
|
||||||
}}
|
|
||||||
|
|
||||||
renderItem={({item}) => {
|
|
||||||
return (
|
|
||||||
<Touchable key={item.id} onPress={() => {}}>
|
|
||||||
<View style={localStyle.box}>
|
|
||||||
<UserIcon iconUrl={item.iconUrl} onPress={() => {}}></UserIcon>
|
|
||||||
<Text style={localStyle.userName}>{item.name}</Text>
|
|
||||||
<Touchable onPress={() => this._onDeletePress(item)}>
|
|
||||||
<Ionicons name="md-close" size={20}
|
|
||||||
style={localStyle.removeIcon}
|
|
||||||
color={Color.inactiveText}
|
|
||||||
/>
|
|
||||||
</Touchable>
|
|
||||||
</View>
|
|
||||||
</Touchable>
|
|
||||||
);
|
|
||||||
}}
|
|
||||||
|
|
||||||
ListFooterComponent={() => <ListFooterEnd></ListFooterEnd>}
|
|
||||||
/>
|
|
||||||
</View>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
const localStyle = StyleSheet.create({
|
|
||||||
container: {
|
|
||||||
flex: 1
|
|
||||||
},
|
|
||||||
list: {
|
|
||||||
height: '100%'
|
|
||||||
},
|
|
||||||
box: {
|
|
||||||
flexDirection: 'row',
|
|
||||||
borderBottomWidth: 1,
|
|
||||||
borderColor: Color.line,
|
|
||||||
alignItems: 'center',
|
|
||||||
backgroundColor: 'white',
|
|
||||||
paddingLeft: 25
|
|
||||||
},
|
|
||||||
userName: {
|
|
||||||
flex: 1,
|
|
||||||
color: Color.text,
|
|
||||||
fontSize: 16
|
|
||||||
},
|
|
||||||
removeIcon: {
|
|
||||||
padding: 20
|
|
||||||
}
|
|
||||||
});
|
|
|
@ -122,14 +122,6 @@ export default class DiaryList extends Component {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
filter(blockUserId) {
|
|
||||||
let diaries = this.state.diaries;
|
|
||||||
let filtered = diaries.filter(d => d.user.id != blockUserId);
|
|
||||||
this.setState({
|
|
||||||
diaries: filtered
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
refreshOne(index, diary) {
|
refreshOne(index, diary) {
|
||||||
if(diary) {
|
if(diary) {
|
||||||
let list = this.state.diaries;
|
let list = this.state.diaries;
|
||||||
|
|
|
@ -2,11 +2,21 @@ import React, {Component} from 'react';
|
||||||
import {Image, StyleSheet, Text, View, TouchableOpacity} from 'react-native';
|
import {Image, StyleSheet, Text, View, TouchableOpacity} from 'react-native';
|
||||||
import Ionicons from 'react-native-vector-icons/Ionicons';
|
import Ionicons from 'react-native-vector-icons/Ionicons';
|
||||||
|
|
||||||
import UserIcon from '../userIcon';
|
|
||||||
import Touchable from '../touchable';
|
import Touchable from '../touchable';
|
||||||
import Color from '../../style/color';
|
import Color from '../../style/color';
|
||||||
|
|
||||||
|
|
||||||
|
function unique(array) {
|
||||||
|
let n = [];
|
||||||
|
for(let i=0; i<array.length; i++) {
|
||||||
|
if(n.indexOf(array[i]) == -1) {
|
||||||
|
n.push(array[i])
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
return n;
|
||||||
|
}
|
||||||
|
|
||||||
export default class Notification extends Component {
|
export default class Notification extends Component {
|
||||||
|
|
||||||
_onDeletePress(msg) {
|
_onDeletePress(msg) {
|
||||||
|
@ -37,43 +47,14 @@ export default class Notification extends Component {
|
||||||
}
|
}
|
||||||
|
|
||||||
renderComment(msg) {
|
renderComment(msg) {
|
||||||
const max = 5;
|
const users = unique(msg.list.map(it => it.content.author.name)).join('、');
|
||||||
const formatMsg = {};
|
const body = `${users} 回复了你`;
|
||||||
|
|
||||||
let key = null;
|
|
||||||
for (let i=0; i<msg.list.length; i++) {
|
|
||||||
key = msg.list[i].link_user_id;
|
|
||||||
if (!formatMsg[key]) {
|
|
||||||
formatMsg[key] = {
|
|
||||||
userId: msg.list[i].content.author.id,
|
|
||||||
userIcon: msg.list[i].link_user_icon,
|
|
||||||
userName: msg.list[i].content.author.name,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Touchable key={msg.link_id} onPress={() => this.props.onCommentPress(msg)}>
|
<Touchable key={msg.link_id} onPress={() => this.props.onCommentPress(msg)}>
|
||||||
<View style={localStyle.container}>
|
<View style={localStyle.container}>
|
||||||
<Ionicons name="ios-text" size={16} style={localStyle.icon} color={Color.light} />
|
<Ionicons name="ios-text" size={16} style={localStyle.icon} color={Color.light} />
|
||||||
{
|
<Text style={localStyle.text}>{body}</Text>
|
||||||
Object.keys(formatMsg).map((it, index) => {
|
|
||||||
if (index >= max) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
|
||||||
<UserIcon key={formatMsg[it].userId || index}
|
|
||||||
iconUrl={formatMsg[it].userIcon}
|
|
||||||
width={24} height={24}
|
|
||||||
onPress={() => this.props.onUserIconPress(formatMsg[it])}
|
|
||||||
/>
|
|
||||||
);
|
|
||||||
})
|
|
||||||
}
|
|
||||||
<Text style={localStyle.text}>
|
|
||||||
{Object.keys(formatMsg).length > max ? '等' : ''}回复了你
|
|
||||||
</Text>
|
|
||||||
{this.renderDeleteButton(msg)}
|
{this.renderDeleteButton(msg)}
|
||||||
</View>
|
</View>
|
||||||
</Touchable>
|
</Touchable>
|
||||||
|
@ -81,17 +62,13 @@ export default class Notification extends Component {
|
||||||
}
|
}
|
||||||
|
|
||||||
renderFollow(msg) {
|
renderFollow(msg) {
|
||||||
const userIcon = msg.link_user_icon;
|
const body = `${msg.content.user.name} 关注了你`;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Touchable key={msg.link_id} onPress={() => this.props.onFollowPress(msg)}>
|
<Touchable key={msg.link_id} onPress={() => this.props.onFollowPress(msg)}>
|
||||||
<View style={localStyle.container}>
|
<View style={localStyle.container}>
|
||||||
<Ionicons name="ios-heart" size={14} style={localStyle.icon} color='#d9534f' />
|
<Ionicons name="ios-heart" size={16} style={localStyle.icon} color='#d9534f' />
|
||||||
<UserIcon
|
<Text key={msg.link_id} style={localStyle.text}>{body}</Text>
|
||||||
iconUrl={userIcon}
|
|
||||||
width={24} height={24}
|
|
||||||
/>
|
|
||||||
<Text style={localStyle.text}>关注了你</Text>
|
|
||||||
{this.renderDeleteButton(msg)}
|
{this.renderDeleteButton(msg)}
|
||||||
</View>
|
</View>
|
||||||
</Touchable>
|
</Touchable>
|
||||||
|
@ -99,11 +76,7 @@ export default class Notification extends Component {
|
||||||
}
|
}
|
||||||
|
|
||||||
renderLike(msg) {
|
renderLike(msg) {
|
||||||
const userData = {
|
const body = `${msg.content.user.name} 给了你一个OK绷`;
|
||||||
userId: msg.content.user.id,
|
|
||||||
userIcon: msg.link_user_icon,
|
|
||||||
userName: msg.content.user.name,
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Touchable key={msg.link_id} onPress={() => this.props.onLikePress(msg)}>
|
<Touchable key={msg.link_id} onPress={() => this.props.onLikePress(msg)}>
|
||||||
|
@ -115,12 +88,7 @@ export default class Notification extends Component {
|
||||||
}
|
}
|
||||||
style={localStyle.icon2}
|
style={localStyle.icon2}
|
||||||
/>
|
/>
|
||||||
<UserIcon
|
<Text style={localStyle.text}>{body}</Text>
|
||||||
iconUrl={userData.userIcon}
|
|
||||||
width={24} height={24}
|
|
||||||
onPress={() => this.props.onUserIconPress(userData)}
|
|
||||||
/>
|
|
||||||
<Text style={localStyle.text}>给了你一个OK绷</Text>
|
|
||||||
{this.renderDeleteButton(msg)}
|
{this.renderDeleteButton(msg)}
|
||||||
</View>
|
</View>
|
||||||
</Touchable>
|
</Touchable>
|
||||||
|
@ -140,18 +108,17 @@ const localStyle = StyleSheet.create({
|
||||||
icon: {
|
icon: {
|
||||||
marginRight: 10,
|
marginRight: 10,
|
||||||
marginTop: 1,
|
marginTop: 1,
|
||||||
lineHeight: 28
|
lineHeight: 20
|
||||||
},
|
},
|
||||||
text: {
|
text: {
|
||||||
flex: 1,
|
flex: 1,
|
||||||
lineHeight: 28
|
lineHeight: 20
|
||||||
},
|
},
|
||||||
icon2: {
|
icon2: {
|
||||||
width: 15,
|
width: 15,
|
||||||
height: 15,
|
height: 15,
|
||||||
marginLeft: -1,
|
marginRight: 10,
|
||||||
marginRight: 9,
|
marginTop: 4,
|
||||||
marginTop: 7,
|
|
||||||
},
|
},
|
||||||
delete: {
|
delete: {
|
||||||
lineHeight: 20,
|
lineHeight: 20,
|
||||||
|
|
|
@ -107,29 +107,6 @@ export default class NotificationList extends Component {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_onUserIconPress(msg) {
|
|
||||||
Navigation.push(this.props.componentId, {
|
|
||||||
component: {
|
|
||||||
name: 'User',
|
|
||||||
options: {
|
|
||||||
bottomTabs: {
|
|
||||||
visible: false,
|
|
||||||
|
|
||||||
// hide bottom tab for android
|
|
||||||
drawBehind: true,
|
|
||||||
animate: true
|
|
||||||
}
|
|
||||||
},
|
|
||||||
passProps: {
|
|
||||||
user: {
|
|
||||||
id: msg.userId,
|
|
||||||
name: msg.userName,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
_onCommentPress(msg) {
|
_onCommentPress(msg) {
|
||||||
Navigation.push(this.props.componentId, {
|
Navigation.push(this.props.componentId, {
|
||||||
component: {
|
component: {
|
||||||
|
@ -183,7 +160,7 @@ export default class NotificationList extends Component {
|
||||||
_onLikePress(msg) {
|
_onLikePress(msg) {
|
||||||
Navigation.push(this.props.componentId, {
|
Navigation.push(this.props.componentId, {
|
||||||
component: {
|
component: {
|
||||||
name: 'DiaryDetail',
|
name: 'User',
|
||||||
options: {
|
options: {
|
||||||
bottomTabs: {
|
bottomTabs: {
|
||||||
visible: false,
|
visible: false,
|
||||||
|
@ -194,7 +171,7 @@ export default class NotificationList extends Component {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
passProps: {
|
passProps: {
|
||||||
diaryId: msg.content.dairy_id
|
user: msg.content.user
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -223,12 +200,11 @@ export default class NotificationList extends Component {
|
||||||
renderItem={({item}) => {
|
renderItem={({item}) => {
|
||||||
return (
|
return (
|
||||||
<Notification msg={item}
|
<Notification msg={item}
|
||||||
onUserIconPress={this._onUserIconPress.bind(this)}
|
onCommentPress={this._onCommentPress.bind(this)}
|
||||||
onCommentPress={this._onCommentPress.bind(this)}
|
onFollowPress={this._onFollowPress.bind(this)}
|
||||||
onFollowPress={this._onFollowPress.bind(this)}
|
onLikePress={this._onLikePress.bind(this)}
|
||||||
onLikePress={this._onLikePress.bind(this)}
|
onDeletePress={this._onDeletePress.bind(this)}
|
||||||
onDeletePress={this._onDeletePress.bind(this)}
|
showDelete={this.props.isSetRead}
|
||||||
showDelete={this.props.isSetRead}
|
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
}}
|
}}
|
||||||
|
|
|
@ -24,7 +24,8 @@ export default class UserIcon extends Component {
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
return (
|
return (
|
||||||
<Avatar rounded containerStyle={localStyle.container}
|
<Avatar rounded
|
||||||
|
containerStyle={localStyle.container}
|
||||||
width={this.props.width || 40}
|
width={this.props.width || 40}
|
||||||
height={this.props.height || 40}
|
height={this.props.height || 40}
|
||||||
source={{uri: this.state.iconUrl}}
|
source={{uri: this.state.iconUrl}}
|
||||||
|
|
|
@ -1,14 +1,14 @@
|
||||||
import React, {Component} from 'react';
|
import React, {Component} from 'react';
|
||||||
import {StyleSheet, Text, View, ScrollView, InteractionManager, Alert} from 'react-native';
|
import {StyleSheet, Text, View, ScrollView, InteractionManager} from 'react-native';
|
||||||
import {Avatar, Button} from "react-native-elements";
|
import {Avatar} from "react-native-elements";
|
||||||
import moment from 'moment';
|
import moment from 'moment';
|
||||||
|
|
||||||
import Color from '../style/color';
|
import Color from '../style/color';
|
||||||
import Api from '../util/api';
|
import Api from '../util/api';
|
||||||
import Msg from '../util/msg';
|
import Msg from '../util/msg';
|
||||||
|
|
||||||
import UserIcon from './userIcon';
|
import UserIcon from './userIcon'
|
||||||
import Loading from './loading';
|
import Loading from './loading'
|
||||||
|
|
||||||
|
|
||||||
export default class UserIntro extends Component {
|
export default class UserIntro extends Component {
|
||||||
|
@ -18,76 +18,37 @@ export default class UserIntro extends Component {
|
||||||
|
|
||||||
this.state = {
|
this.state = {
|
||||||
user: props.user,
|
user: props.user,
|
||||||
followed: 0,
|
|
||||||
|
|
||||||
isLoading: true
|
isLoading: true
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
InteractionManager.runAfterInteractions(() => {
|
Api.getSelfInfoByStore()
|
||||||
this.refresh();
|
.then(user => {
|
||||||
});
|
this.selfInfo = user;
|
||||||
}
|
|
||||||
|
|
||||||
_onAddFollow() {
|
InteractionManager.runAfterInteractions(() => {
|
||||||
Api.addFollow(this.state.user.id)
|
this.refresh();
|
||||||
.then(() => {
|
|
||||||
this.setState({
|
|
||||||
followed: 1
|
|
||||||
});
|
});
|
||||||
|
|
||||||
Alert.alert('已关注');
|
|
||||||
})
|
|
||||||
.catch(e => {
|
|
||||||
Alert.alert('关注失败');
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
_onDeleteFollow() {
|
|
||||||
Api.deleteFollow(this.state.user.id)
|
|
||||||
.then(() => {
|
|
||||||
this.setState({
|
|
||||||
followed: -1,
|
|
||||||
});
|
|
||||||
|
|
||||||
Alert.alert('已取消关注');
|
|
||||||
})
|
|
||||||
.catch(e => {
|
|
||||||
Alert.alert('取消关注失败');
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
refresh(userId) {
|
|
||||||
let targetId = userId;
|
|
||||||
if(!targetId) {
|
|
||||||
targetId = this.state.user ? this.state.user.id : null;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(targetId) {
|
|
||||||
Api.getUserInfo(targetId)
|
|
||||||
.then(user => {
|
|
||||||
this.setState({
|
|
||||||
user: user
|
|
||||||
});
|
|
||||||
})
|
|
||||||
.catch(e => {
|
|
||||||
Msg.showMsg('用户信息加载失败');
|
|
||||||
})
|
|
||||||
.finally(() => {
|
|
||||||
this.setState({
|
|
||||||
isLoading: false
|
|
||||||
})
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
refreshFollowed(followed = 0) {
|
|
||||||
if(followed) {
|
|
||||||
this.setState({
|
|
||||||
followed: followed
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
refresh() {
|
||||||
|
let userId = this.state.user ? this.state.user.id : this.selfInfo.id;
|
||||||
|
Api.getUserInfo(userId)
|
||||||
|
.then(user => {
|
||||||
|
this.setState({
|
||||||
|
user: user
|
||||||
|
});
|
||||||
|
})
|
||||||
|
.catch(e => {
|
||||||
|
Msg.showMsg('用户信息加载失败');
|
||||||
|
})
|
||||||
|
.finally(() => {
|
||||||
|
this.setState({
|
||||||
|
isLoading: false
|
||||||
|
})
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
|
@ -96,37 +57,10 @@ export default class UserIntro extends Component {
|
||||||
}
|
}
|
||||||
|
|
||||||
const user = this.state.user;
|
const user = this.state.user;
|
||||||
const followed = this.state.followed;
|
|
||||||
|
|
||||||
return user ? (
|
return user ? (
|
||||||
<ScrollView style={localStyle.container} automaticallyAdjustContentInsets={false}>
|
<ScrollView style={localStyle.container} automaticallyAdjustContentInsets={false}>
|
||||||
<View style={localStyle.userIcon}>
|
<View style={localStyle.userIcon}>
|
||||||
<UserIcon width={90} height={90} iconUrl={user.coverUrl} />
|
<UserIcon width={90} height={90} iconUrl={user.coverUrl} />
|
||||||
|
|
||||||
{
|
|
||||||
followed < 0
|
|
||||||
? <Button title="+关注"
|
|
||||||
outline={true}
|
|
||||||
color={Color.primary}
|
|
||||||
borderRadius={5}
|
|
||||||
buttonStyle={localStyle.followButton}
|
|
||||||
fontSize={14}
|
|
||||||
onPress={this._onAddFollow.bind(this)}
|
|
||||||
/>
|
|
||||||
: (
|
|
||||||
followed > 0
|
|
||||||
? <Button title="取消关注"
|
|
||||||
outline={true}
|
|
||||||
color={Color.primary}
|
|
||||||
borderRadius={5}
|
|
||||||
buttonStyle={localStyle.followButton}
|
|
||||||
fontSize={14}
|
|
||||||
onPress={this._onDeleteFollow.bind(this)}
|
|
||||||
/>
|
|
||||||
: null
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
<Text style={localStyle.userTitle}>{user.name}</Text>
|
<Text style={localStyle.userTitle}>{user.name}</Text>
|
||||||
</View>
|
</View>
|
||||||
|
|
||||||
|
@ -150,25 +84,14 @@ const localStyle = StyleSheet.create({
|
||||||
backgroundColor: 'white'
|
backgroundColor: 'white'
|
||||||
},
|
},
|
||||||
userIcon: {
|
userIcon: {
|
||||||
marginTop: 20,
|
height: 230,
|
||||||
backgroundColor: 'white',
|
backgroundColor: 'white',
|
||||||
alignItems: 'center',
|
alignItems: 'center',
|
||||||
justifyContent: 'center'
|
justifyContent: 'center'
|
||||||
},
|
},
|
||||||
followButton: {
|
|
||||||
width: 90,
|
|
||||||
height: 28,
|
|
||||||
marginTop: 20,
|
|
||||||
marginRight: 5,
|
|
||||||
paddingTop: 5,
|
|
||||||
paddingBottom: 5,
|
|
||||||
alignItems: 'center',
|
|
||||||
justifyContent: 'center'
|
|
||||||
},
|
|
||||||
userTitle: {
|
userTitle: {
|
||||||
fontSize: 22,
|
fontSize: 22,
|
||||||
marginTop: 30,
|
marginTop: 30,
|
||||||
marginRight: 3,
|
|
||||||
fontWeight: 'bold',
|
fontWeight: 'bold',
|
||||||
color: '#000'
|
color: '#000'
|
||||||
},
|
},
|
||||||
|
|
|
@ -1,49 +0,0 @@
|
||||||
import React, {Component} from 'react';
|
|
||||||
import {StyleSheet, Text, View} from 'react-native';
|
|
||||||
|
|
||||||
import BlockUserList from '../component/block/blockUserList';
|
|
||||||
|
|
||||||
|
|
||||||
export default class BlockUserPage extends Component {
|
|
||||||
|
|
||||||
constructor(props) {
|
|
||||||
super(props);
|
|
||||||
this.state = {
|
|
||||||
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
static options(passProps) {
|
|
||||||
return {
|
|
||||||
topBar: {
|
|
||||||
title: {
|
|
||||||
text: '屏蔽'
|
|
||||||
}
|
|
||||||
},
|
|
||||||
statusBar: {
|
|
||||||
backgroundColor: 'white',
|
|
||||||
style: 'dark'
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
render() {
|
|
||||||
return (
|
|
||||||
<View style={localStyle.wrap}>
|
|
||||||
<BlockUserList ref={(r) => this.list = r}
|
|
||||||
{...this.props}
|
|
||||||
></BlockUserList>
|
|
||||||
</View>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
const localStyle = StyleSheet.create({
|
|
||||||
wrap: {
|
|
||||||
flex: 1,
|
|
||||||
backgroundColor: '#fff',
|
|
||||||
paddingTop: 1
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
|
@ -1,9 +1,8 @@
|
||||||
import React, {Component} from 'react';
|
import React, {Component} from 'react';
|
||||||
import {StyleSheet, Text, View, DeviceEventEmitter} 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 Event from "../util/event";
|
|
||||||
import {Icon} from '../style/icon';
|
import {Icon} from '../style/icon';
|
||||||
import Color from '../style/color';
|
import Color from '../style/color';
|
||||||
|
|
||||||
|
@ -65,15 +64,6 @@ export default class FollowPage extends Component {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
this.blockUserListener = DeviceEventEmitter.addListener(Event.userBlocked, (param) => {
|
|
||||||
this.diaryList.filter(param.blockUserId);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
componentWillUnmount() {
|
|
||||||
this.bottomTabEventListener.remove();
|
|
||||||
this.blockUserListener.remove();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import React, {Component} from 'react';
|
import React, {Component} from 'react';
|
||||||
import {StyleSheet, Text, View, Animated, DeviceEventEmitter} from 'react-native';
|
import {StyleSheet, Text, View, Animated} from 'react-native';
|
||||||
import {
|
import {
|
||||||
PagerScroll,
|
PagerScroll,
|
||||||
TabView,
|
TabView,
|
||||||
|
@ -8,9 +8,7 @@ import {
|
||||||
} from 'react-native-tab-view';
|
} from 'react-native-tab-view';
|
||||||
|
|
||||||
import Api from '../util/api';
|
import Api from '../util/api';
|
||||||
import Event from "../util/event";
|
|
||||||
import Color from '../style/color';
|
import Color from '../style/color';
|
||||||
|
|
||||||
import FollowUserList from '../component/follow/followUserList'
|
import FollowUserList from '../component/follow/followUserList'
|
||||||
import FollowingUserData from '../dataLoader/followingUserData'
|
import FollowingUserData from '../dataLoader/followingUserData'
|
||||||
import FollowedByUserData from '../dataLoader/followedByUserData'
|
import FollowedByUserData from '../dataLoader/followedByUserData'
|
||||||
|
@ -46,21 +44,6 @@ export default class FollowUserPage extends Component {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
componentDidMount() {
|
|
||||||
this.blockUserListener = DeviceEventEmitter.addListener(Event.userBlocked, (param) => {
|
|
||||||
if (this.followingList) {
|
|
||||||
this.followingList.refresh();
|
|
||||||
}
|
|
||||||
if (this.folloedByList) {
|
|
||||||
this.folloedByList.refresh();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
componentWillUnmount() {
|
|
||||||
this.blockUserListener.remove();
|
|
||||||
}
|
|
||||||
|
|
||||||
_renderLabel = props => ({route}) => {
|
_renderLabel = props => ({route}) => {
|
||||||
let routes = props.navigationState.routes;
|
let routes = props.navigationState.routes;
|
||||||
let index = props.navigationState.index;
|
let index = props.navigationState.index;
|
||||||
|
@ -89,14 +72,14 @@ export default class FollowUserPage extends Component {
|
||||||
};
|
};
|
||||||
|
|
||||||
_renderScene = SceneMap({
|
_renderScene = SceneMap({
|
||||||
following: () => <FollowUserList ref={(r) => this.followingList = r}
|
following: () => <FollowUserList
|
||||||
listType={'followingUser'} dataSource={new FollowingUserData()}
|
listType={'followingUser'} dataSource={new FollowingUserData()}
|
||||||
onDeletePress={async (id) => {
|
onDeletePress={async (id) => {
|
||||||
return Api.deleteFollow(id);
|
return Api.deleteFollow(id);
|
||||||
}}
|
}}
|
||||||
{...this.props}
|
{...this.props}
|
||||||
/>,
|
/>,
|
||||||
followedBy: () => <FollowUserList ref={(r) => this.followedByList = r}
|
followedBy: () => <FollowUserList
|
||||||
listType={'followedByUser'} dataSource={new FollowedByUserData()}
|
listType={'followedByUser'} dataSource={new FollowedByUserData()}
|
||||||
onDeletePress={async (id) => {
|
onDeletePress={async (id) => {
|
||||||
return Api.deleteFollowBy(id);
|
return Api.deleteFollowBy(id);
|
||||||
|
|
|
@ -9,8 +9,7 @@ import {
|
||||||
Modal,
|
Modal,
|
||||||
TouchableWithoutFeedback,
|
TouchableWithoutFeedback,
|
||||||
InteractionManager,
|
InteractionManager,
|
||||||
StatusBar,
|
StatusBar
|
||||||
DeviceEventEmitter,
|
|
||||||
} from 'react-native';
|
} from 'react-native';
|
||||||
import {Navigation} from 'react-native-navigation';
|
import {Navigation} from 'react-native-navigation';
|
||||||
import {Button} from 'react-native-elements';
|
import {Button} from 'react-native-elements';
|
||||||
|
@ -19,7 +18,6 @@ import ActionSheet from 'react-native-actionsheet-api';
|
||||||
import Color from '../style/color'
|
import Color from '../style/color'
|
||||||
import Api from '../util/api';
|
import Api from '../util/api';
|
||||||
import Update from '../util/update';
|
import Update from '../util/update';
|
||||||
import Event from '../util/event'
|
|
||||||
|
|
||||||
import DiaryList from '../component/diary/diaryList'
|
import DiaryList from '../component/diary/diaryList'
|
||||||
import HomeDiaryData from '../dataLoader/homeDiaryData';
|
import HomeDiaryData from '../dataLoader/homeDiaryData';
|
||||||
|
@ -78,15 +76,10 @@ export default class HomePage extends Component {
|
||||||
Update.updateAndroid();
|
Update.updateAndroid();
|
||||||
}, 2000);
|
}, 2000);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.blockUserListener = DeviceEventEmitter.addListener(Event.userBlocked, (param) => {
|
|
||||||
this.diaryList.filter(param.blockUserId);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
componentWillUnmount() {
|
componentWillUnmount() {
|
||||||
this.bottomTabEventListener.remove();
|
this.bottomTabEventListener.remove();
|
||||||
this.blockUserListener.remove();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
startTimer() {
|
startTimer() {
|
||||||
|
|
|
@ -40,6 +40,15 @@ export default class NotificationPage extends Component {
|
||||||
constructor(props) {
|
constructor(props) {
|
||||||
super(props);
|
super(props);
|
||||||
Navigation.events().bindComponent(this);
|
Navigation.events().bindComponent(this);
|
||||||
|
|
||||||
|
// const ds = new ListView.DataSource({
|
||||||
|
// rowHasChanged: (r1, r2) => r1 !== r2
|
||||||
|
// });
|
||||||
|
// this.state = ({
|
||||||
|
// messages: [],
|
||||||
|
// messagesDataSource: ds,
|
||||||
|
// refreshing: true,
|
||||||
|
// });
|
||||||
}
|
}
|
||||||
|
|
||||||
navigationButtonPressed({buttonId}) {
|
navigationButtonPressed({buttonId}) {
|
||||||
|
|
|
@ -179,13 +179,6 @@ export default class SettingPage extends Component {
|
||||||
{/*</View>*/}
|
{/*</View>*/}
|
||||||
</View>
|
</View>
|
||||||
|
|
||||||
<View style={localStyle.group}>
|
|
||||||
<TouchableOpacity style={localStyle.item} onPress={() => this.jumpTo('BlockUser')}>
|
|
||||||
<Text style={localStyle.title}>屏蔽</Text>
|
|
||||||
<Ionicons name="ios-arrow-forward" style={localStyle.arrow} size={18}/>
|
|
||||||
</TouchableOpacity>
|
|
||||||
</View>
|
|
||||||
|
|
||||||
<View style={localStyle.group}>
|
<View style={localStyle.group}>
|
||||||
{
|
{
|
||||||
Api.IS_IOS ? (
|
Api.IS_IOS ? (
|
||||||
|
|
|
@ -61,14 +61,10 @@ export default class TopicPage extends Component {
|
||||||
this.diaryListener = DeviceEventEmitter.addListener(Event.updateDiarys, (param) => {
|
this.diaryListener = DeviceEventEmitter.addListener(Event.updateDiarys, (param) => {
|
||||||
this.diaryList.refresh();
|
this.diaryList.refresh();
|
||||||
});
|
});
|
||||||
this.blockUserListener = DeviceEventEmitter.addListener(Event.userBlocked, (param) => {
|
|
||||||
this.diaryList.filter(param.blockUserId);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
componentWillUnmount() {
|
componentWillUnmount() {
|
||||||
this.diaryListener.remove();
|
this.diaryListener.remove();
|
||||||
this.blockUserListener.remove();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
|
|
|
@ -8,7 +8,6 @@ import {
|
||||||
} from 'react-native-tab-view';
|
} from 'react-native-tab-view';
|
||||||
import {Navigation} from 'react-native-navigation';
|
import {Navigation} from 'react-native-navigation';
|
||||||
|
|
||||||
import Msg from '../util/msg';
|
|
||||||
import Api from '../util/api';
|
import Api from '../util/api';
|
||||||
import {Icon} from '../style/icon';
|
import {Icon} from '../style/icon';
|
||||||
import Event from "../util/event";
|
import Event from "../util/event";
|
||||||
|
@ -49,8 +48,8 @@ export default class UserPage extends Component {
|
||||||
text: passProps.user.name
|
text: passProps.user.name
|
||||||
},
|
},
|
||||||
rightButtons: [{
|
rightButtons: [{
|
||||||
id: 'navButtonMore',
|
id: 'followIcon',
|
||||||
icon: Icon.navButtonMore
|
icon: Icon.navButtonFollow
|
||||||
}]
|
}]
|
||||||
},
|
},
|
||||||
statusBar: {
|
statusBar: {
|
||||||
|
@ -77,26 +76,41 @@ export default class UserPage extends Component {
|
||||||
}
|
}
|
||||||
|
|
||||||
navigationButtonPressed({buttonId}) {
|
navigationButtonPressed({buttonId}) {
|
||||||
if(buttonId == 'navButtonMore') {
|
if(buttonId == 'followIcon') {
|
||||||
ActionSheet.showActionSheetWithOptions({
|
Api.addFollow(this.userId)
|
||||||
options: ['屏蔽', '取消'],
|
.then(() => {
|
||||||
cancelButtonIndex: 1,
|
Navigation.mergeOptions(this.props.componentId, {
|
||||||
destructiveButtonIndex: 0
|
topBar: {
|
||||||
|
rightButtons: [{
|
||||||
|
id: 'navButtonFollowSelected',
|
||||||
|
icon: Icon.navButtonFollowSelected
|
||||||
|
}]
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
}, (index) => {
|
Alert.alert('已关注');
|
||||||
if(index == 0) {
|
})
|
||||||
Api.addUserBlock(this.userId)
|
.catch(e => {
|
||||||
.then(() => {
|
Alert.alert('关注失败');
|
||||||
DeviceEventEmitter.emit(Event.userBlocked, {blockUserId: this.userId});
|
})
|
||||||
Navigation.popToRoot(this.props.componentId);
|
|
||||||
Msg.showMsg('该用户已被屏蔽');
|
} else if(buttonId == 'navButtonFollowSelected') {
|
||||||
})
|
Api.deleteFollow(this.userId)
|
||||||
.catch(e => {
|
.then(() => {
|
||||||
console.log('block error:', e);
|
Navigation.mergeOptions(this.props.componentId, {
|
||||||
Alert.alert('屏蔽失败');
|
topBar: {
|
||||||
});
|
rightButtons: [{
|
||||||
}
|
id: 'followIcon',
|
||||||
});
|
icon: Icon.navButtonFollow
|
||||||
|
}]
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
Alert.alert('已取消关注');
|
||||||
|
})
|
||||||
|
.catch(e => {
|
||||||
|
Alert.alert('取消关注失败');
|
||||||
|
})
|
||||||
|
|
||||||
} else if(buttonId == 'setting') {
|
} else if(buttonId == 'setting') {
|
||||||
Navigation.push(this.props.componentId, {
|
Navigation.push(this.props.componentId, {
|
||||||
|
@ -117,27 +131,23 @@ export default class UserPage extends Component {
|
||||||
}
|
}
|
||||||
|
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
Api.getSelfInfoByStore()
|
if(this.userId) {
|
||||||
.then(user => {
|
Api.getRelation(this.userId)
|
||||||
if(!this.userId || (user && user.id == this.userId)) {
|
.then(re => {
|
||||||
this.userIntro.refresh(user.id);
|
this.followed = re;
|
||||||
Navigation.mergeOptions(this.props.componentId, {
|
if(this.followed) {
|
||||||
topBar: {
|
Navigation.mergeOptions(this.props.componentId, {
|
||||||
rightButtons: [{
|
topBar: {
|
||||||
id: 'setting',
|
rightButtons: [{
|
||||||
icon: Icon.navButtonSetting
|
id: 'navButtonFollowSelected',
|
||||||
}]
|
icon: Icon.navButtonFollowSelected
|
||||||
}
|
}]
|
||||||
});
|
}
|
||||||
|
|
||||||
} else {
|
|
||||||
Api.getRelation(this.userId)
|
|
||||||
.then(re => {
|
|
||||||
this.followed = re ? 1 : -1;
|
|
||||||
this.userIntro.refreshFollowed(this.followed);
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
this.notebookListener = DeviceEventEmitter.addListener(Event.updateNotebooks, (param) => {
|
this.notebookListener = DeviceEventEmitter.addListener(Event.updateNotebooks, (param) => {
|
||||||
this.notebookList.refresh();
|
this.notebookList.refresh();
|
||||||
|
|
|
@ -1,25 +1,24 @@
|
||||||
export default {
|
export default {
|
||||||
About: require("./AboutPage.js").default,
|
About: require("./AboutPage.js").default,
|
||||||
BlockUser: require("./BlockUserPage.js").default,
|
DiaryDetail: require("./DiaryDetailPage.js").default,
|
||||||
DiaryDetail: require("./DiaryDetailPage.js").default,
|
Empty: require("./EmptyPage.js").default,
|
||||||
Empty: require("./EmptyPage.js").default,
|
Feedback: require("./FeedbackPage.js").default,
|
||||||
Feedback: require("./FeedbackPage.js").default,
|
Follow: require("./FollowPage.js").default,
|
||||||
Follow: require("./FollowPage.js").default,
|
FollowUser: require("./FollowUserPage.js").default,
|
||||||
FollowUser: require("./FollowUserPage.js").default,
|
Home: require("./HomePage.js").default,
|
||||||
Home: require("./HomePage.js").default,
|
NotebookDetail: require("./NotebookDetailPage.js").default,
|
||||||
NotebookDetail: require("./NotebookDetailPage.js").default,
|
NotebookEdit: require("./NotebookEditPage.js").default,
|
||||||
NotebookEdit: require("./NotebookEditPage.js").default,
|
NotebookMerge: require("./NotebookMergePage.js").default,
|
||||||
NotebookMerge: require("./NotebookMergePage.js").default,
|
NotificationHistory: require("./NotificationHistoryPage.js").default,
|
||||||
NotificationHistory: require("./NotificationHistoryPage.js").default,
|
Notification: require("./NotificationPage.js").default,
|
||||||
Notification: require("./NotificationPage.js").default,
|
Password: require("./PasswordPage.js").default,
|
||||||
Password: require("./PasswordPage.js").default,
|
Photo: require("./PhotoPage.js").default,
|
||||||
Photo: require("./PhotoPage.js").default,
|
Setting: require("./SettingPage.js").default,
|
||||||
Setting: require("./SettingPage.js").default,
|
Topic: require("./TopicPage.js").default,
|
||||||
Topic: require("./TopicPage.js").default,
|
UserInfoEdit: require("./UserInfoEditPage.js").default,
|
||||||
UserInfoEdit: require("./UserInfoEditPage.js").default,
|
UserIntroEdit: require("./UserIntroEditPage.js").default,
|
||||||
UserIntroEdit: require("./UserIntroEditPage.js").default,
|
UserNameEdit: require("./UserNameEditPage.js").default,
|
||||||
UserNameEdit: require("./UserNameEditPage.js").default,
|
User: require("./UserPage.js").default,
|
||||||
User: require("./UserPage.js").default,
|
WebView: require("./WebViewPage.js").default,
|
||||||
WebView: require("./WebViewPage.js").default,
|
Write: require("./WritePage.js").default
|
||||||
Write: require("./WritePage.js").default
|
|
||||||
}
|
}
|
|
@ -140,7 +140,7 @@ async function syncSplash() {
|
||||||
}
|
}
|
||||||
|
|
||||||
async function getSelfInfo() {
|
async function getSelfInfo() {
|
||||||
return callV2('GET', '/users/my');
|
return call('GET', '/users/my');
|
||||||
}
|
}
|
||||||
|
|
||||||
async function getSelfInfoByStore() {
|
async function getSelfInfoByStore() {
|
||||||
|
@ -148,7 +148,7 @@ async function getSelfInfoByStore() {
|
||||||
}
|
}
|
||||||
|
|
||||||
async function getUserInfo(id) {
|
async function getUserInfo(id) {
|
||||||
return callV2('GET', '/users/' + id)
|
return call('GET', '/users/' + id)
|
||||||
}
|
}
|
||||||
|
|
||||||
async function updateUserIcon(photoUri) {
|
async function updateUserIcon(photoUri) {
|
||||||
|
@ -267,7 +267,7 @@ async function getMessages() {
|
||||||
}
|
}
|
||||||
|
|
||||||
async function getMessagesHistory() {
|
async function getMessagesHistory() {
|
||||||
return callV2('GET', '/tips/history');
|
return call('GET', '/tip/history');
|
||||||
}
|
}
|
||||||
|
|
||||||
async function deleteMessage(ids) {
|
async function deleteMessage(ids) {
|
||||||
|
@ -368,23 +368,11 @@ async function getUpdateInfo() {
|
||||||
return callV2('GET', '/updateInfo');
|
return callV2('GET', '/updateInfo');
|
||||||
}
|
}
|
||||||
|
|
||||||
async function addUserBlock(user_id) {
|
|
||||||
return call('POST', `/blocks/${user_id}`);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
async function deleteUserBlock(user_id) {
|
|
||||||
return call('DELETE', `/blocks/${user_id}`);
|
|
||||||
}
|
|
||||||
|
|
||||||
async function getBlockUsers() {
|
|
||||||
return call('GET', `/blocks`);
|
|
||||||
}
|
|
||||||
|
|
||||||
export async function updatePushInfo() {
|
export async function updatePushInfo() {
|
||||||
return callV2('POST', '/push');
|
return callV2('POST', '/push');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
async function upload(method, api, body) {
|
async function upload(method, api, body) {
|
||||||
let token = await Token.getUserToken();
|
let token = await Token.getUserToken();
|
||||||
let formData = new FormData();
|
let formData = new FormData();
|
||||||
|
@ -589,8 +577,4 @@ export default {
|
||||||
getUpdateInfo,
|
getUpdateInfo,
|
||||||
|
|
||||||
updatePushInfo,
|
updatePushInfo,
|
||||||
|
|
||||||
addUserBlock,
|
|
||||||
deleteUserBlock,
|
|
||||||
getBlockUsers,
|
|
||||||
}
|
}
|
|
@ -7,7 +7,5 @@ export default {
|
||||||
commentPressed: 'commentPressed',
|
commentPressed: 'commentPressed',
|
||||||
passwordUpdated: 'passwordUpdated',
|
passwordUpdated: 'passwordUpdated',
|
||||||
updateNewsRead: 'updateNewsRead',
|
updateNewsRead: 'updateNewsRead',
|
||||||
userInfoUpdated: 'userInfoUpdated',
|
userInfoUpdated: 'userInfoUpdated'
|
||||||
|
|
||||||
userBlocked: 'userBlocked',
|
|
||||||
}
|
}
|
Loading…
Reference in a new issue