Skip to content

Commit 709d457

Browse files
committed
new: Placeholder has the color animation now
1 parent cd5a2ea commit 709d457

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

example/App.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,15 @@ import InteractiveTextInput from "./lib/InteractiveTextInput";
1515
const App = () => {
1616
return (
1717
<SafeAreaView
18-
style={{ flex: 1, alignItems: "center", justifyContent: "center" }}
18+
style={{
19+
height: 300,
20+
alignItems: "center",
21+
justifyContent: "space-evenly",
22+
}}
1923
>
2024
<InteractiveTextInput />
25+
<InteractiveTextInput />
26+
<InteractiveTextInput />
2127
</SafeAreaView>
2228
);
2329
};

example/lib/InteractiveTextInput.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ const SUCCESS_COLOR = "#008FEB";
1919
const ORIGINAL_COLOR = "transparent";
2020
const ORIGINAL_VALUE = 0;
2121
const SUCCESS_VALUE = 1;
22+
const PLACEHOLDER_COLOR = "#757575";
2223

2324
type CustomStyleProp = StyleProp<ViewStyle> | Array<StyleProp<ViewStyle>>;
2425

@@ -42,7 +43,7 @@ export default class InteractiveTextInput extends React.Component<
4243

4344
showOriginColor = () => {
4445
Animated.timing(this.interpolatedColor, {
45-
duration: 450,
46+
duration: 350,
4647
toValue: ORIGINAL_VALUE,
4748
useNativeDriver: false,
4849
}).start();
@@ -61,6 +62,10 @@ export default class InteractiveTextInput extends React.Component<
6162
inputRange: [ORIGINAL_VALUE, SUCCESS_VALUE],
6263
outputRange: [ORIGINAL_COLOR, SUCCESS_COLOR],
6364
});
65+
let placeholderTextColor = this.interpolatedColor.interpolate({
66+
inputRange: [ORIGINAL_VALUE, SUCCESS_VALUE],
67+
outputRange: [PLACEHOLDER_COLOR, SUCCESS_COLOR],
68+
});
6469
return (
6570
<AnimatedTextInput
6671
style={{
@@ -74,6 +79,7 @@ export default class InteractiveTextInput extends React.Component<
7479
borderWidth: 1,
7580
borderColor: borderColor,
7681
}}
82+
placeholderTextColor={placeholderTextColor}
7783
placeholder="Email"
7884
onFocus={() => {
7985
this.showFocusColor();

0 commit comments

Comments
 (0)