@planningcenter/chat-react-native 4.8.0-rc.9 → 4.8.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.
Files changed (55) hide show
  1. package/build/components/conversation/message_form.d.ts.map +1 -1
  2. package/build/components/conversation/message_form.js +31 -25
  3. package/build/components/conversation/message_form.js.map +1 -1
  4. package/build/components/conversations/app_update_banner.d.ts +2 -0
  5. package/build/components/conversations/app_update_banner.d.ts.map +1 -0
  6. package/build/components/conversations/app_update_banner.js +52 -0
  7. package/build/components/conversations/app_update_banner.js.map +1 -0
  8. package/build/components/conversations/bulk_conversation_actions_bar.d.ts +2 -0
  9. package/build/components/conversations/bulk_conversation_actions_bar.d.ts.map +1 -0
  10. package/build/components/conversations/bulk_conversation_actions_bar.js +215 -0
  11. package/build/components/conversations/bulk_conversation_actions_bar.js.map +1 -0
  12. package/build/components/conversations/conversation_actions.d.ts.map +1 -1
  13. package/build/components/conversations/conversation_actions.js +202 -161
  14. package/build/components/conversations/conversation_actions.js.map +1 -1
  15. package/build/components/conversations/conversation_preview.d.ts.map +1 -1
  16. package/build/components/conversations/conversation_preview.js +129 -115
  17. package/build/components/conversations/conversation_preview.js.map +1 -1
  18. package/build/components/conversations/swipeable_toggle_button.d.ts +5 -1
  19. package/build/components/conversations/swipeable_toggle_button.d.ts.map +1 -1
  20. package/build/components/conversations/swipeable_toggle_button.js +96 -67
  21. package/build/components/conversations/swipeable_toggle_button.js.map +1 -1
  22. package/build/components/display/icon.d.ts +3 -1
  23. package/build/components/display/icon.d.ts.map +1 -1
  24. package/build/components/display/icon.js +2 -0
  25. package/build/components/display/icon.js.map +1 -1
  26. package/build/components/primitive/banner_primitive.js +7 -3
  27. package/build/components/primitive/banner_primitive.js.map +1 -1
  28. package/build/screens/conversation_actions_screen.d.ts +2 -0
  29. package/build/screens/conversation_actions_screen.d.ts.map +1 -1
  30. package/build/screens/conversation_actions_screen.js +380 -46
  31. package/build/screens/conversation_actions_screen.js.map +1 -1
  32. package/build/screens/conversations/conversations_screen.d.ts +1 -0
  33. package/build/screens/conversations/conversations_screen.d.ts.map +1 -1
  34. package/build/screens/conversations/conversations_screen.js +105 -33
  35. package/build/screens/conversations/conversations_screen.js.map +1 -1
  36. package/build/utils/theme.js +20 -21
  37. package/build/utils/theme.js.map +1 -1
  38. package/package.json +2 -2
  39. package/src/components/conversation/__tests__/message_form.test.tsx +19 -2
  40. package/src/components/conversation/message_form.tsx +15 -2
  41. package/src/components/conversations/__tests__/app_update_banner.test.tsx +27 -0
  42. package/src/components/conversations/__tests__/bulk_conversation_actions_bar.test.tsx +95 -0
  43. package/src/components/conversations/__tests__/conversation_actions.test.tsx +10 -3
  44. package/src/components/conversations/app_update_banner.tsx +36 -0
  45. package/src/components/conversations/bulk_conversation_actions_bar.tsx +140 -0
  46. package/src/components/conversations/conversation_actions.tsx +51 -34
  47. package/src/components/conversations/conversation_preview.tsx +8 -1
  48. package/src/components/conversations/swipeable_toggle_button.tsx +45 -16
  49. package/src/components/display/icon.tsx +3 -0
  50. package/src/components/primitive/banner_primitive.tsx +5 -1
  51. package/src/screens/__tests__/conversation_actions_screen.test.tsx +48 -6
  52. package/src/screens/conversation_actions_screen.tsx +145 -12
  53. package/src/screens/conversations/__tests__/conversations_screen.test.tsx +34 -8
  54. package/src/screens/conversations/conversations_screen.tsx +28 -2
  55. package/src/utils/theme.ts +20 -21
