NavBarTitle.js
3.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
'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,
},
});