license import { StyleSheet } from 'react-native' ; import { ThemeService , ThemeType , useTheme , } from '../theme/theme.service' ; export type StyleType = Record < string , any > ; export type Styles < T > = StyleSheet . NamedStyles < T > ; /**
 * User interactions that can be handled by Eva.
 */ export enum Interaction { HOVER = 'hover' , ACTIVE = 'active' , FOCUSED = 'focused' , INDETERMINATE = 'indeterminate' , VISIBLE = 'visible' } /**
 * Component states that can be handled by Eva.
 */ export enum State { CHECKED = 'checked' , SELECTED = 'selected' , DISABLED = 'disabled' } overview-example export const useStyleSheet = < T extends Styles < T > > ( styles ) : T => { const theme = useTheme ( ) ; return StyleService . createThemed ( styles , theme ) ; } ; /**
 * Service for creating styles that fit current theme.
 * Unlike StyleSheet class exported from React Native package, it allows using Eva theme variables.
 */ export class StyleService { see { StyleSheet . setStyleAttributePreprocessor } example static create = < T extends Styles < T > > ( styles ) : T => { return styles ; } ; returns static createThemed = < T extends Styles < T > > ( styles , theme ) : T => { return Object . keys ( styles ) . reduce ( ( acc , key ) : T => { return { ... acc , [ key ] : StyleService . createThemedEntry ( styles [ key ] , theme ) } ; } , { } as T ) ; } ; returns static createThemedEntry = ( style , theme ) : StyleType => { return Object . keys ( style ) . reduce ( ( acc , key ) : StyleType => { const value = style [ key ] ; return { ... acc , [ key ] : ThemeService . getValue ( value , theme , value ) } ; } , { } ) ; } ; }