react-native-external-keyboard
Version:
Toolkit for improving physical keyboard support in React Native
32 lines • 976 B
JavaScript
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