@@ -132,10 +132,6 @@ export default class Slider extends PureBaseComponent {
132
132
}
133
133
}
134
134
135
- generateStyles ( ) {
136
- this . styles = createStyles ( this . getThemeProps ( ) ) ;
137
- }
138
-
139
135
UNSAFE_componentWillMount ( ) {
140
136
this . _panResponder = PanResponder . create ( {
141
137
onMoveShouldSetPanResponder : this . handleMoveShouldSetPanResponder ,
@@ -243,8 +239,8 @@ export default class Slider extends PureBaseComponent {
243
239
updateThumbStyle ( start ) {
244
240
if ( this . thumb && ! this . props . disableActiveStyling ) {
245
241
const { thumbStyle, activeThumbStyle} = this . props ;
246
- const style = thumbStyle || this . styles . thumb ;
247
- const activeStyle = activeThumbStyle || this . styles . activeThumb ;
242
+ const style = thumbStyle || styles . thumb ;
243
+ const activeStyle = activeThumbStyle || styles . activeThumb ;
248
244
249
245
this . _thumbStyles . style = ! this . props . disabled && ( start ? activeStyle : style ) ;
250
246
this . thumb . setNativeProps ( this . _thumbStyles ) ;
@@ -373,11 +369,20 @@ export default class Slider extends PureBaseComponent {
373
369
/* Renders */
374
370
375
371
render ( ) {
376
- const { containerStyle, thumbStyle, trackStyle, renderTrack, disabled, thumbTintColor} = this . getThemeProps ( ) ;
372
+ const {
373
+ containerStyle,
374
+ thumbStyle,
375
+ trackStyle,
376
+ renderTrack,
377
+ disabled,
378
+ thumbTintColor,
379
+ minimumTrackTintColor = ACTIVE_COLOR ,
380
+ maximumTrackTintColor = DEFAULT_COLOR
381
+ } = this . getThemeProps ( ) ;
377
382
378
383
return (
379
384
< View
380
- style = { [ this . styles . container , containerStyle ] }
385
+ style = { [ styles . container , containerStyle ] }
381
386
onLayout = { this . onContainerLayout }
382
387
accessible
383
388
accessibilityLabel = { 'Slider' }
@@ -389,22 +394,33 @@ export default class Slider extends PureBaseComponent {
389
394
onAccessibilityAction = { this . onAccessibilityAction }
390
395
>
391
396
{ _ . isFunction ( renderTrack ) ? (
392
- < View style = { [ this . styles . track , trackStyle ] } onLayout = { this . onTrackLayout } >
397
+ < View
398
+ style = { [ styles . track , { backgroundColor : maximumTrackTintColor } , trackStyle ] }
399
+ onLayout = { this . onTrackLayout }
400
+ >
393
401
{ renderTrack ( ) }
394
402
</ View >
395
403
) : (
396
404
< View >
397
405
< View
398
- style = { [ this . styles . track , trackStyle , disabled && this . styles . trackDisabled ] }
406
+ style = { [
407
+ styles . track ,
408
+ trackStyle ,
409
+ {
410
+ backgroundColor : disabled ? INACTIVE_COLOR : maximumTrackTintColor
411
+ }
412
+ ] }
399
413
onLayout = { this . onTrackLayout }
400
414
/>
401
415
< View
402
416
ref = { this . setMinTrackRef }
403
417
style = { [
404
- this . styles . track ,
418
+ styles . track ,
405
419
trackStyle ,
406
- this . styles . minimumTrack ,
407
- disabled && { backgroundColor : DEFAULT_COLOR }
420
+ styles . minimumTrack ,
421
+ {
422
+ backgroundColor : disabled ? DEFAULT_COLOR : minimumTrackTintColor
423
+ }
408
424
] }
409
425
/>
410
426
</ View >
@@ -413,60 +429,53 @@ export default class Slider extends PureBaseComponent {
413
429
ref = { this . setThumbRef }
414
430
onLayout = { this . onThumbLayout }
415
431
style = { [
416
- this . styles . thumb ,
432
+ styles . thumb ,
417
433
thumbStyle ,
418
434
{
419
435
backgroundColor : disabled ? DEFAULT_COLOR : thumbTintColor || ACTIVE_COLOR
420
436
}
421
437
] }
422
438
/>
423
- < View style = { this . styles . touchArea } { ...this . _panResponder . panHandlers } />
439
+ < View style = { styles . touchArea } { ...this . _panResponder . panHandlers } />
424
440
</ View >
425
441
) ;
426
442
}
427
443
}
428
444
429
- function createStyles ( { minimumTrackTintColor = ACTIVE_COLOR , maximumTrackTintColor = DEFAULT_COLOR } ) {
430
- return StyleSheet . create ( {
431
- container : {
432
- height : THUMB_SIZE + SHADOW_RADIUS ,
433
- justifyContent : 'center'
434
- } ,
435
- track : {
436
- height : TRACK_SIZE ,
437
- borderRadius : TRACK_SIZE / 2 ,
438
- backgroundColor : maximumTrackTintColor ,
439
- overflow : 'hidden'
440
- } ,
441
- trackDisabled : {
442
- backgroundColor : INACTIVE_COLOR
443
- } ,
444
- minimumTrack : {
445
- position : 'absolute' ,
446
- backgroundColor : minimumTrackTintColor
447
- } ,
448
- thumb : {
449
- position : 'absolute' ,
450
- width : THUMB_SIZE ,
451
- height : THUMB_SIZE ,
452
- borderRadius : THUMB_SIZE / 2 ,
453
- borderWidth : BORDER_WIDTH ,
454
- borderColor : Colors . white ,
455
- shadowColor : Colors . rgba ( Colors . black , 0.3 ) ,
456
- shadowOffset : { width : 0 , height : 0 } ,
457
- shadowOpacity : 0.9 ,
458
- shadowRadius : SHADOW_RADIUS ,
459
- elevation : 2
460
- } ,
461
- activeThumb : {
462
- width : THUMB_SIZE + 16 ,
463
- height : THUMB_SIZE + 16 ,
464
- borderRadius : ( THUMB_SIZE + 16 ) / 2 ,
465
- borderWidth : BORDER_WIDTH + 6
466
- } ,
467
- touchArea : {
468
- ...StyleSheet . absoluteFillObject ,
469
- backgroundColor : 'transparent'
470
- }
471
- } ) ;
472
- }
445
+ const styles = StyleSheet . create ( {
446
+ container : {
447
+ height : THUMB_SIZE + SHADOW_RADIUS ,
448
+ justifyContent : 'center'
449
+ } ,
450
+ track : {
451
+ height : TRACK_SIZE ,
452
+ borderRadius : TRACK_SIZE / 2 ,
453
+ overflow : 'hidden'
454
+ } ,
455
+ minimumTrack : {
456
+ position : 'absolute'
457
+ } ,
458
+ thumb : {
459
+ position : 'absolute' ,
460
+ width : THUMB_SIZE ,
461
+ height : THUMB_SIZE ,
462
+ borderRadius : THUMB_SIZE / 2 ,
463
+ borderWidth : BORDER_WIDTH ,
464
+ borderColor : Colors . white ,
465
+ shadowColor : Colors . rgba ( Colors . black , 0.3 ) ,
466
+ shadowOffset : { width : 0 , height : 0 } ,
467
+ shadowOpacity : 0.9 ,
468
+ shadowRadius : SHADOW_RADIUS ,
469
+ elevation : 2
470
+ } ,
471
+ activeThumb : {
472
+ width : THUMB_SIZE + 16 ,
473
+ height : THUMB_SIZE + 16 ,
474
+ borderRadius : ( THUMB_SIZE + 16 ) / 2 ,
475
+ borderWidth : BORDER_WIDTH + 6
476
+ } ,
477
+ touchArea : {
478
+ ...StyleSheet . absoluteFillObject ,
479
+ backgroundColor : 'transparent'
480
+ }
481
+ } ) ;
0 commit comments