PliWould/components/MeasurementInput.tsx

45 lines
1.0 KiB
TypeScript
Raw Normal View History

2024-07-01 17:05:24 +02:00
import { Length } from "convert";
import { StyleSheet, Text, View } from "react-native";
import { NumberInput, NumberInputProps } from "./NumberInput";
2024-07-01 04:49:41 +02:00
export type t_length_unit = "foot" | "inch"
export type MeasurementInputProps = NumberInputProps & {
units?: Length,
2024-07-01 04:49:41 +02:00
}
export function MeasurementInput({onValueSet, defaultValue: defaultValue, label, units}: MeasurementInputProps) {
units = units || "ft";
2024-07-01 04:49:41 +02:00
return (
<View style={styles.inputWrapper}>
<NumberInput
onValueSet={v => onValueSet && onValueSet(v)}
defaultValue={defaultValue}
label={label}
/>
2024-07-01 04:49:41 +02:00
</View>
)
}
const styles = StyleSheet.create({
inputWrapper: {
alignItems: "flex-start",
flexDirection: "row",
verticalAlign: "middle"
},
2024-07-01 04:49:41 +02:00
unitHints: {
padding: 10,
fontSize: 20,
verticalAlign: "middle",
2024-07-01 04:49:41 +02:00
},
lengthInput: {
borderWidth: 1,
borderRadius: 4,
borderColor: "grey",
padding: 4,
margin: 4,
fontSize: 25,
2024-07-01 04:49:41 +02:00
},
})