import * as React from "react"; import { View, Text, StyleProp, ViewStyle, TextStyle } from "react-native"; import { withTheme } from "../core/theming"; import { COMPONENT_TYPES, FORM_TYPES, GROUPS, PROP_TYPES, FIELD_NAME, BORDER_RADIUS_MODE, } from "../core/component-types"; import IconButton from "./IconButton"; import theme from "../styles/DefaultTheme"; import type Icon from "./Icon"; type Props = { value?: number; theme: typeof theme; style?: StyleProp; onChange?: (value: number) => void; iconSize?: number; iconColor?: string; borderRadius?: number; typeStyle?: StyleProp; IconOverride?: typeof Icon; }; const Stepper: React.FC = ({ value = 0, style, onChange, theme: { colors, typography }, iconSize = 24, iconColor = colors.strong, borderRadius = theme.roundness, IconOverride, typeStyle, }) => { const [stateValue, setStateValue] = React.useState(value); const handleMinus = () => { if (value || value === 0) { onChange && onChange(value - 1); } else { setStateValue(stateValue - 1); } }; const handlePlus = () => { if (value || value === 0) { onChange && onChange(value + 1); } else { setStateValue(stateValue + 1); } }; return ( {value || stateValue} ); }; export default withTheme(Stepper); export const SEED_DATA = [ { name: "Stepper", tag: "Stepper", description: "A component used to control the quantity of something", category: COMPONENT_TYPES.deprecated, preview_image_url: "{CLOUDINARY_URL}/Control_Stepper.png", supports_list_render: false, props: { fieldName: { ...FIELD_NAME, defaultValue: "stepperValue", }, iconSize: { group: GROUPS.basic, label: "Current Icon Size", description: "The size of the icons", editable: true, required: false, min: 0, max: 60, step: 1, formType: FORM_TYPES.number, propType: PROP_TYPES.NUMBER, defaultValue: 24, }, iconColor: { group: GROUPS.basic, label: "Current Icon Color", description: "The color of the icons", editable: true, required: false, formType: FORM_TYPES.color, propType: PROP_TYPES.THEME, defaultValue: "strong", }, borderRadius: { ...BORDER_RADIUS_MODE, }, }, layout: {}, }, ];