Created
May 3, 2025 11:23
-
-
Save benschac/6efe18036717323e8e021891512baaac to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { ScrollView, Separator, Settings, SizableText, YStack, isWeb, useMedia } from '@my/ui' | |
| import { | |
| Book, | |
| Cog, | |
| HeartHandshake, | |
| Info, | |
| Instagram, | |
| Lock, | |
| LogOut, | |
| Mail, | |
| Moon, | |
| User, | |
| } from '@tamagui/lucide-icons' | |
| import { useThemeSetting } from 'app/provider/theme' | |
| import { redirect } from 'app/utils/redirect' | |
| import { useSupabase } from 'app/utils/supabase/useSupabase' | |
| import { usePathname } from 'app/utils/usePathname' | |
| import { useLink } from 'solito/link' | |
| import rootPackageJson from '../../../../package.json' | |
| import packageJson from '../../package.json' | |
| export const SettingsScreen = () => { | |
| const media = useMedia() | |
| const pathname = usePathname() | |
| return ( | |
| <YStack f={1}> | |
| <ScrollView> | |
| <Settings> | |
| <Settings.Items> | |
| <Settings.Group $gtSm={{ space: '$1' }}> | |
| <Settings.Item icon={User} accentTheme="blue" {...useLink({ href: '/edit-profile' })}> | |
| Profile | |
| </Settings.Item> | |
| <Settings.Item | |
| icon={Cog} | |
| isActive={pathname === 'settings/general'} | |
| {...useLink({ href: media.sm ? '/general' : '/settings' })} | |
| accentTheme="green" | |
| > | |
| General | |
| </Settings.Item> | |
| <Settings.Item | |
| icon={HeartHandshake} | |
| isActive={pathname === 'settings/support'} | |
| {...useLink({ href: '/settings/support' })} | |
| accentTheme="red" | |
| > | |
| Support Treasure It | |
| </Settings.Item> | |
| <Settings.Item | |
| icon={Lock} | |
| isActive={pathname === '/settings/change-password'} | |
| {...useLink({ href: '/change-password' })} | |
| accentTheme="green" | |
| > | |
| Change Password | |
| </Settings.Item> | |
| <Settings.Item | |
| icon={Mail} | |
| isActive={pathname === '/settings/change-email'} | |
| {...useLink({ href: '/change-email' })} | |
| accentTheme="green" | |
| > | |
| Change Email | |
| </Settings.Item> | |
| </Settings.Group> | |
| {isWeb && <Separator boc="$color3" mx="$-4" bw="$0.25" />} | |
| <Settings.Group> | |
| <Settings.Item | |
| icon={Book} | |
| isActive={pathname === '/privacy-policy'} | |
| {...useLink({ href: '/privacy-policy' })} | |
| accentTheme="purple" | |
| > | |
| Privacy Policy | |
| </Settings.Item> | |
| <Settings.Item | |
| icon={Book} | |
| isActive={pathname === '/terms-of-service'} | |
| {...useLink({ href: '/terms-of-service' })} | |
| accentTheme="purple" | |
| > | |
| Terms Of Service | |
| </Settings.Item> | |
| {/* removing about from web since landing pages are more common on web - feel free to add back if needed */} | |
| {!isWeb && ( | |
| // isWeb is a constant so this isn't really a conditional hook | |
| // eslint-disable-next-line react-hooks/rules-of-hooks | |
| <Settings.Item icon={Info} {...useLink({ href: '/about' })} accentTheme="blue"> | |
| About | |
| </Settings.Item> | |
| )} | |
| </Settings.Group> | |
| {isWeb && <Separator boc="$color3" mx="$-4" bw="$0.25" />} | |
| <Settings.Group> | |
| <Settings.Item | |
| icon={Instagram} | |
| onPress={() => redirect('https://www.instagram.com/treasureit.fun')} | |
| accentTheme="blue" | |
| > | |
| </Settings.Item> | |
| </Settings.Group> | |
| {isWeb && <Separator boc="$color3" mx="$-4" bw="$0.25" />} | |
| <Settings.Group> | |
| <SettingsThemeAction /> | |
| <SettingsItemLogoutAction /> | |
| </Settings.Group> | |
| </Settings.Items> | |
| </Settings> | |
| </ScrollView> | |
| {/* | |
| NOTE: you should probably get the actual native version here using https://www.npmjs.com/package/react-native-version-info | |
| we just did a simple package.json read since we want to keep things simple for the starter | |
| */} | |
| <SizableText fontSize={12} fontWeight={600} py="$2" ta="center" theme="alt2"> | |
| {rootPackageJson.name} {packageJson.version} | |
| </SizableText> | |
| </YStack> | |
| ) | |
| } | |
| const SettingsThemeAction = () => { | |
| const { toggle, current } = useThemeSetting() | |
| return ( | |
| <Settings.Item icon={Moon} accentTheme="blue" onPress={toggle} rightLabel={current}> | |
| Theme | |
| </Settings.Item> | |
| ) | |
| } | |
| const SettingsItemLogoutAction = () => { | |
| const supabase = useSupabase() | |
| return ( | |
| <Settings.Item icon={LogOut} accentTheme="red" onPress={() => supabase.auth.signOut()}> | |
| Log Out | |
| </Settings.Item> | |
| ) | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment