import { Ionicons } from "@expo/vector-icons"; import { Pressable, StyleSheet, Text, TextInput, View, type TextInputProps } from "react-native"; import { fonts, radii, spacing } from "@/constants/theme"; import { useAppTheme } from "@/contexts/ThemeContext"; type StepperInputProps = Omit & { label: string; value: string; onChangeText: (value: string) => void; step?: number; min?: number; }; export function StepperInput({ label, value, onChangeText, step = 0.25, min = 0, ...props }: StepperInputProps) { const { colors } = useAppTheme(); function adjust(delta: number) { const current = Number.parseFloat(value) || 0; const next = Math.max(min, Math.round((current + delta) * 100) / 100); onChangeText(Number.isInteger(next) ? String(next) : String(next)); } return ( {label} adjust(-step)} style={({ pressed }) => [styles.stepButton, pressed && styles.stepPressed]} > adjust(step)} style={({ pressed }) => [styles.stepButton, pressed && styles.stepPressed]} > ); } const styles = StyleSheet.create({ wrapper: { gap: spacing.sm, }, label: { fontSize: 14, fontFamily: fonts.bodyMedium, }, field: { minHeight: 44, borderWidth: 1, borderRadius: radii.md, flexDirection: "row", alignItems: "center", paddingHorizontal: spacing.xs, }, stepButton: { width: 36, height: 36, alignItems: "center", justifyContent: "center", borderRadius: radii.sm, }, stepPressed: { opacity: 0.65, }, input: { flex: 1, textAlign: "center", fontSize: 14, fontFamily: fonts.body, paddingVertical: spacing.sm, }, });