-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathCustomizeExample.tsx
132 lines (108 loc) · 3.42 KB
/
CustomizeExample.tsx
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
/**
* Created by syjmac on 2017/9/19.
*/
/**
* Sample React Native App
* https://github.com/facebook/react-native
* @flow
*/
import * as React from "react";
import {StyleSheet, Text, View, Button, Image} from "react-native";
import CheckBoxGroup,{SelectedStatus} from "../checkBoxGroup";
const uri='data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADMAAAAzCAYAAAA6oTAqAAAAEXRFWHRTb2Z0d2FyZQBwbmdjcnVzaEB1SfMAAABQSURBVGje7dSxCQBACARB+2/ab8BEeQNhFi6WSYzYLYudDQYGBgYGBgYGBgYGBgYGBgZmcvDqYGBgmhivGQYGBgYGBgYGBgYGBgYGBgbmQw+P/eMrC5UTVAAAAABJRU5ErkJggg=='
export default class MyAwesomeProject extends React.Component<object, {a:number}> {
refs:{
[k:string]:any
};
renderCheckBox=(isSel:boolean)=>{
return <View style={{flex:1,width:24,backgroundColor:isSel?"#4ce40d":"#e08c0d",justifyContent:"center"}}>
<Text>{isSel?"On":"Off"}</Text>
</View>
}
rowTemplate=(checkbox:React.ReactElement<any>,item:React.ReactElement<any>,key:string)=>{
return <View style={{borderWidth:1,borderColor:"red",marginBottom:6}}>
<View style={{flexDirection:"row"}}>
{checkbox}
{item}
</View>
<View style={{backgroundColor:"yellow"}}><Text>bottom bar {key}</Text></View>
</View>
}
render() {
return (
<View style={styles.container} >
<Button title="toggle whole checkboxgroup2"
onPress={()=>{
this.refs.checkgp.toggle()
}}></Button>
<CheckBoxGroup rowTemplate = {this.rowTemplate}
renderCheckBox={this.renderCheckBox}
renderTitle={()=>{
return <View style={{backgroundColor:"#a0ff1b"}}><Text>Outter Group Title</Text></View>
}}
key="OuterGP"
style={{backgroundColor:"transparent",padding:5}}
ref="checkgp" identifier="OuterGroup"
onChange={(v:SelectedStatus)=>{
console.log(v)
}}
>
<CheckBoxGroup style={{borderColor:"blue",borderWidth:1,marginBottom:20,padding:5}}
renderTitle={()=>{
return <View style={{backgroundColor:"#a0ff1b"}}><Text>Inner Group Title</Text></View>
}}
key="AGroup"
>
<View style={[styles.item]} key="A1">
<Text>A1 balabala...</Text>
<Image style={styles.img}
source={{uri:uri}}></Image>
</View>
<View style={[styles.item]} key="A2">
<Text>A2 balabala. 111..</Text>
<Image style={styles.img}
source={{uri:uri}}></Image>
</View>
<View style={[styles.item]} key="A3">
<Text>A3 balabala..333.</Text>
<Image style={styles.img}
source={{uri:uri}}></Image>
</View>
<Text key="A">Grouo Item A</Text>
<Text key="AA">Grouo Item AA</Text>
<Text key="AAA">Grouo Item AAA</Text>
</CheckBoxGroup>
<Text key="B">Item B</Text>
<Text key="BB">Item BB</Text>
<Text key="BBB">Item BBB</Text>
</CheckBoxGroup>
</View>
);
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
backgroundColor: '#F5FCFF',
},
welcome: {
fontSize: 20,
textAlign: 'center',
margin: 10,
},
instructions: {
textAlign: 'center',
color: '#333333',
marginBottom: 5,
},
item:{
height:100,
width:300,
backgroundColor:"green"
},
img:{
width:66,height:58
}
});