Authored by 于良

Merge branch 'local' into develop

'use strict'
/**
* 照片选择页面
*/
import React, {Component} from 'react';
import {
StyleSheet,
View,
TextInput,
Image,
Platform,
Dimensions,
Text,
TouchableOpacity,
Keyboard,
Animated,
Easing,
ScrollView,
TouchableOpacity,
Platform,
Dimensions,
StyleSheet,
NativeModules,
NativeAppEventEmitter,
CameraRoll,
} from 'react-native'
} from 'react-native';
let YH_CommunityAssetsPicker = NativeModules.YH_CommunityAssetsPicker;
export default class AssertsPicker extends Component {
constructor(props) {
super(props);
this.observer = null;
this.renderContent = this.renderContent.bind(this);
this.renderPlus = this.renderPlus.bind(this);
this.deleteAsset = this.deleteAsset.bind(this);
}
componentDidMount() {
this.observer = NativeAppEventEmitter.addListener('EventReminder', (event) => {
this.props.assetsSelected(event.assets);
})
}
componentWillUnmount() {
this.observer.remove();
}
renderPlus(assets) {
if (assets.length >= 9) {
return null;
}
let plusStyle = styles.itemContainer;
if (assets.length == 0) {
plusStyle = {
flex: 1,
alignItems: 'center',
justifyContent: 'center',
};
}
function renderPlus(assets) {
if (assets.length<9) {
return(
return (
<TouchableOpacity
style={styles.itemContainer}
onPress={()=>{YH_CommunityAssetsPicker.presentImagePicker(assets);}}
>
style={plusStyle}
onPress={() => {
YH_CommunityAssetsPicker.presentImagePicker(assets);
}}
>
<Image style={styles.item} source={require('../../images/posting/add.png')}/>
</TouchableOpacity>
);
}
}
function renderContent(assets, delAction) {
if (assets.length) {
return(
renderContent(assets) {
if (assets.length == 0) {
return this.renderPlus(assets);
}
return (
<ScrollView
style={styles.scroll}
contentContainerStyle={styles.scrollContainer}
horizontal={true}
>
<View style={styles.scrollContainer}>
{
assets.map((asset,index)=>{
return(
<View style={styles.itemContainer} key={index}>
<Image style={styles.item} source={asset}/>
<TouchableOpacity onPress={()=>{delAction(index);}}>
{assets.map((asset, index) => {
return (
<View style={styles.itemContainer} key={index}>
<Image style={styles.item} source={asset}/>
<TouchableOpacity onPress={() => {this.deleteAsset(index);}}>
<Image style={styles.itemDelete} source={require('../../images/posting/delete.png')}/>
</TouchableOpacity>
</View>
);
})
}
{renderPlus(assets)}
</View>
</TouchableOpacity>
</View>
);
})}
{this.renderPlus(assets)}
</ScrollView>
);
}else {
return(
<TouchableOpacity
style={{flex:1,alignItems:'center',justifyContent:'center',}}
onPress={()=>{YH_CommunityAssetsPicker.presentImagePicker(assets);}}
>
<Image style={styles.item} source={require('../../images/posting/add.png')}/>
</TouchableOpacity>
);
}
}
export default class AssertsPicker extends Component {
constructor(props) {
super(props);
this.observer;
this.deleteAsset=this.deleteAsset.bind(this);
}
componentDidMount() {
this.observer = NativeAppEventEmitter.addListener('EventReminder',(event)=>{
this.props.assetsSelected(event.assets);
})
}
componentWillUnmount() {
this.observer.remove();
}
deleteAsset(assetIndex) {
let existedAssets=this.props.assets;
existedAssets.splice(assetIndex,1);
let existedAssets = this.props.assets;
existedAssets.splice(assetIndex, 1);
this.props.assetsSelected(existedAssets);
YH_CommunityAssetsPicker.deleteAssetAtIndex(assetIndex);
}
render() {
return (
<View style={styles.container} opacity={this.props.opacityToHide>0}>
{renderContent(this.props.assets,this.deleteAsset)}
<Text style={styles.pageText}>{this.props.assets.length + '/9'} </Text>
<View style={styles.container} opacity={this.props.opacityToHide > 0}>
{this.renderContent(this.props.assets)}
<Text style={styles.pageText}>{this.props.assets.length + '/9'}</Text>
</View>
);
}
}
const styles = StyleSheet.create({
container:{
flex:1,
container: {
flex: 1,
},
scroll: {
flex:1,
height: 200,
},
scrollContainer: {
flex:1,
flexDirection:'row',
alignItems:'center',
paddingLeft: 15,
flexDirection: 'row',
alignItems: 'center',
paddingLeft: 24,
paddingRight: 12,
},
itemContainer: {
flexDirection: 'row',
width: 90,
height: 130,
right:10,
flexDirection:'row',
},
item: {
top:10,
width:80,
height:120,
backgroundColor:'#b0b0b0',
top: 10,
width: 80,
height: 120,
backgroundColor: '#b0b0b0',
},
itemDelete: {
width:20,
height:20,
left:-13
width: 20,
height: 20,
left: -13,
},
pageText: {
color: '#a0a0a0',
height: 41,
fontSize:14,
color: '#B0B0B0',
fontFamily: 'Helvetica Light',
fontSize: 13,
textAlign: 'center',
fontWeight:'100',
bottom: 15,
},
});
... ...
... ... @@ -120,45 +120,45 @@ export default class SubjectPost extends Component {
render() {
return(
<View style={styles.container}>
<Animated.View
style={[styles.contentInputContainer,{height:this.state.contentInputHeight}]}
>
<ListView
style={styles.container}
dataSource={this.dataSource.cloneWithRowsAndSections(this.props.dataBlob)}
renderRow={this.renderRow}
enableEmptySections={true}
onEndReached={() => {
this.props.onEndReached && this.props.onEndReached();
}}
renderFooter={()=>{
if (!this.props.dataBlob.comments.length) {
return <View style={styles.sofaContainer}>
<Image style={styles.sofaImage} source={require('../../images/posting/ic_null_message.png')}/>
<Text style={styles.sofaText}>快来抢沙发吧~</Text>
</View>
}
if (this.props.endReached) {
return <LoadMoreIndicator
isVisible={true}
text={'没有更多啦'}
/>
} else {
return <LoadMoreIndicator
isVisible={true}
animating={this.props.isFetching}
/>
}
}}
/>
{this.renderToolContainer(this.state.replyState)}
</Animated.View>
<AssertsPicker
style={[styles.boardSelectionContainer,{height:this.state.imageState,}]}
opacityToHide={this.state.imageState}
assets={this.props.assets}
assetsSelected={this.props.assetsSelected}
/>
<Animated.View
style={[styles.contentInputContainer,{height:this.state.contentInputHeight}]}
>
<ListView
style={styles.container}
dataSource={this.dataSource.cloneWithRowsAndSections(this.props.dataBlob)}
renderRow={this.renderRow}
enableEmptySections={true}
onEndReached={() => {
this.props.onEndReached && this.props.onEndReached();
}}
renderFooter={()=>{
if (!this.props.dataBlob.comments.length) {
return <View style={styles.sofaContainer}>
<Image style={styles.sofaImage} source={require('../../images/posting/ic_null_message.png')}/>
<Text style={styles.sofaText}>快来抢沙发吧~</Text>
</View>
}
if (this.props.endReached) {
return <LoadMoreIndicator
isVisible={true}
text={'没有更多啦'}
/>
} else {
return <LoadMoreIndicator
isVisible={true}
animating={this.props.isFetching}
/>
}
}}
/>
{this.renderToolContainer(this.state.replyState)}
</Animated.View>
{this.state.imageState == 0 ? null : <AssertsPicker
style={[styles.boardSelectionContainer,{height:this.state.imageState,}]}
opacityToHide={this.state.imageState}
assets={this.props.assets}
assetsSelected={this.props.assetsSelected}
/>}
</View>
);
}
... ... @@ -220,6 +220,8 @@ export default class SubjectPost extends Component {
</TouchableOpacity>
</View>
<View style={styles.toolTopLine}/>
<View style={styles.toolBottomLine}/>
</View>
);
}
... ... @@ -252,6 +254,8 @@ export default class SubjectPost extends Component {
/>
<Text style={styles.submitText} onPress={this.commitComment}>发送</Text>
</View>
<View style={styles.toolTopLine}/>
<View style={styles.toolBottomLine}/>
</View>
);
}
... ... @@ -284,6 +288,8 @@ export default class SubjectPost extends Component {
/>
<Text style={styles.submitText} onPress={this.commitComment}>发送</Text>
</View>
<View style={styles.toolTopLine}/>
<View style={styles.toolBottomLine}/>
</View>
);
}
... ... @@ -479,21 +485,6 @@ export default class SubjectPost extends Component {
this.currentReplyState = ReplyState.replySomeone;
this.setState({replyState: this.currentReplyState});
}
renderLikeAvatar(avatars) {
if (avatars.length) {
return (
<View style={styles.avatarPannel}>
{avatars.map((item, i)=> {
let headURI = item.headIcon||'';
return (
<SlicedImage key={i} style={[styles.likeAvatar,{right:10*i}]} source={{uri:headURI}}/>
);
})}
</View>
);
}
}
}
const styles = StyleSheet.create({
... ... @@ -502,51 +493,6 @@ const styles = StyleSheet.create({
flex: 1,
backgroundColor: 'white',
},
likePannel: {
backgroundColor: 'white',
height: 50,
borderColor: '#a0a0a0',
borderTopWidth: 0.5,
borderBottomWidth: 0.5,
paddingLeft: 15,
paddingRight: 15,
flexDirection: 'row',
},
likeContainer: {
height:50,
flex: 1,
flexDirection: 'row',
alignItems: 'center',
},
leftLikeContainer: {
height: 50,
flex: 1,
flexDirection: 'row',
alignItems: 'center',
},
avatarPannel: {
flexDirection: 'row-reverse',
justifyContent: 'flex-end',
},
rightLikeContainer: {
flex: 1,
flexDirection: 'row',
alignItems: 'center',
justifyContent: 'flex-end',
},
likeAvatar: {
width: 30,
height: 30,
borderRadius: 15,
},
likeText: {
fontSize: 14,
left: -10,
},
browseText: {
fontSize: 14,
paddingLeft: 15,
},
header: {
flexDirection: 'row',
paddingTop: 10,
... ... @@ -592,14 +538,27 @@ const styles = StyleSheet.create({
toolContainer: {
flexDirection: 'row',
height: 41,
borderColor: '#a0a0a0',
borderBottomWidth:0.5,
borderTopWidth:0.5,
alignItems:'center',
backgroundColor: 'white',
paddingLeft: 15,
paddingRight: 15,
},
toolTopLine: {
position: 'absolute',
left: 0,
top: 0,
width: width,
height: 0.5,
backgroundColor: '#e0e0e0',
},
toolBottomLine: {
position: 'absolute',
left: 0,
bottom: 0,
width: width,
height: 0.5,
backgroundColor: '#e0e0e0',
},
imgIcon: {
left:0,
width:19,
... ...
... ... @@ -219,7 +219,7 @@ let styles = StyleSheet.create({
},
sectionHeaderBottomLine: {
position: 'absolute',
left: 17,
left: 0,
bottom: 0,
width: width,
height: 0.5,
... ...
... ... @@ -258,7 +258,8 @@ let navbarHeight = (Platform.OS === 'android') ? 50 : 64;
let styles = StyleSheet.create({
container: {
top: navbarHeight,
height: height - navbarHeight - 49,
marginBottom: navbarHeight,
flex: 1,
},
});
... ...