@planningcenter/chat-react-native 3.42.3-qa-staging.2 → 3.42.3-qa-staging.4
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/conversation/messages_disabled_banners.d.ts +2 -3
- package/build/components/conversation/messages_disabled_banners.d.ts.map +1 -1
- package/build/components/conversation/messages_disabled_banners.js +2 -7
- package/build/components/conversation/messages_disabled_banners.js.map +1 -1
- package/build/components/display/adult_requirement_notice.js +1 -1
- package/build/components/display/adult_requirement_notice.js.map +1 -1
- package/build/components/display/platform_modal_header_buttons.d.ts +47 -7
- package/build/components/display/platform_modal_header_buttons.d.ts.map +1 -1
- package/build/components/display/platform_modal_header_buttons.js +119 -9
- package/build/components/display/platform_modal_header_buttons.js.map +1 -1
- package/build/hooks/use_conversation.d.ts.map +1 -1
- package/build/hooks/use_conversation.js +1 -0
- package/build/hooks/use_conversation.js.map +1 -1
- package/build/hooks/use_conversation_jolt_events.d.ts.map +1 -1
- package/build/hooks/use_conversation_jolt_events.js +10 -2
- package/build/hooks/use_conversation_jolt_events.js.map +1 -1
- package/build/navigation/index.d.ts +67 -170
- package/build/navigation/index.d.ts.map +1 -1
- package/build/navigation/index.js +59 -70
- package/build/navigation/index.js.map +1 -1
- package/build/screens/bug_report_screen.d.ts.map +1 -1
- package/build/screens/bug_report_screen.js +10 -13
- package/build/screens/bug_report_screen.js.map +1 -1
- package/build/screens/conversation_details_screen.d.ts.map +1 -1
- package/build/screens/conversation_details_screen.js +11 -12
- package/build/screens/conversation_details_screen.js.map +1 -1
- package/build/screens/conversation_filters_screen.js +2 -2
- package/build/screens/conversation_filters_screen.js.map +1 -1
- package/build/screens/conversation_screen.d.ts.map +1 -1
- package/build/screens/conversation_screen.js +10 -3
- package/build/screens/conversation_screen.js.map +1 -1
- package/build/screens/message_report_screen.d.ts.map +1 -1
- package/build/screens/message_report_screen.js +14 -18
- package/build/screens/message_report_screen.js.map +1 -1
- package/build/screens/notification_settings_screen.d.ts.map +1 -1
- package/build/screens/notification_settings_screen.js +0 -14
- package/build/screens/notification_settings_screen.js.map +1 -1
- package/build/types/jolt_events/conversation_events.d.ts +2 -2
- package/build/types/jolt_events/conversation_events.d.ts.map +1 -1
- package/build/types/jolt_events/conversation_events.js.map +1 -1
- package/build/types/resources/conversation.d.ts +2 -2
- package/build/types/resources/conversation.d.ts.map +1 -1
- package/build/types/resources/conversation.js.map +1 -1
- package/build/utils/conversation_safety_constants.d.ts +1 -1
- package/build/utils/conversation_safety_constants.d.ts.map +1 -1
- package/build/utils/conversation_safety_constants.js +1 -1
- package/build/utils/conversation_safety_constants.js.map +1 -1
- package/build/utils/request/conversation.d.ts.map +1 -1
- package/build/utils/request/conversation.js +1 -0
- package/build/utils/request/conversation.js.map +1 -1
- package/package.json +3 -3
- package/src/components/conversation/messages_disabled_banners.tsx +3 -11
- package/src/components/display/adult_requirement_notice.tsx +1 -1
- package/src/components/display/platform_modal_header_buttons.tsx +254 -13
- package/src/hooks/use_conversation.ts +1 -0
- package/src/hooks/use_conversation_jolt_events.ts +16 -3
- package/src/navigation/index.tsx +147 -164
- package/src/screens/bug_report_screen.tsx +16 -15
- package/src/screens/conversation_details_screen.tsx +11 -17
- package/src/screens/conversation_filters_screen.tsx +2 -2
- package/src/screens/conversation_screen.tsx +11 -3
- package/src/screens/message_report_screen.tsx +20 -21
- package/src/screens/notification_settings_screen.tsx +1 -21
- package/src/types/jolt_events/conversation_events.ts +2 -2
- package/src/types/resources/conversation.ts +2 -3
- package/src/utils/conversation_safety_constants.ts +1 -1
- package/src/utils/request/conversation.ts +1 -0
|
@@ -1,9 +1,19 @@
|
|
|
1
|
-
import { HeaderButton } from '@react-navigation/elements'
|
|
2
|
-
import
|
|
1
|
+
import { HeaderBackButton, HeaderButton, PlatformPressable } from '@react-navigation/elements'
|
|
2
|
+
import { useNavigation } from '@react-navigation/native'
|
|
3
|
+
import type {
|
|
4
|
+
NativeStackHeaderItemProps,
|
|
5
|
+
NativeStackNavigationOptions,
|
|
6
|
+
} from '@react-navigation/native-stack'
|
|
7
|
+
import { useLayoutEffect } from 'react'
|
|
3
8
|
import { ColorValue, Platform, StyleSheet } from 'react-native'
|
|
4
|
-
import
|
|
5
|
-
import {
|
|
9
|
+
import LinearGradient from 'react-native-linear-gradient'
|
|
10
|
+
import { useFontScale, useTheme } from '../../hooks'
|
|
11
|
+
import { MAX_FONT_SIZE_MULTIPLIER_LANDMARK } from '../../utils'
|
|
12
|
+
import { isLiquidGlassEnabled } from '../../utils/liquid_glass'
|
|
13
|
+
import { tokens } from '../../vendor/tapestry/tokens'
|
|
14
|
+
import { Icon, type IconString } from './icon'
|
|
6
15
|
import { TextButton } from './text_button'
|
|
16
|
+
import { getColorKey, useGradientColorMap } from './utils/button_colors'
|
|
7
17
|
|
|
8
18
|
interface HeaderTextButtonProps {
|
|
9
19
|
onPress: () => void
|
|
@@ -63,19 +73,250 @@ export const HeaderDismissButton = ({
|
|
|
63
73
|
})
|
|
64
74
|
}
|
|
65
75
|
|
|
66
|
-
|
|
67
|
-
|
|
76
|
+
const createTextHeaderRight =
|
|
77
|
+
({ onPress, title, disabled }: HeaderTextButtonProps) =>
|
|
78
|
+
(props: NativeStackHeaderItemProps) => (
|
|
79
|
+
<HeaderTextButton {...props} onPress={onPress} title={title} disabled={disabled} />
|
|
80
|
+
)
|
|
81
|
+
|
|
82
|
+
export type OptionsDecorator = (
|
|
83
|
+
options: NativeStackNavigationOptions
|
|
84
|
+
) => NativeStackNavigationOptions
|
|
85
|
+
|
|
86
|
+
export const composeOptions = (
|
|
87
|
+
base: NativeStackNavigationOptions,
|
|
88
|
+
...decorators: OptionsDecorator[]
|
|
89
|
+
): NativeStackNavigationOptions => decorators.reduce((options, decorate) => decorate(options), base)
|
|
90
|
+
|
|
91
|
+
interface TextButtonDecoratorProps {
|
|
92
|
+
text: string
|
|
93
|
+
onPress: () => void
|
|
94
|
+
disabled?: boolean
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
// Native bar items pick up liquid glass on iOS 26; hosts on an older
|
|
98
|
+
// react-navigation ignore the unstable option and keep using the
|
|
99
|
+
// headerRight/headerLeft fallbacks, as does Android.
|
|
100
|
+
export const withRightText =
|
|
101
|
+
({ text, onPress, disabled }: TextButtonDecoratorProps): OptionsDecorator =>
|
|
102
|
+
options => ({
|
|
103
|
+
...options,
|
|
104
|
+
headerRight: createTextHeaderRight({ onPress, title: text, disabled }),
|
|
105
|
+
unstable_headerRightItems: () => [{ type: 'button' as const, label: text, onPress, disabled }],
|
|
106
|
+
})
|
|
107
|
+
|
|
108
|
+
const HEADER_ICON_SIZE = 17
|
|
109
|
+
const HEADER_FILL_ICON_SIZE = 16
|
|
110
|
+
const HEADER_FILL_PADDING = 14
|
|
111
|
+
const HEADER_BAR_INSET = 16
|
|
112
|
+
const HEADER_SLOT_GAP = 12
|
|
113
|
+
|
|
114
|
+
const headerFillSize = (fontScale: number) => {
|
|
115
|
+
const icon = HEADER_FILL_ICON_SIZE * fontScale
|
|
116
|
+
|
|
117
|
+
return { icon, circle: icon + HEADER_FILL_PADDING * 2 }
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
// Liquid glass icons don't communicate
|
|
121
|
+
export const useHeaderSlotReserve = (): number => {
|
|
122
|
+
const fontScale = useFontScale({ maxFontSizeMultiplier: MAX_FONT_SIZE_MULTIPLIER_LANDMARK })
|
|
123
|
+
|
|
124
|
+
return HEADER_BAR_INSET + headerFillSize(fontScale).circle + HEADER_SLOT_GAP
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
const HEADER_FALLBACK_HIT_SLOP = 14
|
|
128
|
+
|
|
129
|
+
const iconStyles = StyleSheet.create({
|
|
130
|
+
disabled: {
|
|
131
|
+
opacity: 0.4,
|
|
132
|
+
},
|
|
133
|
+
fallbackButton: {
|
|
134
|
+
alignItems: 'center',
|
|
135
|
+
justifyContent: 'center',
|
|
136
|
+
paddingHorizontal: 8,
|
|
137
|
+
},
|
|
138
|
+
fillCircle: {
|
|
139
|
+
alignItems: 'center',
|
|
140
|
+
justifyContent: 'center',
|
|
141
|
+
},
|
|
142
|
+
})
|
|
143
|
+
|
|
144
|
+
export interface HeaderIconProps {
|
|
145
|
+
icon: IconString
|
|
146
|
+
accessibilityLabel: string
|
|
147
|
+
onPress: () => void
|
|
148
|
+
disabled?: boolean
|
|
149
|
+
variant?: 'plain' | 'fill'
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
const HeaderIcon = ({
|
|
153
|
+
icon,
|
|
154
|
+
disabled,
|
|
155
|
+
variant,
|
|
156
|
+
}: Pick<HeaderIconProps, 'icon' | 'disabled' | 'variant'>) => {
|
|
157
|
+
const { colors } = useTheme()
|
|
158
|
+
const gradients = useGradientColorMap()
|
|
159
|
+
const fontScale = useFontScale({ maxFontSizeMultiplier: MAX_FONT_SIZE_MULTIPLIER_LANDMARK })
|
|
160
|
+
|
|
161
|
+
if (variant !== 'fill') return <Icon name={icon} size={HEADER_ICON_SIZE} />
|
|
162
|
+
|
|
163
|
+
const { icon: iconSize, circle: circleSize } = headerFillSize(fontScale)
|
|
164
|
+
|
|
165
|
+
return (
|
|
166
|
+
<LinearGradient
|
|
167
|
+
start={{ x: 0.1, y: 0.1 }}
|
|
168
|
+
end={{ x: 0.9, y: 0.9 }}
|
|
169
|
+
colors={gradients[getColorKey({ disabled: Boolean(disabled), appearance: 'interaction' })]}
|
|
170
|
+
style={[
|
|
171
|
+
iconStyles.fillCircle,
|
|
172
|
+
{ borderRadius: circleSize, height: circleSize, width: circleSize },
|
|
173
|
+
]}
|
|
174
|
+
>
|
|
175
|
+
<Icon
|
|
176
|
+
name={icon}
|
|
177
|
+
size={iconSize}
|
|
178
|
+
color={disabled ? colors.iconColorDefaultDisabled : tokens.colorNeutral100White}
|
|
179
|
+
/>
|
|
180
|
+
</LinearGradient>
|
|
181
|
+
)
|
|
68
182
|
}
|
|
69
183
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
184
|
+
// Native bar items take SF Symbols, images, or any element, so both paths
|
|
185
|
+
// render the same icon: iOS 26 puts this one in the glass circle, and the
|
|
186
|
+
// element below covers Android and older iOS.
|
|
187
|
+
const createHeaderIconItem = ({
|
|
188
|
+
icon,
|
|
189
|
+
accessibilityLabel,
|
|
190
|
+
onPress,
|
|
191
|
+
disabled,
|
|
192
|
+
variant,
|
|
193
|
+
}: HeaderIconProps) => ({
|
|
194
|
+
type: 'custom' as const,
|
|
195
|
+
// The gradient circle replaces the glass one rather than sitting on it.
|
|
196
|
+
hidesSharedBackground: variant === 'fill',
|
|
197
|
+
element: (
|
|
198
|
+
<PlatformPressable
|
|
199
|
+
onPress={onPress}
|
|
200
|
+
disabled={disabled}
|
|
201
|
+
hitSlop={12}
|
|
202
|
+
accessibilityRole="button"
|
|
203
|
+
accessibilityLabel={accessibilityLabel}
|
|
204
|
+
style={disabled && variant !== 'fill' && iconStyles.disabled}
|
|
205
|
+
>
|
|
206
|
+
<HeaderIcon icon={icon} disabled={disabled} variant={variant} />
|
|
207
|
+
</PlatformPressable>
|
|
208
|
+
),
|
|
209
|
+
})
|
|
210
|
+
|
|
211
|
+
const createHeaderIconElement =
|
|
212
|
+
({ icon, accessibilityLabel, onPress, disabled, variant }: HeaderIconProps) =>
|
|
213
|
+
() => (
|
|
214
|
+
<PlatformPressable
|
|
215
|
+
onPress={onPress}
|
|
216
|
+
disabled={disabled}
|
|
217
|
+
hitSlop={HEADER_FALLBACK_HIT_SLOP}
|
|
218
|
+
accessibilityRole="button"
|
|
219
|
+
accessibilityLabel={accessibilityLabel}
|
|
220
|
+
style={[iconStyles.fallbackButton, disabled && variant !== 'fill' && iconStyles.disabled]}
|
|
221
|
+
>
|
|
222
|
+
<HeaderIcon icon={icon} disabled={disabled} variant={variant} />
|
|
223
|
+
</PlatformPressable>
|
|
224
|
+
)
|
|
225
|
+
|
|
226
|
+
export const withRightIcon =
|
|
227
|
+
(props: HeaderIconProps): OptionsDecorator =>
|
|
228
|
+
options => ({
|
|
229
|
+
...options,
|
|
230
|
+
headerRight: createHeaderIconElement(props),
|
|
231
|
+
unstable_headerRightItems: () => [createHeaderIconItem(props)],
|
|
232
|
+
})
|
|
233
|
+
|
|
234
|
+
export const withLeftIcon =
|
|
235
|
+
(props: HeaderIconProps): OptionsDecorator =>
|
|
236
|
+
options => ({
|
|
237
|
+
...options,
|
|
238
|
+
headerLeft: createHeaderIconElement(props),
|
|
239
|
+
unstable_headerLeftItems: () => [createHeaderIconItem(props)],
|
|
240
|
+
})
|
|
241
|
+
|
|
242
|
+
export const withRightClose = ({ onPress }: { onPress: () => void }) =>
|
|
243
|
+
withRightIcon({ icon: 'general.x', accessibilityLabel: 'Close', onPress })
|
|
244
|
+
|
|
245
|
+
export const withLeftClose = ({ onPress }: { onPress: () => void }) =>
|
|
246
|
+
withLeftIcon({ icon: 'general.x', accessibilityLabel: 'Close', onPress })
|
|
247
|
+
|
|
248
|
+
export const withRightDone = ({ onPress }: { onPress: () => void }) =>
|
|
249
|
+
withRightIcon({ icon: 'general.check', accessibilityLabel: 'Done', onPress })
|
|
250
|
+
|
|
251
|
+
// The default back icon reserves trailing space for a label that
|
|
252
|
+
// displayMode="minimal" never shows; a custom image skips it so the glass
|
|
253
|
+
// capsule hugs the glyph.
|
|
254
|
+
const renderGlassBackImage = ({ tintColor }: { tintColor: string }) => (
|
|
255
|
+
<Icon name="general.leftChevron" size={18} color={tintColor} />
|
|
256
|
+
)
|
|
257
|
+
|
|
258
|
+
// The iOS 26 glass capsule manages its own insets — negative margins clip
|
|
259
|
+
// the button against the capsule edge.
|
|
260
|
+
export const createMinimalHeaderBackButton =
|
|
261
|
+
({ onPress }: { onPress: () => void }) =>
|
|
262
|
+
(props: NativeStackHeaderItemProps) => (
|
|
263
|
+
<HeaderBackButton
|
|
264
|
+
style={
|
|
265
|
+
isLiquidGlassEnabled()
|
|
266
|
+
? undefined
|
|
267
|
+
: {
|
|
268
|
+
marginLeft: Platform.select({ ios: -8, default: -3 }),
|
|
269
|
+
marginRight: Platform.select({ ios: 0, default: 30 }),
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
backImage={isLiquidGlassEnabled() ? renderGlassBackImage : undefined}
|
|
273
|
+
displayMode="minimal"
|
|
274
|
+
onPress={onPress}
|
|
275
|
+
{...props}
|
|
276
|
+
/>
|
|
277
|
+
)
|
|
278
|
+
|
|
279
|
+
// Under glass the native minimal back button suffices; pre-26 needs the
|
|
280
|
+
// custom button and its layout nudges.
|
|
281
|
+
export const withMinimalBack =
|
|
282
|
+
({ onPress }: { onPress: () => void }): OptionsDecorator =>
|
|
283
|
+
options => ({
|
|
284
|
+
...options,
|
|
285
|
+
...(isLiquidGlassEnabled() ? {} : { headerLeft: createMinimalHeaderBackButton({ onPress }) }),
|
|
286
|
+
})
|
|
287
|
+
|
|
288
|
+
// An icon or a title, never both — passing both is a compile error rather
|
|
289
|
+
// than a question of which one wins.
|
|
290
|
+
type UseHeaderRightOptions = {
|
|
291
|
+
onPress: () => void
|
|
292
|
+
disabled?: boolean
|
|
293
|
+
enabled?: boolean
|
|
294
|
+
} & (
|
|
295
|
+
| (HeaderIconProps & { title?: never })
|
|
296
|
+
| { title: string; icon?: never; accessibilityLabel?: never; variant?: never }
|
|
297
|
+
)
|
|
298
|
+
|
|
299
|
+
// For screens whose header button depends on live state (form validity,
|
|
300
|
+
// mutation callbacks). Static buttons belong in the navigator options.
|
|
301
|
+
export const useHeaderRight = (options: UseHeaderRightOptions) => {
|
|
302
|
+
const navigation = useNavigation()
|
|
303
|
+
const { onPress, disabled, enabled = true } = options
|
|
304
|
+
const icon = options.icon
|
|
305
|
+
const label = options.icon !== undefined ? options.accessibilityLabel : options.title
|
|
306
|
+
const variant = options.variant
|
|
307
|
+
|
|
308
|
+
useLayoutEffect(() => {
|
|
309
|
+
if (!enabled) {
|
|
310
|
+
navigation.setOptions({ headerRight: () => null, unstable_headerRightItems: undefined })
|
|
311
|
+
return
|
|
312
|
+
}
|
|
73
313
|
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
314
|
+
const decorate = icon
|
|
315
|
+
? withRightIcon({ icon, accessibilityLabel: label, onPress, disabled, variant })
|
|
316
|
+
: withRightText({ text: label, onPress, disabled })
|
|
77
317
|
|
|
78
|
-
|
|
318
|
+
navigation.setOptions(decorate({}))
|
|
319
|
+
}, [disabled, enabled, icon, label, navigation, onPress, variant])
|
|
79
320
|
}
|
|
80
321
|
|
|
81
322
|
const useStyles = () => {
|
|
@@ -26,8 +26,13 @@ export function useConversationJoltEvents({ conversationId }: Props) {
|
|
|
26
26
|
|
|
27
27
|
const handleUpdatedConversation = useCallback(
|
|
28
28
|
(e: JoltConversationEvent) => {
|
|
29
|
-
const {
|
|
30
|
-
|
|
29
|
+
const {
|
|
30
|
+
last_message_idempotent_key,
|
|
31
|
+
last_message_author_id,
|
|
32
|
+
disabled,
|
|
33
|
+
disabled_reason,
|
|
34
|
+
disabled_message,
|
|
35
|
+
} = e.data.data
|
|
31
36
|
|
|
32
37
|
if (last_message_idempotent_key && last_message_author_id === currentPersonId) {
|
|
33
38
|
completeMessageCreationConversationTracking({
|
|
@@ -38,7 +43,15 @@ export function useConversationJoltEvents({ conversationId }: Props) {
|
|
|
38
43
|
|
|
39
44
|
queryClient.setQueryData<ApiResource<ConversationResource>>(queryKey, prev => {
|
|
40
45
|
if (!prev?.data) return prev
|
|
41
|
-
return {
|
|
46
|
+
return {
|
|
47
|
+
...prev,
|
|
48
|
+
data: {
|
|
49
|
+
...prev.data,
|
|
50
|
+
disabled,
|
|
51
|
+
disabledReason: disabled_reason,
|
|
52
|
+
disabledMessage: disabled_message,
|
|
53
|
+
},
|
|
54
|
+
}
|
|
42
55
|
})
|
|
43
56
|
|
|
44
57
|
queryClient.invalidateQueries({ queryKey })
|