import * as React from "react";
import { Animated, StyleSheet } from "react-native";
import AnimatedText from "../../Text/AnimatedText";
import type { LabelBackgroundProps } from "../types";
const LabelBackground = ({
parentState,
labelProps: {
placeholderStyle,
baseLabelTranslateX,
topPosition,
hasActiveOutline,
label,
backgroundColor,
},
labelStyle,
}: LabelBackgroundProps) => {
const hasFocus = hasActiveOutline || parentState.value;
const opacity = parentState.labeled.interpolate({
inputRange: [0, 1],
outputRange: [hasFocus ? 1 : 0, 0],
});
const labelTranslationX = {
transform: [
{
translateX: parentState.labeled.interpolate({
inputRange: [0, 1],
outputRange: [-baseLabelTranslateX, 0],
}),
},
],
};
return label
? [
,
{label}
,
]
: null;
};
export default LabelBackground;
const styles = StyleSheet.create({
view: {
position: "absolute",
top: 6,
left: 10,
width: 8,
height: 2,
},
outlinedLabel: {
position: "absolute",
left: 18,
paddingHorizontal: 0,
color: "transparent",
},
});