@@ -0,0 +1,95 @@
1
+ import { act, fireEvent, render } from '@testing-library/react-native'
2
+ import React from 'react'
3
+ import { SafeAreaProvider } from 'react-native-safe-area-context'
4
+ import type { ConversationResource } from '../../../types'
5
+ import { BulkConversationActionsBar } from '../bulk_conversation_actions_bar'
6
+
7
+ jest.mock('react-native-reanimated', () => ({
8
+ ...jest.requireActual('react-native-reanimated/mock'),
9
+ LayoutAnimationConfig: ({ children }: { children: React.ReactNode }) => children,
10
+ useReducedMotion: () => false,
11
+ }))
12
+
13
+ const mockHide = jest.fn(async () => {})
14
+ const mockSilence = jest.fn(async () => {})
15
+ jest.mock('../../../hooks/use_bulk_conversation_actions', () => ({
16
+ useBulkConversationActions: () => ({
17
+ hide: mockHide,
18
+ unhide: jest.fn(),
19
+ silence: mockSilence,
20
+ markRead: jest.fn(),
21
+ }),
22
+ }))
23
+
24
+ const createdAt = '2026-10-01T12:00:00Z'
25
+
26
+ const conversation = (overrides: Partial<ConversationResource>): ConversationResource => ({
27
+ type: 'Conversation',
28
+ id: 1,
29
+ title: 'Youth Group',
30
+ conversationPreview: null,
31
+ createdAt,
32
+ lastMessageCreatedAt: createdAt,
33
+ muted: false,
34
+ repliesDisabled: false,
35
+ unreadCount: 1,
36
+ unreadReaction: false,
37
+ updatedAt: createdAt,
38
+ ...overrides,
39
+ })
40
+
41
+ const first = conversation({ id: 1 })
42
+ const second = conversation({ id: 2 })
43
+ const archived = conversation({ id: 3, disabled: true, disabledReason: 'archived' })
44
+ const mockConversations = [first, second, archived]
45
+
46
+ const mockClearSelection = jest.fn()
47
+ let mockSelectedIds: number[] = []
48
+ jest.mock('../../../contexts/conversations_context', () => ({
49
+ useConversationsContext: () => ({
50
+ selectMode: true,
51
+ selectedIds: mockSelectedIds,
52
+ conversations: mockConversations,
53
+ hideable: true,
54
+ clearSelection: mockClearSelection,
55
+ args: {},
56
+ }),
57
+ }))
58
+
59
+ const safeAreaMetrics = {
60
+ frame: { x: 0, y: 0, width: 390, height: 844 },
61
+ insets: { top: 0, right: 0, bottom: 0, left: 0 },
62
+ }
63
+
64
+ const renderBar = () =>
65
+ render(
66
+ <SafeAreaProvider initialMetrics={safeAreaMetrics}>
67
+ <BulkConversationActionsBar />
68
+ </SafeAreaProvider>
69
+ )
70
+
71
+ describe('BulkConversationActionsBar', () => {
72
+ beforeEach(() => jest.clearAllMocks())
73
+
74
+ it('hides every selected conversation and then clears the selection', async () => {
75
+ mockSelectedIds = [1, 2]
76
+ const view = renderBar()
77
+
78
+ await act(async () => fireEvent.press(view.getByText('Hide')))
79
+
80
+ expect(mockHide).toHaveBeenCalledWith([first, second])
81
+ expect(mockClearSelection).toHaveBeenCalled()
82
+ })
83
+
84
+ it('disables hide and silence when an archived conversation is selected', () => {
85
+ mockSelectedIds = [1, 3]
86
+ const view = renderBar()
87
+
88
+ fireEvent.press(view.getByText('Hide'))
89
+ fireEvent.press(view.getByText('Silence'))
90
+
91
+ expect(mockHide).not.toHaveBeenCalled()
92
+ expect(mockSilence).not.toHaveBeenCalled()
93
+ expect(mockClearSelection).not.toHaveBeenCalled()
94
+ })
95
+ })
@@ -13,10 +13,13 @@ jest.mock('react-native-gesture-handler/ReanimatedSwipeable', () => {
13
13
  renderLeftActions,
14
14
  }: {
15
15
  children: React.ReactNode
16
- renderLeftActions: () => React.ReactNode
16
+ renderLeftActions: (
17
+ progress: { value: number },
18
+ translation: { value: number }
19
+ ) => React.ReactNode
17
20
  }) => (
18
21
  <MockView>
19
- {renderLeftActions()}
22
+ {renderLeftActions({ value: 1 }, { value: 360 })}
20
23
  {children}
21
24
  </MockView>
22
25
  ),
