Authored by 张丽霞

merge, review by 于良

Showing 36 changed files with 154 additions and 68 deletions
... ... @@ -54,7 +54,7 @@ export default class SuperMan extends React.Component {
render() {
let avatarContainerStyle = this.props.uid > 0 && this.props.avatar ? styles.avatarContainer : null;
let avatarStyle = this.props.uid > 0 && this.props.avatar ? styles.avatarBorder : null;
let defaultSource = this.props.uid > 0 && this.props.avatar ? null : require('../../images/home/superman.png');
let defaultSource = this.props.uid > 0 && this.props.avatar ? null : require('../../images/avatar/superman.png');
return (
<View style={[styles.container, this.props.fly]}>
<TouchableOpacity activeOpacity={0.8} onPress={() => {
... ...
... ... @@ -58,7 +58,7 @@ export default class UserBrief extends React.Component {
<TouchableOpacity onPress={() => {
this.props.onPressAvatar && this.props.onPressAvatar();
}}>
<SlicedImage style={styles.avatar} source={{uri: this.props.avatar}} resizeMode={'cover'} defaultSource={require('../../images/user/avatar-default.png')}/>
<SlicedImage style={styles.avatar} source={{uri: this.props.avatar}} resizeMode={'cover'} defaultSource={require('../../images/avatar/avatar_default.png')}/>
</TouchableOpacity>
<View style={styles.text}>
... ...
... ... @@ -41,7 +41,7 @@ export default class MessageIcon extends React.Component {
render() {
let defaultSource = this.props.defaultSource || require('../../images/user/avatar-default.png');
let defaultSource = this.props.defaultSource || require('../../images/avatar/avatar_default.png');
return (
<View style={[styles.container, this.props.extraStyle]}>
... ...
... ... @@ -169,7 +169,6 @@ export default class Posting extends Component {
<TextInput
style={styles.contentInput}
placeholder='用力敲出你想说的...'
maxLength={2000}
multiline={true}
autoCorrect={false}
onFocus={() => {
... ... @@ -178,6 +177,9 @@ export default class Posting extends Component {
});
}}
onChangeText={(text) => {
if(text.length>2000) {
text = text.substring(0,2000);
}
this.contentLength = text.length;
this.props.contentEdited(text);
}}
... ...
... ... @@ -32,8 +32,8 @@ export default class PostingToolBar extends Component {
render() {
let {imageCount, selectedSectionName, keyboardInView, imageInView} = this.props;
let keyboardImage = keyboardInView ? require('../../images/jianpan1.png') : require('../../images/keyboard_normal.png');
let picImage = imageInView ? require('../../images/pic1.png') : require('../../images/pic_normal.png')
let keyboardImage = keyboardInView ? require('../../images/posting/jianpan1.png') : require('../../images/posting/keyboard_normal.png');
let picImage = imageInView ? require('../../images/posting/pic1.png') : require('../../images/posting/pic_normal.png')
return (
<View style={styles.container}>
<TouchableOpacity style={styles.imgIcon} onPress={() => {
... ...
... ... @@ -202,6 +202,9 @@ export default class Section extends React.Component {
initialPage={this.currentPage}
onScroll={this._updateScrollValue}
getCurrentPageHeight={this._getCurrentPageHeight}
onChangeTab={(tab) => {
this.currentPage = tab.i;
}}
>
<SectionList
ref={(c) => {
... ... @@ -213,7 +216,6 @@ export default class Section extends React.Component {
onPressSectionTag={this.props.onPressSectionTag}
onPressComment={this.props.onPressComment}
onPressLike={this.props.onPressLike}
onContentSizeChange={(width, height) => {}}
/>
<SectionList
ref={(c) => {
... ... @@ -225,7 +227,6 @@ export default class Section extends React.Component {
onPressSectionTag={this.props.onPressSectionTag}
onPressComment={this.props.onPressComment}
onPressLike={this.props.onPressLike}
onContentSizeChange={(width, height) => {}}
/>
</ScrollableTabView>
);
... ...
... ... @@ -76,7 +76,7 @@ export default class Setting extends React.Component {
}}
>
<Image
source={require('../../images/delete.png')}
source={require('../../images/user/delete.png')}
/>
</TouchableOpacity>
... ... @@ -146,8 +146,8 @@ let styles = StyleSheet.create({
sign: {
fontFamily: 'Helvetica Light',
fontSize: 15,
margin: 15,
height: 150,
padding: 15,
},
separator: {
... ...
... ... @@ -47,7 +47,7 @@ export default class SPLikeCell extends React.Component {
key={i}
style={[styles.likeAvatar, {right: space * i}]}
source={{uri: headStr}}
defaultSource={require('../../images/user/avatar-default.png')}
defaultSource={require('../../images/avatar/avatar_default.png')}
/>
);
})}
... ...
... ... @@ -167,7 +167,7 @@ export default class SubjectPost extends Component {
}
renderToolContainer() {
let iconSouce = (this.state.replyState === ReplyState.replyNone)?require('../../images/home/like.png'):require('../../images/pic1.png');
let iconSouce = (this.state.replyState === ReplyState.replyNone)?require('../../images/home/like.png'):require('../../images/posting/pic1.png');
switch (this.state.replyState) {
case ReplyState.replyNone: {
... ... @@ -237,7 +237,7 @@ export default class SubjectPost extends Component {
</TouchableOpacity>
<TouchableOpacity style={styles.keyboardIcon} onPress={this.blurAll}>
<SlicedImage source={require('../../images/jianpan1.png')} />
<SlicedImage source={require('../../images/posting/jianpan1.png')} />
</TouchableOpacity>
<View style={[styles.rightContainer]}>
<TextInput
... ... @@ -282,7 +282,7 @@ export default class SubjectPost extends Component {
</TouchableOpacity>
<TouchableOpacity style={styles.keyboardIcon} onPress={this.blurAll}>
<SlicedImage source={require('../../images/jianpan1.png')} />
<SlicedImage source={require('../../images/posting/jianpan1.png')} />
</TouchableOpacity>
<View style={[styles.rightContainer]}>
<TextInput
... ...
... ... @@ -4,6 +4,7 @@ import React from 'react';
import ReactNative from 'react-native';
import ListCell from '../home/ListCell';
import ImmutablePropTypes from 'react-immutable-proptypes';
import EmptyListTip from './EmptyListTip';
const {
View,
... ... @@ -83,11 +84,32 @@ export default class CommunityList extends React.Component {
);
}
getContentHeight() {
let {data, endReached, index, endReachedViewHeight} = this.props;
return this.state.contentHeight;
}
render() {
let data = this.props.data.toArray();
let {data, endReached, page, endReachedViewHeight} = this.props;
if (endReached && data.size == 0) {
let endReachedText = page == 0 ? '你还没有发布的帖子' : '你还没有赞过的帖子';
return (
<EmptyListTip
style={{height: endReachedViewHeight}}
text={endReachedText}
onLayout={(event) => {
this.setState({
contentHeight: this.props.endReachedViewHeight
});
}}
/>
);
}
return (
<ListView
dataSource={this.dataSource.cloneWithRows(data)}
dataSource={this.dataSource.cloneWithRows(data.toArray())}
renderRow={this._renderRow}
renderSectionHeader={this._renderSectionHeader}
renderSeparator={this._renderSeparator}
... ... @@ -101,17 +123,14 @@ export default class CommunityList extends React.Component {
this.props.onContentSizeChange && this.props.onContentSizeChange(width, height);
});
}}
/>
);
}
}
let styles = StyleSheet.create({
separator: {
height: 0.5,
backgroundColor: '#e0e0e0',
... ...
... ... @@ -14,12 +14,12 @@ export default class EmptyListTip extends Component {
};
static defaultProps = {
text: '你还没有发布过帖子',
text: '暂无更多',
};
render() {
return (
<View style={styles.container}>
<View style={[styles.container, this.props.style]} onLayout={this.props.onLayout}>
<Text style={styles.text}>{this.props.text}</Text>
</View>
);
... ... @@ -28,18 +28,14 @@ export default class EmptyListTip extends Component {
const styles = StyleSheet.create({
container: {
flex: 1,
flexDirection: 'row',
justifyContent: 'center',
alignItems: 'center',
height: 200,
},
indicator: {
},
text: {
marginLeft: 10,
textAlign: 'center',
color:'#b0b0b0',
fontSize: 17,
fontFamily: 'Helvetica Light',
marginTop: 100,
},
});
... ...
... ... @@ -3,6 +3,7 @@
import React from 'react';
import ReactNative from 'react-native';
import ReplyCell from './ReplyCell';
import EmptyListTip from './EmptyListTip';
const {
View,
... ... @@ -55,10 +56,25 @@ export default class ReplyList extends React.Component {
}
render() {
let data = this.props.data.toArray();
let {data, endReached, endReachedViewHeight} = this.props;
if (endReached && data.size == 0) {
let endReachedText = '你还没有回复过的帖子';
return (
<EmptyListTip
style={{height: endReachedViewHeight}}
text={endReachedText}
onLayout={(event) => {
this.setState({
contentHeight: this.props.endReachedViewHeight
});
}}
/>
);
}
return (
<ListView
dataSource={this.dataSource.cloneWithRows(data)}
dataSource={this.dataSource.cloneWithRows(data.toArray())}
renderRow={this._renderRow}
renderSectionHeader={this._renderSectionHeader}
renderSeparator={this._renderSeparator}
... ... @@ -74,15 +90,11 @@ export default class ReplyList extends React.Component {
}}
/>
);
}
}
let styles = StyleSheet.create({
separator: {
height: 0.5,
backgroundColor: '#e0e0e0',
... ...
... ... @@ -6,7 +6,7 @@ import ScrollableTabView, {DefaultTabBar} from 'react-native-scrollable-tab-view
import ImmutablePropTypes from 'react-immutable-proptypes';
import UserCenterTop from './UserCenterTop';
import CommunityList from '../CommonComp/CommunityList';
import CommunityList from './CommunityList';
import ReplyList from './ReplyList';
import SectionTabBar from '../section/SectionTabBar';
import LoadMoreIndicator from '../../../common/components/LoadMoreIndicator';
... ... @@ -173,6 +173,7 @@ export default class User extends React.Component {
this._updateHorizontalScrollValue = this._updateHorizontalScrollValue.bind(this);
this._updateVerticalScrollValue = this._updateVerticalScrollValue.bind(this);
this._getCurrentPageHeight = this._getCurrentPageHeight.bind(this);
this.getPageList = this.getPageList.bind(this);
this.dataSource = new ListView.DataSource({
rowHasChanged: (r1, r2) => !Immutable.is(r1, r2),
... ... @@ -213,43 +214,55 @@ export default class User extends React.Component {
initialPage={this.currentPage}
onScroll={this._updateHorizontalScrollValue}
getCurrentPageHeight={this._getCurrentPageHeight}
prerenderingSiblingsNumber={Infinity}
onChangeTab={(tab) => {
this.currentPage = tab.i;
}}
>
<CommunityList
ref={(c) => {
this.tab1 = c;
}}
tabLabel={'posts'}
data={rowData.get('posts')}
onPressPost={this.props.onPressPost}
onPressAvatar={this.props.onPressAvatar}
onPressSectionTag={this.props.onPressSectionTag}
onPressComment={this.props.onPressComment}
onPressLike={this.props.onPressLike}
onContentSizeChange={(width, height) => {}}
page={0}
endReachedViewHeight={this.initialPageHeight}
endReached={this.props.endReached}
/>
<CommunityList
ref={(c) => {
this.tab2 = c;
}}
tabLabel={'like'}
data={rowData.get('like')}
onPressPost={this.props.onPressPost}
onPressAvatar={this.props.onPressAvatar}
onPressSectionTag={this.props.onPressSectionTag}
onPressComment={this.props.onPressComment}
onPressLike={this.props.onPressLike}
onContentSizeChange={(width, height) => {}}
page={1}
endReachedViewHeight={this.initialPageHeight}
endReached={this.props.endReached}
/>
<ReplyList
ref={(c) => {
this.tab3 = c;
}}
tabLabel={'reply'}
data={rowData.get('reply')}
onPressAvatar={this.props.onPressAvatar}
onPressReply={this.props.onPressReply}
onPressPost={this.props.onPressPost}
onContentSizeChange={(width, height) => {}}
endReached={this.props.endReached}
endReachedViewHeight={this.initialPageHeight}
/>
</ScrollableTabView>
... ... @@ -320,9 +333,29 @@ export default class User extends React.Component {
}
let height = ref.state.contentHeight;
let item = this.getPageList(this.currentPage);
if (item.size == 0) {
height = height == 0 ? this.initialPageHeight : height;
}
return height;
}
getPageList(page) {
let item;
let list = this.props.list;
if (page == 0) {
item = list.get(0).get('posts');
} else if (page == 1) {
item = list.get(0).get('like');
} else {
item = list.get(0).get('reply');
}
return item;
}
render() {
let {userInfo, list, endReached, isRefreshing, isLoadingMore, isFetching, endReachedText} = this.props;
let dataSource = {
... ... @@ -330,6 +363,9 @@ export default class User extends React.Component {
list: list.toArray(),
};
let item = this.getPageList(this.currentPage);
let visible = item.size != 0;
return (
<View style={styles.container}>
<ListView
... ... @@ -351,8 +387,9 @@ export default class User extends React.Component {
}}
renderFooter={() => {
if (endReached) {
return <EmptyListTip
text={endReachedText}
return <LoadMoreIndicator
isVisible={visible}
text={'暂无更多'}
/>
} else {
return <LoadMoreIndicator
... ...
... ... @@ -37,7 +37,7 @@ export default class UserCenterTop extends React.Component {
render() {
let data = this.props.userInfo;
let {backgroundImage, avatar, nickName, sign,} = data;
console.log(backgroundImage);
return (
<View style={styles.container}>
<TouchableHighlight
... ... @@ -48,7 +48,7 @@ export default class UserCenterTop extends React.Component {
>
<SlicedImage
style={styles.backgroundImage}
defaultSource={require('../../images/user-bg.png')}
defaultSource={require('../../images/user/user-bg.png')}
source={{uri:backgroundImage}}
>
<TouchableOpacity
... ... @@ -58,7 +58,7 @@ export default class UserCenterTop extends React.Component {
>
<SlicedImage
style={styles.avatarImage}
defaultSource={require('../../images/avatar-default.png')}
defaultSource={require('../../images/avatar/avatar_default_no_border.png')}
source={{uri:avatar}}
/>
</TouchableOpacity>
... ...
... ... @@ -112,18 +112,23 @@ class UserNavBar extends React.Component {
setAnimationValue({ value, }) {
if (value >= 0 && value <= 2) {
if (value > 0.5 && value < 1) {
value = value + 0.1;
}
this.headerView.setNativeProps({
style: {
backgroundColor: this.headerColor(value),
},
});
value = value > 1 ? 1 : value;
this.image.setNativeProps({
style: {
opacity: value,
},
});
// value = value > 1 ? 1 : value;
// this.image.setNativeProps({
// style: {
// opacity: value,
// },
// });
}
}
... ... @@ -133,7 +138,7 @@ class UserNavBar extends React.Component {
const green = 255 + (0 - 255) * progress;
const blue = 255 + (0 - 255) * progress;
if (progress > 1) {
return `rgb(0,0,0)`; //`darkgray`
return `rgb(0, 0, 0)`; //`darkgray`
} else {
return `rgba(${red}, ${green}, ${blue}, ${progress})`;
}
... ...
... ... @@ -9,6 +9,7 @@ import UserCenterTop from '../user/UserCenterTop';
import ListCell from '../home/ListCell';
import LoadMoreIndicator from '../../../common/components/LoadMoreIndicator';
import UserNavBar from '../user/UserNavBar';
import EmptyListTip from '../user/EmptyListTip';
const {
View,
... ... @@ -20,6 +21,12 @@ const {
Animated,
} = ReactNative;
let {width, height} = Dimensions.get('window');
let navbarHeight = (Platform.OS === 'android') ? 50 : 64;
let userBgHieght = Math.ceil((490 / 750) * width);
let sectionBarHeight = 46;
export default class UserThatNotMe extends React.Component {
static propTypes = {
... ... @@ -81,6 +88,8 @@ export default class UserThatNotMe extends React.Component {
this.state = {
scrollValue: new Animated.Value(0),
};
this.initialPageHeight = height - userBgHieght;
}
componentDidMount() {
... ... @@ -98,6 +107,10 @@ export default class UserThatNotMe extends React.Component {
_renderSectionHeader(sectionData, sectionID) {
switch (sectionID) {
case 'posts':
if (this.props.endReached && this.props.posts.size == 0) {
return null;
}
return (
<View style={styles.sectionHeader}>
<Text style={styles.sectionHeaderText}>TA的发布</Text>
... ... @@ -168,15 +181,22 @@ export default class UserThatNotMe extends React.Component {
}}
renderFooter={()=>{
if (endReached) {
return <LoadMoreIndicator
if (posts.size == 0) {
return <EmptyListTip
style={{height: this.initialPageHeight}}
text={'TA还没有发布过帖子'}
/>
} else {
return <LoadMoreIndicator
isVisible={true}
text={'暂无更多'}
/>
}
} else {
return <LoadMoreIndicator
isVisible={isLoadingMore}
animating={isFetching}
/>
isVisible={isLoadingMore}
animating={isFetching}
/>
}
}}
/>
... ... @@ -192,7 +212,6 @@ export default class UserThatNotMe extends React.Component {
}
}
let {width, height} = Dimensions.get('window');
let styles = StyleSheet.create({
container: {
... ... @@ -200,7 +219,7 @@ let styles = StyleSheet.create({
},
sectionHeader: {
flexDirection: 'row',
height: 46,
height: sectionBarHeight,
alignItems: 'center',
backgroundColor: 'white',
},
... ...
... ... @@ -115,18 +115,18 @@ class UserContainer extends React.Component {
this.backgroundUploadObserver && this.backgroundUploadObserver.remove();
}
// private method
_onPressAvatar(url) {
console.log('avatar');
_onPressAvatar(uid) {
let {profile} = this.props.user;
if (profile.uid != uid) {
this.props.actions.goToUserThatNotMe(uid);
}
}
_onPressComment(id) {
console.log('comment');
this.props.actions.goToPost(id);
}
_onPressLike(post) {
console.log('like');
this.props.actions.likeOperation(post);
}
... ... @@ -135,7 +135,6 @@ class UserContainer extends React.Component {
}
_onPressPost(id) {
console.log('posts id =' + id);
this.props.actions.goToPost(id);
}
... ... @@ -159,23 +158,19 @@ class UserContainer extends React.Component {
}
_onPressGotoSettingState(buttonIndex) {
console.log('go to setting state');
switch (buttonIndex) {
case 0:
{
console.log('拍照');
YH_CommunityAssetsPicker.userImagePicker(PickerType.Avatar,SourceType.UIImagePickerControllerSourceTypeCamera, this.props.user.profile.uid + '');
}
break;
case 1:
{
console.log('从相册中选择');
YH_CommunityAssetsPicker.userImagePicker(PickerType.Avatar,SourceType.UIImagePickerControllerSourceTypePhotoLibrary, this.props.user.profile.uid+'');
}
break;
case 2:
{
console.log('编辑个人资料');
this.props.actions.goToSetting();
}
break;
... ...
... ... @@ -74,7 +74,7 @@ class UserThatNotMeContainer extends React.Component {
}
_onPressAvatar(uid) {
this.props.actions.goToUserOrMe(uid);
}
_onPressSectionTag(section) {
... ...