@@ -62,6 +62,10 @@ export default class ColorPicker extends PureBaseComponent {
62
62
* Props to pass the Dialog component
63
63
*/
64
64
dialogProps : PropTypes . object ,
65
+ /**
66
+ * Additional styling for the color preview text.
67
+ */
68
+ previewInputStyle : PropTypes . oneOfType ( [ PropTypes . object , PropTypes . number , PropTypes . array ] ) ,
65
69
/**
66
70
* Accessibility labels as an object of strings, ex. {addButton: 'add custom color using hex code', dismissButton: 'dismiss', doneButton: 'done', input: 'custom hex color code'}
67
71
*/
@@ -109,7 +113,7 @@ export default class ColorPicker extends PureBaseComponent {
109
113
const text = this . getColorValue ( nextProps . initialColor || this . props . initialColor ) ;
110
114
const color = Colors . getHSL ( nextProps . initialColor ) ;
111
115
const { valid} = this . getValidColorString ( text ) ;
112
-
116
+
113
117
this . setState ( { color, text, valid} ) ;
114
118
}
115
119
}
@@ -185,7 +189,7 @@ export default class ColorPicker extends PureBaseComponent {
185
189
186
190
getValidColorString ( text ) {
187
191
const hex = this . getHexColor ( text ) ;
188
-
192
+
189
193
if ( Colors . isValidHex ( hex ) ) {
190
194
return { hex, valid : true } ;
191
195
}
@@ -212,7 +216,7 @@ export default class ColorPicker extends PureBaseComponent {
212
216
const color = Colors . getHSL ( this . props . initialColor ) ;
213
217
const text = this . getColorValue ( this . props . initialColor ) ;
214
218
const { valid} = this . getValidColorString ( text ) ;
215
-
219
+
216
220
this . setState ( {
217
221
show : false ,
218
222
color,
@@ -275,8 +279,8 @@ export default class ColorPicker extends PureBaseComponent {
275
279
const colorValue = color . a === 0 ? Colors . black : Colors . getHexString ( color ) ;
276
280
277
281
return (
278
- < ColorSliderGroup
279
- initialColor = { colorValue }
282
+ < ColorSliderGroup
283
+ initialColor = { colorValue }
280
284
containerStyle = { [ this . styles . sliderGroup , { height : keyboardHeight } ] }
281
285
sliderContainerStyle = { this . styles . slider }
282
286
showLabels
@@ -288,7 +292,7 @@ export default class ColorPicker extends PureBaseComponent {
288
292
}
289
293
290
294
renderPreview ( ) {
291
- const { accessibilityLabels} = this . getThemeProps ( ) ;
295
+ const { accessibilityLabels, previewInputStyle } = this . getThemeProps ( ) ;
292
296
const { color, text} = this . state ;
293
297
const hex = this . getHexString ( color ) ;
294
298
const textColor = this . getTextColor ( hex ) ;
@@ -299,11 +303,11 @@ export default class ColorPicker extends PureBaseComponent {
299
303
< View style = { [ this . styles . preview , { backgroundColor : hex } ] } >
300
304
< TouchableOpacity center onPress = { this . setFocus } activeOpacity = { 1 } accessible = { false } >
301
305
< View style = { this . styles . inputContainer } >
302
- < Text
303
- text60
304
- white
305
- marginL-13
306
- marginR-5 = { Constants . isIOS }
306
+ < Text
307
+ text60
308
+ white
309
+ marginL-13
310
+ marginR-5 = { Constants . isIOS }
307
311
style = { {
308
312
color : textColor ,
309
313
transform : [ { scaleX : I18nManager . isRTL ? - 1 : 1 } ]
@@ -321,7 +325,8 @@ export default class ColorPicker extends PureBaseComponent {
321
325
style = { [
322
326
this . styles . input ,
323
327
{ color : textColor , width : ( value . length + 1 ) * 16.5 * fontScale } ,
324
- Constants . isAndroid && { padding : 0 }
328
+ Constants . isAndroid && { padding : 0 } ,
329
+ previewInputStyle
325
330
] }
326
331
selectionColor = { textColor }
327
332
underlineColorAndroid = "transparent"
@@ -410,7 +415,7 @@ function createStyles(props) {
410
415
const iconSize = SWATCH_SIZE ;
411
416
const plusButtonContainerWidth = iconSize + 20 + 12 ;
412
417
const plusButtonContainerHeight = 92 - 2 * SWATCH_MARGIN ;
413
-
418
+
414
419
const styles = StyleSheet . create ( {
415
420
palette : {
416
421
paddingLeft : plusButtonContainerWidth
0 commit comments