Showing
5 changed files
with
19 additions
and
12 deletions
@@ -22,6 +22,10 @@ export default class SlicedImage extends React.Component { | @@ -22,6 +22,10 @@ export default class SlicedImage extends React.Component { | ||
22 | this.mode = 1; | 22 | this.mode = 1; |
23 | } | 23 | } |
24 | 24 | ||
25 | + setNativeProps(nativeProps) { | ||
26 | + this._root.setNativeProps(nativeProps); | ||
27 | + } | ||
28 | + | ||
25 | _generateImageUrl(src) { | 29 | _generateImageUrl(src) { |
26 | let style = StyleSheet.flatten(this.props.style); | 30 | let style = StyleSheet.flatten(this.props.style); |
27 | let {width, height} = style; | 31 | let {width, height} = style; |
@@ -36,7 +40,7 @@ export default class SlicedImage extends React.Component { | @@ -36,7 +40,7 @@ export default class SlicedImage extends React.Component { | ||
36 | .replace('{height}', height); | 40 | .replace('{height}', height); |
37 | } | 41 | } |
38 | 42 | ||
39 | - // __DEV__ && console.log(newSrc); | 43 | + __DEV__ && console.log(newSrc); |
40 | 44 | ||
41 | return newSrc; | 45 | return newSrc; |
42 | } | 46 | } |
@@ -55,12 +59,12 @@ export default class SlicedImage extends React.Component { | @@ -55,12 +59,12 @@ export default class SlicedImage extends React.Component { | ||
55 | if (source && source.uri && this._isRemoteImageSrc(source.uri)) { | 59 | if (source && source.uri && this._isRemoteImageSrc(source.uri)) { |
56 | let uri = this._generateImageUrl(source.uri); | 60 | let uri = this._generateImageUrl(source.uri); |
57 | return ( | 61 | return ( |
58 | - <Image {...this.props} source={{uri}}/> | 62 | + <Image ref={component => this._root = component} {...this.props} source={{uri}}/> |
59 | ); | 63 | ); |
60 | } | 64 | } |
61 | 65 | ||
62 | return ( | 66 | return ( |
63 | - <Image {...this.props}/> | 67 | + <Image ref={component => this._root = component} {...this.props}/> |
64 | ); | 68 | ); |
65 | } | 69 | } |
66 | } | 70 | } |
@@ -54,13 +54,14 @@ export default class SuperMan extends React.Component { | @@ -54,13 +54,14 @@ export default class SuperMan extends React.Component { | ||
54 | render() { | 54 | render() { |
55 | let avatarContainerStyle = this.props.uid > 0 ? styles.avatarContainer : null; | 55 | let avatarContainerStyle = this.props.uid > 0 ? styles.avatarContainer : null; |
56 | let avatarStyle = this.props.uid > 0 ? styles.avatarBorder : null; | 56 | let avatarStyle = this.props.uid > 0 ? styles.avatarBorder : null; |
57 | + let defaultSource = this.props.uid > 0 ? null : require('../../images/home/superman.png'); | ||
57 | return ( | 58 | return ( |
58 | <View style={[styles.container, this.props.fly]}> | 59 | <View style={[styles.container, this.props.fly]}> |
59 | <TouchableOpacity activeOpacity={0.8} onPress={() => { | 60 | <TouchableOpacity activeOpacity={0.8} onPress={() => { |
60 | this.props.onSaveingTheWorld && this.props.onSaveingTheWorld(); | 61 | this.props.onSaveingTheWorld && this.props.onSaveingTheWorld(); |
61 | }}> | 62 | }}> |
62 | <View style={avatarContainerStyle}> | 63 | <View style={avatarContainerStyle}> |
63 | - <SlicedImage style={[styles.avatar, avatarStyle]} source={{uri: this.props.avatar}} resizeMode={'cover'} defaultSource={require('../../images/home/superman.png')}/> | 64 | + <SlicedImage style={[styles.avatar, avatarStyle]} source={{uri: this.props.avatar}} resizeMode={'cover'} defaultSource={defaultSource}/> |
64 | </View> | 65 | </View> |
65 | {this.renderText()} | 66 | {this.renderText()} |
66 | {this.renderMsgCount()} | 67 | {this.renderMsgCount()} |
@@ -80,7 +80,6 @@ export default class UploadProgress extends React.Component { | @@ -80,7 +80,6 @@ export default class UploadProgress extends React.Component { | ||
80 | } | 80 | } |
81 | 81 | ||
82 | return ( | 82 | return ( |
83 | - | ||
84 | <Animated.View style={[styles.container, {opacity: this.state.fadeAnim,}]}> | 83 | <Animated.View style={[styles.container, {opacity: this.state.fadeAnim,}]}> |
85 | <Image | 84 | <Image |
86 | style={styles.image} | 85 | style={styles.image} |
@@ -99,7 +98,7 @@ export default class UploadProgress extends React.Component { | @@ -99,7 +98,7 @@ export default class UploadProgress extends React.Component { | ||
99 | style={styles.bar} | 98 | style={styles.bar} |
100 | /> | 99 | /> |
101 | {this._renderButton(uploadState)} | 100 | {this._renderButton(uploadState)} |
102 | - </Animated.View > | 101 | + </Animated.View> |
103 | ); | 102 | ); |
104 | } | 103 | } |
105 | 104 |
@@ -3,6 +3,7 @@ | @@ -3,6 +3,7 @@ | ||
3 | import React from 'react'; | 3 | import React from 'react'; |
4 | import ReactNative from 'react-native'; | 4 | import ReactNative from 'react-native'; |
5 | import ImmutablePropTypes from 'react-immutable-proptypes'; | 5 | import ImmutablePropTypes from 'react-immutable-proptypes'; |
6 | +import SlicedImage from '../../../common/components/SlicedImage'; | ||
6 | 7 | ||
7 | const { | 8 | const { |
8 | View, | 9 | View, |
@@ -43,7 +44,7 @@ export default class UserCenterTop extends React.Component { | @@ -43,7 +44,7 @@ export default class UserCenterTop extends React.Component { | ||
43 | this.props.onPressBackgroundImg && this.props.onPressBackgroundImg(); | 44 | this.props.onPressBackgroundImg && this.props.onPressBackgroundImg(); |
44 | }} | 45 | }} |
45 | > | 46 | > |
46 | - <Image | 47 | + <SlicedImage |
47 | style={styles.backgroundImage} | 48 | style={styles.backgroundImage} |
48 | defaultSource={require('../../images/user-bg.png')} | 49 | defaultSource={require('../../images/user-bg.png')} |
49 | source={{uri:backgroundImage}} | 50 | source={{uri:backgroundImage}} |
@@ -53,12 +54,11 @@ export default class UserCenterTop extends React.Component { | @@ -53,12 +54,11 @@ export default class UserCenterTop extends React.Component { | ||
53 | this.props.onPressUserAvatar && this.props.onPressUserAvatar(); | 54 | this.props.onPressUserAvatar && this.props.onPressUserAvatar(); |
54 | }} | 55 | }} |
55 | > | 56 | > |
56 | - <Image | 57 | + <SlicedImage |
57 | style={styles.avatarImage} | 58 | style={styles.avatarImage} |
58 | defaultSource={require('../../images/avatar-default.png')} | 59 | defaultSource={require('../../images/avatar-default.png')} |
59 | source={{uri:avatar}} | 60 | source={{uri:avatar}} |
60 | - > | ||
61 | - </Image> | 61 | + /> |
62 | </TouchableOpacity> | 62 | </TouchableOpacity> |
63 | <Text | 63 | <Text |
64 | style={styles.name} | 64 | style={styles.name} |
@@ -71,7 +71,7 @@ export default class UserCenterTop extends React.Component { | @@ -71,7 +71,7 @@ export default class UserCenterTop extends React.Component { | ||
71 | > | 71 | > |
72 | {sign} | 72 | {sign} |
73 | </Text> | 73 | </Text> |
74 | - </Image> | 74 | + </SlicedImage> |
75 | </TouchableHighlight> | 75 | </TouchableHighlight> |
76 | </View> | 76 | </View> |
77 | ); | 77 | ); |
@@ -55,7 +55,10 @@ export function goAction(inputUrl) { | @@ -55,7 +55,10 @@ export function goAction(inputUrl) { | ||
55 | } | 55 | } |
56 | 56 | ||
57 | } else if (action == 'go.comm.postdetail') { | 57 | } else if (action == 'go.comm.postdetail') { |
58 | - let id = params && params.postId ? params.postId : 0; | 58 | + let id = params && params.postid ? params.postid : 0; |
59 | + if (id == 0) { | ||
60 | + id = params && params.postId ? params.postId : 0; | ||
61 | + } | ||
59 | if (id != 0) { | 62 | if (id != 0) { |
60 | dispatch(goToPost(id)); | 63 | dispatch(goToPost(id)); |
61 | } | 64 | } |
-
Please register or login to post a comment