|
|
'use strict';
|
|
|
|
|
|
import React from 'react';
|
|
|
import ReactNative from 'react-native';
|
|
|
|
|
|
const {
|
|
|
View,
|
|
|
Text,
|
|
|
Image,
|
|
|
TouchableOpacity,
|
|
|
StyleSheet,
|
|
|
Animated,
|
|
|
Dimensions,
|
|
|
Platform,
|
|
|
} = ReactNative;
|
|
|
|
|
|
let {width, height} = Dimensions.get('window');
|
|
|
let titleMarginLeft = Math.ceil(70 * width / 320);
|
|
|
let titleWidth = Math.ceil(180 * width / 320);
|
|
|
let titleItemWidth = Math.ceil(titleWidth / 3) - 3;
|
|
|
|
|
|
export default class NavBarTitle extends React.Component {
|
|
|
|
|
|
constructor(props) {
|
|
|
super (props);
|
|
|
|
|
|
}
|
|
|
|
|
|
render() {
|
|
|
let index = this.props.index;
|
|
|
|
|
|
return (
|
|
|
<Animated.View
|
|
|
style={[
|
|
|
styles.title,
|
|
|
{
|
|
|
opacity: this.props.position.interpolate({
|
|
|
inputRange: [index - 1, index, index + 1],
|
|
|
outputRange: [0, this.props.titleOpacity, 0],
|
|
|
}),
|
|
|
left: this.props.position.interpolate({
|
|
|
inputRange: [index - 1, index + 1],
|
|
|
outputRange: [200, -200],
|
|
|
}),
|
|
|
right: this.props.position.interpolate({
|
|
|
inputRange: [index - 1, index + 1],
|
|
|
outputRange: [-200, 200],
|
|
|
}),
|
|
|
},
|
|
|
]}>
|
|
|
<TouchableOpacity onPress={() => {
|
|
|
ReactNative.NativeModules.YH_CommunityHelper.hideRNNavBar(0);
|
|
|
}}>
|
|
|
<Text style={[styles.text, {}]}>逛</Text>
|
|
|
</TouchableOpacity>
|
|
|
|
|
|
<View style={[{}]}>
|
|
|
<Text style={[styles.text, {marginLeft: -10.5}]}>社区</Text>
|
|
|
<Image
|
|
|
style={{
|
|
|
position: 'absolute',
|
|
|
left: titleItemWidth / 2,
|
|
|
top: -10,
|
|
|
width: 20,
|
|
|
height: 10,
|
|
|
marginLeft: -10
|
|
|
}}
|
|
|
resizeMode={'contain'}
|
|
|
source={require('../../images/home/nav_new.png')}
|
|
|
/>
|
|
|
</View>
|
|
|
|
|
|
<TouchableOpacity onPress={() => {
|
|
|
ReactNative.NativeModules.YH_CommunityHelper.hideRNNavBar(2);
|
|
|
}}>
|
|
|
<Image style={{left: -5.5, top: -0.5}} source={require('../../images/home/sd_show_ic.png')}/>
|
|
|
<Image
|
|
|
style={{
|
|
|
position: 'absolute',
|
|
|
left: titleItemWidth / 2 + 0,
|
|
|
top: -10,
|
|
|
width: 20,
|
|
|
height: 10,
|
|
|
}}
|
|
|
resizeMode={'contain'}
|
|
|
source={require('../../images/home/nav_hot.png')}
|
|
|
/>
|
|
|
</TouchableOpacity>
|
|
|
|
|
|
<View style={{
|
|
|
backgroundColor: 'white',
|
|
|
position: 'absolute',
|
|
|
width: 45,
|
|
|
height: 2,
|
|
|
left: (titleWidth - 45) / 2 + 0,
|
|
|
top: 30,
|
|
|
}}/>
|
|
|
</Animated.View>
|
|
|
);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
let styles = StyleSheet.create({
|
|
|
title: {
|
|
|
flexDirection: 'row',
|
|
|
justifyContent: 'space-between',
|
|
|
alignItems: 'center',
|
|
|
width: titleWidth,
|
|
|
marginTop: 12,
|
|
|
marginLeft: titleMarginLeft,
|
|
|
position: 'absolute',
|
|
|
...Platform.select({
|
|
|
ios: {
|
|
|
top: 20,
|
|
|
},
|
|
|
android: {
|
|
|
top: 5,
|
|
|
},
|
|
|
}),
|
|
|
left: 0,
|
|
|
right: 0,
|
|
|
backgroundColor: 'transparent',
|
|
|
},
|
|
|
text: {
|
|
|
textAlign: 'center',
|
|
|
fontSize: 18,
|
|
|
fontWeight: 'bold',
|
|
|
color: '#ffffff',
|
|
|
width: titleItemWidth,
|
|
|
marginTop: 1,
|
|
|
},
|
|
|
}); |
...
|
...
|
|