import { MeasurementInput } from "./MeasurementInput"; import { area_t, dimensions_t } from "@/lib/dimensions_t"; import { Length } from "convert"; import { useState } from "react"; import { StyleSheet, Text, View } from "react-native"; export type AreaInputProps = { onMeasurementSet?: (area : dimensions_t) => any, defaultValue?: area_t, lengthLabel?: string, widthLabel?: string, units?: Length, } export function AreaInput({onMeasurementSet, lengthLabel, widthLabel, defaultValue, units} : AreaInputProps) { defaultValue = defaultValue || {l: 0, w: 0, u: "ft"} units = units || "ft" const [area, setArea] = useState(defaultValue) function doOnLengthSet(measurement : dimensions_t) { setArea({ ...area, l: measurement.l }); onMeasurementSet && onMeasurementSet({ ...area, l: measurement.l }); } function doOnWidthSet(measurement : dimensions_t) { setArea({ ...area, w: measurement.l }); onMeasurementSet && onMeasurementSet({ ...area, w: measurement.l }); } return ( x ) } const styles = StyleSheet.create({ areaInputWrapper: { flexDirection: "row", verticalAlign: "middle", } })