@@ -11,7 +11,7 @@ const AnimatedRNBounceable = Animated.createAnimatedComponent(RNBounceable);
1111
1212const MAIN_COLOR = "#f1bb7b" ;
1313const ORIGINAL_COLOR = "#fff" ;
14- const PLACEHOLDER_COLOR = "#757575 " ;
14+ const TINT_COLOR = "#f1bb7b " ;
1515const ORIGINAL_VALUE = 0 ;
1616const ANIMATED_VALUE = 1 ;
1717
@@ -23,6 +23,7 @@ interface ISwitchButtonProps {
2323 inactiveImageSource : ImageSourcePropType ;
2424 mainColor ?: string ;
2525 originalColor ?: string ;
26+ tintColor ?: string ;
2627}
2728
2829interface IState {
@@ -65,24 +66,24 @@ export default class SwitchButton extends React.Component<
6566 render ( ) {
6667 const mainColor = this . props . mainColor || MAIN_COLOR ;
6768 const originalColor = this . props . originalColor || ORIGINAL_COLOR ;
68- let backgroundColor = this . interpolatedColor . interpolate ( {
69+ const tintColor = this . props . tintColor || TINT_COLOR ;
70+ let animatedBackgroundColor = this . interpolatedColor . interpolate ( {
6971 inputRange : [ ORIGINAL_VALUE , ANIMATED_VALUE ] ,
7072 outputRange : [ originalColor , mainColor ] ,
7173 } ) ;
72-
73- let tintColor = this . interpolatedColor . interpolate ( {
74+ let animatedTintColor = this . interpolatedColor . interpolate ( {
7475 inputRange : [ ORIGINAL_VALUE , ANIMATED_VALUE ] ,
75- outputRange : [ mainColor , originalColor ] ,
76+ outputRange : [ tintColor , originalColor ] ,
7677 } ) ;
7778
7879 const { style, activeImageSource, inactiveImageSource } = this . props ;
7980 return (
8081 < View style = { { alignItems : "center" ,
8182 } } >
82- < AnimatedRNBounceable style = { [ _containerStyle ( backgroundColor ) , style ] } onPress = { ( ) => { this . setState ( { isActive : ! this . state . isActive } , ( ) => {
83+ < AnimatedRNBounceable style = { [ _containerStyle ( animatedBackgroundColor ) , style ] } onPress = { ( ) => { this . setState ( { isActive : ! this . state . isActive } , ( ) => {
8384 this . state . isActive ? this . showFocusColor ( ) : this . showOriginColor ( )
8485 } ) } } >
85- < Animated . Image source = { this . state . isActive ? activeImageSource : inactiveImageSource } style = { { height : 30 , width : 30 , tintColor : tintColor } } />
86+ < Animated . Image source = { this . state . isActive ? activeImageSource : inactiveImageSource } style = { { height : 30 , width : 30 , tintColor : animatedTintColor } } />
8687 </ AnimatedRNBounceable >
8788 < View style = { { marginTop : 8 } } >
8889 < Text > Notification</ Text >
0 commit comments