-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
121 lines (102 loc) · 3.26 KB
/
index.js
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
{/* RN引用区 */}
import React, { Component,PropTypes} from 'react';
import {
StyleSheet,
View,
Text,
TextInput,
TouchableOpacity,
Image,
Platform,
Keyboard,PixelRatio,Dimensions
} from 'react-native';
{/* 自定义引用区 */}
var size = Dimensions.get('window');
{/* 类实现 */}
export default class RightArrowView extends Component {
/* props定义 */
static defaultProps = {
title : '', //标题
subTitle:'', //副标题
isLine : true, //是否显示分割线
titleWidth : 80, //标题宽度
subtitleWidth : 100, //副标题宽度
lineAlign : 'right',//分割线位置
titleFontSize : 16,//标题文字大小
subTitleFontSize : 14,//输入框文字大小
isTouch : true , //是否触发点击事件
selectStyle : 'Custom',//点击类型 (默认为自定义 如果是地区选择 传:Area)
onClick(){} // 回调方法
}
static propTypes = {
title : PropTypes.string,
subTitle : PropTypes.string,
isLine : PropTypes.bool,
titleWidth : PropTypes.number,
subtitleWidth : PropTypes.number,
isDefaultImage : PropTypes.bool,
lineAlign : PropTypes.string,
titleFontSize : PropTypes.number,
subTitleFontSize : PropTypes.number,
isTouch : PropTypes.bool,
selectStyle : PropTypes.string,
onClick : PropTypes.func,
imageSource:PropTypes.node
}
/* 构造函数 */
constructor (props) {
super(props);
}
/* 页面布局 */
render() {
return(
<View>
<TouchableOpacity activeOpacity={0.8} style={this.props.style} onPress={this.onClick.bind(this)}>
<View style={styles.parentStyle}>
<Text style={[styles.textStyle,{width:this.props.titleWidth}]}>{this.props.title}</Text>
<Text style={styles.subTitleStyle}>{this.props.subTitle}</Text>
<Image style ={{width:9,height:16}} source={!this.props.imageSource?require('./Cell-Arrow.png'):this.props.imageSource}/>
</View>
{
this.props.isLine? <View style={[styles.lineStyle,this.props.lineAlign=='right'?{marginLeft:15}:this.props.lineAlign=='center'?{marginHorizontal:15}:{marginRight:15}]}></View>:null
}
</TouchableOpacity>
</View>
);
}
/*点击事件*/
onClick(){
let _this=this;
return _this.props.onClick();
}
}
{/* 布局样式 */}
const styles = StyleSheet.create({
parentStyle:{
flex:1,
flexDirection : 'row',
backgroundColor : '#fff',
alignItems:'center',
width : size.width,
paddingLeft:15,
paddingRight:15
},
subTitleStyle:{
flex:1,
backgroundColor:'#fff',
marginLeft:15,
marginRight:15,
color:'#C7C7C7',
textAlign: 'right',
fontSize:15,
},
textStyle:{
fontSize:16,
color:'#181818',
marginLeft:0,
},
lineStyle:{
borderBottomWidth:1/PixelRatio.get(),
borderBottomColor:'#d2d2d2'
},
})