@@ -141,7 +144,11 @@ describe('ConversationActions hide', () => {
141
144
 
142
145
  fireEvent(view.getByTestId('conversation-7'), 'longPress')
143
146
 
144
- expect(mockNavigate).toHaveBeenCalledWith('ConversationActions', { conversation_id: 7 })
147
+ expect(mockNavigate).toHaveBeenCalledWith('ConversationActions', {
148
+ conversation_id: 7,
149
+ read: false,
150
+ muted: false,
151
+ })
145
152
  })
146
153
  })
147
154
 
@@ -0,0 +1,36 @@
1
+ import React from 'react'
2
+ import { StyleSheet, View } from 'react-native'
3
+ import { Updates } from '../../utils/native_adapters'
4
+ import { Banner } from '../display/banner'
5
+ import BannerPrimitive from '../primitive/banner_primitive'
6
+
7
+ export function AppUpdateBanner() {
8
+ const styles = useStyles()
9
+ const downloadedUpdateId = Updates.useDownloadedUpdateId()
10
+
11
+ if (!downloadedUpdateId) return null
12
+
13
+ return (
14
+ <View style={styles.container}>
15
+ <Banner
16
+ appearance="info"
17
+ heading="Chat update available"
18
+ description={
19
+ <BannerPrimitive.Text>
20
+ <BannerPrimitive.Link onPress={Updates.restart}>Reload</BannerPrimitive.Link> to get the
21
+ latest fixes and improvements.
22
+ </BannerPrimitive.Text>
23
+ }
24
+ />
25
+ </View>
26
+ )
27
+ }
28
+
29
+ const useStyles = () => {
30
+ return StyleSheet.create({
31
+ container: {
32
+ paddingHorizontal: 16,
33
+ paddingVertical: 12,
34
+ },
35
+ })
36
+ }
@@ -0,0 +1,140 @@
1
+ import React, { useEffect, useState } from 'react'
2
+ import { Pressable, StyleSheet } from 'react-native'
3
+ import Animated, { FadeIn, LayoutAnimationConfig, ReduceMotion } from 'react-native-reanimated'
4
+ import { useSafeAreaInsets } from 'react-native-safe-area-context'
5
+ import { useConversationsContext } from '../../contexts/conversations_context'
6
+ import { useReduceMotion, useTheme } from '../../hooks'
7
+ import { useBulkConversationActions } from '../../hooks/use_bulk_conversation_actions'
8
+ import { ConversationResource } from '../../types'
9
+ import {
10
+ MAX_FONT_SIZE_MULTIPLIER_LANDMARK,
11
+ isArchivedConversation,
12
+ platformPressedOpacityStyle,
13
+ } from '../../utils'
14
+ import { dismissToast } from '../../utils/toast_store'
15
+ import { Icon, IconString, Text } from '../display'
16
+
17
+ export function BulkConversationActionsBar() {
18
+ const styles = useStyles()
19
+ const reduceMotion = useReduceMotion() ? ReduceMotion.Always : ReduceMotion.Never
20
+ const {
21
+ selectMode,
22
+ selectedIds,
23
+ conversations,
24
+ hideable,
25
+ clearSelection,
26
+ args: { show_hidden: hiddenView = false },
27
+ } = useConversationsContext()
28
+ const { hide, unhide, silence, markRead } = useBulkConversationActions()
29
+ const [pending, setPending] = useState(false)
30
+
31
+ const selected = conversations.filter(({ id }) => selectedIds.includes(id))
32
+ const disabled = pending || selected.length === 0
33
+ const canSilence = !disabled && !selected.some(isArchivedConversation)
34
+ const canHide = canSilence && hideable
35
+
36
+ const run = (action: (_conversations: ConversationResource[]) => Promise<void>) => async () => {
37
+ setPending(true)
38
+ try {
39
+ await action(selected)
40
+ } finally {
41
+ setPending(false)
42
+ clearSelection()
43
+ }
44
+ }
45
+
46
+ useEffect(() => {
47
+ if (selectMode) dismissToast()
48
+ }, [selectMode])
49
+
50
+ return (
51
+ <LayoutAnimationConfig skipEntering>
52
+ {selectMode && (
53
+ <Animated.View
54
+ entering={FadeIn.duration(300).reduceMotion(reduceMotion)}
55
+ style={styles.container}
56
+ testID="bulk-conversation-actions-bar"
57
+ >
58
+ <BulkAction
59
+ title="Mark read"
60
+ iconName="general.check"
61
+ disabled={disabled}
62
+ onPress={run(markRead)}
63
+ />
64
+ <BulkAction
65
+ title="Silence"
66
+ iconName="general.bellMuted"
67
+ disabled={!canSilence}
68
+ onPress={run(silence)}
69
+ />
70
+ <BulkAction
71
+ title={hiddenView ? 'Unhide' : 'Hide'}
72
+ iconName={hiddenView ? 'general.showEye' : 'general.hideEye'}
73
+ disabled={!canHide}
74
+ onPress={run(hiddenView ? unhide : hide)}
75
+ />
76
+ </Animated.View>
77
+ )}
78
+ </LayoutAnimationConfig>
79
+ )
80
+ }
81
+
82
+ function BulkAction({
83
+ title,
84
+ iconName,
85
+ disabled,
86
+ onPress,
87
+ }: {
88
+ title: string
89
+ iconName: IconString
90
+ disabled: boolean
91
+ onPress: () => void
92
+ }) {
93
+ const styles = useStyles({ disabled })
94
+
95
+ return (
96
+ <Pressable
97
+ onPress={onPress}
98
+ disabled={disabled}
99
+ accessibilityRole="button"
100
+ accessibilityState={{ disabled }}
101
+ style={({ pressed }) => [styles.action, pressed && platformPressedOpacityStyle]}
102
+ >
103
+ <Icon name={iconName} size={20} style={styles.actionIcon} accessibilityElementsHidden />
104
+ <Text style={styles.actionTitle} maxFontSizeMultiplier={MAX_FONT_SIZE_MULTIPLIER_LANDMARK}>
105
+ {title}
106
+ </Text>
107
+ </Pressable>
108
+ )
109
+ }
110
+
111
+ const useStyles = ({ disabled = false }: { disabled?: boolean } = {}) => {
112
+ const { bottom } = useSafeAreaInsets()
113
+ const { colors } = useTheme()
114
+ const containerVerticalPadding = 12
115
+ const actionColor = disabled ? colors.textColorDefaultDisabled : colors.textColorDefaultPrimary
116
+
117
+ return StyleSheet.create({
118
+ container: {
119
+ flexDirection: 'row',
120
+ backgroundColor: colors.surfaceColor090,
121
+ paddingHorizontal: 16,
122
+ paddingTop: containerVerticalPadding,
123
+ paddingBottom: bottom + containerVerticalPadding,
124
+ borderTopWidth: 1,
125
+ borderTopColor: colors.borderColorDefaultDim,
126
+ },
127
+ action: {
128
+ flex: 1,
129
+ alignItems: 'center',
130
+ gap: 4,
131
+ },
132
+ actionIcon: {
133
+ color: actionColor,
134
+ },
135
+ actionTitle: {
136
+ color: actionColor,
137
+ fontWeight: '600',
138
+ },
139
+ })
140
+ }
@@ -12,6 +12,7 @@ import {
12
12
  import ReanimatedSwipeable, {
13
13
  SwipeableMethods,
14
14
  } from 'react-native-gesture-handler/ReanimatedSwipeable'
15
+ import Animated, { SharedValue, useAnimatedStyle } from 'react-native-reanimated'
15
16
  import { useConversationsContext } from '../../contexts/conversations_context'
16
17
  import { useTheme, useCreateAndroidRippleColor } from '../../hooks'
17
18
  import {
@@ -24,7 +25,7 @@ import { ConversationResource } from '../../types'
24
25
  import { isArchivedConversation, platformPressedOpacityStyle } from '../../utils'
25
26
  import { Haptic } from '../../utils/native_adapters'
26
27
  import { tokens } from '../../vendor/tapestry/tokens'
27
- import { SwipeableToggleButton } from './swipeable_toggle_button'
28
+ import { SWIPEABLE_TOGGLE_BUTTON_WIDTH, SwipeableToggleButton } from './swipeable_toggle_button'
28
29
 
29
30
  export function ConversationActions({
30
31
  children,
@@ -70,6 +71,7 @@ export function ConversationActions({
70
71
  const canMute = !isArchivedConversation(conversation)
71
72
  const canHide = hideable && hideConversationsEnabled && !isArchivedConversation(conversation)
72
73
  const selectMode = selected !== undefined
74
+ const canOpenActions = hideable && hideConversationsEnabled && !selectMode
73
75
 
74
76
  const handleSwipeableClose = useCallback(() => {
75
77
  setDisabled(false)
@@ -100,8 +102,8 @@ export function ConversationActions({
100
102
  if (disabled) return
101
103
 
102
104
  Haptic.impactLight()
103
- navigation.navigate('ConversationActions', { conversation_id: conversation.id })
104
- }, [disabled, navigation, conversation.id])
105
+ navigation.navigate('ConversationActions', { conversation_id: conversation.id, read, muted })
106
+ }, [disabled, navigation, conversation.id, read, muted])
105
107
 
106
108
  const handleLatestMessageUnread = useCallback(() => {
107
109
  markRead(!read)
@@ -185,8 +187,10 @@ export function ConversationActions({
185
187
  onSwipeableOpenStartDrag={handleSwipeableOpen}
186
188
  onSwipeableClose={() => setDisabled(false)}
187
189
  renderRightActions={() => <></>}
188
- renderLeftActions={() => (
190
+ renderLeftActions={(progress, translation) => (
189
191
  <LeftActions
192
+ progress={progress}
193
+ translation={translation}
190
194
  isConversationEmpty={isConversationEmpty}
191
195
  canMute={canMute}
192
196
  canHide={canHide}
@@ -205,7 +209,7 @@ export function ConversationActions({
205
209
  <Pressable
206
210
  testID={`conversation-${conversation.id}`}
207
211
  onPress={handlePress}
208
- onLongPress={canHide ? handleLongPress : undefined}
212
+ onLongPress={canOpenActions ? handleLongPress : undefined}
209
213
  style={({ pressed }) => [style, pressed && platformPressedOpacityStyle]}
210
214
  android_ripple={{ color: androidRippleColor, borderless: false, foreground: true }}
211
215
  accessibilityLabel={accessibilityLabel}
@@ -221,6 +225,8 @@ export function ConversationActions({
221
225
  }
222
226
 
223
227
  interface LeftActionsProps {
228
+ progress: SharedValue<number>
229
+ translation: SharedValue<number>
224
230
  isConversationEmpty: boolean
225
231
  canMute: boolean
226
232
  canHide: boolean
@@ -236,6 +242,8 @@ interface LeftActionsProps {
236
242
  }
237
243
 
238
244
  function LeftActions({
245
+ progress,
246
+ translation,
239
247
  isConversationEmpty,
240
248
  canMute,
241
249
  canHide,
@@ -250,6 +258,9 @@ function LeftActions({
250
258
  isMarkReadPending,
251
259
  }: LeftActionsProps) {
252
260
  const styles = useStyles({ actionButtonCount: 1 + Number(canMute) + Number(canHide) })
261
+ // The buttons split whatever the drag has uncovered, so every action is on screen from the
262
+ // first few points and grows with the drag, instead of the last one waiting for a full open.
263
+ const revealStyle = useAnimatedStyle(() => ({ width: Math.max(translation.value, 0) }))
253
264
 
254
265
  const muteToggleContent = {
255
266
  true: { iconName: 'general.bell', label: 'Enable' },
@@ -268,38 +279,41 @@ function LeftActions({
268
279
 
269
280
  return (
270
281
  <View style={styles.actionButtonContainer}>
271
- <SwipeableToggleButton
272
- loading={isMarkReadPending}
273
- disabled={isConversationEmpty}
274
- toggled={!read}
275
- onPress={handleLatestMessageUnread}
276
- toggleContent={latestMessageUnreadToggleContent}
277
- backgroundColor={tokens.fillColorInteractionSwipeDefault}
278
- />
279
- {canMute && (
282
+ <Animated.View style={[styles.actionButtonReveal, revealStyle]}>
280
283
  <SwipeableToggleButton
281
- loading={isMutedPending}
282
- toggled={muted}
283
- onPress={handleMute}
284
- toggleContent={muteToggleContent}
285
- backgroundColor={tokens.fillColorInteractionSwipeSecondary}
284
+ progress={progress}
285
+ loading={isMarkReadPending}
286
+ disabled={isConversationEmpty}
287
+ toggled={!read}
288
+ onPress={handleLatestMessageUnread}
289
+ toggleContent={latestMessageUnreadToggleContent}
290
+ backgroundColor={tokens.fillColorInteractionSwipeDefault}
286
291
  />
287
- )}
288
- {canHide && (
289
- <SwipeableToggleButton
290
- loading={isHiddenPending}
291
- toggled={hidden}
292
- onPress={handleHide}
293
- toggleContent={hideToggleContent}
294
- backgroundColor={tokens.colorNeutral45}
295
- />
296
- )}
292
+ {canMute && (
293
+ <SwipeableToggleButton
294
+ progress={progress}
295
+ loading={isMutedPending}
296
+ toggled={muted}
297
+ onPress={handleMute}
298
+ toggleContent={muteToggleContent}
299
+ backgroundColor={tokens.fillColorInteractionSwipeSecondary}
300
+ />
301
+ )}
302
+ {canHide && (
303
+ <SwipeableToggleButton
304
+ progress={progress}
305
+ loading={isHiddenPending}
306
+ toggled={hidden}
307
+ onPress={handleHide}
308
+ toggleContent={hideToggleContent}
309
+ backgroundColor={tokens.colorNeutral45}
310
+ />
311
+ )}
312
+ </Animated.View>
297
313
  </View>
298
314
  )
299
315
  }
300
316
 
301
- const ACTION_BUTTON_WIDTH = 120
302
-
303
317
  const useStyles = ({ actionButtonCount = 2 }: { actionButtonCount?: number } = {}) => {
304
318
  const { colors } = useTheme()
305
319
  return StyleSheet.create({
@@ -307,10 +321,13 @@ const useStyles = ({ actionButtonCount = 2 }: { actionButtonCount?: number } = {
307
321
  backgroundColor: colors.conversationActionsBackground,
308
322
  },
309
323
  actionButtonContainer: {
324
+ // Fixed at the fully open width: the swipeable measures this to find its snap point.
325
+ width: SWIPEABLE_TOGGLE_BUTTON_WIDTH * actionButtonCount,
326
+ height: '100%',
327
+ },
328
+ actionButtonReveal: {
310
329
  flexDirection: 'row',
311
- alignItems: 'center',
312
- width: ACTION_BUTTON_WIDTH * actionButtonCount,
313
- alignContent: 'stretch',
330
+ height: '100%',
314
331
  },
315
332
  swipeableContainer: {
316
333
  backgroundColor: colors.surfaceColor090,
@@ -7,6 +7,7 @@ import {
7
7
  useFontScale,
8
8
  useScalableNumberOfLines,
9
9
  } from '../../hooks'
10
+ import { useSelectedChipBackgroundColor } from '../../hooks/use_selected_chip_background_color'
10
11
  import { ConversationPreviewData, ConversationResource } from '../../types'
11
12
  import { REACTION_EMOJIS, isArchivedConversation, platformFontWeightBold } from '../../utils'
12
13
  import { formatDatePreview } from '../../utils/date'
@@ -67,6 +68,7 @@ export const ConversationPreview = ({
67
68
  const hasMetaContent = lastMessageCreatedAt || unreadCount > 0 || muted || hidden
68
69
  const isUnread = unreadCount > 0 || unreadReaction
69
70
  const selected = selectMode ? selectedIds.includes(id) : undefined
71
+ const selectedBackgroundColor = useSelectedChipBackgroundColor()
70
72
 
71
73
  const numberOfLinesScaledTitle = useScalableNumberOfLines(1)
72
74
  const numberOfLinesScaledPreviewText = useScalableNumberOfLines(2)
@@ -85,7 +87,12 @@ export const ConversationPreview = ({
85
87
  return (
86
88
  <ConversationActions
87
89
  conversation={conversation}
88
- style={[styles.previewRow, disabled && !archived && styles.disabled, style]}
90
+ style={[
91
+ styles.previewRow,
92
+ disabled && !archived && styles.disabled,
93
+ selected && { backgroundColor: selectedBackgroundColor },
94
+ style,
95
+ ]}
89
96
  onPress={selectMode ? () => toggleSelected(id) : onPress}
90
97
  accessibilityLabel={conversationAccessibilityLabel}
91
98
  selected={selected}
@@ -1,6 +1,12 @@
1
1
  import React from 'react'
2
- import { StyleSheet } from 'react-native'
2
+ import { StyleSheet, View } from 'react-native'
3
3
  import { Pressable, type PressableProps } from 'react-native-gesture-handler'
4
+ import Animated, {
5
+ Extrapolation,
6
+ SharedValue,
7
+ interpolate,
8
+ useAnimatedStyle,
9
+ } from 'react-native-reanimated'
4
10
  import { useCreateAndroidRippleColor, useTheme } from '../../hooks'
5
11
  import { Haptic } from '../../utils/native_adapters/configuration'
6
12
  import {
@@ -11,8 +17,12 @@ import {
11
17
  import { tokens } from '../../vendor/tapestry/tokens'
12
18
  import { Icon, IconString, Spinner, Text } from '../display'
13
19
 
20
+ export const SWIPEABLE_TOGGLE_BUTTON_WIDTH = 120
21
+
14
22
  interface SwipeableToggleButtonProps extends PressableProps {
15
23
  backgroundColor: string
24
+ /** How far the swipe is open, 0 (closed) to 1 (fully open). */
25
+ progress: SharedValue<number>
16
26
  toggled: boolean
17
27
  toggleContent: {
18
28
  true: { iconName: IconString; label: string }
@@ -24,6 +34,7 @@ interface SwipeableToggleButtonProps extends PressableProps {
24
34
  export function SwipeableToggleButton({
25
35
  backgroundColor,
26
36
  onPress,
37
+ progress,
27
38
  toggleContent,
28
39
  disabled = false,
29
40
  toggled,
@@ -37,6 +48,13 @@ export function SwipeableToggleButton({
37
48
 
38
49
  const { iconName, label } = toggleContent[toggled ? 'true' : 'false']
39
50
 
51
+ const iconStyle = useAnimatedStyle(() => ({
52
+ transform: [{ scale: interpolate(progress.value, [0, 1], [0.7, 1], Extrapolation.CLAMP) }],
53
+ }))
54
+ const labelStyle = useAnimatedStyle(() => ({
55
+ opacity: interpolate(progress.value, [0.5, 1], [0, 1], Extrapolation.CLAMP),
56
+ }))
57
+
40
58
  return (
41
59
  <Pressable
42
60
  onPress={event => {
@@ -53,20 +71,24 @@ export function SwipeableToggleButton({
53
71
  {loading ? (
54
72
  <Spinner size={20} />
55
73
  ) : (
56
- <>
57
- <Icon
58
- name={iconName}
59
- style={styles.icon}
60
- maxFontSizeMultiplier={MAX_FONT_SIZE_MULTIPLIER}
61
- />
62
- <Text
63
- variant="footnote"
64
- style={styles.text}
65
- maxFontSizeMultiplier={MAX_FONT_SIZE_MULTIPLIER}
66
- >
67
- {label}
68
- </Text>
69
- </>
74
+ <View style={styles.content}>
75
+ <Animated.View style={iconStyle}>
76
+ <Icon
77
+ name={iconName}
78
+ style={styles.icon}
79
+ maxFontSizeMultiplier={MAX_FONT_SIZE_MULTIPLIER}
80
+ />
81
+ </Animated.View>
82
+ <Animated.View style={labelStyle}>
83
+ <Text
84
+ variant="footnote"
85
+ style={styles.text}
86
+ maxFontSizeMultiplier={MAX_FONT_SIZE_MULTIPLIER}
87
+ >
88
+ {label}
89
+ </Text>
90
+ </Animated.View>
91
+ </View>
70
92
  )}
71
93
  </Pressable>
72
94
  )
@@ -85,10 +107,17 @@ const useStyles = ({ backgroundColor, disabled }: Partial<SwipeableToggleButtonP
85
107
  flexDirection: 'column',
86
108
  alignItems: 'center',
87
109
  justifyContent: 'center',
88
- gap: 4,
89
110
  height: '100%',
111
+ overflow: 'hidden',
90
112
  backgroundColor: buttonBackgroundColor,
91
113
  },
114
+ // Laid out at the fully open width and clipped by the button, so the icon and label stay
115
+ // centered and never reflow while the button is narrower than that.
116
+ content: {
117
+ width: SWIPEABLE_TOGGLE_BUTTON_WIDTH,
118
+ alignItems: 'center',
119
+ gap: 4,
120
+ },
92
121
  icon: {
93
122
  fontSize: 20,
94
123
  color: fillColor,
@@ -3,6 +3,7 @@ import * as api from '@planningcenter/icons/paths/api'
3
3
  import * as brand from '@planningcenter/icons/paths/brand'
4
4
  import * as calendar from '@planningcenter/icons/paths/calendar'
5
5
  import * as chat from '@planningcenter/icons/paths/chat'
6
+ import * as checkIns from '@planningcenter/icons/paths/check-ins'
6
7
  import * as churchCenter from '@planningcenter/icons/paths/church-center'
7
8
  import * as general from '@planningcenter/icons/paths/general'
8
9
  import * as groups from '@planningcenter/icons/paths/groups'
@@ -30,6 +31,7 @@ const ICONS = {
30
31
  brand,
31
32
  calendar,
32
33
  chat,
34
+ checkIns,
33
35
  churchCenter,
34
36
  general,
35
37
  groups,
@@ -55,6 +57,7 @@ export type IconString =
55
57
  | `brand.${IconName<'brand'>}`
56
58
  | `calendar.${IconName<'calendar'>}`
57
59
  | `chat.${IconName<'chat'>}`
60
+ | `checkIns.${IconName<'checkIns'>}`
58
61
  | `churchCenter.${IconName<'churchCenter'>}`
59
62
  | `general.${IconName<'general'>}`
60
63
  | `groups.${IconName<'groups'>}`
@@ -249,7 +249,7 @@ function BannerLink({ children, onPress }: BannerLinkProps) {
249
249
  const styles = useStyles({ appearance })
250
250
 
251
251
  return (
252
- <TextInlineButton variant="tertiary" style={styles.text} onPress={onPress}>
252
+ <TextInlineButton variant="tertiary" style={styles.link} onPress={onPress}>
253
253
  {children}
254
254
  </TextInlineButton>
255
255
  )
@@ -295,5 +295,9 @@ const useStyles = ({ appearance = 'neutral' }: Styles = {}) => {
295
295
  text: {
296
296
  color: statusColorMap[appearance].text,
297
297
  },
298
+ link: {
299
+ color: statusColorMap[appearance].text,
300
+ textDecorationColor: statusColorMap[appearance].text,
301
+ },
298
302
  })
299
303
  }