@@ -8,7 +8,7 @@ import { useSafeAreaInsets } from "react-native-safe-area-context"
88import { Text } from "@/src/components/ui/typography/Text"
99import { CheckFilledIcon } from "@/src/icons/check_filled"
1010import { MingcuteDownLineIcon } from "@/src/icons/mingcute_down_line"
11- import { accentColor } from "@/src/theme/colors"
11+ import { accentColor , useColor } from "@/src/theme/colors"
1212
1313import { BottomModal } from "../modal/BottomModal"
1414import { FormLabel } from "./Label"
@@ -25,6 +25,7 @@ interface SelectProps<T> {
2525 wrapperClassName ?: string
2626 wrapperStyle ?: StyleProp < ViewStyle >
2727 label ?: string
28+ disabled ?: boolean
2829}
2930export function Select < T > ( {
3031 options,
@@ -34,7 +35,9 @@ export function Select<T>({
3435 wrapperClassName,
3536 wrapperStyle,
3637 label,
38+ disabled,
3739} : SelectProps < T > ) {
40+ const grayColor = useColor ( "gray" )
3841 const [ isModalVisible , setModalVisible ] = useState ( false )
3942 const selectedOption = options . find ( ( opt ) => opt . value === value )
4043 const insets = useSafeAreaInsets ( )
@@ -68,6 +71,7 @@ export function Select<T>({
6871 activeOpacity = { 0.7 }
6972 onPress = { ( ) => handleSelectOption ( item . value ) }
7073 className = "flex-row items-center justify-between p-4"
74+ disabled = { disabled }
7175 >
7276 < View className = "flex-1" >
7377 < Text
@@ -94,27 +98,29 @@ export function Select<T>({
9498 </ >
9599 )
96100 } ,
97- [ handleSelectOption , value ] ,
101+ [ handleSelectOption , value , disabled ] ,
98102 )
99103 const Trigger = (
100104 < TouchableOpacity
101105 className = { cn (
102106 "min-w-24 flex-1 shrink flex-row items-center rounded-lg pl-3" ,
107+ disabled ? "opacity-50" : "" ,
103108 wrapperClassName ,
104109 ) }
105110 hitSlop = { 30 }
106111 onPress = { showOptions }
112+ disabled = { disabled }
107113 style = { wrapperStyle }
108114 >
109115 < Text
110- className = "text-accent flex-1 text-right font-semibold"
116+ className = { cn ( " flex-1 text-right font-semibold", disabled ? "text-gray" : "text-accent" ) }
111117 ellipsizeMode = "middle"
112118 numberOfLines = { 1 }
113119 >
114120 { displayValue || selectedOption ?. label || "Select" }
115121 </ Text >
116122 < View className = "ml-auto shrink-0 pl-1" >
117- < MingcuteDownLineIcon color = { accentColor } height = { 18 } width = { 18 } />
123+ < MingcuteDownLineIcon color = { disabled ? grayColor : accentColor } height = { 18 } width = { 18 } />
118124 </ View >
119125 </ TouchableOpacity >
120126 )
0 commit comments