react-native-paper
Version:
Material design for React Native
34 lines (27 loc) • 678 B
text/typescript
import color from 'color';
import type { InternalTheme } from '../../../types';
type BaseProps = {
theme: InternalTheme;
disabled?: boolean;
};
export function getTextColor({ theme, disabled }: BaseProps) {
if (theme.isV3) {
if (disabled) {
return theme.colors.onSurfaceDisabled;
}
return theme.colors.onSurfaceVariant;
}
return color(theme.colors?.text)
.alpha(theme.dark ? 0.7 : 0.54)
.rgb()
.string();
}
export function getIconColor({ theme, disabled }: BaseProps) {
if (!theme.isV3) {
return theme.colors.text;
}
if (disabled) {
return theme.colors.onSurfaceDisabled;
}
return theme.colors.onSurfaceVariant;
}