@react-native-paper-abstracted/cli
Version:
React Native Paper Abstracted is a package that allows you to use only the components you need from [React Native Paper](https://reactnativepaper.com). Thus allowing users to keep their app size small, and provides endless customization.
49 lines (41 loc) • 975 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,
isTextInputFocused,
disabled,
customColor,
}: BaseProps & {
isTextInputFocused: boolean;
customColor?: ((isTextInputFocused: boolean) => string | undefined) | string;
}) {
if (typeof customColor === 'function') {
return customColor(isTextInputFocused);
}
if (customColor) {
return customColor;
}
if (!theme.isV3) {
return theme.colors.text;
}
if (disabled) {
return theme.colors.onSurfaceDisabled;
}
return theme.colors.onSurfaceVariant;
}