UNPKG

react-native-external-keyboard

Version:
32 lines 976 B
import { useState, useMemo, useCallback } from 'react'; export const useTintStyle = ({ focusStyle, haloEffect, onFocusChange, tintBackground = '#dce3f9' }) => { const [focused, setFocusStatus] = useState(false); const onFocusChangeHandler = useCallback(isFocused => { setFocusStatus(isFocused); onFocusChange === null || onFocusChange === void 0 || onFocusChange(isFocused); }, [onFocusChange]); const fStyle = useMemo(() => { if (!focusStyle) return undefined; const specificStyle = typeof focusStyle === 'function' ? focusStyle({ focused }) : focusStyle; return focused ? specificStyle : undefined; }, [focused, focusStyle]); const tintStyle = useMemo(() => { if (haloEffect) return; return focused ? { backgroundColor: tintBackground } : undefined; }, [haloEffect, focused, tintBackground]); return { onFocusChangeHandler, tintStyle, fStyle }; }; //# sourceMappingURL=useTintStyle.js.map