1
1
import React , { Component } from 'react' ;
2
2
import { ScrollView , StyleSheet } from 'react-native' ;
3
- import { Colors , View , Badge , Button , Text , Image } from 'react-native-ui-lib' ; //eslint-disable-line
4
-
3
+ import { Colors , View , Badge , Text , Image , Stepper } from 'react-native-ui-lib' ; //eslint-disable-line
5
4
6
5
const BadgesSpace = 30 ;
7
- const plusIcon = require ( '../../assets/icons/chevronUp.png' ) ;
8
- const minusIcon = require ( '../../assets/icons/chevronDown.png' ) ;
9
6
const star = require ( '../../assets/icons/star.png' ) ;
10
7
const bell = require ( '../../assets/icons/bell.png' ) ;
11
8
@@ -22,165 +19,149 @@ export default class BadgesScreen extends Component {
22
19
}
23
20
}
24
21
25
- render ( ) {
26
- const customElement1 = (
27
- < View row >
28
- < Image source = { bell } />
29
- < Image source = { bell } />
30
- </ View >
31
- ) ;
22
+ customElement1 = (
23
+ < View row >
24
+ < Image source = { bell } />
25
+ < Image source = { bell } />
26
+ </ View >
27
+ ) ;
28
+
29
+ customElement2 = (
30
+ < View row >
31
+ < Image source = { bell } />
32
+ < Text white text90 >
33
+ 37
34
+ </ Text >
35
+ < Image source = { bell } />
36
+ </ View >
37
+ ) ;
38
+
39
+ onValueChange = ( value : number , _ ?: string ) => {
40
+ this . setState ( { value} ) ;
41
+ } ;
32
42
33
- const customElement2 = (
34
- < View row >
35
- < Image source = { bell } />
36
- < Text white text90 >
37
- 37
38
- </ Text >
39
- < Image source = { bell } />
40
- </ View >
41
- ) ;
43
+ render ( ) {
44
+ const { value} = this . state ;
42
45
43
46
return (
44
- < ScrollView style = { { backgroundColor : Colors . grey70 } } contentContainerStyle = { styles . container } >
45
- < Text text50 row center marginB-15 >
47
+ < View flex >
48
+ < Text h1 $textDefault margin-20 >
46
49
Badges
47
50
</ Text >
48
- < View row center style = { { alignItems : 'flex-start' } } >
49
- < View center paddingH-10 >
50
- < Badge size = { 20 } label = { this . state . value . toString ( ) } backgroundColor = { Colors . red30 } />
51
- < Badge
52
- label = { this . state . value . toString ( ) }
53
- containerStyle = { { marginTop : BadgesSpace } }
54
- backgroundColor = { Colors . red30 }
55
- borderWidth = { 1 }
56
- />
57
- < Badge
58
- size = { 16 }
59
- label = { this . state . value . toString ( ) }
60
- containerStyle = { { marginTop : BadgesSpace } }
61
- backgroundColor = { Colors . red30 }
62
- />
63
- </ View >
64
51
65
- < View center paddingH-10 >
52
+ < ScrollView contentContainerStyle = { styles . container } showsVerticalScrollIndicator = { false } >
53
+ < View row spread >
66
54
< Badge label = { '9999' } labelFormatterLimit = { 3 } />
67
55
< Badge
68
56
label = { '999' }
69
57
labelFormatterLimit = { 2 }
70
- containerStyle = { { marginTop : BadgesSpace } }
71
58
borderWidth = { 2 }
72
59
borderColor = { Colors . white }
73
60
/>
74
- < Badge labelFormatterLimit = { 1 } size = { 16 } label = { '99999999' } containerStyle = { { marginTop : BadgesSpace } } />
75
- </ View >
76
- </ View >
77
-
78
- < View row paddingT-20 marginB-15 >
79
- < Button
80
- bg-grey60
81
- style = { { width : 30 , height : 30 , borderWidth : 1 , marginRight : 15 } }
82
- iconSource = { minusIcon }
83
- avoidMinWidth
84
- onPress = { ( ) => this . changeLabelValue ( - 1 ) }
85
- onLongPress = { ( ) => this . changeLabelValue ( - 10 ) }
86
- />
87
- < Button
88
- bg-grey60
89
- style = { { width : 30 , height : 30 , borderWidth : 1 } }
90
- iconSource = { plusIcon }
91
- avoidMinWidth
92
- onPress = { ( ) => this . changeLabelValue ( 1 ) }
93
- onLongPress = { ( ) => this . changeLabelValue ( 10 ) }
94
- />
95
- </ View >
96
- < Text center > Press buttons to change red badge value by 1.{ '\n' } Long press to change it by 10.</ Text >
97
-
98
- < Text text50 row center marginT-40 >
99
- Pimple Badges
100
- </ Text >
101
- < View row >
102
- < View
103
- center
104
- style = { { justifyContent : 'space-around' , alignItems : 'flex-start' , width : 140 , height : 140 } }
105
- >
106
- < Text text80 row >
107
- size={ '{6}' }
108
- </ Text >
109
- < Text text80 > size={ '{10}' } </ Text >
110
- < Text text80 row >
111
- size={ '{14}' }
112
- </ Text >
61
+ < Badge labelFormatterLimit = { 1 } size = { 16 } label = { '99999999' } />
113
62
</ View >
114
63
115
- < View center style = { { justifyContent : 'space-around' , width : 40 , height : 140 } } >
116
- < Badge containerStyle = { { marginLeft : BadgesSpace } } backgroundColor = { Colors . green30 } size = { 6 } />
117
- < Badge containerStyle = { { marginLeft : BadgesSpace } } backgroundColor = { Colors . red30 } size = { 10 } />
118
- < Badge containerStyle = { { marginLeft : BadgesSpace } } backgroundColor = { Colors . blue30 } size = { 14 } />
64
+ < View row spread marginV-20 >
65
+ < Badge size = { 20 } label = { value . toString ( ) } backgroundColor = { Colors . red30 } />
66
+ < Badge
67
+ label = { value . toString ( ) }
68
+ backgroundColor = { Colors . red30 }
69
+ borderWidth = { 1 }
70
+ borderColor = { Colors . $outlinePrimary }
71
+ />
72
+ < Badge
73
+ size = { 16 }
74
+ label = { value . toString ( ) }
75
+ backgroundColor = { Colors . red30 }
76
+ />
119
77
</ View >
120
- </ View >
121
- < Text text50 marginB-10 row center marginT-25 >
122
- Icon Badges
123
- </ Text >
124
- < View row paddingH-15 >
125
- < View style = { styles . iconBadgeColumnContainer } >
126
- < Badge size = { 16 } icon = { star } borderWidth = { 1 } borderColor = { Colors . red30 } />
127
- < Text text80 style = { { marginTop : 10 } } >
128
- small(16)
129
- </ Text >
78
+ < View center >
79
+ < Stepper onValueChange = { this . onValueChange } value = { value } maxValue = { 100 } minValue = { 1 } />
130
80
</ View >
131
-
132
- < View style = { styles . iconBadgeColumnContainer } >
133
- < Badge icon = { star } iconStyle = { { tintColor : Colors . red30 } } />
134
- < Text text80 style = { { marginTop : 10 } } >
135
- default(20)
136
- </ Text >
81
+ < Text center $textDefault marginT-10 > Press buttons to change red badge value by 1.{ '\n' } Long press to change it by 10.</ Text >
82
+
83
+ < Text row center text50 $textDefault marginT-40 >
84
+ Pimple Badges
85
+ </ Text >
86
+ < View row >
87
+ < View center style = { { justifyContent : 'space-around' , alignItems : 'flex-start' , width : 140 , height : 140 } } >
88
+ < Text row text80 $textDefault >
89
+ size={ '{6}' }
90
+ </ Text >
91
+ < Text text80 $textDefault > size={ '{10}' } </ Text >
92
+ < Text row text80 $textDefault >
93
+ size={ '{14}' }
94
+ </ Text >
95
+ </ View >
96
+ < View center style = { { justifyContent : 'space-around' , width : 40 , height : 140 } } >
97
+ < Badge containerStyle = { { marginLeft : BadgesSpace } } backgroundColor = { Colors . green30 } size = { 6 } />
98
+ < Badge containerStyle = { { marginLeft : BadgesSpace } } backgroundColor = { Colors . red30 } size = { 10 } />
99
+ < Badge containerStyle = { { marginLeft : BadgesSpace } } backgroundColor = { Colors . blue30 } size = { 14 } />
100
+ </ View >
137
101
</ View >
138
102
139
- < View style = { styles . iconBadgeColumnContainer } >
140
- < Badge size = { 24 } icon = { star } iconStyle = { { backgroundColor : Colors . red30 } } />
141
- < Text text80 style = { { marginTop : 10 } } >
142
- large(24)
143
- </ Text >
103
+ < Text row center text50 $textDefault margin-25 >
104
+ Icon Badges
105
+ </ Text >
106
+ < View row spread >
107
+ < View center >
108
+ < Badge
109
+ size = { 16 }
110
+ icon = { star }
111
+ borderWidth = { 1 }
112
+ borderColor = { Colors . red30 }
113
+ iconStyle = { { tintColor : Colors . red30 } }
114
+ />
115
+ < Text $textDefault text80 style = { { marginTop : 10 } } >
116
+ small(16)
117
+ </ Text >
118
+ </ View >
119
+
120
+ < View center >
121
+ < Badge icon = { star } iconStyle = { { tintColor : Colors . red30 } } />
122
+ < Text $textDefault text80 style = { { marginTop : 10 } } >
123
+ default(20)
124
+ </ Text >
125
+ </ View >
126
+
127
+ < View center >
128
+ < Badge size = { 24 } icon = { star } iconStyle = { { backgroundColor : Colors . red30 } } />
129
+ < Text $textDefault text80 style = { { marginTop : 10 } } >
130
+ large(24)
131
+ </ Text >
132
+ </ View >
133
+
134
+ < View center >
135
+ < Badge icon = { star } borderRadius = { 6 } iconStyle = { { backgroundColor : Colors . red30 } } />
136
+ < Text $textDefault text80 style = { { marginTop : 10 } } >
137
+ border radius
138
+ </ Text >
139
+ </ View >
144
140
</ View >
145
141
146
- < View style = { styles . iconBadgeColumnContainer } >
147
- < Badge icon = { star } borderRadius = { 6 } iconStyle = { { backgroundColor : Colors . red30 } } />
148
- < Text text80 style = { { marginTop : 10 } } >
149
- border radius
150
- </ Text >
142
+ < Text row center text50 $textDefault margin-25 >
143
+ Counter Icon Badges
144
+ </ Text >
145
+ < View row spread marginH-50 >
146
+ < Badge marginR-10 label = { '9999' } labelFormatterLimit = { 3 } icon = { bell } backgroundColor = { Colors . red30 } />
147
+ < Badge marginR-10 label = { '4' } icon = { bell } backgroundColor = { Colors . red30 } />
151
148
</ View >
152
- </ View >
153
-
154
- < Text text50 marginB-10 row center marginT-25 >
155
- Counter Icon Badges
156
- </ Text >
157
- < View row paddingH-15 >
158
- < Badge marginR-10 label = { '9999' } labelFormatterLimit = { 3 } icon = { bell } backgroundColor = { Colors . red30 } />
159
- < Badge marginR-10 label = { '4' } icon = { bell } backgroundColor = { Colors . red30 } />
160
- </ View >
161
149
162
- < Text text50 marginB-10 row center marginT-25 >
163
- Custom Element Badges
164
- </ Text >
165
- < View row paddingH-15 >
166
- < Badge marginR-10 label = { '17' } customElement = { customElement1 } />
167
- < Badge marginR-10 customElement = { customElement2 } backgroundColor = { Colors . grey30 } />
168
- </ View >
169
- </ ScrollView >
150
+ < Text row center text50 $textDefault margin-25 >
151
+ Custom Element Badges
152
+ </ Text >
153
+ < View row spread marginH-50 >
154
+ < Badge marginR-10 label = { '17' } customElement = { this . customElement1 } />
155
+ < Badge marginR-10 customElement = { this . customElement2 } backgroundColor = { Colors . grey30 } />
156
+ </ View >
157
+ </ ScrollView >
158
+ </ View >
170
159
) ;
171
160
}
172
161
}
173
162
174
163
const styles = StyleSheet . create ( {
175
164
container : {
176
- alignItems : 'center' ,
177
- padding : 20 ,
178
- backgroundColor : Colors . grey70
179
- } ,
180
- iconBadgeColumnContainer : {
181
- flex : 1 ,
182
- justifyContent : 'space-between' ,
183
- alignItems : 'center' ,
184
- flexDirection : 'column'
165
+ padding : 20
185
166
}
186
167
} ) ;
0 commit comments