use same visuals for notification sounds setting as the allow messages from (#4141)

This commit is contained in:
Hailey 2024-05-20 20:08:29 -07:00 committed by GitHub
parent 8be65a8790
commit 5bbb5f5806
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -35,7 +35,7 @@ export function MessagesSettingsScreen({}: Props) {
}, },
}) })
const onSelectItem = useCallback( const onSelectMessagesFrom = useCallback(
(keys: string[]) => { (keys: string[]) => {
const key = keys[0] const key = keys[0]
if (!key) return if (!key) return
@ -44,6 +44,15 @@ export function MessagesSettingsScreen({}: Props) {
[updateDeclaration], [updateDeclaration],
) )
const onSelectSoundSetting = useCallback(
(keys: string[]) => {
const key = keys[0]
if (!key) return
setPref('playSoundChat', key === 'enabled')
},
[setPref],
)
return ( return (
<CenteredView sideBorders style={a.h_full_vh}> <CenteredView sideBorders style={a.h_full_vh}>
<ViewHeader title={_(msg`Settings`)} showOnDesktop showBorder /> <ViewHeader title={_(msg`Settings`)} showOnDesktop showBorder />
@ -58,7 +67,7 @@ export function MessagesSettingsScreen({}: Props) {
(profile?.associated?.chat?.allowIncoming as AllowIncoming) ?? (profile?.associated?.chat?.allowIncoming as AllowIncoming) ??
'following', 'following',
]} ]}
onChange={onSelectItem}> onChange={onSelectMessagesFrom}>
<View> <View>
<Toggle.Item <Toggle.Item
name="all" name="all"
@ -91,19 +100,36 @@ export function MessagesSettingsScreen({}: Props) {
</Toggle.Group> </Toggle.Group>
{isNative && ( {isNative && (
<> <>
<Divider style={[a.my_lg]} /> <Divider />
<Toggle.Item <Text style={[a.text_lg, a.font_bold]}>
name="playSoundChat" <Trans>Notification Sounds</Trans>
label={_(msg`Play notification sounds`)} </Text>
value={preferences.playSoundChat} <Toggle.Group
onChange={() => { label={_(msg`Notification sounds`)}
setPref('playSoundChat', !preferences.playSoundChat) type="radio"
}}> values={[preferences.playSoundChat ? 'enabled' : 'disabled']}
<Toggle.Checkbox /> onChange={onSelectSoundSetting}>
<Toggle.LabelText> <View>
<Trans>Play notification sounds</Trans> <Toggle.Item
</Toggle.LabelText> name="enabled"
</Toggle.Item> label={_(msg`Enabled`)}
style={[a.justify_between, a.py_sm]}>
<Toggle.LabelText>
<Trans>Enabled</Trans>
</Toggle.LabelText>
<Toggle.Radio />
</Toggle.Item>
<Toggle.Item
name="disabled"
label={_(msg`Disabled`)}
style={[a.justify_between, a.py_sm]}>
<Toggle.LabelText>
<Trans>Disabled</Trans>
</Toggle.LabelText>
<Toggle.Radio />
</Toggle.Item>
</View>
</Toggle.Group>
</> </>
)} )}
</View> </View>