TagItemView.js
5.87 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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
import React, {Component} from 'react';
import {
View,
Text,
TouchableOpacity, Image, ScrollView, Modal, StyleSheet
} from 'react-native';
const defaultHeight = (30);
const HPading = (16);
const VPading = (6);
/**
* 标签
*/
export default class TagItemView extends Component {
constructor(props) {
super(props);
this.state = {
showModal:false,
tagDataList:[],// 标签列表
}
this.attrData = this.props.attrData;
}
componentWillMount() {
}
showModal() {
this.setState({
showModal: true,
});
}
/**
* 模态框取消操作
*/
closeModal() {
this.setState({
showModal: false,
});
}
render() {
let {name, labelName, labelColor} = this.attrData;
return (
<View>
<TouchableOpacity
style={{width: '100%', backgroundColor: 'white', flexDirection: 'row', paddingVertical: 10, paddingHorizontal: 6, alignItems: 'center'}}
activeOpacity={0.8}
onPress={()=> {
this.showModal();
}}
>
<Text style={{fontSize: 16, color: 'rgba(0, 0, 0, 1)'}}>{name|| '标签'}</Text>
<View style={{flex: 1, justifyContent: 'flex-end', alignItems: 'center', flexDirection: 'row'}}>
{!!labelName && labelName.length > 0 &&
<Text
style={{
fontSize: 14,
color: 'white',
backgroundColor: labelColor||'rgba(255, 141, 26, 1)',
paddingVertical: 3,
paddingHorizontal: 10,
borderRadius: 4
}}
>{labelName}</Text>}
{labelName === undefined || labelName.length === 0 &&
<Text style={{fontSize: 14, color: 'rgba(166, 166, 166, 1)'}}>添加标签</Text>}
<Image style={{width: 16, height: 16, marginLeft: 10}} source={require('../img/bread.png')} resizeMode={'contain'}/>
</View>
</TouchableOpacity>
<Modal animationType={"fade"} transparent={true} visible={this.state.showModal} onRequestClose={() => this.closeModal()}>
{/** 目录弹窗 */}
<View style={{flex: 1}}>
<TouchableOpacity style={styles.modalBg} activeOpacity={1} onPress={() => this.closeModal()}/>
{/** 实体内容 */}
<View style={styles.contentBg}>
{/** 标题栏 */}
<View style={styles.titleBar}>
<TouchableOpacity
style={{paddingLeft: 15, paddingRight: 5}}
activeOpacity={0.8}
onPress={() => this.closeModal()}
>
<Image style={{width: 14, height: 14}}
source={require('../img/loadBack.png')}/>
</TouchableOpacity>
<Text style={styles.modelTitle}>添加标签</Text>
<TouchableOpacity
style={{
justifyContent: "center",
alignItems: "center",
paddingVertical: 3,
paddingHorizontal: 8,
}}
activeOpacity={0.8}
onPress={() => {
this.props.navigation.navigate("CreateTagView");
this.closeModal();
}}
>
<Text style={{fontSize: 16, color: global.homeColor}}>+新增</Text>
</TouchableOpacity>
</View>
<View style={{width: '100%', height: 1, backgroundColor: 'rgba(245,245,245,1)'}}/>
{/** 内容 */}
{!!this.state.tagDataList && this.state.tagDataList.length > 0 && <View></View>
}
{/*<ScrollView style={{flex: 1}} horizontal={false} showsVerticalScrollIndicator={false}>
{this.state.options && this.state.options.map((value, index) => this.renderCheckboxItem(value, index))}
</ScrollView>*/}
</View>
</View>
</Modal>
</View>
);
}
}
const styles = StyleSheet.create({
modalBg: {
backgroundColor: 'rgba(0,0,0,.5)',
width: '100%',
height: '100%',
display: 'flex',
position: 'absolute'
},
contentBg: {
width: '100%',
flex: 1,
marginTop: 122,
backgroundColor: "rgba(255, 255, 255, 1)",
borderTopLeftRadius: 16,
borderTopRightRadius: 16
},
titleBar: {
flexDirection: "row",
justifyContent: "flex-start",
alignItems: "center",
marginTop: 15,
marginBottom: 10,
marginRight: 15
},
modelTitle: {
flex: 1,
color: "rgba(0, 0, 0, 1)",
fontSize: 16,
textAlign: "center",
justifyContent: "center"
},
checkedBox: {
width: 20,
height: 20,
marginLeft: 8,
marginRight: 8
},
});