stream-chat-react-native-core 5.1.0 → 5.2.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/lib/commonjs/components/ChannelList/ChannelListMessenger.js +32 -15
- package/lib/commonjs/components/ChannelList/ChannelListMessenger.js.map +1 -1
- package/lib/commonjs/components/Chat/Chat.js +17 -5
- package/lib/commonjs/components/Chat/Chat.js.map +1 -1
- package/lib/commonjs/components/ImageGallery/ImageGallery.js +106 -100
- package/lib/commonjs/components/ImageGallery/ImageGallery.js.map +1 -1
- package/lib/commonjs/components/ImageGallery/components/AnimatedGalleryVideo.js +14 -16
- package/lib/commonjs/components/ImageGallery/components/AnimatedGalleryVideo.js.map +1 -1
- package/lib/commonjs/components/ImageGallery/components/ImageGalleryFooter.js +13 -16
- package/lib/commonjs/components/ImageGallery/components/ImageGalleryFooter.js.map +1 -1
- package/lib/commonjs/components/ImageGallery/components/ImageGalleryVideoControl.js +6 -6
- package/lib/commonjs/components/ImageGallery/components/ImageGalleryVideoControl.js.map +1 -1
- package/lib/commonjs/components/MessageList/MessageList.js +39 -26
- package/lib/commonjs/components/MessageList/MessageList.js.map +1 -1
- package/lib/commonjs/components/MessageOverlay/OverlayReactions.js +19 -19
- package/lib/commonjs/components/MessageOverlay/OverlayReactions.js.map +1 -1
- package/lib/commonjs/components/ProgressControl/ProgressControl.js +6 -6
- package/lib/commonjs/components/ProgressControl/ProgressControl.js.map +1 -1
- package/lib/commonjs/contexts/debugContext/DebugContext.js +63 -0
- package/lib/commonjs/contexts/debugContext/DebugContext.js.map +1 -0
- package/lib/commonjs/contexts/index.js +13 -0
- package/lib/commonjs/contexts/index.js.map +1 -1
- package/lib/commonjs/native.js.map +1 -1
- package/lib/commonjs/version.json +1 -1
- package/lib/module/components/ChannelList/ChannelListMessenger.js +32 -15
- package/lib/module/components/ChannelList/ChannelListMessenger.js.map +1 -1
- package/lib/module/components/Chat/Chat.js +17 -5
- package/lib/module/components/Chat/Chat.js.map +1 -1
- package/lib/module/components/ImageGallery/ImageGallery.js +106 -100
- package/lib/module/components/ImageGallery/ImageGallery.js.map +1 -1
- package/lib/module/components/ImageGallery/components/AnimatedGalleryVideo.js +14 -16
- package/lib/module/components/ImageGallery/components/AnimatedGalleryVideo.js.map +1 -1
- package/lib/module/components/ImageGallery/components/ImageGalleryFooter.js +13 -16
- package/lib/module/components/ImageGallery/components/ImageGalleryFooter.js.map +1 -1
- package/lib/module/components/ImageGallery/components/ImageGalleryVideoControl.js +6 -6
- package/lib/module/components/ImageGallery/components/ImageGalleryVideoControl.js.map +1 -1
- package/lib/module/components/MessageList/MessageList.js +39 -26
- package/lib/module/components/MessageList/MessageList.js.map +1 -1
- package/lib/module/components/MessageOverlay/OverlayReactions.js +19 -19
- package/lib/module/components/MessageOverlay/OverlayReactions.js.map +1 -1
- package/lib/module/components/ProgressControl/ProgressControl.js +6 -6
- package/lib/module/components/ProgressControl/ProgressControl.js.map +1 -1
- package/lib/module/contexts/debugContext/DebugContext.js +63 -0
- package/lib/module/contexts/debugContext/DebugContext.js.map +1 -0
- package/lib/module/contexts/index.js +13 -0
- package/lib/module/contexts/index.js.map +1 -1
- package/lib/module/native.js.map +1 -1
- package/lib/module/version.json +1 -1
- package/lib/typescript/components/ImageGallery/ImageGallery.d.ts +3 -0
- package/lib/typescript/components/ImageGallery/components/AnimatedGalleryVideo.d.ts +5 -3
- package/lib/typescript/components/ImageGallery/components/ImageGalleryFooter.d.ts +1 -3
- package/lib/typescript/components/MessageOverlay/OverlayReactions.d.ts +1 -0
- package/lib/typescript/components/ProgressControl/ProgressControl.d.ts +1 -1
- package/lib/typescript/contexts/debugContext/DebugContext.d.ts +27 -0
- package/lib/typescript/contexts/index.d.ts +1 -0
- package/lib/typescript/native.d.ts +3 -2
- package/package.json +2 -2
- package/src/components/ChannelList/ChannelListMessenger.tsx +17 -0
- package/src/components/Chat/Chat.tsx +13 -0
- package/src/components/ImageGallery/ImageGallery.tsx +87 -65
- package/src/components/ImageGallery/__tests__/AnimatedVideoGallery.test.tsx +2 -2
- package/src/components/ImageGallery/__tests__/ImageGallery.test.tsx +40 -28
- package/src/components/ImageGallery/components/AnimatedGalleryVideo.tsx +16 -9
- package/src/components/ImageGallery/components/ImageGalleryFooter.tsx +1 -6
- package/src/components/ImageGallery/components/ImageGalleryVideoControl.tsx +5 -6
- package/src/components/MessageList/MessageList.tsx +15 -0
- package/src/components/MessageOverlay/OverlayReactions.tsx +1 -0
- package/src/components/ProgressControl/ProgressControl.tsx +8 -4
- package/src/contexts/debugContext/DebugContext.tsx +77 -0
- package/src/contexts/index.ts +1 -0
- package/src/native.ts +3 -2
- package/src/version.json +1 -1
|
@@ -33,6 +33,8 @@ var _ChannelsStateContext = require("../../contexts/channelsStateContext/Channel
|
|
|
33
33
|
|
|
34
34
|
var _ChatContext = require("../../contexts/chatContext/ChatContext");
|
|
35
35
|
|
|
36
|
+
var _DebugContext = require("../../contexts/debugContext/DebugContext");
|
|
37
|
+
|
|
36
38
|
var _OverlayContext = require("../../contexts/overlayContext/OverlayContext");
|
|
37
39
|
|
|
38
40
|
var _ThemeContext = require("../../contexts/themeContext/ThemeContext");
|
|
@@ -97,12 +99,22 @@ var ChatWithContext = function ChatWithContext(props) {
|
|
|
97
99
|
isOnline = _useIsOnline.isOnline;
|
|
98
100
|
|
|
99
101
|
var mutedUsers = (0, _useMutedUsers.useMutedUsers)(client);
|
|
102
|
+
var debugRef = (0, _DebugContext.useDebugContext)();
|
|
103
|
+
var isDebugModeEnabled = __DEV__ && debugRef && debugRef.current;
|
|
100
104
|
(0, _react.useEffect)(function () {
|
|
101
105
|
if (client) {
|
|
102
106
|
client.setUserAgent(_native.SDK + "-" + _reactNative.Platform.OS + "-" + _version.version);
|
|
103
107
|
client.recoverStateOnReconnect = false;
|
|
104
108
|
client.persistUserOnConnectionFailure = enableOfflineSupport;
|
|
105
109
|
}
|
|
110
|
+
|
|
111
|
+
if (isDebugModeEnabled) {
|
|
112
|
+
if (debugRef.current.setEventType) debugRef.current.setEventType('send');
|
|
113
|
+
if (debugRef.current.setSendEventParams) debugRef.current.setSendEventParams({
|
|
114
|
+
action: 'Client',
|
|
115
|
+
data: client.user
|
|
116
|
+
});
|
|
117
|
+
}
|
|
106
118
|
}, [client]);
|
|
107
119
|
|
|
108
120
|
var setActiveChannel = function setActiveChannel(newChannel) {
|
|
@@ -143,7 +155,7 @@ var ChatWithContext = function ChatWithContext(props) {
|
|
|
143
155
|
__self: _this,
|
|
144
156
|
__source: {
|
|
145
157
|
fileName: _jsxFileName,
|
|
146
|
-
lineNumber:
|
|
158
|
+
lineNumber: 229,
|
|
147
159
|
columnNumber: 5
|
|
148
160
|
}
|
|
149
161
|
}, _react["default"].createElement(_TranslationContext.TranslationProvider, {
|
|
@@ -153,7 +165,7 @@ var ChatWithContext = function ChatWithContext(props) {
|
|
|
153
165
|
__self: _this,
|
|
154
166
|
__source: {
|
|
155
167
|
fileName: _jsxFileName,
|
|
156
|
-
lineNumber:
|
|
168
|
+
lineNumber: 230,
|
|
157
169
|
columnNumber: 7
|
|
158
170
|
}
|
|
159
171
|
}, _react["default"].createElement(_ThemeContext.ThemeProvider, {
|
|
@@ -161,14 +173,14 @@ var ChatWithContext = function ChatWithContext(props) {
|
|
|
161
173
|
__self: _this,
|
|
162
174
|
__source: {
|
|
163
175
|
fileName: _jsxFileName,
|
|
164
|
-
lineNumber:
|
|
176
|
+
lineNumber: 233,
|
|
165
177
|
columnNumber: 9
|
|
166
178
|
}
|
|
167
179
|
}, _react["default"].createElement(_ChannelsStateContext.ChannelsStateProvider, {
|
|
168
180
|
__self: _this,
|
|
169
181
|
__source: {
|
|
170
182
|
fileName: _jsxFileName,
|
|
171
|
-
lineNumber:
|
|
183
|
+
lineNumber: 234,
|
|
172
184
|
columnNumber: 11
|
|
173
185
|
}
|
|
174
186
|
}, children))));
|
|
@@ -184,7 +196,7 @@ var Chat = function Chat(props) {
|
|
|
184
196
|
__self: _this,
|
|
185
197
|
__source: {
|
|
186
198
|
fileName: _jsxFileName,
|
|
187
|
-
lineNumber:
|
|
199
|
+
lineNumber: 269,
|
|
188
200
|
columnNumber: 10
|
|
189
201
|
}
|
|
190
202
|
}));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["Chat.tsx"],"names":["ChatWithContext","props","children","client","closeConnectionOnBackground","enableOfflineSupport","i18nInstance","style","channel","setChannel","t","key","tDateTimeParser","input","translators","setTranslators","loadingTranslators","connectionRecovering","isOnline","mutedUsers","setUserAgent","SDK","Platform","OS","version","recoverStateOnReconnect","persistUserOnConnectionFailure","setActiveChannel","newChannel","appSettings","subscribeConnectionRecoveredCallback","chatContext","QuickSqliteClient","initializeDatabase","userLanguage","user","language","DEFAULT_USER_LANGUAGE","Chat"],"mappings":";;;;;;;;;;;;;AAAA;;AACA;;AAEA;;AAIA;;AACA;;AACA;;AACA;;AACA;;AAEA;;AAEA;;AACA;;AACA;;AACA;;AAEA;;AAKA;;AACA;;AAEA;;AACA;;AAGA;;;;;;;;;AAEA;;AAmGA,IAAMA,eAAe,GAAG,SAAlBA,eAAkB,CAGtBC,KAHsB,EAInB;AAAA;;AACH,MACEC,QADF,GAOID,KAPJ,CACEC,QADF;AAAA,MAEEC,MAFF,GAOIF,KAPJ,CAEEE,MAFF;AAAA,8BAOIF,KAPJ,CAGEG,2BAHF;AAAA,MAGEA,2BAHF,sCAGgC,IAHhC;AAAA,8BAOIH,KAPJ,CAIEI,oBAJF;AAAA,MAIEA,oBAJF,sCAIyB,KAJzB;AAAA,MAKEC,YALF,GAOIL,KAPJ,CAKEK,YALF;AAAA,MAMEC,KANF,GAOIN,KAPJ,CAMEM,KANF;;AASA,kBAA8B,sBAA9B;AAAA;AAAA,MAAOC,OAAP;AAAA,MAAgBC,UAAhB;;AACA,mBAAsC,qBAA8B;AAClEC,IAAAA,CAAC,EAAE,WAACC,GAAD;AAAA,aAAiBA,GAAjB;AAAA,KAD+D;AAElEC,IAAAA,eAAe,EAAE,yBAACC,KAA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vCa,IAAAA,QAAQ,EAARA,QANuC;AAOvCC,IAAAA,UAAU,EAAVA,UAPuC;AAQvCQ,IAAAA,gBAAgB,EAAhBA,gBARuC;AASvCG,IAAAA,oCAAoC,EAApCA;AATuC,GAArB,CAApB;AAYA,wBAAU,YAAM;AACd,QAAIzB,oBAAJ,EAA0B;AACxB2B,2CAAkBC,kBAAlB;AACD;AACF,GAJD,EAIG,EAJH;AAMA,wCAAgB;AACd9B,IAAAA,MAAM,EAANA,MADc;AAEdE,IAAAA,oBAAoB,EAApBA;AAFc,GAAhB;AAKA,MAAIW,kBAAJ,EAAwB,OAAO,IAAP;AAExB,SACE,gCAAC,yBAAD;AAAkC,IAAA,KAAK,EAAEe,WAAzC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,KACE,gCAAC,uCAAD;AACE,IAAA,KAAK,gCAAOjB,WAAP;AAAoBoB,MAAAA,YAAY,EAAE,iBAAA/B,MAAM,CAACgC,IAAP,kCAAaC,QAAb,KAAyBC;AAA3D,MADP;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,KAGE,gCAAC,2BAAD;AAAe,IAAA,KAAK,EAAE9B,KAAtB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,KACE,gCAAC,2CAAD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,KAA4CL,QAA5C,CADF,CAHF,CADF,CADF;AAWD,CA5FD;;AAmHO,IAAMoC,IAAI,GAAG,SAAPA,IAAO,CAGlBrC,KAHkB,EAIf;AACH,2BAAkB,wCAAlB;AAAA,MAAQM,KAAR,sBAAQA,KAAR;;AAEA,SAAO,gCAAC,eAAD;AAAuBA,IAAAA,KAAK,EAALA;AAAvB,KAAoCN,KAApC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,KAAP;AACD,CARM","sourcesContent":["import React, { PropsWithChildren, useEffect, useState } from 'react';\nimport { Platform } from 'react-native';\n\nimport Dayjs from 'dayjs';\n\nimport type { Channel } from 'stream-chat';\n\nimport { useAppSettings } from './hooks/useAppSettings';\nimport { useConnectionRecovered } from './hooks/useConnectionRecovered';\nimport { useCreateChatContext } from './hooks/useCreateChatContext';\nimport { useIsOnline } from './hooks/useIsOnline';\nimport { useMutedUsers } from './hooks/useMutedUsers';\n\nimport { useSyncDatabase } from './hooks/useSyncDatabase';\n\nimport { ChannelsStateProvider } from '../../contexts/channelsStateContext/ChannelsStateContext';\nimport { ChatContextValue, ChatProvider } from '../../contexts/chatContext/ChatContext';\nimport { useOverlayContext } from '../../contexts/overlayContext/OverlayContext';\nimport { DeepPartial, ThemeProvider } from '../../contexts/themeContext/ThemeContext';\nimport type { Theme } from '../../contexts/themeContext/utils/theme';\nimport {\n DEFAULT_USER_LANGUAGE,\n TranslationProvider,\n TranslatorFunctions,\n} from '../../contexts/translationContext/TranslationContext';\nimport { useStreami18n } from '../../hooks/useStreami18n';\nimport init from '../../init';\n\nimport { SDK } from '../../native';\nimport { QuickSqliteClient } from '../../store/QuickSqliteClient';\nimport type { DefaultStreamChatGenerics } from '../../types/types';\nimport type { Streami18n } from '../../utils/Streami18n';\nimport { version } from '../../version.json';\n\ninit();\n\nexport type ChatProps<\n StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,\n> = Pick<ChatContextValue<StreamChatGenerics>, 'client'> & {\n /**\n * When false, ws connection won't be disconnection upon backgrounding the app.\n * To receive push notifications, its necessary that user doesn't have active\n * websocket connection. So by default, we disconnect websocket connection when\n * app goes to background, and reconnect when app comes to foreground.\n */\n closeConnectionOnBackground?: boolean;\n /**\n * Enables offline storage and loading for chat data.\n */\n enableOfflineSupport?: boolean;\n /**\n * Instance of Streami18n class should be provided to Chat component to enable internationalization.\n *\n * Stream provides following list of in-built translations:\n * 1. English (en)\n * 2. Dutch (nl)\n * 3. ...\n * 4. ...\n *\n * Simplest way to start using chat components in one of the in-built languages would be following:\n *\n * ```\n * const i18n = new Streami18n('nl');\n * <Chat client={chatClient} i18nInstance={i18n}>\n * ...\n * </Chat>\n * ```\n *\n * If you would like to override certain keys in in-built translation.\n * UI will be automatically updated in this case.\n *\n * ```\n * const i18n = new Streami18n('nl');\n *\n * i18n.registerTranslation('nl', {\n * 'Nothing yet...': 'Nog Niet ...',\n * '{{ firstUser }} and {{ secondUser }} are typing...': '{{ firstUser }} en {{ secondUser }} zijn aan het typen...',\n * });\n *\n * <Chat client={chatClient} i18nInstance={i18n}>\n * ...\n * </Chat>\n * ```\n *\n * You can use the same function to add whole new language.\n *\n * ```\n * const i18n = new Streami18n('it');\n *\n * i18n.registerTranslation('it', {\n * 'Nothing yet...': 'Non ancora ...',\n * '{{ firstUser }} and {{ secondUser }} are typing...': '{{ firstUser }} a {{ secondUser }} stanno scrivendo...',\n * });\n *\n * // Make sure to call setLanguage to reflect new language in UI.\n * i18n.setLanguage('it');\n * <Chat client={chatClient} i18nInstance={i18n}>\n * ...\n * </Chat>\n * ```\n */\n i18nInstance?: Streami18n;\n /**\n * You can pass the theme object to customize the styles of Chat components. You can check the default theme in [theme.ts](https://github.com/GetStream/stream-chat-react-native/blob/main/package/src/contexts/themeContext/utils/theme.ts)\n *\n * Please check section about [themes in cookbook](https://github.com/GetStream/stream-chat-react-native/wiki/Cookbook-v3.0#theme) for details.\n *\n * ```\n * import type { DeepPartial, Theme } from 'stream-chat-react-native';\n *\n * const theme: DeepPartial<Theme> = {\n * messageSimple: {\n * file: {\n * container: {\n * backgroundColor: 'red',\n * },\n * icon: {\n * height: 16,\n * width: 16,\n * },\n * },\n * },\n * };\n *\n * <Chat style={theme}>\n * </Chat>\n * ```\n *\n * @overrideType object\n */\n style?: DeepPartial<Theme>;\n};\n\nconst ChatWithContext = <\n StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,\n>(\n props: PropsWithChildren<ChatProps<StreamChatGenerics>>,\n) => {\n const {\n children,\n client,\n closeConnectionOnBackground = true,\n enableOfflineSupport = false,\n i18nInstance,\n style,\n } = props;\n\n const [channel, setChannel] = useState<Channel<StreamChatGenerics>>();\n const [translators, setTranslators] = useState<TranslatorFunctions>({\n t: (key: string) => key,\n tDateTimeParser: (input?: string | number | Date) => Dayjs(input),\n });\n\n /**\n * Setup translators\n */\n const loadingTranslators = useStreami18n({ i18nInstance, setTranslators });\n\n /**\n * Setup connection event listeners\n */\n const { connectionRecovering, isOnline } = useIsOnline<StreamChatGenerics>(\n client,\n closeConnectionOnBackground,\n );\n\n /**\n * Setup muted user listener\n * TODO: reimplement\n */\n const mutedUsers = useMutedUsers<StreamChatGenerics>(client);\n\n useEffect(() => {\n if (client) {\n client.setUserAgent(`${SDK}-${Platform.OS}-${version}`);\n // This is to disable recovery related logic in js client, since we handle it in this SDK\n client.recoverStateOnReconnect = false;\n client.persistUserOnConnectionFailure = enableOfflineSupport;\n }\n }, [client]);\n\n const setActiveChannel = (newChannel?: Channel<StreamChatGenerics>) => setChannel(newChannel);\n\n const appSettings = useAppSettings(client, isOnline);\n const { subscribeConnectionRecoveredCallback } = useConnectionRecovered<StreamChatGenerics>({\n client,\n enableOfflineSupport,\n });\n\n const chatContext = useCreateChatContext({\n appSettings,\n channel,\n client,\n connectionRecovering,\n enableOfflineSupport,\n isOnline,\n mutedUsers,\n setActiveChannel,\n subscribeConnectionRecoveredCallback,\n });\n\n useEffect(() => {\n if (enableOfflineSupport) {\n QuickSqliteClient.initializeDatabase();\n }\n }, []);\n\n useSyncDatabase({\n client,\n enableOfflineSupport,\n });\n\n if (loadingTranslators) return null;\n\n return (\n <ChatProvider<StreamChatGenerics> value={chatContext}>\n <TranslationProvider\n value={{ ...translators, userLanguage: client.user?.language || DEFAULT_USER_LANGUAGE }}\n >\n <ThemeProvider style={style}>\n <ChannelsStateProvider<StreamChatGenerics>>{children}</ChannelsStateProvider>\n </ThemeProvider>\n </TranslationProvider>\n </ChatProvider>\n );\n};\n\n/**\n * Chat - Wrapper component for Chat. The needs to be placed around any other chat components.\n * This Chat component provides the ChatContext to all other components.\n *\n * The ChatContext provides the following props:\n *\n * - channel - currently active channel\n * - client - client connection\n * - connectionRecovering - whether or not websocket is reconnecting\n * - isOnline - whether or not set user is active\n * - setActiveChannel - function to set the currently active channel\n *\n * The Chat Component takes the following generics in order:\n * - At (AttachmentType) - custom Attachment object extension\n * - Ct (ChannelType) - custom Channel object extension\n * - Co (CommandType) - custom Command string union extension\n * - Ev (EventType) - custom Event object extension\n * - Me (MessageType) - custom Message object extension\n * - Re (ReactionType) - custom Reaction object extension\n * - Us (UserType) - custom User object extension\n */\nexport const Chat = <\n StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,\n>(\n props: PropsWithChildren<ChatProps<StreamChatGenerics>>,\n) => {\n const { style } = useOverlayContext();\n\n return <ChatWithContext {...{ style }} {...props} />;\n};\n"]}
|
|
1
|
+
{"version":3,"sources":["Chat.tsx"],"names":["ChatWithContext","props","children","client","closeConnectionOnBackground","enableOfflineSupport","i18nInstance","style","channel","setChannel","t","key","tDateTimeParser","input","translators","setTranslators","loadingTranslators","connectionRecovering","isOnline","mutedUsers","debugRef","isDebugModeEnabled","__DEV__","current","setUserAgent","SDK","Platform","OS","version","recoverStateOnReconnect","persistUserOnConnectionFailure","setEventType","setSendEventParams","action","data","user","setActiveChannel","newChannel","appSettings","subscribeConnectionRecoveredCallback","chatContext","QuickSqliteClient","initializeDatabase","userLanguage","language","DEFAULT_USER_LANGUAGE","Chat"],"mappings":";;;;;;;;;;;;;AAAA;;AACA;;AAEA;;AAIA;;AACA;;AACA;;AACA;;AACA;;AAEA;;AAEA;;AACA;;AACA;;AACA;;AACA;;AAEA;;AAKA;;AACA;;AAEA;;AACA;;AAGA;;;;;;;;;AAEA;;AAmGA,IAAMA,eAAe,GAAG,SAAlBA,eAAkB,CAGtBC,KAHsB,EAInB;AAAA;;AACH,MACEC,QADF,GAOID,KAPJ,CACEC,QADF;AAAA,MAEEC,MAFF,GAOIF,KAPJ,CAEEE,MAFF;AAAA,8BAOIF,KAPJ,CAGEG,2BAHF;AAAA,MAGEA,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ExB,SACE,gCAAC,yBAAD;AAAkC,IAAA,KAAK,EAAEwB,WAAzC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,KACE,gCAAC,uCAAD;AACE,IAAA,KAAK,gCAAO1B,WAAP;AAAoB6B,MAAAA,YAAY,EAAE,iBAAAxC,MAAM,CAACgC,IAAP,kCAAaS,QAAb,KAAyBC;AAA3D,MADP;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,KAGE,gCAAC,2BAAD;AAAe,IAAA,KAAK,EAAEtC,KAAtB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,KACE,gCAAC,2CAAD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,KAA4CL,QAA5C,CADF,CAHF,CADF,CADF;AAWD,CAxGD;;AA+HO,IAAM4C,IAAI,GAAG,SAAPA,IAAO,CAGlB7C,KAHkB,EAIf;AACH,2BAAkB,wCAAlB;AAAA,MAAQM,KAAR,sBAAQA,KAAR;;AAEA,SAAO,gCAAC,eAAD;AAAuBA,IAAAA,KAAK,EAALA;AAAvB,KAAoCN,KAApC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,KAAP;AACD,CARM","sourcesContent":["import React, { PropsWithChildren, useEffect, useState } from 'react';\nimport { Platform } from 'react-native';\n\nimport Dayjs from 'dayjs';\n\nimport type { Channel } from 'stream-chat';\n\nimport { useAppSettings } from './hooks/useAppSettings';\nimport { useConnectionRecovered } from './hooks/useConnectionRecovered';\nimport { useCreateChatContext } from './hooks/useCreateChatContext';\nimport { useIsOnline } from './hooks/useIsOnline';\nimport { useMutedUsers } from './hooks/useMutedUsers';\n\nimport { useSyncDatabase } from './hooks/useSyncDatabase';\n\nimport { ChannelsStateProvider } from '../../contexts/channelsStateContext/ChannelsStateContext';\nimport { ChatContextValue, ChatProvider } from '../../contexts/chatContext/ChatContext';\nimport { useDebugContext } from '../../contexts/debugContext/DebugContext';\nimport { useOverlayContext } from '../../contexts/overlayContext/OverlayContext';\nimport { DeepPartial, ThemeProvider } from '../../contexts/themeContext/ThemeContext';\nimport type { Theme } from '../../contexts/themeContext/utils/theme';\nimport {\n DEFAULT_USER_LANGUAGE,\n TranslationProvider,\n TranslatorFunctions,\n} from '../../contexts/translationContext/TranslationContext';\nimport { useStreami18n } from '../../hooks/useStreami18n';\nimport init from '../../init';\n\nimport { SDK } from '../../native';\nimport { QuickSqliteClient } from '../../store/QuickSqliteClient';\nimport type { DefaultStreamChatGenerics } from '../../types/types';\nimport type { Streami18n } from '../../utils/Streami18n';\nimport { version } from '../../version.json';\n\ninit();\n\nexport type ChatProps<\n StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,\n> = Pick<ChatContextValue<StreamChatGenerics>, 'client'> & {\n /**\n * When false, ws connection won't be disconnection upon backgrounding the app.\n * To receive push notifications, its necessary that user doesn't have active\n * websocket connection. So by default, we disconnect websocket connection when\n * app goes to background, and reconnect when app comes to foreground.\n */\n closeConnectionOnBackground?: boolean;\n /**\n * Enables offline storage and loading for chat data.\n */\n enableOfflineSupport?: boolean;\n /**\n * Instance of Streami18n class should be provided to Chat component to enable internationalization.\n *\n * Stream provides following list of in-built translations:\n * 1. English (en)\n * 2. Dutch (nl)\n * 3. ...\n * 4. ...\n *\n * Simplest way to start using chat components in one of the in-built languages would be following:\n *\n * ```\n * const i18n = new Streami18n('nl');\n * <Chat client={chatClient} i18nInstance={i18n}>\n * ...\n * </Chat>\n * ```\n *\n * If you would like to override certain keys in in-built translation.\n * UI will be automatically updated in this case.\n *\n * ```\n * const i18n = new Streami18n('nl');\n *\n * i18n.registerTranslation('nl', {\n * 'Nothing yet...': 'Nog Niet ...',\n * '{{ firstUser }} and {{ secondUser }} are typing...': '{{ firstUser }} en {{ secondUser }} zijn aan het typen...',\n * });\n *\n * <Chat client={chatClient} i18nInstance={i18n}>\n * ...\n * </Chat>\n * ```\n *\n * You can use the same function to add whole new language.\n *\n * ```\n * const i18n = new Streami18n('it');\n *\n * i18n.registerTranslation('it', {\n * 'Nothing yet...': 'Non ancora ...',\n * '{{ firstUser }} and {{ secondUser }} are typing...': '{{ firstUser }} a {{ secondUser }} stanno scrivendo...',\n * });\n *\n * // Make sure to call setLanguage to reflect new language in UI.\n * i18n.setLanguage('it');\n * <Chat client={chatClient} i18nInstance={i18n}>\n * ...\n * </Chat>\n * ```\n */\n i18nInstance?: Streami18n;\n /**\n * You can pass the theme object to customize the styles of Chat components. You can check the default theme in [theme.ts](https://github.com/GetStream/stream-chat-react-native/blob/main/package/src/contexts/themeContext/utils/theme.ts)\n *\n * Please check section about [themes in cookbook](https://github.com/GetStream/stream-chat-react-native/wiki/Cookbook-v3.0#theme) for details.\n *\n * ```\n * import type { DeepPartial, Theme } from 'stream-chat-react-native';\n *\n * const theme: DeepPartial<Theme> = {\n * messageSimple: {\n * file: {\n * container: {\n * backgroundColor: 'red',\n * },\n * icon: {\n * height: 16,\n * width: 16,\n * },\n * },\n * },\n * };\n *\n * <Chat style={theme}>\n * </Chat>\n * ```\n *\n * @overrideType object\n */\n style?: DeepPartial<Theme>;\n};\n\nconst ChatWithContext = <\n StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,\n>(\n props: PropsWithChildren<ChatProps<StreamChatGenerics>>,\n) => {\n const {\n children,\n client,\n closeConnectionOnBackground = true,\n enableOfflineSupport = false,\n i18nInstance,\n style,\n } = props;\n\n const [channel, setChannel] = useState<Channel<StreamChatGenerics>>();\n const [translators, setTranslators] = useState<TranslatorFunctions>({\n t: (key: string) => key,\n tDateTimeParser: (input?: string | number | Date) => Dayjs(input),\n });\n\n /**\n * Setup translators\n */\n const loadingTranslators = useStreami18n({ i18nInstance, setTranslators });\n\n /**\n * Setup connection event listeners\n */\n const { connectionRecovering, isOnline } = useIsOnline<StreamChatGenerics>(\n client,\n closeConnectionOnBackground,\n );\n\n /**\n * Setup muted user listener\n * TODO: reimplement\n */\n const mutedUsers = useMutedUsers<StreamChatGenerics>(client);\n\n const debugRef = useDebugContext();\n const isDebugModeEnabled = __DEV__ && debugRef && debugRef.current;\n\n useEffect(() => {\n if (client) {\n client.setUserAgent(`${SDK}-${Platform.OS}-${version}`);\n // This is to disable recovery related logic in js client, since we handle it in this SDK\n client.recoverStateOnReconnect = false;\n client.persistUserOnConnectionFailure = enableOfflineSupport;\n }\n\n if (isDebugModeEnabled) {\n if (debugRef.current.setEventType) debugRef.current.setEventType('send');\n if (debugRef.current.setSendEventParams)\n debugRef.current.setSendEventParams({\n action: 'Client',\n data: client.user,\n });\n }\n }, [client]);\n\n const setActiveChannel = (newChannel?: Channel<StreamChatGenerics>) => setChannel(newChannel);\n\n const appSettings = useAppSettings(client, isOnline);\n const { subscribeConnectionRecoveredCallback } = useConnectionRecovered<StreamChatGenerics>({\n client,\n enableOfflineSupport,\n });\n\n const chatContext = useCreateChatContext({\n appSettings,\n channel,\n client,\n connectionRecovering,\n enableOfflineSupport,\n isOnline,\n mutedUsers,\n setActiveChannel,\n subscribeConnectionRecoveredCallback,\n });\n\n useEffect(() => {\n if (enableOfflineSupport) {\n QuickSqliteClient.initializeDatabase();\n }\n }, []);\n\n useSyncDatabase({\n client,\n enableOfflineSupport,\n });\n\n if (loadingTranslators) return null;\n\n return (\n <ChatProvider<StreamChatGenerics> value={chatContext}>\n <TranslationProvider\n value={{ ...translators, userLanguage: client.user?.language || DEFAULT_USER_LANGUAGE }}\n >\n <ThemeProvider style={style}>\n <ChannelsStateProvider<StreamChatGenerics>>{children}</ChannelsStateProvider>\n </ThemeProvider>\n </TranslationProvider>\n </ChatProvider>\n );\n};\n\n/**\n * Chat - Wrapper component for Chat. The needs to be placed around any other chat components.\n * This Chat component provides the ChatContext to all other components.\n *\n * The ChatContext provides the following props:\n *\n * - channel - currently active channel\n * - client - client connection\n * - connectionRecovering - whether or not websocket is reconnecting\n * - isOnline - whether or not set user is active\n * - setActiveChannel - function to set the currently active channel\n *\n * The Chat Component takes the following generics in order:\n * - At (AttachmentType) - custom Attachment object extension\n * - Ct (ChannelType) - custom Channel object extension\n * - Co (CommandType) - custom Command string union extension\n * - Ev (EventType) - custom Event object extension\n * - Me (MessageType) - custom Message object extension\n * - Re (ReactionType) - custom Reaction object extension\n * - Us (UserType) - custom User object extension\n */\nexport const Chat = <\n StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,\n>(\n props: PropsWithChildren<ChatProps<StreamChatGenerics>>,\n) => {\n const { style } = useOverlayContext();\n\n return <ChatWithContext {...{ style }} {...props} />;\n};\n"]}
|
|
@@ -88,7 +88,7 @@ exports.IsSwiping = IsSwiping;
|
|
|
88
88
|
})(IsSwiping || (exports.IsSwiping = IsSwiping = {}));
|
|
89
89
|
|
|
90
90
|
var ImageGallery = function ImageGallery(props) {
|
|
91
|
-
var _StatusBar$currentHei,
|
|
91
|
+
var _StatusBar$currentHei, _imageGalleryAttachme;
|
|
92
92
|
|
|
93
93
|
var _props$giphyVersion = props.giphyVersion,
|
|
94
94
|
giphyVersion = _props$giphyVersion === void 0 ? 'fixed_height' : _props$giphyVersion,
|
|
@@ -98,20 +98,10 @@ var ImageGallery = function ImageGallery(props) {
|
|
|
98
98
|
numberOfImageGalleryGridColumns = props.numberOfImageGalleryGridColumns,
|
|
99
99
|
overlayOpacity = props.overlayOpacity;
|
|
100
100
|
|
|
101
|
-
var _useState = (0, _react.useState)(
|
|
101
|
+
var _useState = (0, _react.useState)([]),
|
|
102
102
|
_useState2 = (0, _slicedToArray2["default"])(_useState, 2),
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
var _useState3 = (0, _react.useState)(0),
|
|
107
|
-
_useState4 = (0, _slicedToArray2["default"])(_useState3, 2),
|
|
108
|
-
progress = _useState4[0],
|
|
109
|
-
setProgress = _useState4[1];
|
|
110
|
-
|
|
111
|
-
var _useState5 = (0, _react.useState)(0),
|
|
112
|
-
_useState6 = (0, _slicedToArray2["default"])(_useState5, 2),
|
|
113
|
-
duration = _useState6[0],
|
|
114
|
-
setDuration = _useState6[1];
|
|
103
|
+
imageGalleryAttachments = _useState2[0],
|
|
104
|
+
setImageGalleryAttachments = _useState2[1];
|
|
115
105
|
|
|
116
106
|
var _useTheme = (0, _ThemeContext.useTheme)(),
|
|
117
107
|
_useTheme$theme = _useTheme.theme,
|
|
@@ -121,10 +111,10 @@ var ImageGallery = function ImageGallery(props) {
|
|
|
121
111
|
pager = _useTheme$theme$image.pager,
|
|
122
112
|
slide = _useTheme$theme$image.slide;
|
|
123
113
|
|
|
124
|
-
var
|
|
125
|
-
|
|
126
|
-
gridPhotos =
|
|
127
|
-
setGridPhotos =
|
|
114
|
+
var _useState3 = (0, _react.useState)([]),
|
|
115
|
+
_useState4 = (0, _slicedToArray2["default"])(_useState3, 2),
|
|
116
|
+
gridPhotos = _useState4[0],
|
|
117
|
+
setGridPhotos = _useState4[1];
|
|
128
118
|
|
|
129
119
|
var _useOverlayContext = (0, _OverlayContext.useOverlayContext)(),
|
|
130
120
|
overlay = _useOverlayContext.overlay,
|
|
@@ -148,10 +138,10 @@ var ImageGallery = function ImageGallery(props) {
|
|
|
148
138
|
|
|
149
139
|
var bottomSheetModalRef = (0, _react.useRef)(null);
|
|
150
140
|
|
|
151
|
-
var
|
|
152
|
-
|
|
153
|
-
currentBottomSheetIndex =
|
|
154
|
-
setCurrentBottomSheetIndex =
|
|
141
|
+
var _useState5 = (0, _react.useState)(0),
|
|
142
|
+
_useState6 = (0, _slicedToArray2["default"])(_useState5, 2),
|
|
143
|
+
currentBottomSheetIndex = _useState6[0],
|
|
144
|
+
setCurrentBottomSheetIndex = _useState6[1];
|
|
155
145
|
|
|
156
146
|
var animatedBottomSheetIndex = (0, _reactNativeReanimated.useSharedValue)(0);
|
|
157
147
|
var screenTranslateY = (0, _reactNativeReanimated.useSharedValue)(screenHeight);
|
|
@@ -171,15 +161,15 @@ var ImageGallery = function ImageGallery(props) {
|
|
|
171
161
|
showScreen();
|
|
172
162
|
}, []);
|
|
173
163
|
|
|
174
|
-
var
|
|
175
|
-
|
|
176
|
-
currentImageHeight =
|
|
177
|
-
setCurrentImageHeight =
|
|
164
|
+
var _useState7 = (0, _react.useState)(screenHeight),
|
|
165
|
+
_useState8 = (0, _slicedToArray2["default"])(_useState7, 2),
|
|
166
|
+
currentImageHeight = _useState8[0],
|
|
167
|
+
setCurrentImageHeight = _useState8[1];
|
|
178
168
|
|
|
179
|
-
var
|
|
180
|
-
|
|
181
|
-
selectedIndex =
|
|
182
|
-
setSelectedIndex =
|
|
169
|
+
var _useState9 = (0, _react.useState)(0),
|
|
170
|
+
_useState10 = (0, _slicedToArray2["default"])(_useState9, 2),
|
|
171
|
+
selectedIndex = _useState10[0],
|
|
172
|
+
setSelectedIndex = _useState10[1];
|
|
183
173
|
|
|
184
174
|
var index = (0, _reactNativeReanimated.useSharedValue)(0);
|
|
185
175
|
var headerFooterVisible = (0, _reactNativeReanimated.useSharedValue)(1);
|
|
@@ -208,11 +198,14 @@ var ImageGallery = function ImageGallery(props) {
|
|
|
208
198
|
return {
|
|
209
199
|
channelId: cur.cid,
|
|
210
200
|
created_at: cur.created_at,
|
|
201
|
+
duration: 0,
|
|
211
202
|
id: "photoId-" + cur.id + "-" + imageUrl,
|
|
212
203
|
messageId: cur.id,
|
|
213
204
|
mime_type: a.type === 'giphy' ? (0, _getGiphyMimeType.getGiphyMimeType)(giphyURL != null ? giphyURL : '') : a.mime_type,
|
|
214
205
|
original_height: a.original_height,
|
|
215
206
|
original_width: a.original_width,
|
|
207
|
+
paused: true,
|
|
208
|
+
progress: 0,
|
|
216
209
|
type: a.type,
|
|
217
210
|
uri: a.type === 'giphy' ? giphyURL : (0, _getResizedImageUrl.getResizedImageUrl)({
|
|
218
211
|
height: screenHeight,
|
|
@@ -226,6 +219,9 @@ var ImageGallery = function ImageGallery(props) {
|
|
|
226
219
|
return [].concat((0, _toConsumableArray2["default"])(attachmentPhotos), (0, _toConsumableArray2["default"])(acc));
|
|
227
220
|
}, []);
|
|
228
221
|
var photoLength = photos.length;
|
|
222
|
+
(0, _react.useEffect)(function () {
|
|
223
|
+
setImageGalleryAttachments(photos);
|
|
224
|
+
}, []);
|
|
229
225
|
|
|
230
226
|
var stripQueryFromUrl = function stripQueryFromUrl(url) {
|
|
231
227
|
return url.split('?')[0];
|
|
@@ -245,17 +241,12 @@ var ImageGallery = function ImageGallery(props) {
|
|
|
245
241
|
var newIndex = photos.findIndex(function (photo) {
|
|
246
242
|
return photo.messageId === (selectedMessage == null ? void 0 : selectedMessage.messageId) && stripQueryFromUrl(photo.uri) === stripQueryFromUrl((selectedMessage == null ? void 0 : selectedMessage.url) || '');
|
|
247
243
|
});
|
|
248
|
-
|
|
249
|
-
if (photoLength > 1) {
|
|
250
|
-
setPaused(true);
|
|
251
|
-
}
|
|
252
|
-
|
|
253
244
|
(0, _reactNativeReanimated.runOnUI)(updatePosition)(newIndex);
|
|
254
245
|
}, [selectedMessage, photoLength]);
|
|
255
|
-
var uriForCurrentImage = (
|
|
246
|
+
var uriForCurrentImage = (_imageGalleryAttachme = imageGalleryAttachments[selectedIndex]) == null ? void 0 : _imageGalleryAttachme.uri;
|
|
256
247
|
(0, _react.useEffect)(function () {
|
|
257
248
|
setCurrentImageHeight(screenHeight);
|
|
258
|
-
var photo =
|
|
249
|
+
var photo = imageGalleryAttachments[index.value];
|
|
259
250
|
var height = photo == null ? void 0 : photo.original_height;
|
|
260
251
|
var width = photo == null ? void 0 : photo.original_width;
|
|
261
252
|
|
|
@@ -334,52 +325,66 @@ var ImageGallery = function ImageGallery(props) {
|
|
|
334
325
|
|
|
335
326
|
if ((_bottomSheetModalRef$2 = bottomSheetModalRef.current) != null && _bottomSheetModalRef$2.present) {
|
|
336
327
|
bottomSheetModalRef.current.present();
|
|
337
|
-
setGridPhotos(
|
|
328
|
+
setGridPhotos(imageGalleryAttachments);
|
|
338
329
|
}
|
|
339
330
|
};
|
|
340
331
|
|
|
341
|
-
var videoRef = (0, _react.useRef)(null);
|
|
342
|
-
|
|
343
332
|
var handleEnd = function handleEnd() {
|
|
344
|
-
|
|
345
|
-
|
|
333
|
+
handlePlayPause(imageGalleryAttachments[selectedIndex].id, true);
|
|
334
|
+
handleProgress(imageGalleryAttachments[selectedIndex].id, 1, true);
|
|
346
335
|
};
|
|
347
336
|
|
|
348
|
-
var
|
|
349
|
-
if (payload.duration) setDuration(payload.duration);
|
|
350
|
-
};
|
|
337
|
+
var videoRef = (0, _react.useRef)(null);
|
|
351
338
|
|
|
352
|
-
var
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
339
|
+
var handleLoad = function handleLoad(index, duration) {
|
|
340
|
+
setImageGalleryAttachments(function (prevImageGalleryAttachment) {
|
|
341
|
+
return prevImageGalleryAttachment.map(function (imageGalleryAttachment) {
|
|
342
|
+
return (0, _extends2["default"])({}, imageGalleryAttachment, {
|
|
343
|
+
duration: imageGalleryAttachment.id === index ? duration : imageGalleryAttachment.duration
|
|
344
|
+
});
|
|
345
|
+
});
|
|
346
|
+
});
|
|
356
347
|
};
|
|
357
348
|
|
|
358
|
-
var
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
349
|
+
var handleProgress = function handleProgress(index, progress, hasEnd) {
|
|
350
|
+
setImageGalleryAttachments(function (prevImageGalleryAttachments) {
|
|
351
|
+
return prevImageGalleryAttachments.map(function (imageGalleryAttachment) {
|
|
352
|
+
return (0, _extends2["default"])({}, imageGalleryAttachment, {
|
|
353
|
+
progress: imageGalleryAttachment.id === index ? hasEnd ? 1 : progress : imageGalleryAttachment.progress
|
|
354
|
+
});
|
|
355
|
+
});
|
|
356
|
+
});
|
|
357
|
+
};
|
|
367
358
|
|
|
368
|
-
|
|
369
|
-
|
|
359
|
+
var handlePlayPause = function handlePlayPause(index, pausedStatus) {
|
|
360
|
+
if (pausedStatus === false) {
|
|
361
|
+
setImageGalleryAttachments(function (prevImageGalleryAttachment) {
|
|
362
|
+
return prevImageGalleryAttachment.map(function (imageGalleryAttachment) {
|
|
363
|
+
return (0, _extends2["default"])({}, imageGalleryAttachment, {
|
|
364
|
+
paused: imageGalleryAttachment.id === index ? false : true
|
|
365
|
+
});
|
|
366
|
+
});
|
|
370
367
|
});
|
|
371
368
|
} else {
|
|
372
|
-
|
|
369
|
+
setImageGalleryAttachments(function (prevImageGalleryAttachment) {
|
|
370
|
+
return prevImageGalleryAttachment.map(function (imageGalleryAttachment) {
|
|
371
|
+
return (0, _extends2["default"])({}, imageGalleryAttachment, {
|
|
372
|
+
paused: true
|
|
373
|
+
});
|
|
374
|
+
});
|
|
375
|
+
});
|
|
373
376
|
}
|
|
374
377
|
};
|
|
375
378
|
|
|
376
|
-
var
|
|
377
|
-
if (
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
379
|
+
var onPlayPause = function onPlayPause(status) {
|
|
380
|
+
if (status === undefined) {
|
|
381
|
+
if (imageGalleryAttachments[selectedIndex].paused) {
|
|
382
|
+
handlePlayPause(imageGalleryAttachments[selectedIndex].id, false);
|
|
383
|
+
} else {
|
|
384
|
+
handlePlayPause(imageGalleryAttachments[selectedIndex].id, true);
|
|
385
|
+
}
|
|
386
|
+
} else {
|
|
387
|
+
handlePlayPause(imageGalleryAttachments[selectedIndex].id, status);
|
|
383
388
|
}
|
|
384
389
|
};
|
|
385
390
|
|
|
@@ -390,7 +395,7 @@ var ImageGallery = function ImageGallery(props) {
|
|
|
390
395
|
__self: _this,
|
|
391
396
|
__source: {
|
|
392
397
|
fileName: _jsxFileName,
|
|
393
|
-
lineNumber:
|
|
398
|
+
lineNumber: 532,
|
|
394
399
|
columnNumber: 5
|
|
395
400
|
}
|
|
396
401
|
}, _react["default"].createElement(_reactNativeReanimated["default"].View, {
|
|
@@ -398,7 +403,7 @@ var ImageGallery = function ImageGallery(props) {
|
|
|
398
403
|
__self: _this,
|
|
399
404
|
__source: {
|
|
400
405
|
fileName: _jsxFileName,
|
|
401
|
-
lineNumber:
|
|
406
|
+
lineNumber: 537,
|
|
402
407
|
columnNumber: 7
|
|
403
408
|
}
|
|
404
409
|
}), _react["default"].createElement(_reactNativeGestureHandler.TapGestureHandler, {
|
|
@@ -410,7 +415,7 @@ var ImageGallery = function ImageGallery(props) {
|
|
|
410
415
|
__self: _this,
|
|
411
416
|
__source: {
|
|
412
417
|
fileName: _jsxFileName,
|
|
413
|
-
lineNumber:
|
|
418
|
+
lineNumber: 538,
|
|
414
419
|
columnNumber: 7
|
|
415
420
|
}
|
|
416
421
|
}, _react["default"].createElement(_reactNativeReanimated["default"].View, {
|
|
@@ -418,7 +423,7 @@ var ImageGallery = function ImageGallery(props) {
|
|
|
418
423
|
__self: _this,
|
|
419
424
|
__source: {
|
|
420
425
|
fileName: _jsxFileName,
|
|
421
|
-
lineNumber:
|
|
426
|
+
lineNumber: 545,
|
|
422
427
|
columnNumber: 9
|
|
423
428
|
}
|
|
424
429
|
}, _react["default"].createElement(_reactNativeGestureHandler.TapGestureHandler, {
|
|
@@ -432,7 +437,7 @@ var ImageGallery = function ImageGallery(props) {
|
|
|
432
437
|
__self: _this,
|
|
433
438
|
__source: {
|
|
434
439
|
fileName: _jsxFileName,
|
|
435
|
-
lineNumber:
|
|
440
|
+
lineNumber: 546,
|
|
436
441
|
columnNumber: 11
|
|
437
442
|
}
|
|
438
443
|
}, _react["default"].createElement(_reactNativeReanimated["default"].View, {
|
|
@@ -440,7 +445,7 @@ var ImageGallery = function ImageGallery(props) {
|
|
|
440
445
|
__self: _this,
|
|
441
446
|
__source: {
|
|
442
447
|
fileName: _jsxFileName,
|
|
443
|
-
lineNumber:
|
|
448
|
+
lineNumber: 555,
|
|
444
449
|
columnNumber: 13
|
|
445
450
|
}
|
|
446
451
|
}, _react["default"].createElement(_reactNativeGestureHandler.PinchGestureHandler, {
|
|
@@ -450,7 +455,7 @@ var ImageGallery = function ImageGallery(props) {
|
|
|
450
455
|
__self: _this,
|
|
451
456
|
__source: {
|
|
452
457
|
fileName: _jsxFileName,
|
|
453
|
-
lineNumber:
|
|
458
|
+
lineNumber: 556,
|
|
454
459
|
columnNumber: 15
|
|
455
460
|
}
|
|
456
461
|
}, _react["default"].createElement(_reactNativeReanimated["default"].View, {
|
|
@@ -458,7 +463,7 @@ var ImageGallery = function ImageGallery(props) {
|
|
|
458
463
|
__self: _this,
|
|
459
464
|
__source: {
|
|
460
465
|
fileName: _jsxFileName,
|
|
461
|
-
lineNumber:
|
|
466
|
+
lineNumber: 561,
|
|
462
467
|
columnNumber: 17
|
|
463
468
|
}
|
|
464
469
|
}, _react["default"].createElement(_reactNativeGestureHandler.PanGestureHandler, {
|
|
@@ -471,7 +476,7 @@ var ImageGallery = function ImageGallery(props) {
|
|
|
471
476
|
__self: _this,
|
|
472
477
|
__source: {
|
|
473
478
|
fileName: _jsxFileName,
|
|
474
|
-
lineNumber:
|
|
479
|
+
lineNumber: 562,
|
|
475
480
|
columnNumber: 19
|
|
476
481
|
}
|
|
477
482
|
}, _react["default"].createElement(_reactNativeReanimated["default"].View, {
|
|
@@ -479,7 +484,7 @@ var ImageGallery = function ImageGallery(props) {
|
|
|
479
484
|
__self: _this,
|
|
480
485
|
__source: {
|
|
481
486
|
fileName: _jsxFileName,
|
|
482
|
-
lineNumber:
|
|
487
|
+
lineNumber: 570,
|
|
483
488
|
columnNumber: 21
|
|
484
489
|
}
|
|
485
490
|
}, _react["default"].createElement(_reactNativeReanimated["default"].View, {
|
|
@@ -493,19 +498,21 @@ var ImageGallery = function ImageGallery(props) {
|
|
|
493
498
|
__self: _this,
|
|
494
499
|
__source: {
|
|
495
500
|
fileName: _jsxFileName,
|
|
496
|
-
lineNumber:
|
|
501
|
+
lineNumber: 571,
|
|
497
502
|
columnNumber: 23
|
|
498
503
|
}
|
|
499
|
-
},
|
|
504
|
+
}, imageGalleryAttachments.map(function (photo, i) {
|
|
500
505
|
return photo.type === 'video' ? _react["default"].createElement(_AnimatedGalleryVideo.AnimatedGalleryVideo, {
|
|
506
|
+
attachmentId: photo.id,
|
|
501
507
|
handleEnd: handleEnd,
|
|
502
508
|
handleLoad: handleLoad,
|
|
503
509
|
handleProgress: handleProgress,
|
|
504
510
|
index: i,
|
|
505
511
|
key: photo.uri + "-" + i,
|
|
506
512
|
offsetScale: offsetScale,
|
|
507
|
-
paused: paused,
|
|
513
|
+
paused: photo.paused || false,
|
|
508
514
|
previous: selectedIndex > i,
|
|
515
|
+
repeat: true,
|
|
509
516
|
scale: scale,
|
|
510
517
|
screenHeight: screenHeight,
|
|
511
518
|
selected: selectedIndex === i,
|
|
@@ -524,7 +531,7 @@ var ImageGallery = function ImageGallery(props) {
|
|
|
524
531
|
__self: _this,
|
|
525
532
|
__source: {
|
|
526
533
|
fileName: _jsxFileName,
|
|
527
|
-
lineNumber:
|
|
534
|
+
lineNumber: 588,
|
|
528
535
|
columnNumber: 29
|
|
529
536
|
}
|
|
530
537
|
}) : _react["default"].createElement(_AnimatedGalleryImage.AnimatedGalleryImage, {
|
|
@@ -548,40 +555,39 @@ var ImageGallery = function ImageGallery(props) {
|
|
|
548
555
|
__self: _this,
|
|
549
556
|
__source: {
|
|
550
557
|
fileName: _jsxFileName,
|
|
551
|
-
lineNumber:
|
|
558
|
+
lineNumber: 617,
|
|
552
559
|
columnNumber: 29
|
|
553
560
|
}
|
|
554
561
|
});
|
|
555
562
|
})))))))))), _react["default"].createElement(_ImageGalleryHeader.ImageGalleryHeader, (0, _extends2["default"])({
|
|
556
563
|
opacity: headerFooterOpacity,
|
|
557
|
-
photo:
|
|
564
|
+
photo: imageGalleryAttachments[selectedIndex],
|
|
558
565
|
visible: headerFooterVisible
|
|
559
566
|
}, imageGalleryCustomComponents == null ? void 0 : imageGalleryCustomComponents.header, {
|
|
560
567
|
__self: _this,
|
|
561
568
|
__source: {
|
|
562
569
|
fileName: _jsxFileName,
|
|
563
|
-
lineNumber:
|
|
570
|
+
lineNumber: 650,
|
|
564
571
|
columnNumber: 7
|
|
565
572
|
}
|
|
566
|
-
})), _react["default"].createElement(_ImageGalleryFooter.ImageGalleryFooter, (0, _extends2["default"])({
|
|
573
|
+
})), imageGalleryAttachments.length > 0 && _react["default"].createElement(_ImageGalleryFooter.ImageGalleryFooter, (0, _extends2["default"])({
|
|
567
574
|
accessibilityLabel: 'Image Gallery Footer',
|
|
568
|
-
duration: duration,
|
|
569
|
-
onPlayPause:
|
|
570
|
-
onProgressDrag: onProgressDrag,
|
|
575
|
+
duration: imageGalleryAttachments[selectedIndex].duration || 0,
|
|
576
|
+
onPlayPause: onPlayPause,
|
|
571
577
|
opacity: headerFooterOpacity,
|
|
572
578
|
openGridView: openGridView,
|
|
573
|
-
paused: paused,
|
|
574
|
-
photo:
|
|
575
|
-
photoLength:
|
|
576
|
-
progress: progress,
|
|
579
|
+
paused: imageGalleryAttachments[selectedIndex].paused || false,
|
|
580
|
+
photo: imageGalleryAttachments[selectedIndex],
|
|
581
|
+
photoLength: imageGalleryAttachments.length,
|
|
582
|
+
progress: imageGalleryAttachments[selectedIndex].progress || 0,
|
|
577
583
|
selectedIndex: selectedIndex,
|
|
578
584
|
visible: headerFooterVisible
|
|
579
585
|
}, imageGalleryCustomComponents == null ? void 0 : imageGalleryCustomComponents.footer, {
|
|
580
586
|
__self: _this,
|
|
581
587
|
__source: {
|
|
582
588
|
fileName: _jsxFileName,
|
|
583
|
-
lineNumber:
|
|
584
|
-
columnNumber:
|
|
589
|
+
lineNumber: 658,
|
|
590
|
+
columnNumber: 9
|
|
585
591
|
}
|
|
586
592
|
})), _react["default"].createElement(_ImageGalleryOverlay.ImageGalleryOverlay, {
|
|
587
593
|
animatedBottomSheetIndex: animatedBottomSheetIndex,
|
|
@@ -590,14 +596,14 @@ var ImageGallery = function ImageGallery(props) {
|
|
|
590
596
|
__self: _this,
|
|
591
597
|
__source: {
|
|
592
598
|
fileName: _jsxFileName,
|
|
593
|
-
lineNumber:
|
|
599
|
+
lineNumber: 674,
|
|
594
600
|
columnNumber: 7
|
|
595
601
|
}
|
|
596
602
|
}), _react["default"].createElement(_bottomSheet.BottomSheetModalProvider, {
|
|
597
603
|
__self: _this,
|
|
598
604
|
__source: {
|
|
599
605
|
fileName: _jsxFileName,
|
|
600
|
-
lineNumber:
|
|
606
|
+
lineNumber: 679,
|
|
601
607
|
columnNumber: 7
|
|
602
608
|
}
|
|
603
609
|
}, _react["default"].createElement(_bottomSheet.BottomSheetModal, {
|
|
@@ -610,7 +616,7 @@ var ImageGallery = function ImageGallery(props) {
|
|
|
610
616
|
__self: _this,
|
|
611
617
|
__source: {
|
|
612
618
|
fileName: _jsxFileName,
|
|
613
|
-
lineNumber:
|
|
619
|
+
lineNumber: 684,
|
|
614
620
|
columnNumber: 13
|
|
615
621
|
}
|
|
616
622
|
}));
|
|
@@ -625,7 +631,7 @@ var ImageGallery = function ImageGallery(props) {
|
|
|
625
631
|
__self: _this,
|
|
626
632
|
__source: {
|
|
627
633
|
fileName: _jsxFileName,
|
|
628
|
-
lineNumber:
|
|
634
|
+
lineNumber: 680,
|
|
629
635
|
columnNumber: 9
|
|
630
636
|
}
|
|
631
637
|
}, _react["default"].createElement(_ImageGrid.ImageGrid, (0, _extends2["default"])({
|
|
@@ -637,7 +643,7 @@ var ImageGallery = function ImageGallery(props) {
|
|
|
637
643
|
__self: _this,
|
|
638
644
|
__source: {
|
|
639
645
|
fileName: _jsxFileName,
|
|
640
|
-
lineNumber:
|
|
646
|
+
lineNumber: 695,
|
|
641
647
|
columnNumber: 11
|
|
642
648
|
}
|
|
643
649
|
})))));
|