Skip to content

Commit

Permalink
fix: 基础组件bug
Browse files Browse the repository at this point in the history
  • Loading branch information
lareinayanyu committed Nov 21, 2024
1 parent 9ffe156 commit 5ae0db6
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ export interface CheckboxProps extends Selection {
'parent-height'?: number;
children?: ReactNode
bindtap?: (evt: NativeSyntheticEvent<TouchEvent> | unknown) => void
_onChange?: (evt: NativeSyntheticEvent<TouchEvent> | unknown, { checked }: { checked: boolean }) => void
}

const styles = StyleSheet.create({
Expand Down Expand Up @@ -90,7 +91,8 @@ const Checkbox = forwardRef<HandlerRef<View, CheckboxProps>, CheckboxProps>(
'parent-font-size': parentFontSize,
'parent-width': parentWidth,
'parent-height': parentHeight,
bindtap
bindtap,
_onChange
} = props

const [isChecked, setIsChecked] = useState<boolean>(!!checked)
Expand All @@ -114,10 +116,12 @@ const Checkbox = forwardRef<HandlerRef<View, CheckboxProps>, CheckboxProps>(
groupValue[value].checked = checked
}
notifyChange && notifyChange(evt)
// Called when the switch type attribute is checkbox
_onChange && _onChange(evt, { checked })
}

const onTap = (evt: NativeSyntheticEvent<TouchEvent>) => {
bindtap!(getCustomEvent('tap', evt, { layoutRef }, props))
bindtap && bindtap(getCustomEvent('tap', evt, { layoutRef }, props))
onChange(evt)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ const Input = forwardRef<HandlerRef<TextInput, FinalInputProps>, FinalInputProps
const [contentHeight, setContentHeight] = useState(0)

const styleObj = extendObject(
{ padding: 0 },
{ padding: 0, backgroundColor: '#fff' },
style,
multiline && autoHeight
? {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ const Radio = forwardRef<HandlerRef<View, RadioProps>, RadioProps>(
}

const onTap = (evt: NativeSyntheticEvent<TouchEvent>) => {
bindtap!(getCustomEvent('tap', evt, { layoutRef }, props))
bindtap && bindtap(getCustomEvent('tap', evt, { layoutRef }, props))
onChange(evt)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -439,9 +439,9 @@ const _ScrollView = forwardRef<HandlerRef<ScrollView & View, ScrollViewProps>, S
ref: scrollViewRef,
onScroll: onScroll,
onContentSizeChange: onContentSizeChange,
bindtouchstart: ((enhanced && binddragstart) || bindtouchstart) ? onScrollTouchStart : undefined,
bindtouchmove: ((enhanced && binddragging) || bindtouchend) ? onScrollTouchMove : undefined,
bindtouchend: ((enhanced && binddragend) || bindtouchend) ? onScrollTouchEnd : undefined,
bindtouchstart: ((enhanced && binddragstart) || bindtouchstart) && onScrollTouchStart,
bindtouchmove: ((enhanced && binddragging) || bindtouchend) && onScrollTouchMove,
bindtouchend: ((enhanced && binddragend) || bindtouchend) && onScrollTouchEnd,
onScrollBeginDrag: onScrollDrag,
onScrollEndDrag: onScrollDrag,
onMomentumScrollEnd: onScrollEnd
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ const _Switch = forwardRef<HandlerRef<Switch, _SwitchProps>, _SwitchProps>((prop
'parent-font-size': parentFontSize,
'parent-width': parentWidth,
'parent-height': parentHeight,

bindchange,
catchchange
} = props
Expand Down

0 comments on commit 5ae0db6

Please sign in to comment.