import type { ReactNode } from 'react'; import type { ViewStyle, TextStyle, ViewProps, TextProps, TextInputProps, PressableProps, } from 'react-native'; import type themeType from './theme'; export type spacingType = T['spacing']; export type radiusType = keyof T['borderRadius']; export type colorType = keyof T['colors']; export type zIndicesType = keyof T['zIndices']; export type fontSizesType = keyof T['fontSizes']; export type fontFamilyType = keyof T['fonts']; export type lineHeightType = keyof T['lineHeights']; export type fontWeightType = keyof T['fontWeights']; export type fontLetterSpacingType< T extends themeType > = keyof T['letterSpacings']; export type iconSizesType = keyof T['iconSizes']; export type shadowType = keyof T['shadows']; export type borderRadiusType = { borderRadius?: radiusType; borderBottomEndRadius?: radiusType; borderBottomLeftRadius?: radiusType; borderBottomRightRadius?: radiusType; borderBottomStartRadius?: radiusType; borderTopEndRadius?: radiusType; borderTopLeftRadius?: radiusType; borderTopRightRadius?: radiusType; borderTopStartRadius?: radiusType; }; export type borderRadiusPropsType = keyof borderRadiusType< T >; export type colorValueType = { backgroundColor?: colorType; color?: colorType; borderColor?: colorType; borderRightColor?: colorType; borderLeftColor?: colorType; borderTopColor?: colorType; borderBottomColor?: colorType; }; export type colorValuePropsType = keyof colorValueType; export type spacingValueType = { margin?: spacingType | number; marginBottom?: spacingType | number; marginEnd?: spacingType | number; marginHorizontal?: spacingType | number; marginVertical?: spacingType | number; marginLeft?: spacingType | number; marginRight?: spacingType | number; marginStart?: spacingType | number; marginTop?: spacingType | number; padding?: spacingType | number; paddingBottom?: spacingType | number; paddingEnd?: spacingType | number; paddingHorizontal?: spacingType | number; paddingVertical?: spacingType | number; paddingLeft?: spacingType | number; paddingRight?: spacingType | number; paddingStart?: spacingType | number; paddingTop?: spacingType | number; }; export type spacingValuePropsType = keyof spacingValueType< T >; export type zIndexValueType = { zIndex?: zIndicesType; }; export type zIndexPropsType = keyof zIndexValueType; export type fontStyleValueType = { fontSize?: fontSizesType; fontFamily?: fontFamilyType; lineHeight?: lineHeightType; letterSpacing?: fontLetterSpacingType; fontWeight?: fontWeightType; }; export type fontStyleValuePropsType< T extends themeType > = keyof fontStyleValueType; export type shadowStyleKeys = | 'elevation' | 'shadowColor' | 'shadowOffset' | 'shadowOpacity' | 'shadowRadius'; export type omittedViewTypes = | borderRadiusPropsType | colorValuePropsType | spacingValuePropsType | zIndexPropsType | shadowStyleKeys; export type shadowValueType = { shadow?: shadowType; }; export type nonThemableViewStyles = Omit< ViewStyle, omittedViewTypes >; export type omittedTextTypes = | fontStyleValuePropsType | omittedViewTypes; export type nonThemableTextStyles = Omit< TextStyle, omittedTextTypes >; export interface CommonThemableTypes extends borderRadiusType, colorValueType, zIndexValueType, spacingValueType, shadowValueType {} export interface ThemableViewStyle extends nonThemableViewStyles, CommonThemableTypes { children?: ReactNode; } export interface ThemableTextStyle extends nonThemableTextStyles, CommonThemableTypes, fontStyleValueType { children?: ReactNode; } export interface ThemeableTextInputStyle extends ThemableTextStyle { placeholderTextColor?: colorType; } export interface BoxProps extends ThemableViewStyle { view?: ViewProps; } export interface RowProps extends ThemableViewStyle { spacing?: spacingType; view?: ViewProps; } export interface TextBlockProps extends ThemableTextStyle { text?: TextProps; } export type ThemedInputProps = Omit< TextInputProps, 'placeholderTextColor' | 'underlineColorAndroid' >; export interface InputProps extends ThemeableTextInputStyle { textInput?: ThemedInputProps; underlineColorAndroid?: colorType; } export type NonThemablePressableProps = Omit< PressableProps, 'style' | 'children' >; export interface TouchableProps extends ThemableViewStyle { press?: NonThemablePressableProps; inactiveStyle?: ThemableViewStyle; pressedStyle?: ThemableViewStyle; pressedChildren?: ReactNode; inactiveChildren?: ReactNode; }