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