Skip to content

Commit a45a4e3

Browse files
committed
fix: add disabled state handling to Select component on Android
1 parent 445a9b2 commit a45a4e3

2 files changed

Lines changed: 11 additions & 5 deletions

File tree

apps/mobile/ios/Folo/Info.plist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353
</dict>
5454
</array>
5555
<key>CFBundleVersion</key>
56-
<string>115</string>
56+
<string>116</string>
5757
<key>ITSAppUsesNonExemptEncryption</key>
5858
<false/>
5959
<key>LSApplicationCategoryType</key>

apps/mobile/src/components/ui/form/Select.android.tsx

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { useSafeAreaInsets } from "react-native-safe-area-context"
88
import { Text } from "@/src/components/ui/typography/Text"
99
import { CheckFilledIcon } from "@/src/icons/check_filled"
1010
import { MingcuteDownLineIcon } from "@/src/icons/mingcute_down_line"
11-
import { accentColor } from "@/src/theme/colors"
11+
import { accentColor, useColor } from "@/src/theme/colors"
1212

1313
import { BottomModal } from "../modal/BottomModal"
1414
import { FormLabel } from "./Label"
@@ -25,6 +25,7 @@ interface SelectProps<T> {
2525
wrapperClassName?: string
2626
wrapperStyle?: StyleProp<ViewStyle>
2727
label?: string
28+
disabled?: boolean
2829
}
2930
export 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

Comments
 (0)