import { PlatformPressable } from '@react-navigation/elements' import { StaticScreenProps, useNavigation } from '@react-navigation/native' import type { NativeStackNavigationProp } from '@react-navigation/native-stack' import React, { useEffect } from 'react' import { Platform, StyleSheet, View } from 'react-native' import { Heading, Icon, Text } from '../components' import { useTheme } from '../hooks' import { platformFontWeightBold } from '../utils/styles' import type { GroupNotificationLevelSelectScreenProps } from './group_notification_level_select_screen' import { useGroup } from './notification_settings/hooks/groups' type GroupNotificationSettingsStackParamList = { GroupNotificationLevelSelect: GroupNotificationLevelSelectScreenProps['route']['params'] } export type GroupNotificationSettingsScreenProps = StaticScreenProps<{ groupId: number | string title: string }> export function GroupNotificationSettingsScreen({ route }: GroupNotificationSettingsScreenProps) { const { groupId, title } = route.params const navigation = useNavigation>() const styles = useStyles() const { data: group } = useGroup({ groupId }) const notificationLevelDescription = group.myGroupMembership?.notificationLevelDescription useEffect(() => { if (!group.name || title === group.name) return navigation.setOptions({ title: group.name }) }, [group.name, title, navigation]) const handleOpenSelector = () => { navigation.navigate('GroupNotificationLevelSelect', { groupId }) } return ( Group notification settings The settings are applied to all conversations in{' '} {group.name || title} Notify me for {Boolean(notificationLevelDescription) && ( {notificationLevelDescription} )} {Platform.OS === 'ios' && ( )} ) } const useStyles = () => { const { colors } = useTheme() return StyleSheet.create({ container: { flex: 1, backgroundColor: colors.surfaceColor100, }, sectionOuter: { paddingLeft: 16, backgroundColor: colors.surfaceColor100, }, sectionInner: { paddingRight: 16, paddingTop: 24, paddingBottom: 12, borderBottomWidth: 1, borderBottomColor: colors.borderColorDefaultBase, }, sectionHeading: { paddingBottom: 12, }, sectionSubtitle: { color: colors.textColorDefaultSecondary, paddingBottom: 2, }, groupNameBold: { fontWeight: platformFontWeightBold, }, settingRowPressable: { paddingLeft: 16, }, settingRowInner: { flexDirection: 'row', alignItems: 'center', justifyContent: 'space-between', paddingRight: 16, paddingVertical: 12, }, settingRowText: { flex: 1, gap: 2, }, chevron: { color: colors.iconColorDefaultDisabled, }, }) }