Set the color for the Switch component based on the theme (#6397)
This commit is contained in:
parent
aa0edc2e63
commit
7fa011a89a
1 changed files with 10 additions and 1 deletions
|
|
@ -2,7 +2,7 @@
|
|||
// See LICENSE.txt for license information.
|
||||
|
||||
import React, {useCallback} from 'react';
|
||||
import {StyleProp, Switch, Text, TouchableOpacity, View, ViewStyle} from 'react-native';
|
||||
import {Platform, StyleProp, Switch, Text, TouchableOpacity, View, ViewStyle} from 'react-native';
|
||||
|
||||
import CompassIcon from '@components/compass_icon';
|
||||
import {useTheme} from '@context/theme';
|
||||
|
|
@ -96,10 +96,19 @@ const OptionItem = ({
|
|||
/>
|
||||
);
|
||||
} else if (type === OptionType.TOGGLE) {
|
||||
const trackColor = Platform.select({
|
||||
ios: {true: theme.buttonBg, false: changeOpacity(theme.centerChannelColor, 0.16)},
|
||||
default: {true: changeOpacity(theme.buttonBg, 0.32), false: changeOpacity(theme.centerChannelColor, 0.24)},
|
||||
});
|
||||
const thumbColor = Platform.select({
|
||||
android: selected ? theme.buttonBg : '#F3F3F3', // Hardcoded color specified in ticket MM-45143
|
||||
});
|
||||
actionComponent = (
|
||||
<Switch
|
||||
onValueChange={action}
|
||||
value={selected}
|
||||
trackColor={trackColor}
|
||||
thumbColor={thumbColor}
|
||||
testID={`${testID}.toggled.${selected}`}
|
||||
/>
|
||||
);
|
||||
|
|
|
|||
Loading…
Reference in a new issue