|
| 1 | +import * as Haptics from 'expo-haptics'; |
| 2 | +import { |
| 3 | + Book, |
| 4 | + Calendar, |
| 5 | + Eye, |
| 6 | + HelpCircle, |
| 7 | + Mail, |
| 8 | + Megaphone, |
| 9 | + Search, |
| 10 | + Users, |
| 11 | +} from 'lucide-react-native'; |
| 12 | +import { useState } from 'react'; |
| 13 | +import { Text, TouchableOpacity, View } from 'react-native'; |
| 14 | + |
| 15 | +import { useSettingsStore } from '~/store/useSettingsStore'; |
| 16 | +import { COLORS } from '~/utils/colors'; |
| 17 | +import { cn } from '~/utils/utils'; |
| 18 | + |
| 19 | +type Props = { |
| 20 | + width: number; |
| 21 | + onSelectionChange: (hasSelection: boolean) => void; |
| 22 | + onSelectionUpdate: (selectedTag: string | null) => void; |
| 23 | +}; |
| 24 | + |
| 25 | +const REFERRAL_SOURCES = [ |
| 26 | + { id: 'friend-family', label: 'Friend or family', icon: Users }, |
| 27 | + { id: 'social-media', label: 'Social media (TikTok, LinkedIn, etc.)', icon: Megaphone }, |
| 28 | + { id: 'advertisement', label: 'Advertisement (online or in-person)', icon: Mail }, |
| 29 | + { id: 'on-campus', label: 'Seen being used on campus', icon: Eye }, |
| 30 | + { id: 'search-engine', label: 'Search engine (Google, Bing, etc.)', icon: Search }, |
| 31 | + { id: 'class-professor', label: 'Professor or class', icon: Book }, |
| 32 | + { id: 'event-fair', label: 'At an event or fair', icon: Calendar }, |
| 33 | + { id: 'other', label: 'Other', icon: HelpCircle }, |
| 34 | +]; |
| 35 | + |
| 36 | +const ReferralSourceScreen = ({ width, onSelectionChange, onSelectionUpdate }: Props) => { |
| 37 | + const [selectedTag, setSelectedTag] = useState<string | null>(null); |
| 38 | + const isDark = useSettingsStore((state) => state.isDarkMode); |
| 39 | + |
| 40 | + const toggleTag = (tagId: string) => { |
| 41 | + Haptics.impactAsync(Haptics.ImpactFeedbackStyle.Light); |
| 42 | + |
| 43 | + const newSelection = selectedTag === tagId ? null : tagId; |
| 44 | + |
| 45 | + setSelectedTag(newSelection); |
| 46 | + onSelectionChange(newSelection !== null); |
| 47 | + onSelectionUpdate(newSelection); |
| 48 | + }; |
| 49 | + |
| 50 | + return ( |
| 51 | + <View |
| 52 | + style={{ width }} |
| 53 | + className={cn('flex-1 px-6 py-8', isDark ? 'bg-neutral-900' : 'bg-white')} |
| 54 | + > |
| 55 | + <View className="mb-8"> |
| 56 | + <Text |
| 57 | + className={cn( |
| 58 | + 'mb-1 text-center font-bold text-3xl', |
| 59 | + isDark ? 'text-white' : 'text-gray-900', |
| 60 | + )} |
| 61 | + > |
| 62 | + How’d you hear about us? |
| 63 | + </Text> |
| 64 | + <Text className={cn('text-center text-lg', isDark ? 'text-gray-300' : 'text-gray-600')}> |
| 65 | + Select the option that best fits. |
| 66 | + </Text> |
| 67 | + </View> |
| 68 | + |
| 69 | + <View className="flex-1"> |
| 70 | + <View className="flex-row flex-wrap justify-between"> |
| 71 | + {REFERRAL_SOURCES.map((tag) => ( |
| 72 | + <TouchableOpacity |
| 73 | + activeOpacity={0.7} |
| 74 | + key={tag.id} |
| 75 | + onPress={() => toggleTag(tag.id)} |
| 76 | + className={cn( |
| 77 | + 'mb-4 w-[48%] rounded-xl p-4', |
| 78 | + selectedTag === tag.id |
| 79 | + ? 'border-ut-burnt-orange bg-ut-burnt-orange/10' |
| 80 | + : isDark |
| 81 | + ? ' bg-neutral-800' |
| 82 | + : 'border border-gray-200 bg-white', |
| 83 | + )} |
| 84 | + > |
| 85 | + <View className="items-center"> |
| 86 | + <tag.icon |
| 87 | + size={32} |
| 88 | + color={ |
| 89 | + selectedTag === tag.id |
| 90 | + ? COLORS['ut-burnt-orange'] |
| 91 | + : isDark |
| 92 | + ? COLORS['ut-grey-dark-mode'] |
| 93 | + : COLORS['ut-grey'] |
| 94 | + } |
| 95 | + /> |
| 96 | + <Text |
| 97 | + className={cn( |
| 98 | + 'mt-2 text-center font-medium text-sm', |
| 99 | + selectedTag === tag.id |
| 100 | + ? 'text-ut-burnt-orange' |
| 101 | + : isDark |
| 102 | + ? 'text-gray-300' |
| 103 | + : 'text-gray-700', |
| 104 | + )} |
| 105 | + > |
| 106 | + {tag.label} |
| 107 | + </Text> |
| 108 | + </View> |
| 109 | + </TouchableOpacity> |
| 110 | + ))} |
| 111 | + </View> |
| 112 | + </View> |
| 113 | + </View> |
| 114 | + ); |
| 115 | +}; |
| 116 | + |
| 117 | +export default ReferralSourceScreen; |
0 commit comments