Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[IOAPPX-269] Fix wrong color of TextInput when experimental DS is off #228

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 16 additions & 13 deletions src/components/textInput/TextInputBase.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
} from "react-native";
import Animated, {
Easing,
WithTimingConfig,
useAnimatedStyle,
useSharedValue,
withTiming
Expand All @@ -17,7 +18,8 @@ import {
IOColors,
IOSpacingScale,
IOStyles,
useIOExperimentalDesign
useIOExperimentalDesign,
useIOTheme
} from "../../core";
import { makeFontStyleObject } from "../../utils/fonts";
import { RNTextInputProps, getInputPropsByType } from "../../utils/textInput";
Expand Down Expand Up @@ -161,6 +163,8 @@ export const TextInputBase = ({
isPassword,
autoFocus
}: InputTextProps) => {
const theme = useIOTheme();

const labelSharedValue = useSharedValue<boolean>(false);
const [inputStatus, setInputStatus] = React.useState<InputStatus>(
disabled ? "disabled" : "initial"
Expand All @@ -177,7 +181,7 @@ export const TextInputBase = ({
const boxStyle: ViewStyle = useMemo(() => {
if (inputStatus === "focused") {
return {
borderColor: IOColors["blueIO-500"],
borderColor: IOColors[theme["interactiveElem-default"]],
borderWidth: 2
};
}
Expand All @@ -191,20 +195,17 @@ export const TextInputBase = ({
borderColor: IOColors["grey-200"],
borderWidth: 1
};
}, [inputStatus]);
}, [inputStatus, theme]);

const easingConf: WithTimingConfig = {
duration: 300,
easing: Easing.elastic(0.85)
};

const animatedLabelProps = useAnimatedStyle(() => ({
fontSize: withTiming(labelSharedValue.value ? 12 : 16, {
duration: 300,
easing: Easing.elastic(0.85)
}),
fontSize: withTiming(labelSharedValue.value ? 12 : 16, easingConf),
transform: [
{
translateY: withTiming(labelSharedValue.value ? -14 : 0, {
duration: 300,
easing: Easing.elastic(0.85)
})
}
{ translateY: withTiming(labelSharedValue.value ? -14 : 0, easingConf) }
]
}));

Expand Down Expand Up @@ -294,6 +295,8 @@ export const TextInputBase = ({
labelSharedValue.value = true;
onFocus?.();
}}
selectionColor={IOColors[theme["interactiveElem-default"]]} // Caret iOS
cursorColor={IOColors[theme["interactiveElem-default"]]} // Caret Android
maxLength={counterLimit}
onBlur={onBlurHandler}
value={inputValue}
Expand Down
Loading