Skip to main content

colorHelpers

Content

Used to select color based on platform.

platformNativeColor

Selects color based on platform and if at least one is provided goes it through PlatformColor otherwise returns undefined.

Params

NameTypeRequiredDefault valueDescription
iosColorPlatformColorsIOSFalseUndefinediOS color from PlatformColorsIOS
androidColorPlatformColorsAndroidFalseUndefinedAndroid color from PlatformColorsAndroid

Usage example

export const LoadingComponent = () => {
return (
<View style={CommonStyles.flexCenter}>
<ActivityIndicator color={platformNativeColor(PlatformColorsIOS.label, PlatformColorsAndroid.primary)}/>
<Text style={CommonStyles.normalText} numberOfLines={1}>
{localization.common.loading}
</Text>
</View>
);
};

platformLocalColor

Selects color based on platform and if at least one is provided returns it otherwise returns undefined.

Params

NameTypeRequiredDefault valueDescription
iosColorColorsFalseUndefinediOS color from Colors
androidColorColorsFalseUndefinedAndroid color from Colors

Usage example

export const LoadingComponent = () => {
return (
<View style={CommonStyles.flexCenter}>
<ActivityIndicator color={platformLocalColor(Colors.red, Colors.green)} />
<Text style={CommonStyles.normalText} numberOfLines={1}>
{localization.common.loading}
</Text>
</View>
);
};

platformMixedColor

Selects color based on platform and if at least one is provided returns it or goes it through PlatformColor if it's type of PlatformColorsIOS or PlatformColorsAndroid otherwise returns undefined.

Params

NameTypeRequiredDefault valueDescription
iosColorColors, PlatformColorsIOSFalseUndefinediOS color from Colors or PlatformColorsIOS
androidColorColors, PlatformColorsAndroidFalseUndefinedAndroid color from Colors or PlatformColorsAndroid

Usage example

export const LoadingComponent = () => {
return (
<View style={CommonStyles.flexCenter}>
<ActivityIndicator color={platformMixedColor(Colors.red, PlatformColorsAndroid.primary)} />
<Text style={CommonStyles.normalText} numberOfLines={1}>
{localization.common.loading}
</Text>
</View>
);
};