Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions example/src/DrawerItems.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
import * as React from 'react';
import { I18nManager, StyleSheet, View, Platform } from 'react-native';
import {
ColorValue,
I18nManager,
Platform,
StyleSheet,
View,
} from 'react-native';

import { DrawerContentScrollView } from '@react-navigation/drawer';
import Constants, { ExecutionEnvironment } from 'expo-constants';
Expand Down Expand Up @@ -31,7 +37,7 @@ const DrawerItemsData = [
label: 'Starred',
icon: 'star',
key: 1,
right: ({ color }: { color: string }) => (
right: ({ color }: { color: ColorValue }) => (
<Badge
visible
size={8}
Expand Down
2 changes: 1 addition & 1 deletion example/src/Examples/BottomNavigationBarExample.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export default function BottomNavigationBarExample() {
renderIcon={({ route, focused, color }) =>
descriptors[route.key].options.tabBarIcon?.({
focused,
color,
color: typeof color === 'string' ? color : '',
size: 24,
}) || null
}
Expand Down
3 changes: 2 additions & 1 deletion src/components/ActivityIndicator.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import * as React from 'react';
import {
Animated,
ColorValue,
Easing,
Platform,
StyleProp,
Expand All @@ -20,7 +21,7 @@ export type Props = React.ComponentPropsWithRef<typeof View> & {
/**
* The color of the spinner.
*/
color?: string;
color?: ColorValue;
/**
* Size of the indicator.
*/
Expand Down
10 changes: 8 additions & 2 deletions src/components/Appbar/AppbarAction.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
import * as React from 'react';
import type { Animated, StyleProp, View, ViewStyle } from 'react-native';
import type {
Animated,
ColorValue,
StyleProp,
View,
ViewStyle,
} from 'react-native';

import { useInternalTheme } from '../../core/theming';
import type { Theme, ThemeProp } from '../../types';
Expand All @@ -11,7 +17,7 @@ export type Props = React.ComponentPropsWithoutRef<typeof IconButton> & {
/**
* Custom color for action icon.
*/
color?: string;
color?: ColorValue;
/**
* Name of the icon to show.
*/
Expand Down
3 changes: 2 additions & 1 deletion src/components/Appbar/AppbarBackAction.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import * as React from 'react';
import type {
Animated,
ColorValue,
GestureResponderEvent,
StyleProp,
View,
Expand All @@ -19,7 +20,7 @@ export type Props = $Omit<
/**
* Custom color for back icon.
*/
color?: string;
color?: ColorValue;
/**
* Optional icon size.
*/
Expand Down
10 changes: 8 additions & 2 deletions src/components/Appbar/AppbarBackIcon.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
import * as React from 'react';
import { Image, Platform, StyleSheet, View } from 'react-native';
import { ColorValue, Image, Platform, StyleSheet, View } from 'react-native';

import { useLocale } from '../../core/locale';
import MaterialCommunityIcon from '../MaterialCommunityIcon';

const AppbarBackIcon = ({ size, color }: { size: number; color: string }) => {
const AppbarBackIcon = ({
size,
color,
}: {
size: number;
color: ColorValue;
}) => {
const { direction } = useLocale();
const isRTL = direction === 'rtl';
const iosIconSize = size - 3;
Expand Down
4 changes: 2 additions & 2 deletions src/components/BottomNavigation/BottomNavigation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -155,15 +155,15 @@ export type Props<Route extends BaseRoute> = {
renderIcon?: (props: {
route: Route;
focused: boolean;
color: string;
color: ColorValue;
}) => React.ReactNode;
/**
* Callback which React Element to be used as tab label.
*/
renderLabel?: (props: {
route: Route;
focused: boolean;
color: string;
color: ColorValue;
}) => React.ReactNode;
/**
* Callback which returns a React element to be used as the touchable for the tab item.
Expand Down
4 changes: 2 additions & 2 deletions src/components/BottomNavigation/BottomNavigationBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -122,15 +122,15 @@ export type Props<Route extends BaseRoute> = {
renderIcon?: (props: {
route: Route;
focused: boolean;
color: string;
color: ColorValue;
}) => React.ReactNode;
/**
* Callback which React Element to be used as tab label.
*/
renderLabel?: (props: {
route: Route;
focused: boolean;
color: string;
color: ColorValue;
}) => React.ReactNode;
/**
* Callback which returns a React element to be used as the touchable for the tab item.
Expand Down
12 changes: 7 additions & 5 deletions src/components/BottomNavigation/utils.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
import type { ColorValue } from 'react-native';

import type { InternalTheme, Theme } from '../../types';

export const getActiveTintColor = ({
activeColor,
theme,
}: {
activeColor: string | undefined;
activeColor: ColorValue | undefined;
theme: InternalTheme;
}) => {
if (typeof activeColor === 'string') {
if (activeColor != null) {
return activeColor;
}

Expand All @@ -18,10 +20,10 @@ export const getInactiveTintColor = ({
inactiveColor,
theme,
}: {
inactiveColor: string | undefined;
inactiveColor: ColorValue | undefined;
theme: InternalTheme;
}) => {
if (typeof inactiveColor === 'string') {
if (inactiveColor != null) {
return inactiveColor;
}

Expand All @@ -34,7 +36,7 @@ export const getLabelColor = ({
focused,
theme,
}: {
tintColor: string;
tintColor: ColorValue;
hasColor: boolean;
focused: boolean;
theme: InternalTheme;
Expand Down
7 changes: 4 additions & 3 deletions src/components/Button/Button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import * as React from 'react';
import {
AccessibilityRole,
Animated,
ColorValue,
GestureResponderEvent,
Platform,
PressableAndroidRippleConfig,
Expand Down Expand Up @@ -54,15 +55,15 @@ export type Props = $Omit<React.ComponentProps<typeof Surface>, 'mode'> & {
* @deprecated Deprecated in v5.x - use `buttonColor` or `textColor` instead.
* Custom text color for flat button, or background color for contained button.
*/
color?: string;
color?: ColorValue;
/**
* Custom button's background color.
*/
buttonColor?: string;
buttonColor?: ColorValue;
/**
* Custom button's text color.
*/
textColor?: string;
textColor?: ColorValue;
/**
* Whether to show a loading indicator.
*/
Expand Down
14 changes: 7 additions & 7 deletions src/components/Button/utils.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { ViewStyle } from 'react-native';
import type { ColorValue, ViewStyle } from 'react-native';

import { black, white } from '../../theme/colors';
import { tokens } from '../../theme/tokens';
Expand All @@ -25,7 +25,7 @@ const isDark = ({
backgroundColor,
}: {
dark?: boolean;
backgroundColor?: string;
backgroundColor?: ColorValue;
}) => {
if (typeof dark === 'boolean') {
return dark;
Expand All @@ -44,7 +44,7 @@ const getButtonBackgroundColor = ({
disabled,
customButtonColor,
}: BaseProps & {
customButtonColor?: string;
customButtonColor?: ColorValue;
}) => {
const { colors } = theme as Theme;
if (customButtonColor && !disabled) {
Expand Down Expand Up @@ -81,8 +81,8 @@ const getButtonTextColor = ({
backgroundColor,
dark,
}: BaseProps & {
customTextColor?: string;
backgroundColor: string;
customTextColor?: ColorValue;
backgroundColor: ColorValue;
dark?: boolean;
}) => {
const { colors } = theme as Theme;
Expand Down Expand Up @@ -145,8 +145,8 @@ export const getButtonColors = ({
}: {
theme: InternalTheme;
mode: ButtonMode;
customButtonColor?: string;
customTextColor?: string;
customButtonColor?: ColorValue;
customTextColor?: ColorValue;
disabled?: boolean;
dark?: boolean;
}) => {
Expand Down
5 changes: 3 additions & 2 deletions src/components/Checkbox/CheckboxAndroid.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import * as React from 'react';
import {
Animated,
ColorValue,
GestureResponderEvent,
StyleSheet,
View,
Expand Down Expand Up @@ -28,11 +29,11 @@ export type Props = $RemoveChildren<typeof TouchableRipple> & {
/**
* Custom color for unchecked checkbox.
*/
uncheckedColor?: string;
uncheckedColor?: ColorValue;
/**
* Custom color for checkbox.
*/
color?: string;
color?: ColorValue;
/**
* @optional
*/
Expand Down
9 changes: 7 additions & 2 deletions src/components/Checkbox/CheckboxIOS.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
import * as React from 'react';
import { GestureResponderEvent, StyleSheet, View } from 'react-native';
import {
ColorValue,
GestureResponderEvent,
StyleSheet,
View,
} from 'react-native';

import { getSelectionControlIOSColor } from './utils';
import { useInternalTheme } from '../../core/theming';
Expand All @@ -23,7 +28,7 @@ export type Props = $RemoveChildren<typeof TouchableRipple> & {
/**
* Custom color for checkbox.
*/
color?: string;
color?: ColorValue;
/**
* @optional
*/
Expand Down
18 changes: 10 additions & 8 deletions src/components/Checkbox/utils.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import type { ColorValue } from 'react-native';

import { tokens } from '../../theme/tokens';
import type { InternalTheme } from '../../types';

Expand All @@ -8,7 +10,7 @@ const getAndroidCheckedColor = ({
customColor,
}: {
theme: InternalTheme;
customColor?: string;
customColor?: ColorValue;
}) => {
if (customColor) {
return customColor;
Expand All @@ -22,7 +24,7 @@ const getAndroidUncheckedColor = ({
customUncheckedColor,
}: {
theme: InternalTheme;
customUncheckedColor?: string;
customUncheckedColor?: ColorValue;
}) => {
if (customUncheckedColor) {
return customUncheckedColor;
Expand All @@ -40,8 +42,8 @@ const getAndroidControlColor = ({
}: {
theme: InternalTheme;
checked: boolean;
checkedColor: string;
uncheckedColor: string;
checkedColor: ColorValue;
uncheckedColor: ColorValue;
disabled?: boolean;
}) => {
if (disabled) {
Expand All @@ -64,8 +66,8 @@ export const getAndroidSelectionControlColor = ({
theme: InternalTheme;
checked: boolean;
disabled?: boolean;
customColor?: string;
customUncheckedColor?: string;
customColor?: ColorValue;
customUncheckedColor?: ColorValue;
}) => {
const checkedColor = getAndroidCheckedColor({ theme, customColor });
const uncheckedColor = getAndroidUncheckedColor({
Expand Down Expand Up @@ -94,7 +96,7 @@ const getIOSCheckedColor = ({
customColor,
}: {
theme: InternalTheme;
customColor?: string;
customColor?: ColorValue;
disabled?: boolean;
}) => {
if (disabled) {
Expand All @@ -115,7 +117,7 @@ export const getSelectionControlIOSColor = ({
}: {
theme: InternalTheme;
disabled?: boolean;
customColor?: string;
customColor?: ColorValue;
}) => {
const checkedColor = getIOSCheckedColor({ theme, disabled, customColor });
const checkedColorOpacity = disabled
Expand Down
3 changes: 2 additions & 1 deletion src/components/Chip/Chip.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import * as React from 'react';
import {
AccessibilityState,
Animated,
ColorValue,
GestureResponderEvent,
Platform,
PressableAndroidRippleConfig,
Expand Down Expand Up @@ -61,7 +62,7 @@ export type Props = $Omit<React.ComponentProps<typeof Surface>, 'mode'> & {
* Note: With theme version 3 `selectedColor` doesn't apply to the `icon`.
* If you want specify custom color for the `icon`, render your own `Icon` component.
*/
selectedColor?: string;
selectedColor?: ColorValue;
/**
* @supported Available in v5.x with theme version 3
* Whether to display overlay on selected chip
Expand Down
Loading
Loading