Authored by 于良

Merge branch 'local' into develop

... ... @@ -69,13 +69,16 @@ export default class LoadingIndicator extends Component {
}
}
let {width, height} = Dimensions.get('window');
let navbarHeight = (Platform.OS === 'android') ? 50 : 64;
const styles = StyleSheet.create({
container: {
position: 'absolute',
backgroundColor: 'transparent',
justifyContent: 'center',
alignItems: 'center',
top: 0,
top: -navbarHeight,
bottom: 0,
left: 0,
right: 0,
... ...
... ... @@ -270,7 +270,7 @@ export default class Home extends React.Component {
}
render() {
let {progressing, banner, notice, section, recommendation, user, endReached, isRefreshing, isLoadingMore, isFetching} = this.props;
let {progressing, banner, notice, section, recommendation, user, endReached, isRefreshing, isLoadingMore, isFetching, isUserStateFetching} = this.props;
let dataSource = {
progressing: progressing.toArray(),
banner: banner.toArray(),
... ... @@ -313,7 +313,7 @@ export default class Home extends React.Component {
}}
/>
<LoadingIndicator
isVisible={false}
isVisible={isUserStateFetching}
/>
<SuperMan
uid={user.uid}
... ...
... ... @@ -8,11 +8,10 @@ import Notice from '../home/Notice';
import SectionTabBar from './SectionTabBar';
import ScrollableTabView, {DefaultTabBar} from 'react-native-scrollable-tab-view';
import SectionList from './SectionList';
import LoadingIndicator from '../../../common/components/LoadingIndicator';
import LoadMoreIndicator from '../../../common/components/LoadMoreIndicator';
import UploadProgress from '../home/UploadProgress';
import SuperMan from '../home/SuperMan';
import TimerMixin from 'react-timer-mixin';
import {Actions} from 'react-native-router-flux';
const {
View,
... ... @@ -294,7 +293,7 @@ export default class Section extends React.Component {
}
render() {
let {header, notice, list, user, endReached, isRefreshing, isLoadingMore, isFetching} = this.props;
let {header, notice, list, user, endReached, isRefreshing, isLoadingMore, isFetching, isUserStateFetching} = this.props;
let dataSource = {
progressing: this.props.progressing.toArray(),
header: header.toArray(),
... ... @@ -335,6 +334,9 @@ export default class Section extends React.Component {
}
}}
/>
<LoadingIndicator
isVisible={isUserStateFetching}
/>
<SuperMan
uid={user.uid}
avatar={user.avatar}
... ...
import React, {Component} from 'react';
import {
View,
Text,
Image,
TouchableOpacity,
StyleSheet,
Dimensions,
} from 'react-native'
import UserBrief from '../home/UserBrief';
import SubjectContent from './SubjectContent';
let {width, height} = Dimensions.get('window');
export default class SPCommentCell extends Component {
constructor(props) {
super(props);
this.renderDeleteCommentButton = this.renderDeleteCommentButton.bind(this);
}
renderDeleteCommentButton() {
let {data, cidFrom} = this.props;
let {LZ, cidTo, commentId} = data;
if (LZ || (cidTo == cidFrom)) {
return (
<TouchableOpacity
style={styles.delete}
onPress={()=>{
this.props.onPressDeleteComment && this.props.onPressDeleteComment(commentId);
}}
>
<Image
style={styles.deleteImage}
resizeMode={'contain'}
source={require('../../images/posting/ic_dian.png')}
/>
</TouchableOpacity>
)
} else {
return null;
}
}
render() {
let {headIcon, nickName, timeago, LZ, cidTo, commentId, blocks, replyTo} = this.props.data;
return (
<TouchableOpacity
style={styles.container}
onPress={() => {
this.props.onPressComment && this.props.onPressComment();
}}
>
<View>
<View style={styles.header}>
<View style={styles.userContainer}>
<UserBrief
avatar={headIcon}
name={nickName}
timeago={timeago}
isOwner={LZ}
onPressAvatar={this.props.onPressAvatar}
/>
</View>
{this.renderDeleteCommentButton(cidTo, commentId)}
</View>
<SubjectContent
contentWidth={width - 65}
left={20}
blocks={blocks}
replyTo={replyTo}
onPressAvatar={this.props.onPressAvatar}
/>
<View style={styles.separator}/>
</View>
</TouchableOpacity>
);
}
}
const styles = StyleSheet.create({
container: {
paddingTop: 10,
paddingLeft: 15,
paddingRight: 15,
backgroundColor: 'white',
},
separator: {
backgroundColor: '#a0a0a0',
height: 0.5,
width: width-30,
},
header: {
flexDirection: 'row',
},
userContainer: {
flex: 1,
flexDirection: 'row',
alignItems: 'center'
},
delete: {
width: 80,
height: 30,
alignItems: 'flex-end',
},
deleteImage: {
width: 20,
height: 20,
},
});
... ...
... ... @@ -17,7 +17,7 @@ export default class SPHeaderCell extends Component {
render() {
let {avatar, nickName, timeago, isOwner, sectionName, showLZ} = this.props;
return(
return (
<View style={styles.container}>
<View style={styles.top}>
<UserBrief
... ...
... ... @@ -23,8 +23,8 @@ export default class SPLikeCell extends React.Component {
headIcon: React.PropTypes.string,
uid: React.PropTypes.number,
})),
like: React.PropTypes.number,
browse: React.PropTypes.number,
like: React.PropTypes.string,
browse: React.PropTypes.string,
onPressLikeCell: React.PropTypes.func,
};
... ...
'use strict';
import React from 'react';
import ReactNative from 'react-native';
import ImmutablePropTypes from 'react-immutable-proptypes';
import SlicedImage from '../../../common/components/SlicedImage';
const {
View,
Text,
Image,
TouchableOpacity,
StyleSheet,
Dimensions,
} = ReactNative;
export default class SPShareGoodsCell extends React.Component {
constructor(props) {
super (props);
}
render() {
let {goodsImage, productName, salesPrice} = this.props.data;
return (
<TouchableOpacity onPress={() => {
this.props.onPressShareGoods && this.props.onPressShareGoods();
}}>
<View style={styles.container}>
<SlicedImage style={styles.shareGoodsImage} source={{uri: goodsImage}}/>
<View style={styles.shareGoodsRightPannel}>
<Text style={styles.productNameText}>{productName}</Text>
<Text style={styles.productPriceText}>{'¥' + salesPrice}</Text>
</View>
</View>
</TouchableOpacity>
);
}
}
let {width, height} = Dimensions.get('window');
let lineWidth = width - 30;
let styles = StyleSheet.create({
container: {
flexDirection: 'row',
paddingLeft: 15,
paddingBottom: 10,
backgroundColor: 'white',
},
shareGoodsImage: {
width: 52,
height: 70,
backgroundColor:'gray',
},
shareGoodsRightPannel: {
flexDirection: 'column',
paddingLeft: 10,
paddingTop: 5,
},
productNameText: {
fontSize: 15,
width: width - 52 - 30,
},
productPriceText: {
top: 10,
fontSize: 12,
color: '#d0021b',
},
});
... ...
... ... @@ -24,6 +24,9 @@ import PostingService from '../../services/PostingService';
import SPHeaderCell from './SPHeaderCell';
import SubjectContent from './SubjectContent';
import SPLikeCell from './SPLikeCell';
import SPShareGoodsCell from './SPShareGoodsCell';
import SPCommentCell from './SPCommentCell';
import LoadingIndicator from '../../../common/components/LoadingIndicator';
import LoadMoreIndicator from '../../../common/components/LoadMoreIndicator';
import AssertsPicker from '../posting/AssertsPicker';
import SlicedImage from '../../../common/components/SlicedImage';
... ... @@ -64,12 +67,14 @@ export default class SubjectPost extends Component {
this.renderToolContainer = this.renderToolContainer.bind(this);
this.someOneToReply = '';
this.replyToSomeOneElse = this.replyToSomeOneElse.bind(this);
this.renderDeleteCommentButton = this.renderDeleteCommentButton.bind(this);
this.commentId = '';
this.cidTo = '';
this.replyContent='';
this.commitComment = this.commitComment.bind(this);
this.cnameTo = '';
this.onPressComment = this.onPressComment.bind(this);
}
componentDidMount(){
... ... @@ -120,7 +125,15 @@ export default class SubjectPost extends Component {
let targetHeight = height-navbarHeight-0.5- this.boardHeight;
this.stretchContentInputToHeight(targetHeight, 250);
}
render() {
if (this.props.isContentFetching) {
return <LoadingIndicator
isVisible={this.props.isContentFetching}
/>
}
return(
<View style={styles.container}>
<Animated.View
... ... @@ -374,6 +387,7 @@ export default class SubjectPost extends Component {
this.replyContent = '';
this.blurAll();
}
renderRow(rowData, sectionId) {
switch (sectionId) {
case 'header':
... ... @@ -407,15 +421,10 @@ export default class SubjectPost extends Component {
break;
case 'shareGoods':
return (
<TouchableOpacity onPress={this.props.onPressShareGoods}>
<View style={styles.shareGoodsContainer}>
<SlicedImage style={styles.shareGoodsImage} source={{uri:rowData.goodsImage}}/>
<View style={styles.shareGoodsRightPannel}>
<Text style={styles.productNameText}>{rowData.productName}</Text>
<Text style={styles.productPriceText}>{'¥'+rowData.salesPrice}</Text>
</View>
</View>
</TouchableOpacity>
<SPShareGoodsCell
data={rowData}
onPressShareGoods={this.props.onPressShareGoods}
/>
);
break;
case 'like':
... ... @@ -432,23 +441,36 @@ export default class SubjectPost extends Component {
break;
case 'comments':
return (
<TouchableOpacity
style={styles.commentContainer}
onPress={
()=> {
this.cidTo = rowData.cidTo;
this.cnameTo = rowData.nickName;
this.commentId = rowData.commentId;
<SPCommentCell
data={rowData}
cidFrom={this.props.cidFrom}
onPressAvatar={this.props.onPressAvatar}
onPressComment={() => {
this.onPressComment(rowData.cidTo, rowData.nickName, rowData.commentId);
}}
/>
);
break;
default:
return null;
break;
}
}
onPressComment(cidTo, nickName, commentId) {
this.cidTo = cidTo;
this.cnameTo = nickName;
this.commentId = commentId;
NativeModules.YH_CommunityHelper.uid()
.then(uid => {
new PostingService().getPostUser(uid).then(json => {
if (json.forbidSpeaking === 'Y') {
Alert.alert('抱歉','您暂时被禁言,请等待禁言解除哦~');
} else {
this.replyToSomeOneElse(rowData.nickName);
this.replyToSomeOneElse(nickName);
}
}).catch(error => {
this.replyToSomeOneElse(rowData.nickName);
this.replyToSomeOneElse(nickName);
})
})
.catch(error => {
... ... @@ -458,59 +480,15 @@ export default class SubjectPost extends Component {
if (json.forbidSpeaking === 'Y') {
Alert.alert('抱歉','您暂时被禁言,请等待禁言解除哦~');
} else {
this.replyToSomeOneElse(rowData.nickName);
this.replyToSomeOneElse(nickName);
}
}).catch(error => {
this.replyToSomeOneElse(rowData.nickName);
this.replyToSomeOneElse(nickName);
})
});
});
}
}
>
<View>
<View style={{flexDirection:'row'}}>
<View style={{flex:1,flexDirection: 'row',alignItems:'center'}}>
<UserBrief
avatar={rowData.headIcon}
name={rowData.nickName}
timeago={rowData.timeago}
isOwner={rowData.LZ}
onPressAvatar={() => {
this.props.onPressAvatar && this.props.onPressAvatar();
}}
/>
</View>
{this.renderDeleteCommentButton(rowData.cidTo,rowData.commentId)}
</View>
<SubjectContent contentWidth={width-65} left={20} blocks={rowData.blocks} replyTo={rowData.replyTo} onPressAvatar={this.props.onPressAvatar}/>
<View style={styles.commentSeparator}/>
</View>
</TouchableOpacity>
);
break;
default:
return null;
break;
}
}
renderDeleteCommentButton(commentUserId,id) {
if (this.props.dataBlob.header[0].LZ||(commentUserId == this.props.cidFrom)) {
return(
<TouchableOpacity
style={{width:80,height:30,alignItems:'flex-end'}}
onPress={()=>{
this.props.onPressDeleteComment&&this.props.onPressDeleteComment(id);
}}
>
<Image style={{width:20,height:20}} resizeMode={'contain'} source={require('../../images/posting/ic_dian.png')}/>
</TouchableOpacity>
)
}
}
replyToSomeOneElse(someOne) {
this.someOneToReply = someOne;
... ... @@ -532,17 +510,6 @@ const styles = StyleSheet.create({
backgroundColor: 'white',
paddingLeft: 15,
},
commentContainer: {
paddingTop: 10,
paddingLeft: 15,
paddingRight: 15,
backgroundColor: 'white',
},
commentSeparator: {
backgroundColor: '#a0a0a0',
height: 0.5,
width: width-30,
},
headerRight: {
flex: 1,
flexDirection: 'row',
... ...
... ... @@ -233,6 +233,7 @@ class HomeContainer extends React.Component {
let containerStyle = parseInt(this.props.app.container) === 1 ? null : {marginBottom: 64};
let scrollToTop = false;
if (this.props.route.scene && this.props.route.scene.sceneKey == 'Posting') {
if (this.props.posting.canSubmit) {
... ... @@ -240,6 +241,8 @@ class HomeContainer extends React.Component {
}
}
let isUserStateFetching = this.props.posting.userState.isFetching && this.props.route.scene.sceneKey == 'Home';
return (
<View style={[styles.container, containerStyle]}>
<Home
... ... @@ -265,7 +268,6 @@ class HomeContainer extends React.Component {
onPressLike={this._onPressLike}
onRefresh={this._onRefresh}
isFetching={recommendation.isFetching}
ptr={ptr}
endReached={recommendation.endReached}
isRefreshing={isFetching}
isLoadingMore={!ptr && recommendation.isFetching}
... ... @@ -274,8 +276,8 @@ class HomeContainer extends React.Component {
onUploadRetry={this._onUploadRetry}
onUploadDelete={this._onUploadDelete}
onSaveingTheWorld={this._onSaveingTheWorld}
ptrError={error}
scrollToTop={scrollToTop}
isUserStateFetching={isUserStateFetching}
/>
</View>
);
... ...
... ... @@ -145,23 +145,15 @@ class SectionContainer extends React.Component {
}
_onUploadSuccess() {
this.props.actions.resetState();
console.log('upload success!');
}
_onUploadRetry() {
this.props.actions.startPosting(this.props.posting.assets.toJS());
console.log('upload retry!');
this.props.actions.startPosting();
}
_onUploadDelete() {
this.props.actions.resetState();
console.log('upload delete!');
}
render() {
... ... @@ -217,6 +209,8 @@ class SectionContainer extends React.Component {
}
}
let isUserStateFetching = this.props.posting.userState.isFetching && this.props.route.scene.sceneKey == 'Section';
return (
<View style={styles.container}>
<Section
... ... @@ -243,6 +237,7 @@ class SectionContainer extends React.Component {
onEndReached={this._onEndReached}
onSaveingTheWorld={this._onSaveingTheWorld}
scrollToTop={scrollToTop}
isUserStateFetching={isUserStateFetching}
/>
</View>
);
... ...
... ... @@ -229,10 +229,10 @@ class SubjectPostContainer extends Component {
like: [likeData],
comments: item.commentList.toJS(),
};
return (
<View style={styles.container}>
{
item.isContentFetching?null:<SubjectPost
<SubjectPost
dataBlob={dataBlob}
onEndReached={this.onEndReached}
endReached={item.commentReachEnd}
... ... @@ -253,9 +253,8 @@ class SubjectPostContainer extends Component {
onPressShareGoods={this.onPressShareGoods}
onPressLargeImage={this.onPressLargeImage}
onPressDeleteComment={this.onPressDeleteComment}
isContentFetching={item.isContentFetching}
/>
}
</View>
);
}
... ...