1
1
import _ from 'lodash' ;
2
2
import React , { Component } from 'react' ;
3
3
import { Alert } from 'react-native' ;
4
- import { Chip , Colors , Spacings , Text , Typography , View , Dialog , WheelPickerDialog } from 'react-native-ui-lib' ;
4
+ import { Chip , Colors , Spacings , Text , Typography , View , Dialog , WheelPickerDialog , Image } from 'react-native-ui-lib' ;
5
5
6
6
const avatarImage = {
7
7
uri : 'https://randomuser.me/api/portraits/women/24.jpg'
8
8
} ;
9
9
const checkmark = require ( '../../assets/icons/check-small.png' ) ;
10
10
const chevron = require ( '../../assets/icons/chevronDown.png' ) ;
11
-
11
+ const bell = require ( '../../assets/icons/bell.png' ) ;
12
12
13
13
export default class ChipScreen extends Component {
14
-
15
14
colors = [
16
15
{ value : Colors . red10 , label : 'Red' } ,
17
16
{ value : Colors . blue10 , label : 'Blue' } ,
@@ -31,7 +30,7 @@ export default class ChipScreen extends Component {
31
30
32
31
openDialog = ( ) => {
33
32
this . toggleDialog ( true ) ;
34
- }
33
+ } ;
35
34
36
35
closeDialog = ( ) => {
37
36
this . toggleDialog ( false ) ;
@@ -73,13 +72,7 @@ export default class ChipScreen extends Component {
73
72
const { showDialog} = this . state ;
74
73
75
74
return (
76
- < Dialog
77
- migrate
78
- visible = { showDialog }
79
- useSafeArea
80
- bottom
81
- onDismiss = { this . closeDialog }
82
- >
75
+ < Dialog migrate visible = { showDialog } useSafeArea bottom onDismiss = { this . closeDialog } >
83
76
{ this . renderContent ( ) }
84
77
</ Dialog >
85
78
) ;
@@ -104,59 +97,34 @@ export default class ChipScreen extends Component {
104
97
< Text marginB-10 text70BO >
105
98
Default
106
99
</ Text >
107
- { this . renderExample (
108
- 'Label' ,
109
- < Chip label = { 'Chip' } />
110
- ) }
111
- { this . renderExample (
112
- 'Label + onPress' ,
113
- < Chip label = { 'Chip' } onPress = { ( ) => Alert . alert ( 'onPress' ) } />
114
- ) }
115
- { this . renderExample (
116
- 'Label + onDismiss' ,
100
+ { this . renderExample ( 'Label' , < Chip label = { 'Chip' } /> ) }
101
+ { this . renderExample ( 'Label + onPress' , < Chip label = { 'Chip' } onPress = { ( ) => Alert . alert ( 'onPress' ) } /> ) }
102
+ { this . renderExample ( 'Label + onDismiss' ,
117
103
< Chip
118
104
label = { 'Chip' }
119
105
iconColor = { Colors . black }
120
106
onDismiss = { ( ) => Alert . alert ( 'onDismiss' ) }
121
107
onPress = { ( ) => Alert . alert ( 'onPress' ) }
122
108
dismissIconStyle = { { width : 10 , height : 10 } }
123
- />
124
- ) }
125
- { this . renderExample (
126
- 'Icon' ,
127
- < Chip
128
- iconSource = { checkmark }
129
- iconStyle = { { width : 24 , height : 24 } }
130
- iconProps = { { tintColor : Colors . black } }
131
- />
132
- ) }
133
- { this . renderExample (
134
- 'Left icon' ,
109
+ /> ) }
110
+ { this . renderExample ( 'Icon' ,
111
+ < Chip iconSource = { checkmark } iconStyle = { { width : 24 , height : 24 } } iconProps = { { tintColor : Colors . black } } /> ) }
112
+ { this . renderExample ( 'Left icon' ,
135
113
< Chip
136
114
label = { 'Chip' }
137
115
iconSource = { checkmark }
138
116
iconStyle = { { width : 24 , height : 24 } }
139
117
iconProps = { { tintColor : Colors . black } }
140
- />
141
- ) }
142
- { this . renderExample (
143
- 'Right icon + onPress + dynamic label' ,
118
+ /> ) }
119
+ { this . renderExample ( 'Right icon + onPress + dynamic label' ,
144
120
< Chip
145
121
label = { this . state . selectedValue }
146
122
rightIconSource = { chevron }
147
123
iconStyle = { { margin : 8 } }
148
124
onPress = { this . openDialog }
149
- />
150
- ) }
151
- { this . renderExample (
152
- 'Label + Avatar' ,
153
- < Chip
154
- label = { 'Chip' }
155
- avatarProps = { { source : avatarImage , size : 20 } }
156
- />
157
- ) }
158
- { this . renderExample (
159
- 'Label + Counter' ,
125
+ /> ) }
126
+ { this . renderExample ( 'Label + Avatar' , < Chip label = { 'Chip' } avatarProps = { { source : avatarImage , size : 20 } } /> ) }
127
+ { this . renderExample ( 'Label + Counter' ,
160
128
< Chip
161
129
label = { 'Chip' }
162
130
labelStyle = { {
@@ -170,18 +138,15 @@ export default class ChipScreen extends Component {
170
138
color : Colors . grey20
171
139
}
172
140
} }
173
- />
174
- ) }
175
- { this . renderExample (
176
- 'Label + Badge' ,
141
+ /> ) }
142
+ { this . renderExample ( 'Label + Badge' ,
177
143
< Chip
178
144
label = { 'Chip' }
179
145
badgeProps = { {
180
146
label : '4' ,
181
147
backgroundColor : 'red'
182
148
} }
183
- />
184
- ) }
149
+ /> ) }
185
150
186
151
< Text marginT-20 marginB-10 text70BO >
187
152
Custom
@@ -234,6 +199,36 @@ export default class ChipScreen extends Component {
234
199
} }
235
200
/>
236
201
</ View >
202
+ < View center row marginT-10 >
203
+ < Chip
204
+ rightElement = { < Image tintColor = { Colors . yellow30 } source = { bell } width = { 24 } height = { 24 } /> }
205
+ label = { 'Chip' }
206
+ />
207
+ < Chip
208
+ marginL-s3
209
+ rightElement = { < Image tintColor = { Colors . green20 } source = { bell } width = { 20 } height = { 20 } /> }
210
+ leftElement = { < Image tintColor = { Colors . green20 } source = { bell } width = { 20 } height = { 20 } /> }
211
+ label = { 'Chip' }
212
+ />
213
+ < Chip
214
+ marginL-s3
215
+ leftElement = {
216
+ < View center row marginL-s1 >
217
+ < Image tintColor = { Colors . blue30 } source = { bell } />
218
+ < Image tintColor = { Colors . blue30 } source = { bell } width = { 20 } height = { 20 } />
219
+ < Image tintColor = { Colors . blue30 } source = { bell } width = { 24 } height = { 24 } />
220
+ </ View >
221
+ }
222
+ label = { 'Chip' }
223
+ />
224
+ < Chip
225
+ marginL-s3
226
+ paddingR-s2
227
+ rightIconSource = { chevron }
228
+ rightElement = { < Image tintColor = { Colors . red30 } source = { bell } width = { 20 } height = { 20 } /> }
229
+ label = { 'Chip' }
230
+ />
231
+ </ View >
237
232
</ View >
238
233
) ;
239
234
}
0 commit comments