@planningcenter/chat-react-native 3.24.0-rc.8 → 3.24.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/components/display/platform_modal_header_buttons.d.ts +8 -0
- package/build/components/display/platform_modal_header_buttons.d.ts.map +1 -1
- package/build/components/display/platform_modal_header_buttons.js +8 -0
- package/build/components/display/platform_modal_header_buttons.js.map +1 -1
- package/build/navigation/index.d.ts +29 -79
- package/build/navigation/index.d.ts.map +1 -1
- package/build/navigation/index.js +20 -28
- package/build/navigation/index.js.map +1 -1
- package/build/screens/group_notification_settings_screen.d.ts +8 -0
- package/build/screens/group_notification_settings_screen.d.ts.map +1 -0
- package/build/screens/group_notification_settings_screen.js +79 -0
- package/build/screens/group_notification_settings_screen.js.map +1 -0
- package/build/screens/index.d.ts +1 -0
- package/build/screens/index.d.ts.map +1 -1
- package/build/screens/index.js +1 -0
- package/build/screens/index.js.map +1 -1
- package/build/screens/message_report/components/message_preview.d.ts.map +1 -1
- package/build/screens/message_report/components/message_preview.js +12 -19
- package/build/screens/message_report/components/message_preview.js.map +1 -1
- package/build/screens/notification_settings/hooks/groups.d.ts +94 -0
- package/build/screens/notification_settings/hooks/groups.d.ts.map +1 -0
- package/build/screens/notification_settings/hooks/groups.js +92 -0
- package/build/screens/notification_settings/hooks/groups.js.map +1 -0
- package/build/screens/notification_settings_screen.d.ts.map +1 -1
- package/build/screens/notification_settings_screen.js +50 -32
- package/build/screens/notification_settings_screen.js.map +1 -1
- package/build/screens/preferred_app_selection_screen.js +1 -1
- package/build/screens/preferred_app_selection_screen.js.map +1 -1
- package/build/types/resources/group_membership.d.ts +6 -0
- package/build/types/resources/group_membership.d.ts.map +1 -0
- package/build/types/resources/group_membership.js +2 -0
- package/build/types/resources/group_membership.js.map +1 -0
- package/build/types/resources/group_resource.d.ts +4 -0
- package/build/types/resources/group_resource.d.ts.map +1 -1
- package/build/types/resources/group_resource.js.map +1 -1
- package/build/types/resources/index.d.ts +2 -0
- package/build/types/resources/index.d.ts.map +1 -1
- package/build/types/resources/index.js +2 -0
- package/build/types/resources/index.js.map +1 -1
- package/package.json +2 -2
- package/src/components/display/platform_modal_header_buttons.tsx +16 -0
- package/src/navigation/index.tsx +27 -31
- package/src/screens/group_notification_settings_screen.tsx +92 -0
- package/src/screens/index.ts +1 -0
- package/src/screens/message_report/components/message_preview.tsx +15 -22
- package/src/screens/notification_settings/hooks/groups.ts +101 -0
- package/src/screens/notification_settings_screen.tsx +61 -34
- package/src/screens/preferred_app_selection_screen.tsx +1 -1
- package/src/types/resources/group_membership.ts +6 -0
- package/src/types/resources/group_resource.ts +5 -0
- package/src/types/resources/index.ts +2 -0
|
@@ -3,10 +3,12 @@ import { StaticScreenProps, useNavigation } from '@react-navigation/native'
|
|
|
3
3
|
import type { NativeStackNavigationProp } from '@react-navigation/native-stack'
|
|
4
4
|
import React, { useCallback, useEffect, type ReactNode } from 'react'
|
|
5
5
|
import { FlatList, Platform, StyleSheet, View, type ViewProps, type ViewStyle } from 'react-native'
|
|
6
|
-
import { Heading, Icon, Text } from '../components'
|
|
6
|
+
import { Badge, Heading, Icon, Text } from '../components'
|
|
7
7
|
import { HeaderTextButton } from '../components/display/platform_modal_header_buttons'
|
|
8
8
|
import { useTheme } from '../hooks'
|
|
9
9
|
import { isDefined } from '../types'
|
|
10
|
+
import type { GroupNotificationSettingsScreenProps } from './group_notification_settings_screen'
|
|
11
|
+
import { useGroups } from './notification_settings/hooks/groups'
|
|
10
12
|
import { useChatTypes } from './preferred_app/hooks/use_chat_types'
|
|
11
13
|
import type { PreferredAppSelectionScreenProps } from './preferred_app_selection_screen'
|
|
12
14
|
|
|
@@ -17,6 +19,7 @@ import type { PreferredAppSelectionScreenProps } from './preferred_app_selection
|
|
|
17
19
|
type NotificationSettingsStackParamList = {
|
|
18
20
|
NotificationSettings: {}
|
|
19
21
|
PreferredAppSelection: PreferredAppSelectionScreenProps['route']['params']
|
|
22
|
+
GroupNotificationSettings: GroupNotificationSettingsScreenProps['route']['params']
|
|
20
23
|
}
|
|
21
24
|
|
|
22
25
|
enum SectionTypes {
|
|
@@ -53,6 +56,7 @@ export function NotificationSettingsScreen({}: NotificationSettingsScreenProps)
|
|
|
53
56
|
const navigation = useNavigation<NativeStackNavigationProp<NotificationSettingsStackParamList>>()
|
|
54
57
|
const styles = useStyles()
|
|
55
58
|
const { data: chatTypes } = useChatTypes()
|
|
59
|
+
const { data: groups } = useGroups()
|
|
56
60
|
|
|
57
61
|
// Header configuration
|
|
58
62
|
const HeaderRight = useCallback(() => {
|
|
@@ -84,7 +88,7 @@ export function NotificationSettingsScreen({}: NotificationSettingsScreenProps)
|
|
|
84
88
|
type: SectionTypes.view,
|
|
85
89
|
data: {
|
|
86
90
|
children: (
|
|
87
|
-
<Text variant="
|
|
91
|
+
<Text variant="tertiary" style={styles.sectionDescription}>
|
|
88
92
|
Choose which app receives each type of chat notification
|
|
89
93
|
</Text>
|
|
90
94
|
),
|
|
@@ -95,32 +99,47 @@ export function NotificationSettingsScreen({}: NotificationSettingsScreenProps)
|
|
|
95
99
|
type: SectionTypes.link,
|
|
96
100
|
data: {
|
|
97
101
|
title: `${type.title} Conversations`,
|
|
98
|
-
|
|
102
|
+
rightLabel: type.preferredApp,
|
|
99
103
|
onPress: () =>
|
|
100
104
|
navigation.navigate('PreferredAppSelection', {
|
|
101
105
|
chatTypeId: type.id,
|
|
102
106
|
}),
|
|
103
107
|
},
|
|
108
|
+
sectionInnerStyle: { paddingVertical: 0 },
|
|
109
|
+
showBottomBorder: true,
|
|
110
|
+
})),
|
|
111
|
+
{
|
|
112
|
+
type: SectionTypes.header,
|
|
113
|
+
data: {
|
|
114
|
+
title: 'Manage chat settings',
|
|
115
|
+
},
|
|
116
|
+
sectionInnerStyle: styles.sectionInnerHeader,
|
|
117
|
+
},
|
|
118
|
+
{
|
|
119
|
+
type: SectionTypes.view,
|
|
120
|
+
data: {
|
|
121
|
+
children: (
|
|
122
|
+
<Text variant="tertiary" style={styles.sectionDescription}>
|
|
123
|
+
Notification settings for all of your group, team and event related conversations
|
|
124
|
+
</Text>
|
|
125
|
+
),
|
|
126
|
+
},
|
|
127
|
+
showBottomBorder: true,
|
|
128
|
+
},
|
|
129
|
+
...groups.map(group => ({
|
|
130
|
+
type: SectionTypes.link,
|
|
131
|
+
data: {
|
|
132
|
+
title: group.name,
|
|
133
|
+
rightLabel: group.sourceType,
|
|
134
|
+
onPress: () =>
|
|
135
|
+
navigation.navigate('GroupNotificationSettings', {
|
|
136
|
+
groupId: group.id,
|
|
137
|
+
title: group.name || 'Group',
|
|
138
|
+
}),
|
|
139
|
+
},
|
|
140
|
+
sectionInnerStyle: { paddingVertical: 0 },
|
|
104
141
|
showBottomBorder: true,
|
|
105
142
|
})),
|
|
106
|
-
// {
|
|
107
|
-
// type: SectionTypes.header,
|
|
108
|
-
// data: {
|
|
109
|
-
// title: 'Manage chat settings',
|
|
110
|
-
// },
|
|
111
|
-
// sectionInnerStyle: styles.sectionInnerHeader,
|
|
112
|
-
// },
|
|
113
|
-
// {
|
|
114
|
-
// type: SectionTypes.view,
|
|
115
|
-
// data: {
|
|
116
|
-
// children: (
|
|
117
|
-
// <Text variant="footnote" style={styles.sectionDescription}>
|
|
118
|
-
// Notification settings for all of your group, team and event related conversations
|
|
119
|
-
// </Text>
|
|
120
|
-
// ),
|
|
121
|
-
// },
|
|
122
|
-
// showBottomBorder: true,
|
|
123
|
-
// },
|
|
124
143
|
].filter(item => item.type !== SectionTypes.hidden)
|
|
125
144
|
|
|
126
145
|
const headerIndices = listData
|
|
@@ -148,7 +167,7 @@ export function NotificationSettingsScreen({}: NotificationSettingsScreenProps)
|
|
|
148
167
|
outerStyle={item?.sectionOuterStyle}
|
|
149
168
|
innerStyle={item?.sectionInnerStyle}
|
|
150
169
|
>
|
|
151
|
-
<Heading variant="
|
|
170
|
+
<Heading variant="h2">{item.data.title}</Heading>
|
|
152
171
|
</ListSection>
|
|
153
172
|
)
|
|
154
173
|
case SectionTypes.setting:
|
|
@@ -227,11 +246,11 @@ interface SettingRowProps {
|
|
|
227
246
|
title: string
|
|
228
247
|
style?: ViewStyle
|
|
229
248
|
rightItem?: ReactNode
|
|
230
|
-
|
|
249
|
+
rightLabel?: string
|
|
231
250
|
rightItemStyle?: ViewStyle
|
|
232
251
|
}
|
|
233
252
|
|
|
234
|
-
function SettingRow({ title, style,
|
|
253
|
+
function SettingRow({ title, style, rightLabel, rightItem, rightItemStyle = {} }: SettingRowProps) {
|
|
235
254
|
const styles = useStyles()
|
|
236
255
|
|
|
237
256
|
return (
|
|
@@ -240,7 +259,7 @@ function SettingRow({ title, style, subtitle, rightItem, rightItemStyle = {} }:
|
|
|
240
259
|
<Text variant="plain" style={styles.settingRowText}>
|
|
241
260
|
{title}
|
|
242
261
|
</Text>
|
|
243
|
-
{Boolean(
|
|
262
|
+
{Boolean(rightLabel) && <Text variant="footnote">{rightLabel}</Text>}
|
|
244
263
|
</View>
|
|
245
264
|
{Boolean(rightItem) && <View style={rightItemStyle}>{rightItem}</View>}
|
|
246
265
|
</View>
|
|
@@ -249,12 +268,13 @@ function SettingRow({ title, style, subtitle, rightItem, rightItemStyle = {} }:
|
|
|
249
268
|
|
|
250
269
|
interface LinkRowProps {
|
|
251
270
|
title: string
|
|
252
|
-
|
|
271
|
+
rightLabel: string
|
|
253
272
|
onPress: () => void
|
|
254
273
|
}
|
|
255
274
|
|
|
256
|
-
function LinkRow({ title,
|
|
275
|
+
function LinkRow({ title, rightLabel, onPress }: LinkRowProps) {
|
|
257
276
|
const styles = useLinkRowStyles()
|
|
277
|
+
const isSourceType = rightLabel === 'Team' || rightLabel === 'Group' || rightLabel === 'PlanTeam'
|
|
258
278
|
|
|
259
279
|
return (
|
|
260
280
|
<PlatformPressable
|
|
@@ -269,7 +289,13 @@ function LinkRow({ title, subtitle, onPress }: LinkRowProps) {
|
|
|
269
289
|
{title}
|
|
270
290
|
</Text>
|
|
271
291
|
<View style={styles.rightContent}>
|
|
272
|
-
|
|
292
|
+
{isSourceType ? (
|
|
293
|
+
<Badge label={rightLabel} appearance="neutral" variant="meta" />
|
|
294
|
+
) : (
|
|
295
|
+
<Text numberOfLines={1} style={styles.rightLabelText}>
|
|
296
|
+
{rightLabel}
|
|
297
|
+
</Text>
|
|
298
|
+
)}
|
|
273
299
|
{Platform.OS === 'ios' && (
|
|
274
300
|
<Icon name="general.rightChevron" size={16} style={styles.icon} />
|
|
275
301
|
)}
|
|
@@ -283,24 +309,21 @@ function LinkRow({ title, subtitle, onPress }: LinkRowProps) {
|
|
|
283
309
|
// ====== Styles ===================
|
|
284
310
|
// =================================
|
|
285
311
|
|
|
286
|
-
const useStyles = ({
|
|
312
|
+
const useStyles = ({}: { isStart?: boolean; isEnd?: boolean } = {}) => {
|
|
287
313
|
const { colors } = useTheme()
|
|
288
314
|
const headerBottomPadding = 0
|
|
289
315
|
|
|
290
316
|
return StyleSheet.create({
|
|
291
317
|
listContainer: {
|
|
292
318
|
flex: 1,
|
|
293
|
-
backgroundColor: colors.surfaceColor080,
|
|
294
319
|
},
|
|
295
320
|
contentContainer: {},
|
|
296
321
|
sectionOuterBase: {
|
|
297
322
|
paddingLeft: 16,
|
|
298
|
-
backgroundColor: colors.surfaceColor100,
|
|
299
323
|
},
|
|
300
324
|
sectionInnerBase: {
|
|
301
325
|
paddingRight: 16,
|
|
302
|
-
|
|
303
|
-
paddingBottom: isEnd ? 16 : 12,
|
|
326
|
+
paddingVertical: 16,
|
|
304
327
|
},
|
|
305
328
|
sectionInnerHeader: {
|
|
306
329
|
paddingBottom: headerBottomPadding,
|
|
@@ -333,13 +356,13 @@ const useLinkRowStyles = () => {
|
|
|
333
356
|
return StyleSheet.create({
|
|
334
357
|
row: {
|
|
335
358
|
paddingLeft: 0,
|
|
359
|
+
paddingVertical: 16,
|
|
336
360
|
},
|
|
337
361
|
innerContainer: {
|
|
338
362
|
flexDirection: 'row',
|
|
339
363
|
alignItems: 'center',
|
|
340
364
|
justifyContent: 'space-between',
|
|
341
365
|
gap: 12,
|
|
342
|
-
paddingVertical: 4,
|
|
343
366
|
},
|
|
344
367
|
rightContent: {
|
|
345
368
|
flexDirection: 'row',
|
|
@@ -348,6 +371,10 @@ const useLinkRowStyles = () => {
|
|
|
348
371
|
},
|
|
349
372
|
title: {
|
|
350
373
|
flexShrink: 1,
|
|
374
|
+
alignSelf: 'center',
|
|
375
|
+
},
|
|
376
|
+
rightLabelText: {
|
|
377
|
+
color: theme.colors.textColorDefaultSecondary,
|
|
351
378
|
},
|
|
352
379
|
icon: {
|
|
353
380
|
color: theme.colors.iconColorDefaultDisabled,
|
|
@@ -31,7 +31,7 @@ export function PreferredAppSelectionScreen({ route }: PreferredAppSelectionScre
|
|
|
31
31
|
mutationFn: (app: PreferredApp) => {
|
|
32
32
|
return apiClient.chat
|
|
33
33
|
.post({
|
|
34
|
-
url: `/me/chat_types/${chatTypeId}/
|
|
34
|
+
url: `/me/chat_types/${chatTypeId}/set_preferred_app`,
|
|
35
35
|
data: { data: { type: 'ChatType', attributes: { app } } },
|
|
36
36
|
})
|
|
37
37
|
.catch(throwResponseError)
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { AppName } from './app_name'
|
|
2
|
+
import { GroupMembership } from './group_membership'
|
|
2
3
|
|
|
3
4
|
export type SourceType = 'Team' | 'Group' | 'PlanTeam'
|
|
4
5
|
export type GraphId = `${AppName}-${SourceType}-${number}`
|
|
@@ -11,3 +12,7 @@ export interface GroupResource {
|
|
|
11
12
|
sourceAppName: AppName
|
|
12
13
|
sourceType: SourceType
|
|
13
14
|
}
|
|
15
|
+
|
|
16
|
+
export interface GroupResourceWithMembership extends GroupResource {
|
|
17
|
+
myGroupMembership?: GroupMembership
|
|
18
|
+
}
|