@repzo/widget-react-native 1.3.0 → 1.4.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/CHANGELOG.md +179 -0
- package/README.md +72 -16
- package/lib/commonjs/api/client.js +113 -0
- package/lib/commonjs/api/client.js.map +1 -1
- package/lib/commonjs/attachments/file-size.js +52 -0
- package/lib/commonjs/attachments/file-size.js.map +1 -0
- package/lib/commonjs/attachments/local-previews.js +40 -0
- package/lib/commonjs/attachments/local-previews.js.map +1 -0
- package/lib/commonjs/attachments/pickers.js +76 -28
- package/lib/commonjs/attachments/pickers.js.map +1 -1
- package/lib/commonjs/i18n.js +24 -3
- package/lib/commonjs/i18n.js.map +1 -1
- package/lib/commonjs/locales.js +13 -3
- package/lib/commonjs/locales.js.map +1 -1
- package/lib/commonjs/state/widget-store.js +486 -63
- package/lib/commonjs/state/widget-store.js.map +1 -1
- package/lib/commonjs/storage.js +3 -1
- package/lib/commonjs/storage.js.map +1 -1
- package/lib/commonjs/types.js.map +1 -1
- package/lib/commonjs/ui/WidgetProvider.js +40 -16
- package/lib/commonjs/ui/WidgetProvider.js.map +1 -1
- package/lib/commonjs/ui/components/AttachmentChips.js +109 -40
- package/lib/commonjs/ui/components/AttachmentChips.js.map +1 -1
- package/lib/commonjs/ui/components/ConversationRow.js +65 -10
- package/lib/commonjs/ui/components/ConversationRow.js.map +1 -1
- package/lib/commonjs/ui/components/ImageViewer.js +231 -25
- package/lib/commonjs/ui/components/ImageViewer.js.map +1 -1
- package/lib/commonjs/ui/components/RatingCard.js +5 -2
- package/lib/commonjs/ui/components/RatingCard.js.map +1 -1
- package/lib/commonjs/ui/components/ZoomableImage.js +58 -10
- package/lib/commonjs/ui/components/ZoomableImage.js.map +1 -1
- package/lib/commonjs/ui/components/icons.js +22 -16
- package/lib/commonjs/ui/components/icons.js.map +1 -1
- package/lib/commonjs/ui/hooks/use-retained-state.js +39 -0
- package/lib/commonjs/ui/hooks/use-retained-state.js.map +1 -0
- package/lib/commonjs/ui/screens/chat/ChatView.js +666 -171
- package/lib/commonjs/ui/screens/chat/ChatView.js.map +1 -1
- package/lib/commonjs/ui/screens/chat/ChatView.styles.js +150 -3
- package/lib/commonjs/ui/screens/chat/ChatView.styles.js.map +1 -1
- package/lib/commonjs/ui/screens/conversations/ConversationsList.js +1 -0
- package/lib/commonjs/ui/screens/conversations/ConversationsList.js.map +1 -1
- package/lib/commonjs/ui/screens/home/HomeView.js +38 -55
- package/lib/commonjs/ui/screens/home/HomeView.js.map +1 -1
- package/lib/commonjs/ui/screens/home/HomeView.styles.js +36 -45
- package/lib/commonjs/ui/screens/home/HomeView.styles.js.map +1 -1
- package/lib/commonjs/ui/styles/theme.js +1 -0
- package/lib/commonjs/ui/styles/theme.js.map +1 -1
- package/lib/commonjs/ui/utils/conversations.js +17 -1
- package/lib/commonjs/ui/utils/conversations.js.map +1 -1
- package/lib/commonjs/ui/utils/html.js +13 -0
- package/lib/commonjs/ui/utils/html.js.map +1 -1
- package/lib/commonjs/ui/utils/image-load-queue.js +114 -0
- package/lib/commonjs/ui/utils/image-load-queue.js.map +1 -0
- package/lib/commonjs/ui/utils/inline-attachments.js +88 -0
- package/lib/commonjs/ui/utils/inline-attachments.js.map +1 -0
- package/lib/module/api/client.js +113 -0
- package/lib/module/api/client.js.map +1 -1
- package/lib/module/attachments/file-size.js +47 -0
- package/lib/module/attachments/file-size.js.map +1 -0
- package/lib/module/attachments/local-previews.js +33 -0
- package/lib/module/attachments/local-previews.js.map +1 -0
- package/lib/module/attachments/pickers.js +74 -27
- package/lib/module/attachments/pickers.js.map +1 -1
- package/lib/module/i18n.js +24 -3
- package/lib/module/i18n.js.map +1 -1
- package/lib/module/locales.js +13 -3
- package/lib/module/locales.js.map +1 -1
- package/lib/module/state/widget-store.js +488 -65
- package/lib/module/state/widget-store.js.map +1 -1
- package/lib/module/storage.js +2 -0
- package/lib/module/storage.js.map +1 -1
- package/lib/module/types.js.map +1 -1
- package/lib/module/ui/WidgetProvider.js +40 -16
- package/lib/module/ui/WidgetProvider.js.map +1 -1
- package/lib/module/ui/components/AttachmentChips.js +111 -42
- package/lib/module/ui/components/AttachmentChips.js.map +1 -1
- package/lib/module/ui/components/ConversationRow.js +65 -10
- package/lib/module/ui/components/ConversationRow.js.map +1 -1
- package/lib/module/ui/components/ImageViewer.js +233 -27
- package/lib/module/ui/components/ImageViewer.js.map +1 -1
- package/lib/module/ui/components/RatingCard.js +5 -2
- package/lib/module/ui/components/RatingCard.js.map +1 -1
- package/lib/module/ui/components/ZoomableImage.js +58 -10
- package/lib/module/ui/components/ZoomableImage.js.map +1 -1
- package/lib/module/ui/components/icons.js +21 -15
- package/lib/module/ui/components/icons.js.map +1 -1
- package/lib/module/ui/hooks/use-retained-state.js +34 -0
- package/lib/module/ui/hooks/use-retained-state.js.map +1 -0
- package/lib/module/ui/screens/chat/ChatView.js +672 -177
- package/lib/module/ui/screens/chat/ChatView.js.map +1 -1
- package/lib/module/ui/screens/chat/ChatView.styles.js +152 -4
- package/lib/module/ui/screens/chat/ChatView.styles.js.map +1 -1
- package/lib/module/ui/screens/conversations/ConversationsList.js +1 -0
- package/lib/module/ui/screens/conversations/ConversationsList.js.map +1 -1
- package/lib/module/ui/screens/home/HomeView.js +40 -57
- package/lib/module/ui/screens/home/HomeView.js.map +1 -1
- package/lib/module/ui/screens/home/HomeView.styles.js +36 -45
- package/lib/module/ui/screens/home/HomeView.styles.js.map +1 -1
- package/lib/module/ui/styles/theme.js +1 -0
- package/lib/module/ui/styles/theme.js.map +1 -1
- package/lib/module/ui/utils/conversations.js +15 -1
- package/lib/module/ui/utils/conversations.js.map +1 -1
- package/lib/module/ui/utils/html.js +12 -0
- package/lib/module/ui/utils/html.js.map +1 -1
- package/lib/module/ui/utils/image-load-queue.js +109 -0
- package/lib/module/ui/utils/image-load-queue.js.map +1 -0
- package/lib/module/ui/utils/inline-attachments.js +85 -0
- package/lib/module/ui/utils/inline-attachments.js.map +1 -0
- package/lib/typescript/commonjs/api/client.d.ts +35 -1
- package/lib/typescript/commonjs/api/client.d.ts.map +1 -1
- package/lib/typescript/commonjs/attachments/file-size.d.ts +15 -0
- package/lib/typescript/commonjs/attachments/file-size.d.ts.map +1 -0
- package/lib/typescript/commonjs/attachments/local-previews.d.ts +14 -0
- package/lib/typescript/commonjs/attachments/local-previews.d.ts.map +1 -0
- package/lib/typescript/commonjs/attachments/pickers.d.ts +35 -10
- package/lib/typescript/commonjs/attachments/pickers.d.ts.map +1 -1
- package/lib/typescript/commonjs/i18n.d.ts +13 -3
- package/lib/typescript/commonjs/i18n.d.ts.map +1 -1
- package/lib/typescript/commonjs/locales.d.ts.map +1 -1
- package/lib/typescript/commonjs/state/widget-store.d.ts +67 -4
- package/lib/typescript/commonjs/state/widget-store.d.ts.map +1 -1
- package/lib/typescript/commonjs/storage.d.ts +2 -0
- package/lib/typescript/commonjs/storage.d.ts.map +1 -1
- package/lib/typescript/commonjs/types.d.ts +58 -0
- package/lib/typescript/commonjs/types.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/WidgetProvider.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/components/AttachmentChips.d.ts +13 -3
- package/lib/typescript/commonjs/ui/components/AttachmentChips.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/components/ConversationRow.d.ts +15 -1
- package/lib/typescript/commonjs/ui/components/ConversationRow.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/components/ImageViewer.d.ts +26 -6
- package/lib/typescript/commonjs/ui/components/ImageViewer.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/components/RatingCard.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/components/ZoomableImage.d.ts +10 -1
- package/lib/typescript/commonjs/ui/components/ZoomableImage.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/components/icons.d.ts +2 -1
- package/lib/typescript/commonjs/ui/components/icons.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/hooks/use-retained-state.d.ts +11 -0
- package/lib/typescript/commonjs/ui/hooks/use-retained-state.d.ts.map +1 -0
- package/lib/typescript/commonjs/ui/screens/chat/ChatView.d.ts +4 -4
- package/lib/typescript/commonjs/ui/screens/chat/ChatView.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/screens/chat/ChatView.styles.d.ts +154 -2
- package/lib/typescript/commonjs/ui/screens/chat/ChatView.styles.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/screens/chat/ChatView.types.d.ts +30 -1
- package/lib/typescript/commonjs/ui/screens/chat/ChatView.types.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/screens/conversations/ConversationsList.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/screens/conversations/ConversationsList.types.d.ts +2 -0
- package/lib/typescript/commonjs/ui/screens/conversations/ConversationsList.types.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/screens/home/HomeView.d.ts +7 -5
- package/lib/typescript/commonjs/ui/screens/home/HomeView.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/screens/home/HomeView.styles.d.ts +30 -35
- package/lib/typescript/commonjs/ui/screens/home/HomeView.styles.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/screens/home/HomeView.types.d.ts +5 -6
- package/lib/typescript/commonjs/ui/screens/home/HomeView.types.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/styles/theme.d.ts +2 -0
- package/lib/typescript/commonjs/ui/styles/theme.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/utils/conversations.d.ts +10 -2
- package/lib/typescript/commonjs/ui/utils/conversations.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/utils/html.d.ts +5 -0
- package/lib/typescript/commonjs/ui/utils/html.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/utils/image-load-queue.d.ts +44 -0
- package/lib/typescript/commonjs/ui/utils/image-load-queue.d.ts.map +1 -0
- package/lib/typescript/commonjs/ui/utils/inline-attachments.d.ts +29 -0
- package/lib/typescript/commonjs/ui/utils/inline-attachments.d.ts.map +1 -0
- package/lib/typescript/module/api/client.d.ts +35 -1
- package/lib/typescript/module/api/client.d.ts.map +1 -1
- package/lib/typescript/module/attachments/file-size.d.ts +15 -0
- package/lib/typescript/module/attachments/file-size.d.ts.map +1 -0
- package/lib/typescript/module/attachments/local-previews.d.ts +14 -0
- package/lib/typescript/module/attachments/local-previews.d.ts.map +1 -0
- package/lib/typescript/module/attachments/pickers.d.ts +35 -10
- package/lib/typescript/module/attachments/pickers.d.ts.map +1 -1
- package/lib/typescript/module/i18n.d.ts +13 -3
- package/lib/typescript/module/i18n.d.ts.map +1 -1
- package/lib/typescript/module/locales.d.ts.map +1 -1
- package/lib/typescript/module/state/widget-store.d.ts +67 -4
- package/lib/typescript/module/state/widget-store.d.ts.map +1 -1
- package/lib/typescript/module/storage.d.ts +2 -0
- package/lib/typescript/module/storage.d.ts.map +1 -1
- package/lib/typescript/module/types.d.ts +58 -0
- package/lib/typescript/module/types.d.ts.map +1 -1
- package/lib/typescript/module/ui/WidgetProvider.d.ts.map +1 -1
- package/lib/typescript/module/ui/components/AttachmentChips.d.ts +13 -3
- package/lib/typescript/module/ui/components/AttachmentChips.d.ts.map +1 -1
- package/lib/typescript/module/ui/components/ConversationRow.d.ts +15 -1
- package/lib/typescript/module/ui/components/ConversationRow.d.ts.map +1 -1
- package/lib/typescript/module/ui/components/ImageViewer.d.ts +26 -6
- package/lib/typescript/module/ui/components/ImageViewer.d.ts.map +1 -1
- package/lib/typescript/module/ui/components/RatingCard.d.ts.map +1 -1
- package/lib/typescript/module/ui/components/ZoomableImage.d.ts +10 -1
- package/lib/typescript/module/ui/components/ZoomableImage.d.ts.map +1 -1
- package/lib/typescript/module/ui/components/icons.d.ts +2 -1
- package/lib/typescript/module/ui/components/icons.d.ts.map +1 -1
- package/lib/typescript/module/ui/hooks/use-retained-state.d.ts +11 -0
- package/lib/typescript/module/ui/hooks/use-retained-state.d.ts.map +1 -0
- package/lib/typescript/module/ui/screens/chat/ChatView.d.ts +4 -4
- package/lib/typescript/module/ui/screens/chat/ChatView.d.ts.map +1 -1
- package/lib/typescript/module/ui/screens/chat/ChatView.styles.d.ts +154 -2
- package/lib/typescript/module/ui/screens/chat/ChatView.styles.d.ts.map +1 -1
- package/lib/typescript/module/ui/screens/chat/ChatView.types.d.ts +30 -1
- package/lib/typescript/module/ui/screens/chat/ChatView.types.d.ts.map +1 -1
- package/lib/typescript/module/ui/screens/conversations/ConversationsList.d.ts.map +1 -1
- package/lib/typescript/module/ui/screens/conversations/ConversationsList.types.d.ts +2 -0
- package/lib/typescript/module/ui/screens/conversations/ConversationsList.types.d.ts.map +1 -1
- package/lib/typescript/module/ui/screens/home/HomeView.d.ts +7 -5
- package/lib/typescript/module/ui/screens/home/HomeView.d.ts.map +1 -1
- package/lib/typescript/module/ui/screens/home/HomeView.styles.d.ts +30 -35
- package/lib/typescript/module/ui/screens/home/HomeView.styles.d.ts.map +1 -1
- package/lib/typescript/module/ui/screens/home/HomeView.types.d.ts +5 -6
- package/lib/typescript/module/ui/screens/home/HomeView.types.d.ts.map +1 -1
- package/lib/typescript/module/ui/styles/theme.d.ts +2 -0
- package/lib/typescript/module/ui/styles/theme.d.ts.map +1 -1
- package/lib/typescript/module/ui/utils/conversations.d.ts +10 -2
- package/lib/typescript/module/ui/utils/conversations.d.ts.map +1 -1
- package/lib/typescript/module/ui/utils/html.d.ts +5 -0
- package/lib/typescript/module/ui/utils/html.d.ts.map +1 -1
- package/lib/typescript/module/ui/utils/image-load-queue.d.ts +44 -0
- package/lib/typescript/module/ui/utils/image-load-queue.d.ts.map +1 -0
- package/lib/typescript/module/ui/utils/inline-attachments.d.ts +29 -0
- package/lib/typescript/module/ui/utils/inline-attachments.d.ts.map +1 -0
- package/package.json +1 -1
- package/src/api/client.ts +148 -2
- package/src/attachments/file-size.ts +42 -0
- package/src/attachments/local-previews.ts +32 -0
- package/src/attachments/pickers.ts +90 -30
- package/src/i18n.ts +24 -3
- package/src/locales.ts +13 -3
- package/src/state/widget-store.ts +519 -70
- package/src/storage.ts +2 -0
- package/src/types.ts +58 -0
- package/src/ui/WidgetProvider.tsx +50 -12
- package/src/ui/components/AttachmentChips.tsx +100 -29
- package/src/ui/components/ConversationRow.tsx +90 -9
- package/src/ui/components/ImageViewer.tsx +250 -28
- package/src/ui/components/RatingCard.tsx +5 -2
- package/src/ui/components/ZoomableImage.tsx +58 -5
- package/src/ui/components/icons.tsx +10 -12
- package/src/ui/hooks/use-retained-state.ts +35 -0
- package/src/ui/screens/chat/ChatView.styles.ts +151 -3
- package/src/ui/screens/chat/ChatView.tsx +760 -213
- package/src/ui/screens/chat/ChatView.types.ts +30 -1
- package/src/ui/screens/conversations/ConversationsList.tsx +1 -0
- package/src/ui/screens/conversations/ConversationsList.types.ts +2 -0
- package/src/ui/screens/home/HomeView.styles.ts +36 -45
- package/src/ui/screens/home/HomeView.tsx +54 -70
- package/src/ui/screens/home/HomeView.types.ts +5 -6
- package/src/ui/styles/theme.ts +6 -0
- package/src/ui/utils/conversations.ts +16 -2
- package/src/ui/utils/html.ts +26 -0
- package/src/ui/utils/image-load-queue.ts +108 -0
- package/src/ui/utils/inline-attachments.ts +71 -0
|
@@ -20,6 +20,7 @@ var _jsxRuntime = require("react/jsx-runtime");
|
|
|
20
20
|
*/
|
|
21
21
|
|
|
22
22
|
const AVATAR_SIZE = 40;
|
|
23
|
+
const CARD_AVATAR_SIZE = 32;
|
|
23
24
|
function ConversationRow({
|
|
24
25
|
conversation,
|
|
25
26
|
color,
|
|
@@ -27,47 +28,59 @@ function ConversationRow({
|
|
|
27
28
|
timeLabels,
|
|
28
29
|
unreadCount = 0,
|
|
29
30
|
unreadLabel,
|
|
31
|
+
lastMessageLabels,
|
|
30
32
|
horizontalPadding = _theme.spacing.xl,
|
|
33
|
+
variant = 'list',
|
|
31
34
|
onPress
|
|
32
35
|
}) {
|
|
36
|
+
const card = variant === 'card';
|
|
33
37
|
const displayName = conversation.agentName || fallbackName;
|
|
34
38
|
const hasUnread = unreadCount > 0;
|
|
35
39
|
const unreadSuffix = hasUnread && unreadLabel ? `. ${(0, _i18n.formatLabel)(unreadLabel, {
|
|
36
40
|
count: unreadCount
|
|
37
41
|
})}` : '';
|
|
42
|
+
const attachment = conversation.lastMessageAttachment;
|
|
43
|
+
// "Photo" or "File" over Workstation's "2 attachments".
|
|
44
|
+
const snippet = attachment && lastMessageLabels?.[attachment] || conversation.snippet || '';
|
|
45
|
+
// "You: " is drawn a shade stronger than the message, so it reads as a label.
|
|
46
|
+
const [youBefore, youAfter] = snippet && conversation.lastMessageFromVisitor && lastMessageLabels?.you ? splitAround(lastMessageLabels.you, '{message}') : ['', ''];
|
|
47
|
+
const snippetLabel = `${youBefore}${snippet}${youAfter}`;
|
|
38
48
|
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.Pressable, {
|
|
39
49
|
onPress: onPress,
|
|
40
50
|
accessibilityRole: "button",
|
|
41
|
-
accessibilityLabel: `${
|
|
51
|
+
accessibilityLabel: `${snippet ? `${displayName}. ${snippetLabel}` : displayName}${unreadSuffix}`,
|
|
42
52
|
android_ripple: {
|
|
43
53
|
color: _theme.palette.borderSoft
|
|
44
54
|
},
|
|
45
55
|
style: ({
|
|
46
56
|
pressed
|
|
47
|
-
}) => [styles.row, {
|
|
57
|
+
}) => [styles.row, card && cardStyles.row, {
|
|
48
58
|
paddingHorizontal: horizontalPadding
|
|
49
59
|
}, pressed && styles.rowPressed],
|
|
50
60
|
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_Avatar.Avatar, {
|
|
51
61
|
avatar: conversation.agentAvatar,
|
|
52
62
|
name: conversation.agentName,
|
|
53
|
-
size: AVATAR_SIZE,
|
|
63
|
+
size: card ? CARD_AVATAR_SIZE : AVATAR_SIZE,
|
|
54
64
|
color: color
|
|
55
65
|
}), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
|
|
56
66
|
style: styles.content,
|
|
57
67
|
children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
|
|
58
|
-
style: styles.topLine,
|
|
68
|
+
style: [styles.topLine, card && cardStyles.topLine],
|
|
59
69
|
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
|
|
60
|
-
style: [styles.name, hasUnread && styles.nameUnread],
|
|
70
|
+
style: card ? [cardStyles.name, hasUnread && cardStyles.nameUnread] : [styles.name, hasUnread && styles.nameUnread],
|
|
61
71
|
numberOfLines: 1,
|
|
62
72
|
children: displayName
|
|
63
73
|
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
|
|
64
|
-
style: styles.time,
|
|
74
|
+
style: [styles.time, card && cardStyles.time],
|
|
65
75
|
children: conversation.lastMessageAt ? (0, _conversations.formatRelativeTime)(conversation.lastMessageAt, timeLabels) : ''
|
|
66
76
|
})]
|
|
67
|
-
}),
|
|
68
|
-
style: [styles.snippet, hasUnread && styles.snippetUnread],
|
|
77
|
+
}), snippet ? /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.Text, {
|
|
78
|
+
style: [styles.snippet, card && cardStyles.snippet, hasUnread && styles.snippetUnread],
|
|
69
79
|
numberOfLines: 2,
|
|
70
|
-
children:
|
|
80
|
+
children: [youBefore ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
|
|
81
|
+
style: styles.snippetYou,
|
|
82
|
+
children: youBefore
|
|
83
|
+
}) : null, snippet, youAfter]
|
|
71
84
|
}) : null]
|
|
72
85
|
}), hasUnread ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
|
|
73
86
|
style: [styles.badge, {
|
|
@@ -77,7 +90,7 @@ function ConversationRow({
|
|
|
77
90
|
style: styles.badgeLabel,
|
|
78
91
|
children: unreadCount > 9 ? '9+' : unreadCount
|
|
79
92
|
})
|
|
80
|
-
}) : /*#__PURE__*/(0, _jsxRuntime.jsx)(_icons.ChevronIcon, {
|
|
93
|
+
}) : card ? null : /*#__PURE__*/(0, _jsxRuntime.jsx)(_icons.ChevronIcon, {
|
|
81
94
|
size: 16,
|
|
82
95
|
direction: (0, _rtl.forwardDirection)(),
|
|
83
96
|
color: _theme.palette.textSubtle
|
|
@@ -85,6 +98,13 @@ function ConversationRow({
|
|
|
85
98
|
});
|
|
86
99
|
}
|
|
87
100
|
|
|
101
|
+
/** `'You: {message}'` → `['You: ', '']`; a template without the token goes in front. */
|
|
102
|
+
function splitAround(template, token) {
|
|
103
|
+
const index = template.indexOf(token);
|
|
104
|
+
if (index < 0) return [`${template} `, ''];
|
|
105
|
+
return [template.slice(0, index), template.slice(index + token.length)];
|
|
106
|
+
}
|
|
107
|
+
|
|
88
108
|
/** Where a divider should start so it sits under the text, not the avatar. */
|
|
89
109
|
function rowDividerInset(horizontalPadding = _theme.spacing.xl) {
|
|
90
110
|
return horizontalPadding + AVATAR_SIZE + _theme.spacing.md;
|
|
@@ -136,6 +156,10 @@ const styles = _reactNative.StyleSheet.create({
|
|
|
136
156
|
color: _theme.palette.text,
|
|
137
157
|
fontWeight: '500'
|
|
138
158
|
},
|
|
159
|
+
snippetYou: {
|
|
160
|
+
color: _theme.palette.text,
|
|
161
|
+
fontWeight: '600'
|
|
162
|
+
},
|
|
139
163
|
// Replaces the chevron rather than crowding beside it, so the row keeps
|
|
140
164
|
// the same width whether or not there is anything unread.
|
|
141
165
|
badge: {
|
|
@@ -152,4 +176,35 @@ const styles = _reactNative.StyleSheet.create({
|
|
|
152
176
|
fontWeight: '700'
|
|
153
177
|
}
|
|
154
178
|
});
|
|
179
|
+
|
|
180
|
+
// Overrides for the `card` variant. It sits under the card's title, so it
|
|
181
|
+
// drops the list's minimum height, and its name, time and last message share
|
|
182
|
+
// one size, the way the Home design draws them.
|
|
183
|
+
const cardStyles = _reactNative.StyleSheet.create({
|
|
184
|
+
row: {
|
|
185
|
+
minHeight: 0,
|
|
186
|
+
paddingVertical: _theme.spacing.sm
|
|
187
|
+
},
|
|
188
|
+
// The time follows the name instead of being pushed to the far edge.
|
|
189
|
+
topLine: {
|
|
190
|
+
justifyContent: 'flex-start'
|
|
191
|
+
},
|
|
192
|
+
name: {
|
|
193
|
+
textAlign: _rtl.START_ALIGN,
|
|
194
|
+
flexShrink: 1,
|
|
195
|
+
fontSize: _theme.fontSize.body,
|
|
196
|
+
color: _theme.palette.ink
|
|
197
|
+
},
|
|
198
|
+
nameUnread: {
|
|
199
|
+
fontWeight: '600'
|
|
200
|
+
},
|
|
201
|
+
time: {
|
|
202
|
+
fontSize: _theme.fontSize.body
|
|
203
|
+
},
|
|
204
|
+
snippet: {
|
|
205
|
+
fontSize: _theme.fontSize.body,
|
|
206
|
+
lineHeight: _theme.fontSize.body * 1.35,
|
|
207
|
+
color: _theme.palette.textSubtle
|
|
208
|
+
}
|
|
209
|
+
});
|
|
155
210
|
//# sourceMappingURL=ConversationRow.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_reactNative","require","_Avatar","_i18n","_conversations","_icons","_rtl","_theme","_jsxRuntime","AVATAR_SIZE","ConversationRow","conversation","color","fallbackName","timeLabels","unreadCount","unreadLabel","horizontalPadding","spacing","xl","onPress","displayName","agentName","hasUnread","unreadSuffix","formatLabel","count","jsxs","Pressable","accessibilityRole","accessibilityLabel","
|
|
1
|
+
{"version":3,"names":["_reactNative","require","_Avatar","_i18n","_conversations","_icons","_rtl","_theme","_jsxRuntime","AVATAR_SIZE","CARD_AVATAR_SIZE","ConversationRow","conversation","color","fallbackName","timeLabels","unreadCount","unreadLabel","lastMessageLabels","horizontalPadding","spacing","xl","variant","onPress","card","displayName","agentName","hasUnread","unreadSuffix","formatLabel","count","attachment","lastMessageAttachment","snippet","youBefore","youAfter","lastMessageFromVisitor","you","splitAround","snippetLabel","jsxs","Pressable","accessibilityRole","accessibilityLabel","android_ripple","palette","borderSoft","style","pressed","styles","row","cardStyles","paddingHorizontal","rowPressed","children","jsx","Avatar","avatar","agentAvatar","name","size","View","content","topLine","Text","nameUnread","numberOfLines","time","lastMessageAt","formatRelativeTime","snippetUnread","snippetYou","badge","backgroundColor","badgeLabel","ChevronIcon","direction","forwardDirection","textSubtle","template","token","index","indexOf","slice","length","rowDividerInset","md","StyleSheet","create","flexDirection","alignItems","gap","minHeight","paddingVertical","white","surface","flex","minWidth","justifyContent","sm","textAlign","START_ALIGN","fontSize","body","fontWeight","ink","caption","meta","lineHeight","textMuted","marginTop","text","height","borderRadius","xs","micro","flexShrink"],"sourceRoot":"../../../../src","sources":["ui/components/ConversationRow.tsx"],"mappings":";;;;;;;AAMA,IAAAA,YAAA,GAAAC,OAAA;AAGA,IAAAC,OAAA,GAAAD,OAAA;AACA,IAAAE,KAAA,GAAAF,OAAA;AACA,IAAAG,cAAA,GAAAH,OAAA;AACA,IAAAI,MAAA,GAAAJ,OAAA;AACA,IAAAK,IAAA,GAAAL,OAAA;AACA,IAAAM,MAAA,GAAAN,OAAA;AAA6D,IAAAO,WAAA,GAAAP,OAAA;AAd7D;AACA;AACA;AACA;AACA;;AAYA,MAAMQ,WAAW,GAAG,EAAE;AACtB,MAAMC,gBAAgB,GAAG,EAAE;AAgCpB,SAASC,eAAeA,CAAC;EAC9BC,YAAY;EACZC,KAAK;EACLC,YAAY;EACZC,UAAU;EACVC,WAAW,GAAG,CAAC;EACfC,WAAW;EACXC,iBAAiB;EACjBC,iBAAiB,GAAGC,cAAO,CAACC,EAAE;EAC9BC,OAAO,GAAG,MAAM;EAChBC;AACoB,CAAC,EAAE;EACvB,MAAMC,IAAI,GAAGF,OAAO,KAAK,MAAM;EAC/B,MAAMG,WAAW,GAAGb,YAAY,CAACc,SAAS,IAAIZ,YAAY;EAC1D,MAAMa,SAAS,GAAGX,WAAW,GAAG,CAAC;EACjC,MAAMY,YAAY,GAChBD,SAAS,IAAIV,WAAW,GAAG,KAAK,IAAAY,iBAAW,EAACZ,WAAW,EAAE;IAAEa,KAAK,EAAEd;EAAY,CAAC,CAAC,EAAE,GAAG,EAAE;EACzF,MAAMe,UAAU,GAAGnB,YAAY,CAACoB,qBAAqB;EACrD;EACA,MA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I;IACnBP,UAAU,EAAE;EACd,CAAC;EACD;EACA;EACAhC,KAAK,EAAE;IACLyB,QAAQ,EAAE,EAAE;IACZe,MAAM,EAAE,EAAE;IACVC,YAAY,EAAE,EAAE;IAChB7D,iBAAiB,EAAEhC,cAAO,CAAC8F,EAAE,GAAG,CAAC;IACjCxB,UAAU,EAAE,QAAQ;IACpBQ,cAAc,EAAE;EAClB,CAAC;EACDxB,UAAU,EAAE;IACV7D,KAAK,EAAEgC,cAAO,CAACiD,KAAK;IACpBQ,QAAQ,EAAEA,eAAQ,CAACa,KAAK;IACxBX,UAAU,EAAE;EACd;AACF,CAAC,CAAC;;AAEF;AACA;AACA;AACA,MAAMrD,UAAU,GAAGoC,uBAAU,CAACC,MAAM,CAAC;EACnCtC,GAAG,EAAE;IACH0C,SAAS,EAAE,CAAC;IACZC,eAAe,EAAEzE,cAAO,CAAC+E;EAC3B,CAAC;EACD;EACApC,OAAO,EAAE;IACPmC,cAAc,EAAE;EAClB,CAAC;EACDvC,IAAI,EAAE;IACJyC,SAAS,EAAEC,gBAAW;IACtBe,UAAU,EAAE,CAAC;IACbd,QAAQ,EAAEA,eAAQ,CAACC,IAAI;IACvB1F,KAAK,EAAEgC,cAAO,CAAC4D;EACjB,CAAC;EACDxC,UAAU,EAAE;IACVuC,UAAU,EAAE;EACd,CAAC;EACDrC,IAAI,EAAE;IACJmC,QAAQ,EAAEA,eAAQ,CAACC;EACrB,CAAC;EACDtE,OAAO,EAAE;IACPqE,QAAQ,EAAEA,eAAQ,CAACC,IAAI;IACvBK,UAAU,EAAEN,eAAQ,CAACC,IAAI,GAAG,IAAI;IAChC1F,KAAK,EAAEgC,cAAO,CAACiC;EACjB;AACF,CAAC,CAAC","ignoreList":[]}
|
|
@@ -6,30 +6,138 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.ImageViewer = ImageViewer;
|
|
7
7
|
var _react = require("react");
|
|
8
8
|
var _reactNative = require("react-native");
|
|
9
|
+
var _i18n = require("../../i18n.js");
|
|
10
|
+
var _useReduceMotion = require("../hooks/use-reduce-motion.js");
|
|
9
11
|
var _useWidgetInsets = require("../hooks/use-widget-insets.js");
|
|
10
12
|
var _theme = require("../styles/theme.js");
|
|
13
|
+
var _rtl = require("../utils/rtl.js");
|
|
14
|
+
var _safeUrl = require("../utils/safe-url.js");
|
|
11
15
|
var _icons = require("./icons.js");
|
|
12
16
|
var _ZoomableImage = require("./ZoomableImage.js");
|
|
13
17
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
14
18
|
/**
|
|
15
19
|
* Full-screen viewer for image attachments, so a tap on a photo the agent sent
|
|
16
20
|
* stays inside the messenger instead of bouncing to the browser. Pinch, drag
|
|
17
|
-
* and double-tap zoom work on iOS and Android (see ZoomableImage).
|
|
21
|
+
* and double-tap zoom work on iOS and Android (see ZoomableImage). With
|
|
22
|
+
* several photos in one message, a sideways swipe moves between them.
|
|
18
23
|
*/
|
|
19
24
|
|
|
25
|
+
/** The photos of one message, opened at the one tapped. */
|
|
26
|
+
|
|
27
|
+
/** A swipe changes photo past this share of the screen, or this fast (px/ms). */
|
|
28
|
+
const SWIPE_DISTANCE = 0.25;
|
|
29
|
+
const SWIPE_VELOCITY = 0.5;
|
|
30
|
+
/** Past the first or last photo the strip only gives this much. */
|
|
31
|
+
const EDGE_RESISTANCE = 0.25;
|
|
20
32
|
function ImageViewer({
|
|
21
|
-
|
|
33
|
+
gallery,
|
|
22
34
|
labels,
|
|
23
35
|
onClose,
|
|
24
36
|
onOpenExternally
|
|
25
37
|
}) {
|
|
26
38
|
const insets = (0, _useWidgetInsets.useWidgetInsets)();
|
|
27
|
-
|
|
39
|
+
const reduceMotion = (0, _useReduceMotion.useReduceMotion)();
|
|
40
|
+
// The photo on screen, for the gallery it belongs to: a new gallery opens at its own.
|
|
41
|
+
const [position, setPosition] = (0, _react.useState)({
|
|
42
|
+
of: null,
|
|
43
|
+
index: 0
|
|
44
|
+
});
|
|
45
|
+
const images = gallery?.images ?? [];
|
|
46
|
+
const index = position.of === gallery ? position.index : gallery?.index ?? 0;
|
|
47
|
+
const image = images[index] ?? null;
|
|
48
|
+
// Photos whose own URL failed, now shown from their fallback.
|
|
49
|
+
const [fellBack, setFellBack] = (0, _react.useState)(() => new Set());
|
|
50
|
+
const sourceOf = photo => photo.fallbackUrl && fellBack.has(photo.url) ? photo.fallbackUrl : photo.url;
|
|
51
|
+
const source = image ? sourceOf(image) : null;
|
|
52
|
+
// Keyed by URL so each photo starts from a clean loading state.
|
|
28
53
|
const [status, setStatus] = (0, _react.useState)({
|
|
29
54
|
url: null,
|
|
30
55
|
state: 'loading'
|
|
31
56
|
});
|
|
32
|
-
const state = status.url ===
|
|
57
|
+
const state = status.url === source ? status.state : 'loading';
|
|
58
|
+
// False once there's nothing left to try, so the caller shows the failure.
|
|
59
|
+
const fallBack = photo => {
|
|
60
|
+
if (!photo.fallbackUrl || fellBack.has(photo.url)) return false;
|
|
61
|
+
setFellBack(current => new Set(current).add(photo.url));
|
|
62
|
+
return true;
|
|
63
|
+
};
|
|
64
|
+
// Photos whose screen-size copy is drawn: no spinner over those while the full one decodes.
|
|
65
|
+
const [previewed, setPreviewed] = (0, _react.useState)(() => new Set());
|
|
66
|
+
const markPreviewed = url => setPreviewed(current => current.has(url) ? current : new Set(current).add(url));
|
|
67
|
+
const [width, setWidth] = (0, _react.useState)(0);
|
|
68
|
+
// One page per photo, never reordered: a swipe slides the strip to the photo
|
|
69
|
+
// it lands on and leaves it there. (Re-centring three pages instead showed the
|
|
70
|
+
// wrong photo, then a black frame, for a moment on Android.)
|
|
71
|
+
const [offset] = (0, _react.useState)(() => new _reactNative.Animated.Value(0));
|
|
72
|
+
const rtl = (0, _rtl.isRTL)();
|
|
73
|
+
// Pages run left to right in every language; in Arabic the first photo is the rightmost.
|
|
74
|
+
const restingAt = photo => -(rtl ? images.length - 1 - photo : photo) * width;
|
|
75
|
+
const swiping = (0, _react.useRef)(false);
|
|
76
|
+
// Closing the viewer mid-swipe stops the slide unfinished, so it never
|
|
77
|
+
// settles: the next gallery is placed afresh.
|
|
78
|
+
(0, _react.useLayoutEffect)(() => {
|
|
79
|
+
swiping.current = false;
|
|
80
|
+
}, [gallery]);
|
|
81
|
+
// Places the strip when the viewer opens, the screen turns or the screen reader
|
|
82
|
+
// moves; after a swipe it is already there.
|
|
83
|
+
(0, _react.useLayoutEffect)(() => {
|
|
84
|
+
if (!swiping.current) offset.setValue(restingAt(index));
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
// In Arabic the next photo is the one on the left.
|
|
88
|
+
const step = rtl ? -1 : 1;
|
|
89
|
+
const neighbour = side => {
|
|
90
|
+
const next = index + side * step;
|
|
91
|
+
return next >= 0 && next < images.length ? next : null;
|
|
92
|
+
};
|
|
93
|
+
const show = next => {
|
|
94
|
+
if (next !== null) setPosition({
|
|
95
|
+
of: gallery,
|
|
96
|
+
index: next
|
|
97
|
+
});
|
|
98
|
+
};
|
|
99
|
+
const swipe = {
|
|
100
|
+
move: dx => {
|
|
101
|
+
swiping.current = true;
|
|
102
|
+
const resisted = neighbour(dx < 0 ? 1 : -1) === null ? dx * EDGE_RESISTANCE : dx;
|
|
103
|
+
offset.setValue(restingAt(index) + resisted);
|
|
104
|
+
},
|
|
105
|
+
end: (dx, vx) => {
|
|
106
|
+
const next = neighbour(dx < 0 ? 1 : -1);
|
|
107
|
+
const far = Math.abs(dx) > width * SWIPE_DISTANCE || Math.abs(vx) > SWIPE_VELOCITY && Math.sign(vx) === Math.sign(dx);
|
|
108
|
+
const target = next !== null && dx !== 0 && far ? next : index;
|
|
109
|
+
const toValue = restingAt(target);
|
|
110
|
+
// Switched as the finger lifts: the counter changes at once, and the full
|
|
111
|
+
// photo decodes while the strip is still sliding to it.
|
|
112
|
+
show(target === index ? null : target);
|
|
113
|
+
if (reduceMotion !== false) {
|
|
114
|
+
offset.setValue(toValue);
|
|
115
|
+
swiping.current = false;
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
|
+
const animation = target === index ? _reactNative.Animated.spring(offset, {
|
|
119
|
+
toValue,
|
|
120
|
+
useNativeDriver: true,
|
|
121
|
+
bounciness: 0,
|
|
122
|
+
speed: 18
|
|
123
|
+
}) : _reactNative.Animated.timing(offset, {
|
|
124
|
+
toValue,
|
|
125
|
+
duration: 180,
|
|
126
|
+
useNativeDriver: true
|
|
127
|
+
});
|
|
128
|
+
// A swipe that starts before this one lands takes over the strip; it settles it.
|
|
129
|
+
animation.start(({
|
|
130
|
+
finished
|
|
131
|
+
}) => {
|
|
132
|
+
if (finished) swiping.current = false;
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
};
|
|
136
|
+
const several = images.length > 1;
|
|
137
|
+
const handleAccessibilityAction = event => {
|
|
138
|
+
if (event.nativeEvent.actionName === 'increment' && index < images.length - 1) show(index + 1);
|
|
139
|
+
if (event.nativeEvent.actionName === 'decrement' && index > 0) show(index - 1);
|
|
140
|
+
};
|
|
33
141
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Modal, {
|
|
34
142
|
visible: !!image,
|
|
35
143
|
transparent: true,
|
|
@@ -39,30 +147,98 @@ function ImageViewer({
|
|
|
39
147
|
children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
|
|
40
148
|
style: styles.backdrop,
|
|
41
149
|
accessibilityViewIsModal: true,
|
|
42
|
-
|
|
43
|
-
/*#__PURE__*/
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
150
|
+
onLayout: event => setWidth(event.nativeEvent.layout.width),
|
|
151
|
+
children: [image && width > 0 ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Animated.View, {
|
|
152
|
+
style: [styles.strip, {
|
|
153
|
+
width: width * images.length,
|
|
154
|
+
transform: [{
|
|
155
|
+
translateX: offset
|
|
156
|
+
}]
|
|
157
|
+
}],
|
|
158
|
+
children: (rtl ? [...images].reverse() : images).map(photo => {
|
|
159
|
+
const page = images.indexOf(photo);
|
|
160
|
+
const centre = page === index;
|
|
161
|
+
const uri = sourceOf(photo);
|
|
162
|
+
// Only the photo on screen and the ones a swipe reveals are drawn.
|
|
163
|
+
const near = Math.abs(page - index) <= 1;
|
|
164
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
|
|
165
|
+
style: [styles.page, {
|
|
166
|
+
width
|
|
167
|
+
}],
|
|
168
|
+
...(centre && several ? {
|
|
169
|
+
accessible: true,
|
|
170
|
+
accessibilityRole: 'adjustable',
|
|
171
|
+
accessibilityLabel: photo.name,
|
|
172
|
+
accessibilityValue: {
|
|
173
|
+
text: (0, _i18n.formatLabel)(labels.position, {
|
|
174
|
+
current: index + 1,
|
|
175
|
+
total: images.length
|
|
176
|
+
})
|
|
177
|
+
},
|
|
178
|
+
accessibilityActions: [{
|
|
179
|
+
name: 'increment'
|
|
180
|
+
}, {
|
|
181
|
+
name: 'decrement'
|
|
182
|
+
}],
|
|
183
|
+
onAccessibilityAction: handleAccessibilityAction
|
|
184
|
+
} : null),
|
|
185
|
+
children: [!near ? null : photo.large ? centre ? null : /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.ActivityIndicator, {
|
|
186
|
+
style: styles.layer,
|
|
187
|
+
color: _theme.palette.white
|
|
188
|
+
}) :
|
|
189
|
+
/*#__PURE__*/
|
|
190
|
+
// Decoded at the screen's size, so it's ready mid-swipe, and shown
|
|
191
|
+
// until the full photo on top has decoded.
|
|
192
|
+
(0, _jsxRuntime.jsx)(_reactNative.Image, {
|
|
193
|
+
source: {
|
|
194
|
+
uri
|
|
195
|
+
},
|
|
196
|
+
style: [styles.layer, centre && state === 'ready' && styles.covered],
|
|
197
|
+
resizeMode: "contain",
|
|
198
|
+
resizeMethod: "resize",
|
|
199
|
+
onLoad: () => markPreviewed(uri),
|
|
200
|
+
onError: () => fallBack(photo),
|
|
201
|
+
importantForAccessibility: "no",
|
|
202
|
+
accessibilityIgnoresInvertColors: true
|
|
203
|
+
}), centre ?
|
|
204
|
+
/*#__PURE__*/
|
|
205
|
+
// Keyed by URL so each photo opens at 1×, not at the last one's zoom.
|
|
206
|
+
(0, _jsxRuntime.jsx)(_reactNative.View, {
|
|
207
|
+
style: styles.layer,
|
|
208
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_ZoomableImage.ZoomableImage, {
|
|
209
|
+
uri: uri,
|
|
210
|
+
accessibilityLabel: photo.name,
|
|
211
|
+
onLoad: () => setStatus({
|
|
212
|
+
url: uri,
|
|
213
|
+
state: 'ready'
|
|
214
|
+
}),
|
|
215
|
+
onError: () => {
|
|
216
|
+
if (!fallBack(photo)) setStatus({
|
|
217
|
+
url: uri,
|
|
218
|
+
state: 'failed'
|
|
219
|
+
});
|
|
220
|
+
},
|
|
221
|
+
onSwipe: several ? swipe : undefined
|
|
222
|
+
})
|
|
223
|
+
}, uri) : null]
|
|
224
|
+
}, `${page}:${photo.url}`);
|
|
55
225
|
})
|
|
56
|
-
}
|
|
226
|
+
}) : null, image && source && state === 'loading' && !previewed.has(source) ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
|
|
57
227
|
style: _reactNative.StyleSheet.absoluteFill,
|
|
58
|
-
|
|
59
|
-
|
|
228
|
+
pointerEvents: "none",
|
|
229
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.ActivityIndicator, {
|
|
230
|
+
style: _reactNative.StyleSheet.absoluteFill,
|
|
231
|
+
color: _theme.palette.white
|
|
232
|
+
})
|
|
233
|
+
}) : null, image && source && state === 'failed' ? /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
|
|
60
234
|
style: [_reactNative.StyleSheet.absoluteFill, styles.center, styles.failed],
|
|
235
|
+
pointerEvents: "box-none",
|
|
61
236
|
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
|
|
62
237
|
style: styles.failedText,
|
|
238
|
+
pointerEvents: "none",
|
|
63
239
|
children: labels.loadFailed
|
|
64
|
-
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Pressable, {
|
|
65
|
-
onPress: () => onOpenExternally(
|
|
240
|
+
}), (0, _safeUrl.isHttpUrl)(source) ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Pressable, {
|
|
241
|
+
onPress: () => onOpenExternally(source),
|
|
66
242
|
accessibilityRole: "button",
|
|
67
243
|
style: ({
|
|
68
244
|
pressed
|
|
@@ -71,7 +247,7 @@ function ImageViewer({
|
|
|
71
247
|
style: styles.externalLabel,
|
|
72
248
|
children: labels.openExternally
|
|
73
249
|
})
|
|
74
|
-
})]
|
|
250
|
+
}) : null]
|
|
75
251
|
}) : null, /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
|
|
76
252
|
style: [styles.header, {
|
|
77
253
|
paddingTop: insets.top + _theme.spacing.sm
|
|
@@ -81,7 +257,12 @@ function ImageViewer({
|
|
|
81
257
|
style: styles.title,
|
|
82
258
|
numberOfLines: 1,
|
|
83
259
|
children: image?.name ?? ''
|
|
84
|
-
}), /*#__PURE__*/(0, _jsxRuntime.
|
|
260
|
+
}), several ? /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.Text, {
|
|
261
|
+
style: styles.counter,
|
|
262
|
+
accessibilityElementsHidden: true,
|
|
263
|
+
importantForAccessibility: "no",
|
|
264
|
+
children: [index + 1, " / ", images.length]
|
|
265
|
+
}) : null, /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Pressable, {
|
|
85
266
|
onPress: onClose,
|
|
86
267
|
accessibilityRole: "button",
|
|
87
268
|
accessibilityLabel: labels.close,
|
|
@@ -101,7 +282,27 @@ function ImageViewer({
|
|
|
101
282
|
const styles = _reactNative.StyleSheet.create({
|
|
102
283
|
backdrop: {
|
|
103
284
|
flex: 1,
|
|
104
|
-
backgroundColor: '#000000'
|
|
285
|
+
backgroundColor: '#000000',
|
|
286
|
+
overflow: 'hidden'
|
|
287
|
+
},
|
|
288
|
+
// One screen per photo, laid out left to right in every language (see `restingAt`).
|
|
289
|
+
strip: {
|
|
290
|
+
position: 'absolute',
|
|
291
|
+
top: 0,
|
|
292
|
+
bottom: 0,
|
|
293
|
+
left: 0,
|
|
294
|
+
flexDirection: 'row',
|
|
295
|
+
direction: 'ltr'
|
|
296
|
+
},
|
|
297
|
+
page: {
|
|
298
|
+
height: '100%'
|
|
299
|
+
},
|
|
300
|
+
layer: {
|
|
301
|
+
..._reactNative.StyleSheet.absoluteFillObject
|
|
302
|
+
},
|
|
303
|
+
// Hidden, not removed: it shows again the moment its page stops being the middle one.
|
|
304
|
+
covered: {
|
|
305
|
+
opacity: 0
|
|
105
306
|
},
|
|
106
307
|
center: {
|
|
107
308
|
flexGrow: 1,
|
|
@@ -127,6 +328,11 @@ const styles = _reactNative.StyleSheet.create({
|
|
|
127
328
|
fontSize: _theme.fontSize.body,
|
|
128
329
|
fontWeight: '600'
|
|
129
330
|
},
|
|
331
|
+
counter: {
|
|
332
|
+
color: 'rgba(255,255,255,0.8)',
|
|
333
|
+
fontSize: _theme.fontSize.meta,
|
|
334
|
+
fontVariant: ['tabular-nums']
|
|
335
|
+
},
|
|
130
336
|
closeButton: {
|
|
131
337
|
width: 36,
|
|
132
338
|
height: 36,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_react","require","_reactNative","_useWidgetInsets","_theme","_icons","_ZoomableImage","_jsxRuntime","ImageViewer","image","labels","onClose","onOpenExternally","insets","useWidgetInsets","status","setStatus","useState","url","state","jsx","Modal","visible","transparent","animationType","statusBarTranslucent","onRequestClose","children","jsxs","View","style","styles","backdrop","accessibilityViewIsModal","ZoomableImage","uri","accessibilityLabel","name","onLoad","onError","ActivityIndicator","StyleSheet","absoluteFill","color","palette","white","center","failed","Text","failedText","loadFailed","Pressable","onPress","accessibilityRole","pressed","externalButton","externalLabel","openExternally","header","paddingTop","top","spacing","sm","pointerEvents","title","numberOfLines","close","hitSlop","closeButton","CloseIcon","size","create","flex","backgroundColor","flexGrow","alignItems","justifyContent","position","left","right","flexDirection","gap","md","paddingHorizontal","lg","paddingBottom","minWidth","fontSize","body","fontWeight","width","height","borderRadius","opacity","xxl","textAlign","paddingVertical","borderWidth","hairlineWidth","borderColor","meta","Platform","OS"],"sourceRoot":"../../../../src","sources":["ui/components/ImageViewer.tsx"],"mappings":";;;;;;AAMA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AAUA,IAAAE,gBAAA,GAAAF,OAAA;AACA,IAAAG,MAAA,GAAAH,OAAA;AACA,IAAAI,MAAA,GAAAJ,OAAA;AACA,IAAAK,cAAA,GAAAL,OAAA;AAAgD,IAAAM,WAAA,GAAAN,OAAA;AApBhD;AACA;AACA;AACA;AACA;;AAgCO,SAASO,WAAWA,CAAC;EAAEC,KAAK;EAAEC,MAAM;EAAEC,OAAO;EAAEC;AAAmC,CAAC,EAAE;EAC1F,MAAMC,MAAM,GAAG,IAAAC,gCAAe,EAAC,CAAC;EAChC;EACA,MAAM,CAACC,MAAM,EAAEC,SAAS,CAAC,GAAG,IAAAC,eAAQ,EAClC;IAAEC,GAAG,EAAE,IAAI;IAAEC,KAAK,EAAE;EAAU,CAChC,CAAC;EACD,MAAMA,KAAK,GAAGJ,MAAM,CAACG,GAAG,KAAKT,KAAK,EAAES,GAAG,GAAGH,MAAM,CAACI,KAAK,GAAG,SAAS;EAElE,oBACE,IAAAZ,WAAA,CAAAa,GAAA,EAAClB,YAAA,CAAAmB,KAAK;IACJC,OAAO,EAAE,CAAC,CAACb,KAAM;IACjBc,WAAW;IACXC,aAAa,EAAC,MAAM;IACpBC,oBAAoB;IACpBC,cAAc,EAAEf,OAAQ;IAAAgB,QAAA,eACxB,IAAApB,WAAA,CAAAqB,IAAA,EAAC1B,YAAA,CAAA2B,IAAI;MAACC,KAAK,EAAEC,MAAM,CAACC,QAAS;MA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I;IACvBO,SAAS,EAAE;EACb,CAAC;EACDxC,cAAc,EAAE;IACd4B,iBAAiB,EAAEtB,cAAO,CAACuB,EAAE;IAC7BY,eAAe,EAAEnC,cAAO,CAACC,EAAE;IAC3B8B,YAAY,EAAE,GAAG;IACjBK,WAAW,EAAExD,uBAAU,CAACyD,aAAa;IACrCC,WAAW,EAAE;EACf,CAAC;EACD3C,aAAa,EAAE;IACbb,KAAK,EAAEC,cAAO,CAACC,KAAK;IACpB0C,QAAQ,EAAEA,eAAQ,CAACa,IAAI;IACvBX,UAAU,EAAEY,qBAAQ,CAACC,EAAE,KAAK,KAAK,GAAG,KAAK,GAAG;EAC9C;AACF,CAAC,CAAC","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["_react","require","_reactNative","_i18n","_useReduceMotion","_useWidgetInsets","_theme","_rtl","_safeUrl","_icons","_ZoomableImage","_jsxRuntime","SWIPE_DISTANCE","SWIPE_VELOCITY","EDGE_RESISTANCE","ImageViewer","gallery","labels","onClose","onOpenExternally","insets","useWidgetInsets","reduceMotion","useReduceMotion","position","setPosition","useState","of","index","images","image","fellBack","setFellBack","Set","sourceOf","photo","fallbackUrl","has","url","source","status","setStatus","state","fallBack","current","add","previewed","setPreviewed","markPreviewed","width","setWidth","offset","Animated","Value","rtl","isRTL","restingAt","length","swiping","useRef","useLayoutEffect","setValue","step","neighbour","side","next","show","swipe","move","dx","resisted","end","vx","far","Math","abs","sign","target","toValue","animation","spring","useNativeDriver","bounciness","speed","timing","duration","start","finished","several","handleAccessibilityAction","event","nativeEvent","actionName","jsx","Modal","visible","transparent","animationType","statusBarTranslucent","onRequestClose","children","jsxs","View","style","styles","backdrop","accessibilityViewIsModal","onLayout","layout","strip","transform","translateX","reverse","map","page","indexOf","centre","uri","near","accessible","accessibilityRole","accessibilityLabel","name","accessibilityValue","text","formatLabel","total","accessibilityActions","onAccessibilityAction","large","ActivityIndicator","layer","color","palette","white","Image","covered","resizeMode","resizeMethod","onLoad","onError","importantForAccessibility","accessibilityIgnoresInvertColors","ZoomableImage","onSwipe","undefined","StyleSheet","absoluteFill","pointerEvents","center","failed","Text","failedText","loadFailed","isHttpUrl","Pressable","onPress","pressed","externalButton","externalLabel","openExternally","header","paddingTop","top","spacing","sm","title","numberOfLines","counter","accessibilityElementsHidden","close","hitSlop","closeButton","CloseIcon","size","create","flex","backgroundColor","overflow","bottom","left","flexDirection","direction","height","absoluteFillObject","opacity","flexGrow","alignItems","justifyContent","right","gap","md","paddingHorizontal","lg","paddingBottom","minWidth","fontSize","body","fontWeight","meta","fontVariant","borderRadius","xxl","textAlign","paddingVertical","borderWidth","hairlineWidth","borderColor","Platform","OS"],"sourceRoot":"../../../../src","sources":["ui/components/ImageViewer.tsx"],"mappings":";;;;;;AAOA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AAaA,IAAAE,KAAA,GAAAF,OAAA;AACA,IAAAG,gBAAA,GAAAH,OAAA;AACA,IAAAI,gBAAA,GAAAJ,OAAA;AACA,IAAAK,MAAA,GAAAL,OAAA;AACA,IAAAM,IAAA,GAAAN,OAAA;AACA,IAAAO,QAAA,GAAAP,OAAA;AACA,IAAAQ,MAAA,GAAAR,OAAA;AACA,IAAAS,cAAA,GAAAT,OAAA;AAAoE,IAAAU,WAAA,GAAAV,OAAA;AA5BpE;AACA;AACA;AACA;AACA;AACA;;AAiDA;;AAMA;AACA,MAAMW,cAAc,GAAG,IAAI;AAC3B,MAAMC,cAAc,GAAG,GAAG;AAC1B;AACA,MAAMC,eAAe,GAAG,IAAI;AAUrB,SAASC,WAAWA,CAAC;EAAEC,OAAO;EAAEC,MAAM;EAAEC,OAAO;EAAEC;AAAmC,CAAC,EAAE;EAC5F,MAAMC,MAAM,GAAG,IAAAC,gCAAe,EAAC,CAAC;EAChC,MAAMC,YAAY,GAAG,IAAAC,gCAAe,EAAC,CAAC;EACtC;EACA,MAAM,CAACC,QAAQ,EAAEC,WAAW,CAAC,GAAG,IAAAC,eAAQ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IACpB8D,QAAQ,EAAEA,eAAQ,CAACC,IAAI;IACvBM,SAAS,EAAE;EACb,CAAC;EACD7C,cAAc,EAAE;IACdkC,iBAAiB,EAAE5B,cAAO,CAAC6B,EAAE;IAC7BW,eAAe,EAAExC,cAAO,CAACC,EAAE;IAC3BoC,YAAY,EAAE,GAAG;IACjBI,WAAW,EAAE3D,uBAAU,CAAC4D,aAAa;IACrCC,WAAW,EAAE;EACf,CAAC;EACDhD,aAAa,EAAE;IACb3B,KAAK,EAAEC,cAAO,CAACC,KAAK;IACpB8D,QAAQ,EAAEA,eAAQ,CAACG,IAAI;IACvBD,UAAU,EAAEU,qBAAQ,CAACC,EAAE,KAAK,KAAK,GAAG,KAAK,GAAG;EAC9C;AACF,CAAC,CAAC","ignoreList":[]}
|
|
@@ -9,6 +9,7 @@ exports.isBadRating = void 0;
|
|
|
9
9
|
exports.reasonLabel = reasonLabel;
|
|
10
10
|
var _react = require("react");
|
|
11
11
|
var _reactNative = require("react-native");
|
|
12
|
+
var _useRetainedState = require("../hooks/use-retained-state.js");
|
|
12
13
|
var _theme = require("../styles/theme.js");
|
|
13
14
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
14
15
|
/**
|
|
@@ -84,12 +85,14 @@ function RatingCard({
|
|
|
84
85
|
const [rating, setRating] = (0, _react.useState)(initialRating);
|
|
85
86
|
const [reason, setReason] = (0, _react.useState)(initialReason);
|
|
86
87
|
const [comment, setComment] = (0, _react.useState)(initialComment);
|
|
87
|
-
|
|
88
|
+
// Kept while the thread unmounts the card far off screen; the rating
|
|
89
|
+
// itself is saved on the message.
|
|
90
|
+
const [draft, setDraft] = (0, _useRetainedState.useRetainedState)(`${ratingId}:draft`, '');
|
|
88
91
|
// The comment is optional: "Done" with nothing typed just closes the box —
|
|
89
92
|
// the face (and reason) are already saved. A card that opens with a saved
|
|
90
93
|
// rating starts closed too, so "Done" sticks when the thread is reopened;
|
|
91
94
|
// tapping the chosen face opens the box again.
|
|
92
|
-
const [finished, setFinished] = (0,
|
|
95
|
+
const [finished, setFinished] = (0, _useRetainedState.useRetainedState)(`${ratingId}:finished`, initialRating != null);
|
|
93
96
|
const [pending, setPending] = (0, _react.useState)(false);
|
|
94
97
|
const [closedReason, setClosedReason] = (0, _react.useState)(initialComment ? 'locked' : null);
|
|
95
98
|
const [failed, setFailed] = (0, _react.useState)(false);
|