u
This commit is contained in:
1 parent
d60be4a75b
commit
be8eaae7c5
24 files changed
+595
-232
No files matched your search
@@ -0,0 +1,54 @@
|
||||
import type { ViewStyle } from 'react-native'
|
||||
// components/ui/CustomButton.tsx
|
||||
import React from 'react'
|
||||
import {
|
||||
ButtonSpinner,
|
||||
ButtonText,
|
||||
Button as NativeButton,
|
||||
} from '@/components/ui/button'
|
||||
|
||||
interface CustomButtonProps {
|
||||
children: React.ReactNode
|
||||
onPress?: () => void
|
||||
disabled?: boolean
|
||||
loading?: boolean
|
||||
className?: string
|
||||
style?: ViewStyle
|
||||
action?: 'primary' | 'secondary' | 'positive' | 'negative' | 'default'
|
||||
variant?: 'solid' | 'outline' | 'link'
|
||||
size?: 'xs' | 'sm' | 'md' | 'lg' | 'xl'
|
||||
}
|
||||
|
||||
const Button: React.FC<CustomButtonProps> = ({
|
||||
children,
|
||||
onPress,
|
||||
disabled = false,
|
||||
loading = false,
|
||||
className,
|
||||
style,
|
||||
action = 'primary',
|
||||
variant = 'solid',
|
||||
size = 'md',
|
||||
}) => {
|
||||
const isDisabled = disabled || loading
|
||||
|
||||
return (
|
||||
<NativeButton
|
||||
onPress={onPress}
|
||||
isDisabled={isDisabled}
|
||||
className={className}
|
||||
style={[
|
||||
style,
|
||||
{ opacity: isDisabled ? 0.8 : 1 },
|
||||
]}
|
||||
action={action}
|
||||
variant={variant}
|
||||
size={size}
|
||||
>
|
||||
{loading && <ButtonSpinner color="#fff" className="mr-2" />}
|
||||
<ButtonText>{children}</ButtonText>
|
||||
</NativeButton>
|
||||
)
|
||||
}
|
||||
|
||||
export default Button
|
||||
@@ -0,0 +1,50 @@
|
||||
// components/ui/CustomCheckbox.tsx
|
||||
import type { ViewStyle } from 'react-native'
|
||||
import React from 'react'
|
||||
import {
|
||||
CheckboxIcon,
|
||||
CheckboxIndicator,
|
||||
CheckboxLabel,
|
||||
Checkbox as NativeCheckbox,
|
||||
} from '@/components/ui/checkbox'
|
||||
import { CheckIcon } from '@/components/ui/icon'
|
||||
|
||||
interface CustomCheckboxProps {
|
||||
value?: string
|
||||
isChecked: boolean
|
||||
onChange: (checked: boolean) => void
|
||||
label: React.ReactNode
|
||||
className?: string
|
||||
style?: ViewStyle
|
||||
disabled?: boolean
|
||||
icon?: React.ElementType
|
||||
}
|
||||
|
||||
const Checkbox: React.FC<CustomCheckboxProps> = ({
|
||||
value,
|
||||
isChecked,
|
||||
onChange,
|
||||
label,
|
||||
className,
|
||||
style,
|
||||
disabled,
|
||||
icon,
|
||||
}) => {
|
||||
return (
|
||||
<NativeCheckbox
|
||||
value={value ?? ''} // 避免 undefined
|
||||
isChecked={isChecked}
|
||||
onChange={onChange}
|
||||
className={className}
|
||||
style={style}
|
||||
isDisabled={disabled}
|
||||
>
|
||||
<CheckboxIndicator>
|
||||
<CheckboxIcon as={icon ?? CheckIcon} />
|
||||
</CheckboxIndicator>
|
||||
<CheckboxLabel>{label}</CheckboxLabel>
|
||||
</NativeCheckbox>
|
||||
)
|
||||
}
|
||||
|
||||
export default Checkbox
|
||||
@@ -1,8 +1,12 @@
|
||||
import Button from './Button'
|
||||
import Checkbox from './Checkbox'
|
||||
import Form, { FormRef } from './Form'
|
||||
import FormItem from './FormItem'
|
||||
import Input from './Input'
|
||||
|
||||
export {
|
||||
Button as AButton,
|
||||
Checkbox as ACheckbox,
|
||||
Form as AForm,
|
||||
FormItem as AFormItem,
|
||||
FormRef as AFormRef,
|
||||
|
||||
Reference in new issue
Block a user