import { PlatformPressable } from '@react-navigation/elements' import { StaticScreenProps, useNavigation } from '@react-navigation/native' import React, { useCallback } from 'react' import { Platform, StyleSheet, View } from 'react-native' import { useSafeAreaInsets } from 'react-native-safe-area-context' import { Heading, Icon, Text, VersionFooter } from '../components' import { Switch } from '../components/display/switch' import { useDirectMessagesEligible, useTheme } from '../hooks' import { useAppName } from '../hooks/use_app_name' import { usePersonSettings } from '../hooks/use_person_settings' export type SettingsScreenProps = StaticScreenProps<{}> export function SettingsScreen({}: SettingsScreenProps) { const styles = useStyles() const { directMessagesDisabled, setDirectMessagesDisabled, isMutating } = usePersonSettings() const directMessagesEligible = useDirectMessagesEligible() const appName = useAppName() const navigation = useNavigation() const handleNotificationSettings = useCallback(() => { navigation.navigate('NotificationSettings', {}) }, [navigation]) const handleGetHelp = useCallback(() => { navigation.navigate('GetHelp', { type: 'chat' }) }, [navigation]) return ( Messages {directMessagesEligible && ( Allow direct messages When off, you can't be added to new direct messages, and any you're already in will be turned off. setDirectMessagesDisabled(!enabled)} disabled={isMutating} /> )} {appName !== 'services' && } ) } interface NavRowProps { label: string onPress: () => void } function NavRow({ label, onPress }: NavRowProps) { const styles = useNavRowStyles() return ( {label} {Platform.OS === 'ios' && ( )} ) } const useStyles = () => { const { colors } = useTheme() const insets = useSafeAreaInsets() return StyleSheet.create({ container: { flex: 1, }, footer: { flex: 1, justifyContent: 'flex-end', paddingBottom: Math.max(insets.bottom, 8), }, sectionOuter: { paddingLeft: 16, }, sectionHeader: { paddingRight: 16, paddingTop: 24, paddingBottom: 12, borderBottomWidth: 1, borderBottomColor: colors.borderColorDefaultBase, }, settingRow: { flexDirection: 'row', alignItems: 'flex-start', justifyContent: 'space-between', paddingRight: 16, paddingVertical: 12, borderBottomWidth: 1, borderBottomColor: colors.borderColorDefaultBase, }, settingRowText: { flex: 1, gap: 8, }, }) } const useNavRowStyles = () => { const { colors } = useTheme() return StyleSheet.create({ container: { paddingLeft: 0, }, inner: { flexDirection: 'row', alignItems: 'center', justifyContent: 'space-between', paddingRight: 16, paddingVertical: 14, borderBottomWidth: 1, borderBottomColor: colors.borderColorDefaultBase, }, chevron: { color: colors.iconColorDefaultDisabled, }, }) }