@sendbird/uikit-react-native 3.12.1 → 3.12.3
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/ChannelMessageList/index.js +1 -1
- package/lib/commonjs/components/ChannelMessageList/index.js.map +1 -1
- package/lib/commonjs/components/ChannelThreadMessageList/index.js +1 -1
- package/lib/commonjs/components/ChannelThreadMessageList/index.js.map +1 -1
- package/lib/commonjs/components/FileViewer/FileViewerContent.js +1 -1
- package/lib/commonjs/components/FileViewer/FileViewerContent.js.map +1 -1
- package/lib/commonjs/components/ReactionAddons/BottomSheetReactionAddon.js +57 -27
- package/lib/commonjs/components/ReactionAddons/BottomSheetReactionAddon.js.map +1 -1
- package/lib/commonjs/components/ReactionAddons/MessageReactionAddon.js +46 -17
- package/lib/commonjs/components/ReactionAddons/MessageReactionAddon.js.map +1 -1
- package/lib/commonjs/components/ReactionBottomSheets/ReactionListBottomSheet.js +52 -30
- package/lib/commonjs/components/ReactionBottomSheets/ReactionListBottomSheet.js.map +1 -1
- package/lib/commonjs/components/ReactionBottomSheets/ReactionUserListBottomSheet.js +1 -1
- package/lib/commonjs/components/ReactionBottomSheets/ReactionUserListBottomSheet.js.map +1 -1
- package/lib/commonjs/domain/groupChannel/component/GroupChannelMessageList.js +2 -2
- package/lib/commonjs/domain/groupChannel/component/GroupChannelMessageList.js.map +1 -1
- package/lib/commonjs/fragments/createGroupChannelMembersFragment.js +1 -1
- package/lib/commonjs/fragments/createGroupChannelMembersFragment.js.map +1 -1
- package/lib/commonjs/fragments/createOpenChannelParticipantsFragment.js +1 -1
- package/lib/commonjs/fragments/createOpenChannelParticipantsFragment.js.map +1 -1
- package/lib/commonjs/hooks/useMentionTextInput.js +1 -1
- package/lib/commonjs/hooks/useMentionTextInput.js.map +1 -1
- package/lib/commonjs/hooks/usePushTokenRegistration.js +1 -1
- package/lib/commonjs/hooks/usePushTokenRegistration.js.map +1 -1
- package/lib/commonjs/hooks/useVoiceMessageInput.js +1 -1
- package/lib/commonjs/hooks/useVoiceMessageInput.js.map +1 -1
- package/lib/commonjs/platform/createFileService.expo.js +4 -0
- package/lib/commonjs/platform/createFileService.expo.js.map +1 -1
- package/lib/commonjs/platform/createFileService.native.js +2 -0
- package/lib/commonjs/platform/createFileService.native.js.map +1 -1
- package/lib/commonjs/version.js +1 -1
- package/lib/commonjs/version.js.map +1 -1
- package/lib/module/components/ChannelMessageList/index.js +1 -1
- package/lib/module/components/ChannelMessageList/index.js.map +1 -1
- package/lib/module/components/ChannelThreadMessageList/index.js +1 -1
- package/lib/module/components/ChannelThreadMessageList/index.js.map +1 -1
- package/lib/module/components/FileViewer/FileViewerContent.js +1 -1
- package/lib/module/components/FileViewer/FileViewerContent.js.map +1 -1
- package/lib/module/components/ReactionAddons/BottomSheetReactionAddon.js +56 -26
- package/lib/module/components/ReactionAddons/BottomSheetReactionAddon.js.map +1 -1
- package/lib/module/components/ReactionAddons/MessageReactionAddon.js +45 -17
- package/lib/module/components/ReactionAddons/MessageReactionAddon.js.map +1 -1
- package/lib/module/components/ReactionBottomSheets/ReactionListBottomSheet.js +51 -29
- package/lib/module/components/ReactionBottomSheets/ReactionListBottomSheet.js.map +1 -1
- package/lib/module/components/ReactionBottomSheets/ReactionUserListBottomSheet.js +1 -1
- package/lib/module/components/ReactionBottomSheets/ReactionUserListBottomSheet.js.map +1 -1
- package/lib/module/domain/groupChannel/component/GroupChannelMessageList.js +2 -2
- package/lib/module/domain/groupChannel/component/GroupChannelMessageList.js.map +1 -1
- package/lib/module/fragments/createGroupChannelMembersFragment.js +1 -1
- package/lib/module/fragments/createGroupChannelMembersFragment.js.map +1 -1
- package/lib/module/fragments/createOpenChannelParticipantsFragment.js +1 -1
- package/lib/module/fragments/createOpenChannelParticipantsFragment.js.map +1 -1
- package/lib/module/hooks/useMentionTextInput.js +1 -1
- package/lib/module/hooks/useMentionTextInput.js.map +1 -1
- package/lib/module/hooks/usePushTokenRegistration.js +1 -1
- package/lib/module/hooks/usePushTokenRegistration.js.map +1 -1
- package/lib/module/hooks/useVoiceMessageInput.js +1 -1
- package/lib/module/hooks/useVoiceMessageInput.js.map +1 -1
- package/lib/module/platform/createFileService.expo.js +4 -0
- package/lib/module/platform/createFileService.expo.js.map +1 -1
- package/lib/module/platform/createFileService.native.js +2 -0
- package/lib/module/platform/createFileService.native.js.map +1 -1
- package/lib/module/version.js +1 -1
- package/lib/module/version.js.map +1 -1
- package/lib/typescript/src/components/ChannelMessageList/index.d.ts +1 -2
- package/lib/typescript/src/components/ChannelThreadMessageList/index.d.ts +1 -2
- package/lib/typescript/src/components/ReactionAddons/BottomSheetReactionAddon.d.ts +1 -1
- package/lib/typescript/src/containers/InternalErrorBoundaryContainer.d.ts +1 -1
- package/lib/typescript/src/containers/SendbirdUIKitContainer.d.ts +1 -1
- package/lib/typescript/src/hooks/useChannelInputItems.d.ts +1 -1
- package/lib/typescript/src/hooks/useMentionTextInput.d.ts +1 -1
- package/lib/typescript/src/libs/MentionManager.d.ts +1 -1
- package/lib/typescript/src/version.d.ts +1 -1
- package/package.json +5 -5
- package/src/components/ChannelMessageList/index.tsx +4 -2
- package/src/components/ChannelThreadMessageList/index.tsx +4 -2
- package/src/components/FileViewer/FileViewerContent.tsx +1 -1
- package/src/components/ReactionAddons/BottomSheetReactionAddon.tsx +65 -18
- package/src/components/ReactionAddons/MessageReactionAddon.tsx +61 -25
- package/src/components/ReactionBottomSheets/ReactionListBottomSheet.tsx +61 -27
- package/src/components/ReactionBottomSheets/ReactionUserListBottomSheet.tsx +1 -1
- package/src/domain/groupChannel/component/GroupChannelMessageList.tsx +2 -2
- package/src/fragments/createGroupChannelMembersFragment.tsx +1 -1
- package/src/fragments/createOpenChannelParticipantsFragment.tsx +1 -1
- package/src/hooks/useMentionTextInput.ts +1 -1
- package/src/hooks/usePushTokenRegistration.ts +1 -1
- package/src/hooks/useVoiceMessageInput.ts +1 -1
- package/src/platform/createFileService.expo.ts +4 -0
- package/src/platform/createFileService.native.ts +2 -0
- package/src/version.ts +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["ReactNativeZoomableView","React","useLayoutEffect","useRef","useState","StyleSheet","useWindowDimensions","Box","Image","LoadingSpinner","createStyleSheet","useHeaderStyle","useUIKitTheme","useIIFE","usePlatformService","SBUUtils","FileViewerContent","type","src","topInset","bottomInset","maxZoom","minZoom","onPress","loading","setLoading","defaultHeight","mediaService","palette","source","uri","onLoadEnd","mediaViewer","createElement","ZoomableImageView","style","absoluteFill","resizeMode","zoomProps","onSingleTap","VideoComponent","top","bottom","onLoad","styles","container","position","size","color","primary300","props","width","height","imageSize","contentSizeProps","setContentSizeProps","contentWidth","contentHeight","safeRun","image","current","getImageSize","viewRatio","imageRatio","fitDirection","ratio","actualSize","_extends","visualTouchFeedbackEnabled","initialZoom","zIndex","flex","alignItems","justifyContent"],"sources":["FileViewerContent.tsx"],"sourcesContent":["import { ReactNativeZoomableView, ReactNativeZoomableViewProps } from '@openspacelabs/react-native-zoomable-view';\nimport React, { useLayoutEffect, useRef, useState } from 'react';\nimport { ImageProps, ImageStyle, ImageURISource, StyleProp, StyleSheet, useWindowDimensions } from 'react-native';\n\nimport {\n Box,\n Image,\n LoadingSpinner,\n createStyleSheet,\n useHeaderStyle,\n useUIKitTheme,\n} from '@sendbird/uikit-react-native-foundation';\nimport { FileType, useIIFE } from '@sendbird/uikit-utils';\n\nimport { usePlatformService } from '../../hooks/useContext';\nimport SBUUtils from '../../libs/SBUUtils';\n\ntype Props = {\n type: FileType;\n src: string;\n topInset?: number;\n bottomInset?: number;\n maxZoom?: number;\n minZoom?: number;\n onPress?: () => void;\n};\nconst FileViewerContent = ({ type, src, topInset = 0, bottomInset = 0, maxZoom = 4, minZoom = 1, onPress }: Props) => {\n const [loading, setLoading] = useState(true);\n\n const { defaultHeight } = useHeaderStyle();\n const { mediaService } = usePlatformService();\n const { palette } = useUIKitTheme();\n\n const source = { uri: src };\n const onLoadEnd = () => setLoading(false);\n const mediaViewer = useIIFE(() => {\n switch (type) {\n case 'image': {\n return (\n <ZoomableImageView\n source={source}\n style={StyleSheet.absoluteFill}\n resizeMode={'contain'}\n onLoadEnd={onLoadEnd}\n zoomProps={{\n minZoom,\n maxZoom,\n onSingleTap: onPress,\n }}\n />\n );\n }\n\n case 'video':\n case 'audio': {\n return (\n <mediaService.VideoComponent\n source={source}\n style={[StyleSheet.absoluteFill, { top: topInset, bottom: defaultHeight + bottomInset }]}\n resizeMode={'contain'}\n onLoad={onLoadEnd}\n />\n );\n }\n\n default: {\n return null;\n }\n }\n });\n\n return (\n <Box style={styles.container}>\n {mediaViewer}\n {loading && <LoadingSpinner style={{ position: 'absolute' }} size={40} color={palette.primary300} />}\n </Box>\n );\n};\n\nconst ZoomableImageView = ({\n zoomProps,\n ...props\n}: {\n source: ImageURISource;\n style: StyleProp<ImageStyle>;\n resizeMode: ImageProps['resizeMode'];\n onLoadEnd: () => void;\n zoomProps?: Partial<ReactNativeZoomableViewProps>;\n}) => {\n const { width, height } = useWindowDimensions();\n\n const imageSize = useRef<{ width: number; height: number }>();\n const [contentSizeProps, setContentSizeProps] = useState<{\n contentWidth: number;\n contentHeight: number;\n }>({\n contentWidth: width,\n contentHeight: height,\n });\n\n useLayoutEffect(() => {\n SBUUtils.safeRun(async () => {\n if (props.source.uri) {\n const image = imageSize.current ?? (await SBUUtils.getImageSize(props.source.uri));\n imageSize.current = image;\n\n const viewRatio = width / height;\n const imageRatio = image.width / image.height;\n\n const fitDirection = viewRatio > imageRatio ? 'height' : 'width';\n const ratio = fitDirection === 'height' ? height / image.height : width / image.width;\n const actualSize = { width: image.width * ratio, height: image.height * ratio };\n\n setContentSizeProps({\n contentWidth: actualSize.width,\n contentHeight: actualSize.height,\n });\n }\n });\n }, [props.source.uri, width, height]);\n\n return (\n <ReactNativeZoomableView\n visualTouchFeedbackEnabled={false}\n style={{ width, height }}\n initialZoom={1}\n {...contentSizeProps}\n {...zoomProps}\n >\n <Image {...props} />\n </ReactNativeZoomableView>\n );\n};\n\nconst styles = createStyleSheet({\n container: {\n zIndex: 0,\n flex: 1,\n alignItems: 'center',\n justifyContent: 'center',\n },\n});\n\nexport default FileViewerContent;\n"],"mappings":";AAAA,SAASA,uBAAuB,QAAsC,2CAA2C;AACjH,OAAOC,KAAK,IAAIC,eAAe,EAAEC,MAAM,EAAEC,QAAQ,QAAQ,OAAO;AAChE,SAA4DC,UAAU,EAAEC,mBAAmB,QAAQ,cAAc;AAEjH,SACEC,GAAG,EACHC,KAAK,EACLC,cAAc,EACdC,gBAAgB,EAChBC,cAAc,EACdC,aAAa,QACR,yCAAyC;AAChD,SAAmBC,OAAO,QAAQ,uBAAuB;AAEzD,SAASC,kBAAkB,QAAQ,wBAAwB;AAC3D,OAAOC,QAAQ,MAAM,qBAAqB;AAW1C,MAAMC,iBAAiB,GAAGA,CAAC;EAAEC,IAAI;EAAEC,GAAG;EAAEC,QAAQ,GAAG,CAAC;EAAEC,WAAW,GAAG,CAAC;EAAEC,OAAO,GAAG,CAAC;EAAEC,OAAO,GAAG,CAAC;EAAEC;AAAe,CAAC,KAAK;EACpH,MAAM,CAACC,OAAO,EAAEC,UAAU,CAAC,GAAGrB,QAAQ,CAAC,IAAI,CAAC;EAE5C,MAAM;IAAEsB;EAAc,CAAC,GAAGf,cAAc,CAAC,CAAC;EAC1C,MAAM;IAAEgB;EAAa,CAAC,GAAGb,kBAAkB,CAAC,CAAC;EAC7C,MAAM;IAAEc;EAAQ,CAAC,GAAGhB,aAAa,CAAC,CAAC;EAEnC,MAAMiB,MAAM,GAAG;IAAEC,GAAG,EAAEZ;EAAI,CAAC;EAC3B,MAAMa,SAAS,GAAGA,CAAA,KAAMN,UAAU,CAAC,KAAK,CAAC;EACzC,MAAMO,WAAW,GAAGnB,OAAO,CAAC,MAAM;IAChC,QAAQI,IAAI;MACV,KAAK,OAAO;QAAE;UACZ,oBACEhB,KAAA,CAAAgC,aAAA,CAACC,iBAAiB;YAChBL,MAAM,EAAEA,MAAO;YACfM,KAAK,EAAE9B,UAAU,CAAC+B,YAAa;YAC/BC,UAAU,EAAE,SAAU;YACtBN,SAAS,EAAEA,SAAU;YACrBO,SAAS,EAAE;cACThB,OAAO;cACPD,OAAO;cACPkB,WAAW,EAAEhB;YACf;UAAE,CACH,CAAC;QAEN;MAEA,KAAK,OAAO;MACZ,KAAK,OAAO;QAAE;UACZ,oBACEtB,KAAA,CAAAgC,aAAA,CAACN,YAAY,CAACa,cAAc;YAC1BX,MAAM,EAAEA,MAAO;YACfM,KAAK,EAAE,CAAC9B,UAAU,CAAC+B,YAAY,EAAE;cAAEK,GAAG,EAAEtB,QAAQ;cAAEuB,MAAM,EAAEhB,aAAa,GAAGN;YAAY,CAAC,CAAE;YACzFiB,UAAU,EAAE,SAAU;YACtBM,MAAM,EAAEZ;UAAU,CACnB,CAAC;QAEN;MAEA;QAAS;UACP,OAAO,IAAI;QACb;IACF;EACF,CAAC,CAAC;EAEF,oBACE9B,KAAA,CAAAgC,aAAA,CAAC1B,GAAG;IAAC4B,KAAK,EAAES,MAAM,CAACC;EAAU,GAC1Bb,WAAW,EACXR,OAAO,iBAAIvB,KAAA,CAAAgC,aAAA,CAACxB,cAAc;IAAC0B,KAAK,EAAE;MAAEW,QAAQ,EAAE;IAAW,CAAE;IAACC,IAAI,EAAE,EAAG;IAACC,KAAK,EAAEpB,OAAO,CAACqB;EAAW,CAAE,CAChG,CAAC;AAEV,CAAC;AAED,MAAMf,iBAAiB,GAAGA,CAAC;EACzBI,SAAS;EACT,GAAGY;AAOL,CAAC,KAAK;EACJ,MAAM;IAAEC,KAAK;IAAEC;EAAO,CAAC,GAAG9C,mBAAmB,CAAC,CAAC;EAE/C,MAAM+C,SAAS,GAAGlD,MAAM,
|
|
1
|
+
{"version":3,"names":["ReactNativeZoomableView","React","useLayoutEffect","useRef","useState","StyleSheet","useWindowDimensions","Box","Image","LoadingSpinner","createStyleSheet","useHeaderStyle","useUIKitTheme","useIIFE","usePlatformService","SBUUtils","FileViewerContent","type","src","topInset","bottomInset","maxZoom","minZoom","onPress","loading","setLoading","defaultHeight","mediaService","palette","source","uri","onLoadEnd","mediaViewer","createElement","ZoomableImageView","style","absoluteFill","resizeMode","zoomProps","onSingleTap","VideoComponent","top","bottom","onLoad","styles","container","position","size","color","primary300","props","width","height","imageSize","undefined","contentSizeProps","setContentSizeProps","contentWidth","contentHeight","safeRun","image","current","getImageSize","viewRatio","imageRatio","fitDirection","ratio","actualSize","_extends","visualTouchFeedbackEnabled","initialZoom","zIndex","flex","alignItems","justifyContent"],"sources":["FileViewerContent.tsx"],"sourcesContent":["import { ReactNativeZoomableView, ReactNativeZoomableViewProps } from '@openspacelabs/react-native-zoomable-view';\nimport React, { useLayoutEffect, useRef, useState } from 'react';\nimport { ImageProps, ImageStyle, ImageURISource, StyleProp, StyleSheet, useWindowDimensions } from 'react-native';\n\nimport {\n Box,\n Image,\n LoadingSpinner,\n createStyleSheet,\n useHeaderStyle,\n useUIKitTheme,\n} from '@sendbird/uikit-react-native-foundation';\nimport { FileType, useIIFE } from '@sendbird/uikit-utils';\n\nimport { usePlatformService } from '../../hooks/useContext';\nimport SBUUtils from '../../libs/SBUUtils';\n\ntype Props = {\n type: FileType;\n src: string;\n topInset?: number;\n bottomInset?: number;\n maxZoom?: number;\n minZoom?: number;\n onPress?: () => void;\n};\nconst FileViewerContent = ({ type, src, topInset = 0, bottomInset = 0, maxZoom = 4, minZoom = 1, onPress }: Props) => {\n const [loading, setLoading] = useState(true);\n\n const { defaultHeight } = useHeaderStyle();\n const { mediaService } = usePlatformService();\n const { palette } = useUIKitTheme();\n\n const source = { uri: src };\n const onLoadEnd = () => setLoading(false);\n const mediaViewer = useIIFE(() => {\n switch (type) {\n case 'image': {\n return (\n <ZoomableImageView\n source={source}\n style={StyleSheet.absoluteFill}\n resizeMode={'contain'}\n onLoadEnd={onLoadEnd}\n zoomProps={{\n minZoom,\n maxZoom,\n onSingleTap: onPress,\n }}\n />\n );\n }\n\n case 'video':\n case 'audio': {\n return (\n <mediaService.VideoComponent\n source={source}\n style={[StyleSheet.absoluteFill, { top: topInset, bottom: defaultHeight + bottomInset }]}\n resizeMode={'contain'}\n onLoad={onLoadEnd}\n />\n );\n }\n\n default: {\n return null;\n }\n }\n });\n\n return (\n <Box style={styles.container}>\n {mediaViewer}\n {loading && <LoadingSpinner style={{ position: 'absolute' }} size={40} color={palette.primary300} />}\n </Box>\n );\n};\n\nconst ZoomableImageView = ({\n zoomProps,\n ...props\n}: {\n source: ImageURISource;\n style: StyleProp<ImageStyle>;\n resizeMode: ImageProps['resizeMode'];\n onLoadEnd: () => void;\n zoomProps?: Partial<ReactNativeZoomableViewProps>;\n}) => {\n const { width, height } = useWindowDimensions();\n\n const imageSize = useRef<{ width: number; height: number } | undefined>(undefined);\n const [contentSizeProps, setContentSizeProps] = useState<{\n contentWidth: number;\n contentHeight: number;\n }>({\n contentWidth: width,\n contentHeight: height,\n });\n\n useLayoutEffect(() => {\n SBUUtils.safeRun(async () => {\n if (props.source.uri) {\n const image = imageSize.current ?? (await SBUUtils.getImageSize(props.source.uri));\n imageSize.current = image;\n\n const viewRatio = width / height;\n const imageRatio = image.width / image.height;\n\n const fitDirection = viewRatio > imageRatio ? 'height' : 'width';\n const ratio = fitDirection === 'height' ? height / image.height : width / image.width;\n const actualSize = { width: image.width * ratio, height: image.height * ratio };\n\n setContentSizeProps({\n contentWidth: actualSize.width,\n contentHeight: actualSize.height,\n });\n }\n });\n }, [props.source.uri, width, height]);\n\n return (\n <ReactNativeZoomableView\n visualTouchFeedbackEnabled={false}\n style={{ width, height }}\n initialZoom={1}\n {...contentSizeProps}\n {...zoomProps}\n >\n <Image {...props} />\n </ReactNativeZoomableView>\n );\n};\n\nconst styles = createStyleSheet({\n container: {\n zIndex: 0,\n flex: 1,\n alignItems: 'center',\n justifyContent: 'center',\n },\n});\n\nexport default FileViewerContent;\n"],"mappings":";AAAA,SAASA,uBAAuB,QAAsC,2CAA2C;AACjH,OAAOC,KAAK,IAAIC,eAAe,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CAAC;AAEF,eAAe1D,iBAAiB","ignoreList":[]}
|
|
@@ -1,10 +1,52 @@
|
|
|
1
|
-
import React from 'react';
|
|
1
|
+
import React, { useState } from 'react';
|
|
2
2
|
import { Pressable, View } from 'react-native';
|
|
3
3
|
import { Icon, Image, createStyleSheet, useUIKitTheme } from '@sendbird/uikit-react-native-foundation';
|
|
4
4
|
import { useGroupChannelHandler } from '@sendbird/uikit-tools';
|
|
5
5
|
import { Logger, useSafeAreaPadding } from '@sendbird/uikit-utils';
|
|
6
6
|
import { UNKNOWN_USER_ID } from '../../constants';
|
|
7
7
|
import { useReaction, useSendbirdChat } from '../../hooks/useContext';
|
|
8
|
+
const EmojiReactionPressable = ({
|
|
9
|
+
url,
|
|
10
|
+
reacted,
|
|
11
|
+
selectedBackground,
|
|
12
|
+
enabledBackground,
|
|
13
|
+
onPress
|
|
14
|
+
}) => {
|
|
15
|
+
const [pressed, setPressed] = useState(false);
|
|
16
|
+
return /*#__PURE__*/React.createElement(Pressable, {
|
|
17
|
+
onPress: onPress,
|
|
18
|
+
onPressIn: () => setPressed(true),
|
|
19
|
+
onPressOut: () => setPressed(false),
|
|
20
|
+
style: [styles.button, {
|
|
21
|
+
backgroundColor: reacted || pressed ? selectedBackground : enabledBackground
|
|
22
|
+
}]
|
|
23
|
+
}, /*#__PURE__*/React.createElement(Image, {
|
|
24
|
+
source: {
|
|
25
|
+
uri: url
|
|
26
|
+
},
|
|
27
|
+
style: styles.emoji
|
|
28
|
+
}));
|
|
29
|
+
};
|
|
30
|
+
const EmojiMorePressable = ({
|
|
31
|
+
selectedBackground,
|
|
32
|
+
enabledBackground,
|
|
33
|
+
iconColor,
|
|
34
|
+
onPress
|
|
35
|
+
}) => {
|
|
36
|
+
const [pressed, setPressed] = useState(false);
|
|
37
|
+
return /*#__PURE__*/React.createElement(Pressable, {
|
|
38
|
+
onPress: onPress,
|
|
39
|
+
onPressIn: () => setPressed(true),
|
|
40
|
+
onPressOut: () => setPressed(false),
|
|
41
|
+
style: [styles.button, {
|
|
42
|
+
backgroundColor: pressed ? selectedBackground : enabledBackground
|
|
43
|
+
}]
|
|
44
|
+
}, /*#__PURE__*/React.createElement(Icon, {
|
|
45
|
+
icon: 'emoji-more',
|
|
46
|
+
style: styles.emoji,
|
|
47
|
+
color: iconColor
|
|
48
|
+
}));
|
|
49
|
+
};
|
|
8
50
|
const BottomSheetReactionAddon = ({
|
|
9
51
|
onClose,
|
|
10
52
|
message,
|
|
@@ -63,38 +105,26 @@ const BottomSheetReactionAddon = ({
|
|
|
63
105
|
onClose();
|
|
64
106
|
});
|
|
65
107
|
};
|
|
66
|
-
return /*#__PURE__*/React.createElement(
|
|
108
|
+
return /*#__PURE__*/React.createElement(EmojiReactionPressable, {
|
|
67
109
|
key: key,
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
style: styles.emoji
|
|
79
|
-
}));
|
|
80
|
-
}), /*#__PURE__*/React.createElement(Pressable, {
|
|
110
|
+
url: url,
|
|
111
|
+
reacted: reacted,
|
|
112
|
+
selectedBackground: color.selected.background,
|
|
113
|
+
enabledBackground: color.enabled.background,
|
|
114
|
+
onPress: onPress
|
|
115
|
+
});
|
|
116
|
+
}), /*#__PURE__*/React.createElement(EmojiMorePressable, {
|
|
117
|
+
selectedBackground: color.selected.background,
|
|
118
|
+
enabledBackground: color.enabled.background,
|
|
119
|
+
iconColor: colors.onBackground03,
|
|
81
120
|
onPress: async () => {
|
|
82
121
|
await onClose();
|
|
83
122
|
openReactionList({
|
|
84
123
|
channel,
|
|
85
124
|
message
|
|
86
125
|
});
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
pressed
|
|
90
|
-
}) => [styles.button, {
|
|
91
|
-
backgroundColor: pressed ? color.selected.background : color.enabled.background
|
|
92
|
-
}]
|
|
93
|
-
}, /*#__PURE__*/React.createElement(Icon, {
|
|
94
|
-
icon: 'emoji-more',
|
|
95
|
-
style: styles.emoji,
|
|
96
|
-
color: colors.onBackground03
|
|
97
|
-
})));
|
|
126
|
+
}
|
|
127
|
+
}));
|
|
98
128
|
};
|
|
99
129
|
const styles = createStyleSheet({
|
|
100
130
|
container: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["React","Pressable","View","Icon","Image","createStyleSheet","useUIKitTheme","useGroupChannelHandler","Logger","useSafeAreaPadding","UNKNOWN_USER_ID","useReaction","useSendbirdChat","BottomSheetReactionAddon","onClose","message","channel","emojiManager","currentUser","sdk","updateReactionFocusedItem","openReactionList","colors","safeArea","onReactionUpdated","eventChannel","event","url","messageId","msg","getMessage","includeReactions","channelUrl","channelType","emojiAll","allEmoji","slice","color","ui","reaction","default","createElement","style","styles","container","marginStart","paddingStart","marginEnd","paddingEnd","map","key","_message$reactions","reactionUserIds","reactions","find","it","userIds","currentUserIdx","indexOf","userId","reacted","onPress","action","deleteReaction","addReaction","catch","error","warn","finally","pressed","button","backgroundColor","selected","background","enabled","source","uri","emoji","icon","onBackground03","paddingTop","paddingBottom","paddingHorizontal","flexDirection","justifyContent","width","height","padding","borderRadius"],"sources":["BottomSheetReactionAddon.tsx"],"sourcesContent":["import React from 'react';\nimport { Pressable, View } from 'react-native';\n\nimport type { BaseMessage } from '@sendbird/chat/message';\nimport { Icon, Image, createStyleSheet, useUIKitTheme } from '@sendbird/uikit-react-native-foundation';\nimport { useGroupChannelHandler } from '@sendbird/uikit-tools';\nimport { Logger, SendbirdBaseChannel, SendbirdBaseMessage, useSafeAreaPadding } from '@sendbird/uikit-utils';\n\nimport { UNKNOWN_USER_ID } from '../../constants';\nimport { useReaction, useSendbirdChat } from '../../hooks/useContext';\n\ntype Props = {\n onClose: () => Promise<void>;\n channel: SendbirdBaseChannel;\n message: SendbirdBaseMessage;\n};\nconst BottomSheetReactionAddon = ({ onClose, message, channel }: Props) => {\n const { emojiManager, currentUser, sdk } = useSendbirdChat();\n const { updateReactionFocusedItem, openReactionList } = useReaction();\n const { colors } = useUIKitTheme();\n const safeArea = useSafeAreaPadding(['left', 'right']);\n\n useGroupChannelHandler(sdk, {\n async onReactionUpdated(eventChannel, event) {\n if (channel?.url === eventChannel.url && event.messageId === message?.messageId) {\n const msg = (await sdk.message.getMessage({\n includeReactions: true,\n messageId: message.messageId,\n channelUrl: message.channelUrl,\n channelType: message.channelType,\n })) as null | BaseMessage;\n if (msg) updateReactionFocusedItem({ message: msg });\n }\n },\n });\n\n const emojiAll = emojiManager.allEmoji.slice(0, 5);\n const color = colors.ui.reaction.default;\n\n return (\n <View style={[styles.container, { marginStart: safeArea.paddingStart, marginEnd: safeArea.paddingEnd }]}>\n {emojiAll.map(({ key, url }) => {\n const reactionUserIds = message?.reactions?.find((it) => it.key === key)?.userIds ?? [];\n const currentUserIdx = reactionUserIds.indexOf(currentUser?.userId ?? UNKNOWN_USER_ID);\n const reacted = currentUserIdx > -1;\n\n const onPress = async () => {\n const action = (message: BaseMessage, key: string) => {\n return reacted ? channel.deleteReaction(message, key) : channel.addReaction(message, key);\n };\n\n await action(message, key)\n .catch((error) => {\n Logger.warn('Failed to reaction', error);\n })\n .finally(() => {\n onClose();\n });\n };\n\n return (\n <Pressable\n key={key}\n onPress={onPress}\n style={({ pressed }) => [\n styles.button,\n { backgroundColor: reacted || pressed ? color.selected.background : color.enabled.background },\n ]}\n >\n <Image source={{ uri: url }} style={styles.emoji} />\n </Pressable>\n );\n })}\n\n <Pressable\n onPress={async () => {\n await onClose();\n openReactionList({ channel, message });\n }}\n style={({ pressed }) => [\n styles.button,\n { backgroundColor: pressed ? color.selected.background : color.enabled.background },\n ]}\n >\n <Icon icon={'emoji-more'} style={styles.emoji} color={colors.onBackground03} />\n </Pressable>\n </View>\n );\n};\n\nconst styles = createStyleSheet({\n container: {\n paddingTop: 12,\n paddingBottom: 16,\n paddingHorizontal: 18,\n flexDirection: 'row',\n justifyContent: 'space-between',\n },\n button: {\n width: 44,\n height: 44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IAAW,CAAC;EACnF,gBAEFzE,KAAA,CAAAyC,aAAA,CAACtC,IAAI;IAAC2E,IAAI,EAAE,YAAa;IAACpC,KAAK,EAAEC,MAAM,CAACkC,KAAM;IAACxC,KAAK,EAAEf,MAAM,CAACyD;EAAe,CAAE,CACrE,CACP,CAAC;AAEX,CAAC;AAED,MAAMpC,MAAM,GAAGtC,gBAAgB,CAAC;EAC9BuC,SAAS,EAAE;IACToC,UAAU,EAAE,EAAE;IACdC,aAAa,EAAE,EAAE;IACjBC,iBAAiB,EAAE,EAAE;IACrBC,aAAa,EAAE,KAAK;IACpBC,cAAc,EAAE;EAClB,CAAC;EACDd,MAAM,EAAE;IACNe,KAAK,EAAE,EAAE;IACTC,MAAM,EAAE,EAAE;IACVC,OAAO,EAAE,CAAC;IACVC,YAAY,EAAE;EAChB,CAAC;EACDX,KAAK,EAAE;IACLQ,KAAK,EAAE,MAAM;IACbC,MAAM,EAAE;EACV;AACF,CAAC,CAAC;AAEF,eAAezE,wBAAwB","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["React","useState","Pressable","View","Icon","Image","createStyleSheet","useUIKitTheme","useGroupChannelHandler","Logger","useSafeAreaPadding","UNKNOWN_USER_ID","useReaction","useSendbirdChat","EmojiReactionPressable","url","reacted","selectedBackground","enabledBackground","onPress","pressed","setPressed","createElement","onPressIn","onPressOut","style","styles","button","backgroundColor","source","uri","emoji","EmojiMorePressable","iconColor","icon","color","BottomSheetReactionAddon","onClose","message","channel","emojiManager","currentUser","sdk","updateReactionFocusedItem","openReactionList","colors","safeArea","onReactionUpdated","eventChannel","event","messageId","msg","getMessage","includeReactions","channelUrl","channelType","emojiAll","allEmoji","slice","ui","reaction","default","container","marginStart","paddingStart","marginEnd","paddingEnd","map","key","_message$reactions","reactionUserIds","reactions","find","it","userIds","currentUserIdx","indexOf","userId","action","deleteReaction","addReaction","catch","error","warn","finally","selected","background","enabled","onBackground03","paddingTop","paddingBottom","paddingHorizontal","flexDirection","justifyContent","width","height","padding","borderRadius"],"sources":["BottomSheetReactionAddon.tsx"],"sourcesContent":["import React, { useState } from 'react';\nimport { Pressable, View } from 'react-native';\n\nimport type { BaseMessage } from '@sendbird/chat/message';\nimport { Icon, Image, createStyleSheet, useUIKitTheme } from '@sendbird/uikit-react-native-foundation';\nimport { useGroupChannelHandler } from '@sendbird/uikit-tools';\nimport { Logger, useSafeAreaPadding } from '@sendbird/uikit-utils';\nimport type { SendbirdBaseChannel, SendbirdBaseMessage } from '@sendbird/uikit-utils';\n\nimport { UNKNOWN_USER_ID } from '../../constants';\nimport { useReaction, useSendbirdChat } from '../../hooks/useContext';\n\ntype Props = {\n onClose: () => Promise<void>;\n channel: SendbirdBaseChannel;\n message: SendbirdBaseMessage;\n};\n\nconst EmojiReactionPressable = ({\n url,\n reacted,\n selectedBackground,\n enabledBackground,\n onPress,\n}: {\n url: string;\n reacted: boolean;\n selectedBackground: string;\n enabledBackground: string;\n onPress: () => void;\n}) => {\n const [pressed, setPressed] = useState(false);\n return (\n <Pressable\n onPress={onPress}\n onPressIn={() => setPressed(true)}\n onPressOut={() => setPressed(false)}\n style={[styles.button, { backgroundColor: reacted || pressed ? selectedBackground : enabledBackground }]}\n >\n <Image source={{ uri: url }} style={styles.emoji} />\n </Pressable>\n );\n};\n\nconst EmojiMorePressable = ({\n selectedBackground,\n enabledBackground,\n iconColor,\n onPress,\n}: {\n selectedBackground: string;\n enabledBackground: string;\n iconColor: string;\n onPress: () => void;\n}) => {\n const [pressed, setPressed] = useState(false);\n return (\n <Pressable\n onPress={onPress}\n onPressIn={() => setPressed(true)}\n onPressOut={() => setPressed(false)}\n style={[styles.button, { backgroundColor: pressed ? selectedBackground : enabledBackground }]}\n >\n <Icon icon={'emoji-more'} style={styles.emoji} color={iconColor} />\n </Pressable>\n );\n};\n\nconst BottomSheetReactionAddon = ({ onClose, message, channel }: Props) => {\n const { emojiManager, currentUser, sdk } = useSendbirdChat();\n const { updateReactionFocusedItem, openReactionList } = useReaction();\n const { colors } = useUIKitTheme();\n const safeArea = useSafeAreaPadding(['left', 'right']);\n\n useGroupChannelHandler(sdk, {\n async onReactionUpdated(eventChannel, event) {\n if (channel?.url === eventChannel.url && event.messageId === message?.messageId) {\n const msg = (await sdk.message.getMessage({\n includeReactions: true,\n messageId: message.messageId,\n channelUrl: message.channelUrl,\n channelType: message.channelType,\n })) as null | BaseMessage;\n if (msg) updateReactionFocusedItem({ message: msg });\n }\n },\n });\n\n const emojiAll = emojiManager.allEmoji.slice(0, 5);\n const color = colors.ui.reaction.default;\n\n return (\n <View style={[styles.container, { marginStart: safeArea.paddingStart, marginEnd: safeArea.paddingEnd }]}>\n {emojiAll.map(({ key, url }) => {\n const reactionUserIds = message?.reactions?.find((it) => it.key === key)?.userIds ?? [];\n const currentUserIdx = reactionUserIds.indexOf(currentUser?.userId ?? UNKNOWN_USER_ID);\n const reacted = currentUserIdx > -1;\n\n const onPress = async () => {\n const action = (message: BaseMessage, key: string) => {\n return reacted ? channel.deleteReaction(message, key) : channel.addReaction(message, key);\n };\n\n await action(message, key)\n .catch((error) => {\n Logger.warn('Failed to reaction', error);\n })\n .finally(() => {\n onClose();\n });\n };\n\n return (\n <EmojiReactionPressable\n key={key}\n url={url}\n reacted={reacted}\n selectedBackground={color.selected.background}\n enabledBackground={color.enabled.background}\n onPress={onPress}\n />\n );\n })}\n\n <EmojiMorePressable\n selectedBackground={color.selected.background}\n enabledBackground={color.enabled.background}\n iconColor={colors.onBackground03}\n onPress={async () => {\n await onClose();\n openReactionList({ channel, message });\n }}\n />\n </View>\n );\n};\n\nconst styles = createStyleSheet({\n container: {\n paddingTop: 12,\n paddingBottom: 16,\n paddingHorizontal: 18,\n flexDirection: 'row',\n justifyContent: 'space-between',\n },\n button: {\n width: 44,\n height: 44,\n padding: 4,\n borderRadius: 8,\n },\n emoji: {\n width: '100%',\n height: '100%',\n },\n});\n\nexport default BottomSheetReactionAddon;\n"],"mappings":"AAAA,OAAOA,KAAK,IAAIC,QAAQ,QAAQ,OAAO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,MAAM,EAAE;IACNmE,KAAK,EAAE,EAAE;IACTC,MAAM,EAAE,EAAE;IACVC,OAAO,EAAE,CAAC;IACVC,YAAY,EAAE;EAChB,CAAC;EACDlE,KAAK,EAAE;IACL+D,KAAK,EAAE,MAAM;IACbC,MAAM,EAAE;EACV;AACF,CAAC,CAAC;AAEF,eAAe3D,wBAAwB","ignoreList":[]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React from 'react';
|
|
1
|
+
import React, { useState } from 'react';
|
|
2
2
|
import { Pressable } from 'react-native';
|
|
3
3
|
import { createStyleSheet, useUIKitTheme } from '@sendbird/uikit-react-native-foundation';
|
|
4
4
|
import { useForceUpdate, useGroupChannelHandler } from '@sendbird/uikit-tools';
|
|
@@ -17,34 +17,62 @@ const createOnPressReaction = (reaction, channel, message, reacted) => {
|
|
|
17
17
|
}
|
|
18
18
|
};
|
|
19
19
|
};
|
|
20
|
+
const ReactionPressable = ({
|
|
21
|
+
reaction,
|
|
22
|
+
channel,
|
|
23
|
+
message,
|
|
24
|
+
source,
|
|
25
|
+
onOpenReactionUserList,
|
|
26
|
+
index,
|
|
27
|
+
style
|
|
28
|
+
}) => {
|
|
29
|
+
const [pressed, setPressed] = useState(false);
|
|
30
|
+
return /*#__PURE__*/React.createElement(Pressable, {
|
|
31
|
+
onPress: createOnPressReaction(reaction, channel, message, reaction.hasCurrentUserReacted),
|
|
32
|
+
onLongPress: () => onOpenReactionUserList(index),
|
|
33
|
+
delayLongPress: DEFAULT_LONG_PRESS_DELAY,
|
|
34
|
+
onPressIn: () => setPressed(true),
|
|
35
|
+
onPressOut: () => setPressed(false)
|
|
36
|
+
}, /*#__PURE__*/React.createElement(ReactionRoundedButton, {
|
|
37
|
+
source: source,
|
|
38
|
+
count: getReactionCount(reaction),
|
|
39
|
+
reacted: pressed || reaction.hasCurrentUserReacted,
|
|
40
|
+
style: style
|
|
41
|
+
}));
|
|
42
|
+
};
|
|
43
|
+
const ReactionMorePressable = ({
|
|
44
|
+
onPress
|
|
45
|
+
}) => {
|
|
46
|
+
const [pressed, setPressed] = useState(false);
|
|
47
|
+
return /*#__PURE__*/React.createElement(Pressable, {
|
|
48
|
+
onPress: onPress,
|
|
49
|
+
onPressIn: () => setPressed(true),
|
|
50
|
+
onPressOut: () => setPressed(false)
|
|
51
|
+
}, /*#__PURE__*/React.createElement(ReactionRoundedButton.More, {
|
|
52
|
+
pressed: pressed
|
|
53
|
+
}));
|
|
54
|
+
};
|
|
20
55
|
const createReactionButtons = (channel, message, getIconSource, emojiLimit, onOpenReactionList, onOpenReactionUserList, reactionAddonType) => {
|
|
21
56
|
const reactions = message.reactions ?? [];
|
|
22
57
|
const buttons = reactions.map((reaction, index) => {
|
|
23
58
|
const isNotLastOfRow = index % NUM_COL !== NUM_COL - 1;
|
|
24
59
|
const isNotLastOfCol = index < NUM_COL && reactions.length >= NUM_COL;
|
|
25
|
-
return /*#__PURE__*/React.createElement(
|
|
60
|
+
return /*#__PURE__*/React.createElement(ReactionPressable, {
|
|
26
61
|
key: reaction.key,
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
}, ({
|
|
31
|
-
pressed
|
|
32
|
-
}) => /*#__PURE__*/React.createElement(ReactionRoundedButton, {
|
|
62
|
+
reaction: reaction,
|
|
63
|
+
channel: channel,
|
|
64
|
+
message: message,
|
|
33
65
|
source: getIconSource(reaction.key),
|
|
34
|
-
|
|
35
|
-
|
|
66
|
+
onOpenReactionUserList: onOpenReactionUserList,
|
|
67
|
+
index: index,
|
|
36
68
|
style: reactionAddonType === 'default' ? [isNotLastOfRow && styles.marginEnd, isNotLastOfCol && styles.marginBottom] : [styles.marginEnd, styles.marginBottom]
|
|
37
|
-
})
|
|
69
|
+
});
|
|
38
70
|
});
|
|
39
71
|
if (buttons.length < emojiLimit) {
|
|
40
|
-
buttons.push(/*#__PURE__*/React.createElement(
|
|
72
|
+
buttons.push(/*#__PURE__*/React.createElement(ReactionMorePressable, {
|
|
41
73
|
key: REACTION_MORE_KEY,
|
|
42
74
|
onPress: onOpenReactionList
|
|
43
|
-
}
|
|
44
|
-
pressed
|
|
45
|
-
}) => /*#__PURE__*/React.createElement(ReactionRoundedButton.More, {
|
|
46
|
-
pressed: pressed
|
|
47
|
-
})));
|
|
75
|
+
}));
|
|
48
76
|
}
|
|
49
77
|
return buttons;
|
|
50
78
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["React","Pressable","createStyleSheet","useUIKitTheme","useForceUpdate","useGroupChannelHandler","getReactionCount","DEFAULT_LONG_PRESS_DELAY","useReaction","useSendbirdChat","ReactionRoundedButton","NUM_COL","REACTION_MORE_KEY","createOnPressReaction","reaction","channel","message","reacted","deleteReaction","key","addReaction","createReactionButtons","getIconSource","emojiLimit","onOpenReactionList","onOpenReactionUserList","reactionAddonType","reactions","buttons","map","index","isNotLastOfRow","isNotLastOfCol","length","createElement","onPress","hasCurrentUserReacted","onLongPress","delayLongPress","pressed","source","count","style","styles","marginEnd","marginBottom","push","More","MessageReactionAddon","_message$reactions","colors","sdk","emojiManager","openReactionList","openReactionUserList","forceUpdate","onReactionUpdated","_","event","messageId","applyReactionEvent","reactionButtons","reactionKey","emoji","allEmojiMap","getEmojiIconSource","allEmoji","focusIndex","containerStyle","reactionContainer","reactionThreadParentMessageContainer","backgroundColor","background","borderColor","ui","rounded","enabled","alignItems","flexDirection","flexWrap","padding","borderRadius","borderWidth"],"sources":["MessageReactionAddon.tsx"],"sourcesContent":["import React from 'react';\nimport { ImageProps, Pressable } from 'react-native';\n\nimport { createStyleSheet, useUIKitTheme } from '@sendbird/uikit-react-native-foundation';\nimport { useForceUpdate, useGroupChannelHandler } from '@sendbird/uikit-tools';\nimport type { SendbirdBaseChannel, SendbirdBaseMessage, SendbirdReaction } from '@sendbird/uikit-utils';\nimport { getReactionCount } from '@sendbird/uikit-utils';\n\nimport { DEFAULT_LONG_PRESS_DELAY } from '../../constants';\nimport { useReaction, useSendbirdChat } from '../../hooks/useContext';\nimport ReactionRoundedButton from './ReactionRoundedButton';\n\nconst NUM_COL = 4;\nconst REACTION_MORE_KEY = 'reaction-more-button';\nexport type ReactionAddonType = 'default' | 'thread_parent_message';\n\nconst createOnPressReaction = (\n reaction: SendbirdReaction,\n channel: SendbirdBaseChannel,\n message: SendbirdBaseMessage,\n reacted: boolean,\n) => {\n return () => {\n if (reacted) {\n return channel.deleteReaction(message, reaction.key);\n } else {\n return channel.addReaction(message, reaction.key);\n }\n };\n};\n\nconst createReactionButtons = (\n channel: SendbirdBaseChannel,\n message: SendbirdBaseMessage,\n getIconSource: (reactionKey: string) => ImageProps['source'],\n emojiLimit: number,\n onOpenReactionList: () => void,\n onOpenReactionUserList: (focusIndex: number) => void,\n reactionAddonType?: ReactionAddonType,\n) => {\n const reactions = message.reactions ?? [];\n const buttons = reactions.map((reaction, index) => {\n const isNotLastOfRow = index % NUM_COL !== NUM_COL - 1;\n const isNotLastOfCol = index < NUM_COL && reactions.length >= NUM_COL;\n return (\n <Pressable\n key={reaction.key}\n onPress={createOnPressReaction(reaction, channel, message, reaction.hasCurrentUserReacted)}\n onLongPress={() => onOpenReactionUserList(index)}\n delayLongPress={DEFAULT_LONG_PRESS_DELAY}\n >\n {({ pressed }) => (\n <ReactionRoundedButton\n source={getIconSource(reaction.key)}\n count={getReactionCount(reaction)}\n reacted={pressed || reaction.hasCurrentUserReacted}\n style={\n reactionAddonType === 'default'\n ? [isNotLastOfRow && styles.marginEnd, isNotLastOfCol && styles.marginBottom]\n : [styles.marginEnd, styles.marginBottom]\n }\n />\n )}\n </Pressable>\n );\n });\n if (buttons.length < emojiLimit) {\n buttons.push(\n <Pressable key={REACTION_MORE_KEY} onPress={onOpenReactionList}>\n {({ pressed }) => <ReactionRoundedButton.More pressed={pressed} />}\n </Pressable>,\n );\n }\n\n return buttons;\n};\n\nconst MessageReactionAddon = ({\n channel,\n message,\n reactionAddonType = 'default',\n}: {\n channel: SendbirdBaseChannel;\n message: SendbirdBaseMessage;\n reactionAddonType?: ReactionAddonType;\n}) => {\n const { colors } = useUIKitTheme();\n const { sdk, emojiManager } = useSendbirdChat();\n const { openReactionList, openReactionUserList } = useReaction();\n const forceUpdate = useForceUpdate();\n\n useGroupChannelHandler(sdk, {\n async onReactionUpdated(_, event) {\n if (event.messageId === message.messageId) {\n message.applyReactionEvent(event);\n forceUpdate();\n }\n },\n });\n\n if (reactionAddonType === 'default' && !message.reactions?.length) return null;\n\n const reactionButtons = createReactionButtons(\n channel,\n message,\n (reactionKey) => {\n const emoji = emojiManager.allEmojiMap[reactionKey];\n return emojiManager.getEmojiIconSource(emoji);\n },\n emojiManager.allEmoji.length,\n () => openReactionList({ channel, message }),\n (focusIndex) => openReactionUserList({ channel, message, focusIndex }),\n reactionAddonType,\n );\n\n const containerStyle =\n reactionAddonType === 'default' ? styles.reactionContainer : styles.reactionThreadParentMessageContainer;\n\n return (\n <Pressable\n style={[\n containerStyle,\n { backgroundColor: colors.background, borderColor: colors.ui.reaction.rounded.enabled.background },\n ]}\n >\n {reactionButtons}\n </Pressable>\n );\n};\n\nconst styles = createStyleSheet({\n reactionContainer: {\n alignItems: 'stretch',\n flexDirection: 'row',\n flexWrap: 'wrap',\n padding: 8,\n borderRadius: 16,\n borderWidth: 1,\n },\n reactionThreadParentMessageContainer: {\n flexDirection: 'row',\n flexWrap: 'wrap',\n },\n marginEnd: {\n marginEnd: 4.5,\n },\n marginBottom: {\n marginBottom: 4,\n },\n});\n\nexport default MessageReactionAddon;\n"],"mappings":"AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,SAAqBC,SAAS,QAAQ,cAAc;AAEpD,SAASC,gBAAgB,EAAEC,aAAa,QAAQ,yCAAyC;AACzF,SAASC,cAAc,EAAEC,sBAAsB,QAAQ,uBAAuB;AAE9E,SAASC,gBAAgB,QAAQ,uBAAuB;AAExD,SAASC,wBAAwB,QAAQ,iBAAiB;AAC1D,SAASC,WAAW,EAAEC,eAAe,QAAQ,wBAAwB;AACrE,OAAOC,qBAAqB,MAA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AAQ,EAAE,MAAM;IAChBC,OAAO,EAAE,CAAC;IACVC,YAAY,EAAE,EAAE;IAChBC,WAAW,EAAE;EACf,CAAC;EACDZ,oCAAoC,EAAE;IACpCQ,aAAa,EAAE,KAAK;IACpBC,QAAQ,EAAE;EACZ,CAAC;EACDnC,SAAS,EAAE;IACTA,SAAS,EAAE;EACb,CAAC;EACDC,YAAY,EAAE;IACZA,YAAY,EAAE;EAChB;AACF,CAAC,CAAC;AAEF,eAAeG,oBAAoB","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["React","useState","Pressable","createStyleSheet","useUIKitTheme","useForceUpdate","useGroupChannelHandler","getReactionCount","DEFAULT_LONG_PRESS_DELAY","useReaction","useSendbirdChat","ReactionRoundedButton","NUM_COL","REACTION_MORE_KEY","createOnPressReaction","reaction","channel","message","reacted","deleteReaction","key","addReaction","ReactionPressable","source","onOpenReactionUserList","index","style","pressed","setPressed","createElement","onPress","hasCurrentUserReacted","onLongPress","delayLongPress","onPressIn","onPressOut","count","ReactionMorePressable","More","createReactionButtons","getIconSource","emojiLimit","onOpenReactionList","reactionAddonType","reactions","buttons","map","isNotLastOfRow","isNotLastOfCol","length","styles","marginEnd","marginBottom","push","MessageReactionAddon","_message$reactions","colors","sdk","emojiManager","openReactionList","openReactionUserList","forceUpdate","onReactionUpdated","_","event","messageId","applyReactionEvent","reactionButtons","reactionKey","emoji","allEmojiMap","getEmojiIconSource","allEmoji","focusIndex","containerStyle","reactionContainer","reactionThreadParentMessageContainer","backgroundColor","background","borderColor","ui","rounded","enabled","alignItems","flexDirection","flexWrap","padding","borderRadius","borderWidth"],"sources":["MessageReactionAddon.tsx"],"sourcesContent":["import React, { useState } from 'react';\nimport { ImageProps, Pressable, StyleProp, ViewStyle } from 'react-native';\n\nimport { createStyleSheet, useUIKitTheme } from '@sendbird/uikit-react-native-foundation';\nimport { useForceUpdate, useGroupChannelHandler } from '@sendbird/uikit-tools';\nimport type { SendbirdBaseChannel, SendbirdBaseMessage, SendbirdReaction } from '@sendbird/uikit-utils';\nimport { getReactionCount } from '@sendbird/uikit-utils';\n\nimport { DEFAULT_LONG_PRESS_DELAY } from '../../constants';\nimport { useReaction, useSendbirdChat } from '../../hooks/useContext';\nimport ReactionRoundedButton from './ReactionRoundedButton';\n\nconst NUM_COL = 4;\nconst REACTION_MORE_KEY = 'reaction-more-button';\nexport type ReactionAddonType = 'default' | 'thread_parent_message';\n\nconst createOnPressReaction = (\n reaction: SendbirdReaction,\n channel: SendbirdBaseChannel,\n message: SendbirdBaseMessage,\n reacted: boolean,\n) => {\n return () => {\n if (reacted) {\n return channel.deleteReaction(message, reaction.key);\n } else {\n return channel.addReaction(message, reaction.key);\n }\n };\n};\n\nconst ReactionPressable = ({\n reaction,\n channel,\n message,\n source,\n onOpenReactionUserList,\n index,\n style,\n}: {\n reaction: SendbirdReaction;\n channel: SendbirdBaseChannel;\n message: SendbirdBaseMessage;\n source: ImageProps['source'];\n onOpenReactionUserList: (focusIndex: number) => void;\n index: number;\n style: StyleProp<ViewStyle>;\n}) => {\n const [pressed, setPressed] = useState(false);\n return (\n <Pressable\n onPress={createOnPressReaction(reaction, channel, message, reaction.hasCurrentUserReacted)}\n onLongPress={() => onOpenReactionUserList(index)}\n delayLongPress={DEFAULT_LONG_PRESS_DELAY}\n onPressIn={() => setPressed(true)}\n onPressOut={() => setPressed(false)}\n >\n <ReactionRoundedButton\n source={source}\n count={getReactionCount(reaction)}\n reacted={pressed || reaction.hasCurrentUserReacted}\n style={style}\n />\n </Pressable>\n );\n};\n\nconst ReactionMorePressable = ({ onPress }: { onPress: () => void }) => {\n const [pressed, setPressed] = useState(false);\n return (\n <Pressable onPress={onPress} onPressIn={() => setPressed(true)} onPressOut={() => setPressed(false)}>\n <ReactionRoundedButton.More pressed={pressed} />\n </Pressable>\n );\n};\n\nconst createReactionButtons = (\n channel: SendbirdBaseChannel,\n message: SendbirdBaseMessage,\n getIconSource: (reactionKey: string) => ImageProps['source'],\n emojiLimit: number,\n onOpenReactionList: () => void,\n onOpenReactionUserList: (focusIndex: number) => void,\n reactionAddonType?: ReactionAddonType,\n) => {\n const reactions = message.reactions ?? [];\n const buttons = reactions.map((reaction, index) => {\n const isNotLastOfRow = index % NUM_COL !== NUM_COL - 1;\n const isNotLastOfCol = index < NUM_COL && reactions.length >= NUM_COL;\n return (\n <ReactionPressable\n key={reaction.key}\n reaction={reaction}\n channel={channel}\n message={message}\n source={getIconSource(reaction.key)}\n onOpenReactionUserList={onOpenReactionUserList}\n index={index}\n style={\n reactionAddonType === 'default'\n ? [isNotLastOfRow && styles.marginEnd, isNotLastOfCol && styles.marginBottom]\n : [styles.marginEnd, styles.marginBottom]\n }\n />\n );\n });\n if (buttons.length < emojiLimit) {\n buttons.push(<ReactionMorePressable key={REACTION_MORE_KEY} onPress={onOpenReactionList} />);\n }\n\n return buttons;\n};\n\nconst MessageReactionAddon = ({\n channel,\n message,\n reactionAddonType = 'default',\n}: {\n channel: SendbirdBaseChannel;\n message: SendbirdBaseMessage;\n reactionAddonType?: ReactionAddonType;\n}) => {\n const { colors } = useUIKitTheme();\n const { sdk, emojiManager } = useSendbirdChat();\n const { openReactionList, openReactionUserList } = useReaction();\n const forceUpdate = useForceUpdate();\n\n useGroupChannelHandler(sdk, {\n async onReactionUpdated(_, event) {\n if (event.messageId === message.messageId) {\n message.applyReactionEvent(event);\n forceUpdate();\n }\n },\n });\n\n if (reactionAddonType === 'default' && !message.reactions?.length) return null;\n\n const reactionButtons = createReactionButtons(\n channel,\n message,\n (reactionKey) => {\n const emoji = emojiManager.allEmojiMap[reactionKey];\n return emojiManager.getEmojiIconSource(emoji);\n },\n emojiManager.allEmoji.length,\n () => openReactionList({ channel, message }),\n (focusIndex) => openReactionUserList({ channel, message, focusIndex }),\n reactionAddonType,\n );\n\n const containerStyle =\n reactionAddonType === 'default' ? styles.reactionContainer : styles.reactionThreadParentMessageContainer;\n\n return (\n <Pressable\n style={[\n containerStyle,\n { backgroundColor: colors.background, borderColor: colors.ui.reaction.rounded.enabled.background },\n ]}\n >\n {reactionButtons}\n </Pressable>\n );\n};\n\nconst styles = createStyleSheet({\n reactionContainer: {\n alignItems: 'stretch',\n flexDirection: 'row',\n flexWrap: 'wrap',\n padding: 8,\n borderRadius: 16,\n borderWidth: 1,\n },\n reactionThreadParentMessageContainer: {\n flexDirection: 'row',\n flexWrap: 'wrap',\n },\n marginEnd: {\n marginEnd: 4.5,\n },\n marginBottom: {\n marginBottom: 4,\n },\n});\n\nexport default MessageReactionAddon;\n"],"mappings":"AAAA,OAAOA,KAAK,IAAIC,QAAQ,QAAQ,OAAO;AACvC,SAAqBC,SAAS,QAA8B,cAAc;AAE1E,SAASC,gBAAgB,EAAEC,aAAa,QAAQ,yCAAyC;AACzF,SAASC,cAAc,EAAEC,sBAAsB,QAAQ,uBAAuB;AAE9E,SAASC,gBAAgB,QAAQ,uBAAuB;AAExD,SAASC,wBAAwB,QAAQ,iBAAiB;AAC1D,SAASC,WAAW,EAAEC,eAAe,QAAQ,wBAAwB;AACrE,OAAOC,qBAAqB,MAAM,yBAAyB;AAE3D,MAAMC,OAAO,GAAG,CAAC;AACjB,MAAMC,iBAAiB,GAAG,sBAAsB;AAGhD,MAAMC,qBAAqB,GAAGA,CAC5BC,QAA0B,EAC1BC,OAA4B,EAC5BC,OAA4B,EAC5BC,OAAgB,KACb;EACH,OAAO,MAAM;IACX,IAAIA,OAAO,EAAE;MACX,OAAOF,OAAO,CAACG,cAAc,CAACF,OAAO,EAAEF,QAAQ,CAACK,GAAG,CAAC;IACtD,CAAC,MAAM;MACL,OAAOJ,OAAO,CAACK,WAAW,CAACJ,OAAO,EAAEF,QAAQ,CAACK,GAAG,CAAC;IACnD;EACF,CAAC;AACH,CAAC;AAED,MAAME,iBAAiB,GAAGA,CAAC;EACzBP,QAAQ;EACRC,OAAO;EACPC,OAAO;EACPM,MAAM;EACNC,sBAAsB;EACtBC,KAAK;EACLC;AASF,CAAC,KAAK;EACJ,MAAM,CAACC,OAAO,EAAEC,UAAU,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,eAAe,EAAErB,MAAM,CAACsB,UAAU;MAAEC,WAAW,EAAEvB,MAAM,CAACwB,EAAE,CAACjE,QAAQ,CAACkE,OAAO,CAACC,OAAO,CAACJ;IAAW,CAAC;EAClG,GAEDX,eACQ,CAAC;AAEhB,CAAC;AAED,MAAMjB,MAAM,GAAG/C,gBAAgB,CAAC;EAC9BwE,iBAAiB,EAAE;IACjBQ,UAAU,EAAE,SAAS;IACrBC,aAAa,EAAE,KAAK;IACpBC,QAAQ,EAAE,MAAM;IAChBC,OAAO,EAAE,CAAC;IACVC,YAAY,EAAE,EAAE;IAChBC,WAAW,EAAE;EACf,CAAC;EACDZ,oCAAoC,EAAE;IACpCQ,aAAa,EAAE,KAAK;IACpBC,QAAQ,EAAE;EACZ,CAAC;EACDlC,SAAS,EAAE;IACTA,SAAS,EAAE;EACb,CAAC;EACDC,YAAY,EAAE;IACZA,YAAY,EAAE;EAChB;AACF,CAAC,CAAC;AAEF,eAAeE,oBAAoB","ignoreList":[]}
|
|
@@ -1,8 +1,48 @@
|
|
|
1
|
-
import React from 'react';
|
|
1
|
+
import React, { useState } from 'react';
|
|
2
2
|
import { FlatList, Pressable, View, useWindowDimensions } from 'react-native';
|
|
3
3
|
import { Image, Modal, createStyleSheet, useUIKitTheme } from '@sendbird/uikit-react-native-foundation';
|
|
4
4
|
import { Logger, useSafeAreaPadding } from '@sendbird/uikit-utils';
|
|
5
5
|
import { UNKNOWN_USER_ID } from '../../constants';
|
|
6
|
+
const ReactionEmojiPressable = ({
|
|
7
|
+
emojiKey,
|
|
8
|
+
url,
|
|
9
|
+
message,
|
|
10
|
+
channel,
|
|
11
|
+
currentUserId,
|
|
12
|
+
selectedBackground,
|
|
13
|
+
enabledBackground,
|
|
14
|
+
onClose
|
|
15
|
+
}) => {
|
|
16
|
+
var _message$reactions;
|
|
17
|
+
const [pressed, setPressed] = useState(false);
|
|
18
|
+
const reactedUserIds = (message === null || message === void 0 || (_message$reactions = message.reactions) === null || _message$reactions === void 0 || (_message$reactions = _message$reactions.find(it => it.key === emojiKey)) === null || _message$reactions === void 0 ? void 0 : _message$reactions.userIds) ?? [];
|
|
19
|
+
const idx = reactedUserIds.indexOf(currentUserId ?? UNKNOWN_USER_ID);
|
|
20
|
+
const reacted = idx > -1;
|
|
21
|
+
return /*#__PURE__*/React.createElement(Pressable, {
|
|
22
|
+
onPress: async () => {
|
|
23
|
+
if (message && channel) {
|
|
24
|
+
const action = (msg, key) => {
|
|
25
|
+
return reacted ? channel.deleteReaction(msg, key) : channel.addReaction(msg, key);
|
|
26
|
+
};
|
|
27
|
+
action(message, emojiKey).catch(error => {
|
|
28
|
+
const operation = reacted ? 'remove' : 'add';
|
|
29
|
+
Logger.warn(`Failed to ${operation} reaction (emojiKey=${emojiKey})`, error);
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
await onClose();
|
|
33
|
+
},
|
|
34
|
+
onPressIn: () => setPressed(true),
|
|
35
|
+
onPressOut: () => setPressed(false),
|
|
36
|
+
style: [styles.button, {
|
|
37
|
+
backgroundColor: reacted || pressed ? selectedBackground : enabledBackground
|
|
38
|
+
}]
|
|
39
|
+
}, /*#__PURE__*/React.createElement(Image, {
|
|
40
|
+
source: {
|
|
41
|
+
uri: url
|
|
42
|
+
},
|
|
43
|
+
style: styles.emoji
|
|
44
|
+
}));
|
|
45
|
+
};
|
|
6
46
|
const NUM_COLUMN = 6;
|
|
7
47
|
const ReactionListBottomSheet = ({
|
|
8
48
|
visible,
|
|
@@ -57,36 +97,18 @@ const ReactionListBottomSheet = ({
|
|
|
57
97
|
url
|
|
58
98
|
}
|
|
59
99
|
}) => {
|
|
60
|
-
var _message$reactions;
|
|
61
|
-
const reactedUserIds = (message === null || message === void 0 || (_message$reactions = message.reactions) === null || _message$reactions === void 0 || (_message$reactions = _message$reactions.find(it => it.key === key)) === null || _message$reactions === void 0 ? void 0 : _message$reactions.userIds) ?? [];
|
|
62
|
-
const idx = reactedUserIds.indexOf((currentUser === null || currentUser === void 0 ? void 0 : currentUser.userId) ?? UNKNOWN_USER_ID);
|
|
63
|
-
const reacted = idx > -1;
|
|
64
100
|
return /*#__PURE__*/React.createElement(View, {
|
|
65
101
|
style: styles.emojiItem
|
|
66
|
-
}, /*#__PURE__*/React.createElement(
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
}
|
|
77
|
-
await onClose();
|
|
78
|
-
},
|
|
79
|
-
style: ({
|
|
80
|
-
pressed
|
|
81
|
-
}) => [styles.button, {
|
|
82
|
-
backgroundColor: reacted || pressed ? color.selected.background : color.enabled.background
|
|
83
|
-
}]
|
|
84
|
-
}, /*#__PURE__*/React.createElement(Image, {
|
|
85
|
-
source: {
|
|
86
|
-
uri: url
|
|
87
|
-
},
|
|
88
|
-
style: styles.emoji
|
|
89
|
-
})));
|
|
102
|
+
}, /*#__PURE__*/React.createElement(ReactionEmojiPressable, {
|
|
103
|
+
emojiKey: key,
|
|
104
|
+
url: url,
|
|
105
|
+
message: message,
|
|
106
|
+
channel: channel,
|
|
107
|
+
currentUserId: currentUser === null || currentUser === void 0 ? void 0 : currentUser.userId,
|
|
108
|
+
selectedBackground: color.selected.background,
|
|
109
|
+
enabledBackground: color.enabled.background,
|
|
110
|
+
onClose: onClose
|
|
111
|
+
}));
|
|
90
112
|
}
|
|
91
113
|
})));
|
|
92
114
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["React","FlatList","Pressable","View","useWindowDimensions","Image","Modal","createStyleSheet","useUIKitTheme","Logger","useSafeAreaPadding","UNKNOWN_USER_ID","NUM_COLUMN","ReactionListBottomSheet","visible","onClose","onDismiss","reactionCtx","chatCtx","width","safeArea","colors","currentUser","emojiManager","channel","message","color","ui","reaction","default","createElement","type","Boolean","backgroundStyle","styles","modal","style","container","paddingBottom","backgroundColor","dialog","none","background","paddingStart","paddingHorizontal","paddingEnd","data","allEmoji","numColumns","keyExtractor","item","key","contentContainerStyle","flatlist","ItemSeparatorComponent","height","renderItem","url","_message$reactions","reactedUserIds","reactions","find","it","userIds","idx","indexOf","userId","reacted","emojiItem","onPress","action","deleteReaction","addReaction","catch","error","warn","pressed","button","selected","enabled","source","uri","emoji","overflow","borderTopStartRadius","borderTopEndRadius","paddingTop","flexDirection","alignItems","justifyContent","padding","borderRadius"],"sources":["ReactionListBottomSheet.tsx"],"sourcesContent":["import React from 'react';\nimport { FlatList, Pressable, View, useWindowDimensions } from 'react-native';\n\nimport type { BaseMessage } from '@sendbird/chat/message';\nimport { Image, Modal, createStyleSheet, useUIKitTheme } from '@sendbird/uikit-react-native-foundation';\nimport { Logger, useSafeAreaPadding } from '@sendbird/uikit-utils';\n\nimport { UNKNOWN_USER_ID } from '../../constants';\nimport type { ReactionBottomSheetProps } from './index';\n\nconst NUM_COLUMN = 6;\nconst ReactionListBottomSheet = ({ visible, onClose, onDismiss, reactionCtx, chatCtx }: ReactionBottomSheetProps) => {\n const { width } = useWindowDimensions();\n const safeArea = useSafeAreaPadding(['bottom', 'left', 'right']);\n const { colors } = useUIKitTheme();\n\n const { currentUser, emojiManager } = chatCtx;\n const { channel, message } = reactionCtx;\n const color = colors.ui.reaction.default;\n\n return (\n <Modal\n type={'slide'}\n visible={Boolean(visible && channel && message)}\n onClose={onClose}\n onDismiss={onDismiss}\n backgroundStyle={styles.modal}\n >\n <View\n style={[\n styles.container,\n {\n width,\n paddingBottom: safeArea.paddingBottom,\n backgroundColor: colors.ui.dialog.default.none.background,\n paddingStart: safeArea.paddingStart + styles.container.paddingHorizontal,\n paddingEnd: safeArea.paddingEnd + styles.container.paddingHorizontal,\n },\n ]}\n >\n <FlatList\n data={emojiManager.allEmoji}\n numColumns={NUM_COLUMN}\n keyExtractor={(item) => item.key}\n contentContainerStyle={styles.flatlist}\n ItemSeparatorComponent={() => <View style={{ height: 16 }} />}\n renderItem={({ item: { key, url } }) => {\n const reactedUserIds = message?.reactions?.find((it) => it.key === key)?.userIds ?? [];\n\n const idx = reactedUserIds.indexOf(currentUser?.userId ?? UNKNOWN_USER_ID);\n const reacted = idx > -1;\n\n return (\n <View style={styles.emojiItem}>\n <Pressable\n key={key}\n onPress={async () => {\n if (message && channel) {\n const action = (message: BaseMessage, key: string) => {\n return reacted ? channel.deleteReaction(message, key) : channel.addReaction(message, key);\n };\n\n action(message, key).catch((error) => {\n Logger.warn('Failed to reaction', error);\n });\n }\n await onClose();\n }}\n style={({ pressed }) => [\n styles.button,\n { backgroundColor: reacted || pressed ? color.selected.background : color.enabled.background },\n ]}\n >\n <Image source={{ uri: url }} style={styles.emoji} />\n </Pressable>\n </View>\n );\n }}\n />\n </View>\n </Modal>\n );\n};\n\nconst styles = createStyleSheet({\n container: {\n overflow: 'hidden',\n borderTopStartRadius: 8,\n borderTopEndRadius: 8,\n paddingTop: 16,\n paddingHorizontal: 18,\n flexDirection: 'row',\n },\n modal: {\n alignItems: 'center',\n justifyContent: 'flex-end',\n },\n flatlist: {\n width: '100%',\n flexDirection: 'column',\n justifyContent: 'space-between',\n },\n emojiItem: {\n width: `${100 / NUM_COLUMN}%`,\n alignItems: 'center',\n },\n button: {\n width: 44,\n height: 44,\n padding: 4,\n borderRadius: 8,\n },\n emoji: {\n width: '100%',\n height: '100%',\n },\n});\n\nexport default ReactionListBottomSheet;\n"],"mappings":"AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,SAASC,QAAQ,EAAEC,SAAS,EAAEC,IAAI,EAAEC,mBAAmB,QAAQ,cAAc;AAG7E,SAASC,KAAK,EAAEC,KAAK,EAAEC,gBAAgB,EAAEC,aAAa,QAAQ,yCAAyC;AACvG,SAASC,MAAM,EAAEC,kBAAkB,QAAQ,uBAAuB;AAElE,SAASC,eAAe,QAAQ,iBAAiB;AAGjD,MAAMC,UAAU,GAAG,CAAC;AACpB,MAAMC,uBAAuB,GAAGA,CAAC;EAAEC,OAAO;EAAEC,OAAO;EAAEC,SAAS;EAAEC,WAAW;EA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ACVC,YAAY,EAAE;EAChB,CAAC;EACDT,KAAK,EAAE;IACL/D,KAAK,EAAE,MAAM;IACboC,MAAM,EAAE;EACV;AACF,CAAC,CAAC;AAEF,eAAe1C,uBAAuB","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["React","useState","FlatList","Pressable","View","useWindowDimensions","Image","Modal","createStyleSheet","useUIKitTheme","Logger","useSafeAreaPadding","UNKNOWN_USER_ID","ReactionEmojiPressable","emojiKey","url","message","channel","currentUserId","selectedBackground","enabledBackground","onClose","_message$reactions","pressed","setPressed","reactedUserIds","reactions","find","it","key","userIds","idx","indexOf","reacted","createElement","onPress","action","msg","deleteReaction","addReaction","catch","error","operation","warn","onPressIn","onPressOut","style","styles","button","backgroundColor","source","uri","emoji","NUM_COLUMN","ReactionListBottomSheet","visible","onDismiss","reactionCtx","chatCtx","width","safeArea","colors","currentUser","emojiManager","color","ui","reaction","default","type","Boolean","backgroundStyle","modal","container","paddingBottom","dialog","none","background","paddingStart","paddingHorizontal","paddingEnd","data","allEmoji","numColumns","keyExtractor","item","contentContainerStyle","flatlist","ItemSeparatorComponent","height","renderItem","emojiItem","userId","selected","enabled","overflow","borderTopStartRadius","borderTopEndRadius","paddingTop","flexDirection","alignItems","justifyContent","padding","borderRadius"],"sources":["ReactionListBottomSheet.tsx"],"sourcesContent":["import React, { useState } from 'react';\nimport { FlatList, Pressable, View, useWindowDimensions } from 'react-native';\n\nimport type { BaseMessage } from '@sendbird/chat/message';\nimport { Image, Modal, createStyleSheet, useUIKitTheme } from '@sendbird/uikit-react-native-foundation';\nimport { Logger, useSafeAreaPadding } from '@sendbird/uikit-utils';\nimport type { SendbirdBaseChannel, SendbirdBaseMessage } from '@sendbird/uikit-utils';\n\nimport { UNKNOWN_USER_ID } from '../../constants';\nimport type { ReactionBottomSheetProps } from './index';\n\nconst ReactionEmojiPressable = ({\n emojiKey,\n url,\n message,\n channel,\n currentUserId,\n selectedBackground,\n enabledBackground,\n onClose,\n}: {\n emojiKey: string;\n url: string;\n message: SendbirdBaseMessage | undefined;\n channel: SendbirdBaseChannel | undefined;\n currentUserId: string | undefined;\n selectedBackground: string;\n enabledBackground: string;\n onClose: () => Promise<void>;\n}) => {\n const [pressed, setPressed] = useState(false);\n\n const reactedUserIds = message?.reactions?.find((it) => it.key === emojiKey)?.userIds ?? [];\n const idx = reactedUserIds.indexOf(currentUserId ?? UNKNOWN_USER_ID);\n const reacted = idx > -1;\n\n return (\n <Pressable\n onPress={async () => {\n if (message && channel) {\n const action = (msg: BaseMessage, key: string) => {\n return reacted ? channel.deleteReaction(msg, key) : channel.addReaction(msg, key);\n };\n\n action(message, emojiKey).catch((error) => {\n const operation = reacted ? 'remove' : 'add';\n Logger.warn(`Failed to ${operation} reaction (emojiKey=${emojiKey})`, error);\n });\n }\n await onClose();\n }}\n onPressIn={() => setPressed(true)}\n onPressOut={() => setPressed(false)}\n style={[styles.button, { backgroundColor: reacted || pressed ? selectedBackground : enabledBackground }]}\n >\n <Image source={{ uri: url }} style={styles.emoji} />\n </Pressable>\n );\n};\n\nconst NUM_COLUMN = 6;\nconst ReactionListBottomSheet = ({ visible, onClose, onDismiss, reactionCtx, chatCtx }: ReactionBottomSheetProps) => {\n const { width } = useWindowDimensions();\n const safeArea = useSafeAreaPadding(['bottom', 'left', 'right']);\n const { colors } = useUIKitTheme();\n\n const { currentUser, emojiManager } = chatCtx;\n const { channel, message } = reactionCtx;\n const color = colors.ui.reaction.default;\n\n return (\n <Modal\n type={'slide'}\n visible={Boolean(visible && channel && message)}\n onClose={onClose}\n onDismiss={onDismiss}\n backgroundStyle={styles.modal}\n >\n <View\n style={[\n styles.container,\n {\n width,\n paddingBottom: safeArea.paddingBottom,\n backgroundColor: colors.ui.dialog.default.none.background,\n paddingStart: safeArea.paddingStart + styles.container.paddingHorizontal,\n paddingEnd: safeArea.paddingEnd + styles.container.paddingHorizontal,\n },\n ]}\n >\n <FlatList\n data={emojiManager.allEmoji}\n numColumns={NUM_COLUMN}\n keyExtractor={(item) => item.key}\n contentContainerStyle={styles.flatlist}\n ItemSeparatorComponent={() => <View style={{ height: 16 }} />}\n renderItem={({ item: { key, url } }) => {\n return (\n <View style={styles.emojiItem}>\n <ReactionEmojiPressable\n emojiKey={key}\n url={url}\n message={message}\n channel={channel}\n currentUserId={currentUser?.userId}\n selectedBackground={color.selected.background}\n enabledBackground={color.enabled.background}\n onClose={onClose}\n />\n </View>\n );\n }}\n />\n </View>\n </Modal>\n );\n};\n\nconst styles = createStyleSheet({\n container: {\n overflow: 'hidden',\n borderTopStartRadius: 8,\n borderTopEndRadius: 8,\n paddingTop: 16,\n paddingHorizontal: 18,\n flexDirection: 'row',\n },\n modal: {\n alignItems: 'center',\n justifyContent: 'flex-end',\n },\n flatlist: {\n width: '100%',\n flexDirection: 'column',\n justifyContent: 'space-between',\n },\n emojiItem: {\n width: `${100 / NUM_COLUMN}%`,\n alignItems: 'center',\n },\n button: {\n width: 44,\n height: 44,\n padding: 4,\n borderRadius: 8,\n },\n emoji: {\n width: '100%',\n height: '100%',\n },\n});\n\nexport default ReactionListBottomSheet;\n"],"mappings":"AAAA,OAAOA,KAAK,IAAIC,QAAQ,QAAQ,OAAO;AACvC,SAASC,QAAQ,EAAEC,SAAS,EAAEC,IAAI,EAAEC,mBAAmB,QAAQ,cAAc;AAG7E,SAASC,KAAK,EAAEC,KAAK,EAAEC,gBAAgB,EAAEC,aAAa,QAAQ,yCAAyC;AACvG,SAASC,MAAM,EAAEC,kBAAkB,QAAQ,uBAAuB;AAGlE,SAASC,eAAe,QAAQ,iBAAiB;AAGjD,MAAMC,sBAAsB,GAAGA,CAAC;EAC9BC,QAAQ;EACRC,GAAG;EACHC,OAAO;EACPC,OAAO;EACPC,aAAa;EACbC,kBAAkB;EAClBC,iBAAiB;EACjBC;AAUF,CAAC,KAAK;EAAA,IAAAC,kBAAA;EACJ,MAAM,CAACC,OAAO,EAAEC,UAAU,CAAC,GAAGvB,QAAQ,CAAC,KAAK,CAAC;EAE7C,MAAMwB,cA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EAAE,QAAQ;IAClBC,oBAAoB,EAAE,CAAC;IACvBC,kBAAkB,EAAE,CAAC;IACrBC,UAAU,EAAE,EAAE;IACdnB,iBAAiB,EAAE,EAAE;IACrBoB,aAAa,EAAE;EACjB,CAAC;EACD3B,KAAK,EAAE;IACL4B,UAAU,EAAE,QAAQ;IACpBC,cAAc,EAAE;EAClB,CAAC;EACDd,QAAQ,EAAE;IACR3B,KAAK,EAAE,MAAM;IACbuC,aAAa,EAAE,QAAQ;IACvBE,cAAc,EAAE;EAClB,CAAC;EACDV,SAAS,EAAE;IACT/B,KAAK,EAAE,GAAG,GAAG,GAAGN,UAAU,GAAG;IAC7B8C,UAAU,EAAE;EACd,CAAC;EACDnD,MAAM,EAAE;IACNW,KAAK,EAAE,EAAE;IACT6B,MAAM,EAAE,EAAE;IACVa,OAAO,EAAE,CAAC;IACVC,YAAY,EAAE;EAChB,CAAC;EACDlD,KAAK,EAAE;IACLO,KAAK,EAAE,MAAM;IACb6B,MAAM,EAAE;EACV;AACF,CAAC,CAAC;AAEF,eAAelC,uBAAuB","ignoreList":[]}
|
|
@@ -19,7 +19,7 @@ const ReactionUserListBottomSheet = ({
|
|
|
19
19
|
colors
|
|
20
20
|
} = useUIKitTheme();
|
|
21
21
|
const [tabIndex, setTabIndex] = useState(0);
|
|
22
|
-
const scrollRef = useRef();
|
|
22
|
+
const scrollRef = useRef(undefined);
|
|
23
23
|
const tabIndicatorValue = useRef([]);
|
|
24
24
|
const tabIndicatorAnimated = useRef({
|
|
25
25
|
x: new Animated.Value(0),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["React","useEffect","useRef","useState","Animated","Easing","I18nManager","Pressable","ScrollView","View","useWindowDimensions","Avatar","Divider","Image","Modal","Text","createStyleSheet","useUIKitTheme","getReactionCount","truncatedCount","useSafeAreaPadding","ReactionUserListBottomSheet","visible","onClose","onDismiss","reactionCtx","chatCtx","localizationCtx","onPressUserProfile","width","safeArea","colors","tabIndex","setTabIndex","scrollRef","tabIndicatorValue","tabIndicatorAnimated","x","Value","current","focusedWithLayoutCalculated","emojiManager","channel","message","focusIndex","STRINGS","color","ui","reaction","default","reactions","focusedReaction","containerSafeArea","paddingStart","styles","layout","paddingHorizontal","paddingEnd","focusTab","index","animated","indicatorValue","_scrollRef$current","animateTabIndicator","scrollTo","baseConfig","duration","easing","inOut","ease","useNativeDriver","parallel","timing","toValue","start","layoutCalculated","filter","Boolean","length","renderTabs","createElement","style","tabsWrapper","map","isFocused","key","isLastItem","emoji","allEmojiMap","tabItem","marginEnd","onPress","onLayout","e","indexForLayout","isRTL","nativeEvent","source","getEmojiIconSource","tabEmoji","button","selected","highlight","enabled","tabIndicator","backgroundColor","renderPage","userCountDifference","count","sampledUserInfoList","Fragment","reactedUserInfo","isGroupChannel","userId","pageItem","size","uri","profileUrl","containerStyle","avatar","subtitle2","flex","nickname","LABELS","USER_NO_NAME","body3","onBackground02","REACTION","MORE_USERS","type","backgroundStyle","modal","container","paddingBottom","dialog","none","background","ref","horizontal","bounces","showsHorizontalScrollIndicator","contentContainerStyle","tabsContainer","top","showsVerticalScrollIndicator","pageContainer","overflow","borderTopStartRadius","borderTopEndRadius","paddingTop","alignItems","justifyContent","flexGrow","flexDirection","height","position","bottom"],"sources":["ReactionUserListBottomSheet.tsx"],"sourcesContent":["import React, { useEffect, useRef, useState } from 'react';\nimport { Animated, Easing, I18nManager, Pressable, ScrollView, View, useWindowDimensions } from 'react-native';\n\nimport {\n Avatar,\n Divider,\n Image,\n Modal,\n Text,\n createStyleSheet,\n useUIKitTheme,\n} from '@sendbird/uikit-react-native-foundation';\nimport {\n SendbirdEmoji,\n SendbirdReaction,\n getReactionCount,\n truncatedCount,\n useSafeAreaPadding,\n} from '@sendbird/uikit-utils';\n\nimport type { ReactionBottomSheetProps } from './index';\n\nconst ReactionUserListBottomSheet = ({\n visible,\n onClose,\n onDismiss,\n reactionCtx,\n chatCtx,\n localizationCtx,\n onPressUserProfile,\n}: ReactionBottomSheetProps) => {\n const { width } = useWindowDimensions();\n const safeArea = useSafeAreaPadding(['left', 'right', 'bottom']);\n const { colors } = useUIKitTheme();\n\n const [tabIndex, setTabIndex] = useState(0);\n const scrollRef = useRef<ScrollView>();\n const tabIndicatorValue = useRef<Array<{ x: number; width: number }>>([]);\n const tabIndicatorAnimated = useRef({ x: new Animated.Value(0), width: new Animated.Value(0) }).current;\n const focusedWithLayoutCalculated = useRef(false);\n\n const { emojiManager } = chatCtx;\n const { channel, message, focusIndex } = reactionCtx;\n const { STRINGS } = localizationCtx;\n\n const color = colors.ui.reaction.default;\n const reactions = message?.reactions ?? [];\n const focusedReaction = reactions[tabIndex] as SendbirdReaction | undefined;\n const containerSafeArea = {\n paddingStart: safeArea.paddingStart + styles.layout.paddingHorizontal,\n paddingEnd: safeArea.paddingEnd + styles.layout.paddingHorizontal,\n };\n\n const focusTab = (index: number, animated = true) => {\n const indicatorValue = tabIndicatorValue.current[index];\n if (indicatorValue) {\n setTabIndex(index);\n animateTabIndicator(indicatorValue.x, indicatorValue.width, animated);\n scrollRef.current?.scrollTo({ x: indicatorValue.x, animated });\n }\n };\n\n const animateTabIndicator = (x: number, width: number, animated = true) => {\n const baseConfig = { duration: animated ? 300 : 0, easing: Easing.inOut(Easing.ease), useNativeDriver: false };\n Animated.parallel([\n Animated.timing(tabIndicatorAnimated.x, { toValue: x, ...baseConfig }),\n Animated.timing(tabIndicatorAnimated.width, { toValue: width, ...baseConfig }),\n ]).start();\n };\n\n const layoutCalculated = () => {\n return tabIndicatorValue.current.filter(Boolean).length === reactions.length;\n };\n\n useEffect(() => {\n if (!visible) {\n tabIndicatorValue.current = [];\n tabIndicatorAnimated.x = new Animated.Value(0);\n tabIndicatorAnimated.width = new Animated.Value(0);\n focusedWithLayoutCalculated.current = false;\n }\n }, [visible]);\n\n const renderTabs = () => {\n return (\n <Pressable style={styles.tabsWrapper}>\n {reactions.map((reaction, index) => {\n const isFocused = focusedReaction?.key === reaction.key;\n const isLastItem = reactions.length - 1 === index;\n const emoji = emojiManager.allEmojiMap[reaction.key] as SendbirdEmoji | undefined;\n\n return (\n <Pressable\n key={reaction.key}\n style={[styles.tabItem, isLastItem && { marginEnd: styles.layout.marginEnd }]}\n onPress={() => focusTab(index)}\n onLayout={(e) => {\n const indexForLayout = I18nManager.isRTL ? reactions.length - 1 - index : index;\n tabIndicatorValue.current[indexForLayout] = e.nativeEvent.layout;\n if (layoutCalculated()) {\n if (focusedWithLayoutCalculated.current) {\n // re-calculating layout when screen rotation\n focusTab(tabIndex, false);\n } else {\n focusedWithLayoutCalculated.current = true;\n focusTab(focusIndex);\n }\n }\n }}\n >\n <Image source={emojiManager.getEmojiIconSource(emoji)} style={styles.tabEmoji} />\n <Text button color={isFocused ? color.selected.highlight : color.enabled.highlight}>\n {truncatedCount(getReactionCount(reaction))}\n </Text>\n </Pressable>\n );\n })}\n <Animated.View\n style={[\n styles.tabIndicator,\n {\n start: tabIndicatorAnimated.x,\n width: tabIndicatorAnimated.width,\n backgroundColor: color.selected.highlight,\n },\n ]}\n />\n </Pressable>\n );\n };\n\n const renderPage = () => {\n const userCountDifference = (focusedReaction?.count || 0) - (focusedReaction?.sampledUserInfoList.length || 0);\n\n return (\n <>\n {focusedReaction?.sampledUserInfoList.map((reactedUserInfo) => {\n if (channel?.isGroupChannel()) {\n return (\n <Pressable\n key={reactedUserInfo.userId}\n onPress={async () => {\n await onClose();\n onPressUserProfile(reactedUserInfo);\n }}\n style={styles.pageItem}\n >\n <Avatar size={36} uri={reactedUserInfo?.profileUrl} containerStyle={styles.avatar} />\n <Text subtitle2 style={{ flex: 1 }}>\n {reactedUserInfo?.nickname || STRINGS.LABELS.USER_NO_NAME}\n </Text>\n </Pressable>\n );\n }\n return null;\n })}\n {userCountDifference > 0 && (\n <View style={styles.pageItem}>\n <Text body3 color={colors.onBackground02}>\n {STRINGS.REACTION.MORE_USERS(userCountDifference)}\n </Text>\n </View>\n )}\n </>\n );\n };\n\n return (\n <Modal\n type={'slide-no-gesture'}\n visible={Boolean(visible && channel && message)}\n onClose={onClose}\n onDismiss={onDismiss}\n backgroundStyle={styles.modal}\n >\n <View\n style={[\n styles.container,\n { width, paddingBottom: safeArea.paddingBottom, backgroundColor: colors.ui.dialog.default.none.background },\n ]}\n >\n <ScrollView\n ref={scrollRef as never}\n horizontal\n bounces={false}\n showsHorizontalScrollIndicator={false}\n contentContainerStyle={[containerSafeArea, styles.tabsContainer]}\n >\n {renderTabs()}\n </ScrollView>\n <Divider style={{ top: -1 }} />\n <ScrollView\n bounces={false}\n showsVerticalScrollIndicator={false}\n style={styles.pageContainer}\n contentContainerStyle={containerSafeArea}\n >\n {renderPage()}\n </ScrollView>\n </View>\n </Modal>\n );\n};\n\nconst styles = createStyleSheet({\n layout: {\n paddingHorizontal: 16,\n marginEnd: 0,\n },\n container: {\n overflow: 'hidden',\n borderTopStartRadius: 8,\n borderTopEndRadius: 8,\n paddingTop: 16,\n alignItems: 'center',\n },\n modal: {\n alignItems: 'center',\n justifyContent: 'flex-end',\n },\n tabsContainer: {\n flexGrow: 1,\n },\n tabsWrapper: {\n flexGrow: 1,\n flexDirection: 'row',\n alignItems: 'flex-start',\n justifyContent: 'center',\n height: 44,\n },\n tabItem: {\n marginEnd: 16,\n flexDirection: 'row',\n alignItems: 'center',\n justifyContent: 'center',\n },\n tabEmoji: {\n width: 28,\n height: 28,\n marginEnd: 4,\n },\n tabIndicator: {\n position: 'absolute',\n bottom: 0,\n height: 3,\n },\n pageContainer: {\n height: 216,\n width: '100%',\n },\n pageItem: {\n flexDirection: 'row',\n width: '100%',\n height: 48,\n alignItems: 'center',\n },\n avatar: {\n marginEnd: 16,\n },\n});\n\nexport default ReactionUserListBottomSheet;\n"],"mappings":"AAAA,OAAOA,KAAK,IAAIC,SAAS,EAAEC,MAAM,EAAEC,QAAQ,QAAQ,OAAO;AAC1D,SAASC,QAAQ,EAAEC,MAAM,EAAEC,WAAW,EAAEC,SAAS,EAAEC,UAAU,EAAEC,IAAI,EAAEC,mBAAmB,QA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,EAAE;IACRuC,aAAa,EAAE,KAAK;IACpB5H,KAAK,EAAE,MAAM;IACb6H,MAAM,EAAE,EAAE;IACVJ,UAAU,EAAE;EACd,CAAC;EACD/B,MAAM,EAAE;IACN7B,SAAS,EAAE;EACb;AACF,CAAC,CAAC;AAEF,eAAerE,2BAA2B","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["React","useEffect","useRef","useState","Animated","Easing","I18nManager","Pressable","ScrollView","View","useWindowDimensions","Avatar","Divider","Image","Modal","Text","createStyleSheet","useUIKitTheme","getReactionCount","truncatedCount","useSafeAreaPadding","ReactionUserListBottomSheet","visible","onClose","onDismiss","reactionCtx","chatCtx","localizationCtx","onPressUserProfile","width","safeArea","colors","tabIndex","setTabIndex","scrollRef","undefined","tabIndicatorValue","tabIndicatorAnimated","x","Value","current","focusedWithLayoutCalculated","emojiManager","channel","message","focusIndex","STRINGS","color","ui","reaction","default","reactions","focusedReaction","containerSafeArea","paddingStart","styles","layout","paddingHorizontal","paddingEnd","focusTab","index","animated","indicatorValue","_scrollRef$current","animateTabIndicator","scrollTo","baseConfig","duration","easing","inOut","ease","useNativeDriver","parallel","timing","toValue","start","layoutCalculated","filter","Boolean","length","renderTabs","createElement","style","tabsWrapper","map","isFocused","key","isLastItem","emoji","allEmojiMap","tabItem","marginEnd","onPress","onLayout","e","indexForLayout","isRTL","nativeEvent","source","getEmojiIconSource","tabEmoji","button","selected","highlight","enabled","tabIndicator","backgroundColor","renderPage","userCountDifference","count","sampledUserInfoList","Fragment","reactedUserInfo","isGroupChannel","userId","pageItem","size","uri","profileUrl","containerStyle","avatar","subtitle2","flex","nickname","LABELS","USER_NO_NAME","body3","onBackground02","REACTION","MORE_USERS","type","backgroundStyle","modal","container","paddingBottom","dialog","none","background","ref","horizontal","bounces","showsHorizontalScrollIndicator","contentContainerStyle","tabsContainer","top","showsVerticalScrollIndicator","pageContainer","overflow","borderTopStartRadius","borderTopEndRadius","paddingTop","alignItems","justifyContent","flexGrow","flexDirection","height","position","bottom"],"sources":["ReactionUserListBottomSheet.tsx"],"sourcesContent":["import React, { useEffect, useRef, useState } from 'react';\nimport { Animated, Easing, I18nManager, Pressable, ScrollView, View, useWindowDimensions } from 'react-native';\n\nimport {\n Avatar,\n Divider,\n Image,\n Modal,\n Text,\n createStyleSheet,\n useUIKitTheme,\n} from '@sendbird/uikit-react-native-foundation';\nimport {\n SendbirdEmoji,\n SendbirdReaction,\n getReactionCount,\n truncatedCount,\n useSafeAreaPadding,\n} from '@sendbird/uikit-utils';\n\nimport type { ReactionBottomSheetProps } from './index';\n\nconst ReactionUserListBottomSheet = ({\n visible,\n onClose,\n onDismiss,\n reactionCtx,\n chatCtx,\n localizationCtx,\n onPressUserProfile,\n}: ReactionBottomSheetProps) => {\n const { width } = useWindowDimensions();\n const safeArea = useSafeAreaPadding(['left', 'right', 'bottom']);\n const { colors } = useUIKitTheme();\n\n const [tabIndex, setTabIndex] = useState(0);\n const scrollRef = useRef<ScrollView | undefined>(undefined);\n const tabIndicatorValue = useRef<Array<{ x: number; width: number }>>([]);\n const tabIndicatorAnimated = useRef({ x: new Animated.Value(0), width: new Animated.Value(0) }).current;\n const focusedWithLayoutCalculated = useRef(false);\n\n const { emojiManager } = chatCtx;\n const { channel, message, focusIndex } = reactionCtx;\n const { STRINGS } = localizationCtx;\n\n const color = colors.ui.reaction.default;\n const reactions = message?.reactions ?? [];\n const focusedReaction = reactions[tabIndex] as SendbirdReaction | undefined;\n const containerSafeArea = {\n paddingStart: safeArea.paddingStart + styles.layout.paddingHorizontal,\n paddingEnd: safeArea.paddingEnd + styles.layout.paddingHorizontal,\n };\n\n const focusTab = (index: number, animated = true) => {\n const indicatorValue = tabIndicatorValue.current[index];\n if (indicatorValue) {\n setTabIndex(index);\n animateTabIndicator(indicatorValue.x, indicatorValue.width, animated);\n scrollRef.current?.scrollTo({ x: indicatorValue.x, animated });\n }\n };\n\n const animateTabIndicator = (x: number, width: number, animated = true) => {\n const baseConfig = { duration: animated ? 300 : 0, easing: Easing.inOut(Easing.ease), useNativeDriver: false };\n Animated.parallel([\n Animated.timing(tabIndicatorAnimated.x, { toValue: x, ...baseConfig }),\n Animated.timing(tabIndicatorAnimated.width, { toValue: width, ...baseConfig }),\n ]).start();\n };\n\n const layoutCalculated = () => {\n return tabIndicatorValue.current.filter(Boolean).length === reactions.length;\n };\n\n useEffect(() => {\n if (!visible) {\n tabIndicatorValue.current = [];\n tabIndicatorAnimated.x = new Animated.Value(0);\n tabIndicatorAnimated.width = new Animated.Value(0);\n focusedWithLayoutCalculated.current = false;\n }\n }, [visible]);\n\n const renderTabs = () => {\n return (\n <Pressable style={styles.tabsWrapper}>\n {reactions.map((reaction, index) => {\n const isFocused = focusedReaction?.key === reaction.key;\n const isLastItem = reactions.length - 1 === index;\n const emoji = emojiManager.allEmojiMap[reaction.key] as SendbirdEmoji | undefined;\n\n return (\n <Pressable\n key={reaction.key}\n style={[styles.tabItem, isLastItem && { marginEnd: styles.layout.marginEnd }]}\n onPress={() => focusTab(index)}\n onLayout={(e) => {\n const indexForLayout = I18nManager.isRTL ? reactions.length - 1 - index : index;\n tabIndicatorValue.current[indexForLayout] = e.nativeEvent.layout;\n if (layoutCalculated()) {\n if (focusedWithLayoutCalculated.current) {\n // re-calculating layout when screen rotation\n focusTab(tabIndex, false);\n } else {\n focusedWithLayoutCalculated.current = true;\n focusTab(focusIndex);\n }\n }\n }}\n >\n <Image source={emojiManager.getEmojiIconSource(emoji)} style={styles.tabEmoji} />\n <Text button color={isFocused ? color.selected.highlight : color.enabled.highlight}>\n {truncatedCount(getReactionCount(reaction))}\n </Text>\n </Pressable>\n );\n })}\n <Animated.View\n style={[\n styles.tabIndicator,\n {\n start: tabIndicatorAnimated.x,\n width: tabIndicatorAnimated.width,\n backgroundColor: color.selected.highlight,\n },\n ]}\n />\n </Pressable>\n );\n };\n\n const renderPage = () => {\n const userCountDifference = (focusedReaction?.count || 0) - (focusedReaction?.sampledUserInfoList.length || 0);\n\n return (\n <>\n {focusedReaction?.sampledUserInfoList.map((reactedUserInfo) => {\n if (channel?.isGroupChannel()) {\n return (\n <Pressable\n key={reactedUserInfo.userId}\n onPress={async () => {\n await onClose();\n onPressUserProfile(reactedUserInfo);\n }}\n style={styles.pageItem}\n >\n <Avatar size={36} uri={reactedUserInfo?.profileUrl} containerStyle={styles.avatar} />\n <Text subtitle2 style={{ flex: 1 }}>\n {reactedUserInfo?.nickname || STRINGS.LABELS.USER_NO_NAME}\n </Text>\n </Pressable>\n );\n }\n return null;\n })}\n {userCountDifference > 0 && (\n <View style={styles.pageItem}>\n <Text body3 color={colors.onBackground02}>\n {STRINGS.REACTION.MORE_USERS(userCountDifference)}\n </Text>\n </View>\n )}\n </>\n );\n };\n\n return (\n <Modal\n type={'slide-no-gesture'}\n visible={Boolean(visible && channel && message)}\n onClose={onClose}\n onDismiss={onDismiss}\n backgroundStyle={styles.modal}\n >\n <View\n style={[\n styles.container,\n { width, paddingBottom: safeArea.paddingBottom, backgroundColor: colors.ui.dialog.default.none.background },\n ]}\n >\n <ScrollView\n ref={scrollRef as never}\n horizontal\n bounces={false}\n showsHorizontalScrollIndicator={false}\n contentContainerStyle={[containerSafeArea, styles.tabsContainer]}\n >\n {renderTabs()}\n </ScrollView>\n <Divider style={{ top: -1 }} />\n <ScrollView\n bounces={false}\n showsVerticalScrollIndicator={false}\n style={styles.pageContainer}\n contentContainerStyle={containerSafeArea}\n >\n {renderPage()}\n </ScrollView>\n </View>\n </Modal>\n );\n};\n\nconst styles = createStyleSheet({\n layout: {\n paddingHorizontal: 16,\n marginEnd: 0,\n },\n container: {\n overflow: 'hidden',\n borderTopStartRadius: 8,\n borderTopEndRadius: 8,\n paddingTop: 16,\n alignItems: 'center',\n },\n modal: {\n alignItems: 'center',\n justifyContent: 'flex-end',\n },\n tabsContainer: {\n flexGrow: 1,\n },\n tabsWrapper: {\n flexGrow: 1,\n flexDirection: 'row',\n alignItems: 'flex-start',\n justifyContent: 'center',\n height: 44,\n },\n tabItem: {\n marginEnd: 16,\n flexDirection: 'row',\n alignItems: 'center',\n justifyContent: 'center',\n },\n tabEmoji: {\n width: 28,\n height: 28,\n marginEnd: 4,\n },\n tabIndicator: {\n position: 'absolute',\n bottom: 0,\n height: 3,\n },\n pageContainer: {\n height: 216,\n width: '100%',\n },\n pageItem: {\n flexDirection: 'row',\n width: '100%',\n height: 48,\n alignItems: 'center',\n },\n avatar: {\n marginEnd: 16,\n },\n});\n\nexport default ReactionUserListBottomSheet;\n"],"mappings":"AAAA,OAAOA,KAAK,IAAIC,SAAS,EAAEC,MAAM,EAAEC,QAAQ,QAAQ,OAAO;AAC1D,SAASC,QAAQ,EAAEC,MAAM,EAAEC,WAAW,EAAEC,SAAS,EAAEC,UAAU,EAAEC,IAAI,EAAEC,mBAAmB,QAAQ,cAAc;AAE9G,SACEC,MAAM,EACNC,OAAO,EACPC,KAAK,EACLC,KAAK,EACLC,IAAI,EACJC,gBAAgB,EAChBC,aAAa,QACR,yCAAyC;AAChD,SAGEC,gBAAgB,EAChBC,cAAc,EACdC,kBAAkB,QACb,uBAAuB;AAI9B,MAAMC,2BAA2B,GAAGA,CAAC;EACnCC,OAAO;EACPC,OAAO;EACPC,SAAS;EACTC,WAAW;EACXC,OAAO;EACPC,eAAe;EACfC;AACwB,CAAC,KAAK;EAC9B,MAAM;IAAEC;EAAM,CAAC,GAAGnB,mBAAmB,CAAC,CAAC;EACvC,MAAMoB,QAAQ,GAAGV,kBAAkB,CAAC,CAAC,MAAM,EAAE,OAAO,EAAE,QAAQ,CAAC,CAAC;EAChE,MAAM;IAAEW;EAAO,CAAC,GAAGd,aAAa,CAAC,CAAC;EAElC,MAAM,CAACe,QAAQ,EAAEC,WAAW,CAAC,GAAG9B,QAAQ,CAAC,CAAC,CAAC;EAC3C,MAAM+B,SAAS,GAAGhC,MAAM,CAAyBiC,SAAS,CAAC;EAC3D,MAAMC,iBAAiB,GAAGlC,MAAM,CAAsC,EAAE,CAAC;EACzE,MAAMmC,oBAAoB,GAAGnC,MAAM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pBH,UAAU,EAAE,YAAY;IACxBC,cAAc,EAAE,QAAQ;IACxBG,MAAM,EAAE;EACV,CAAC;EACDjE,OAAO,EAAE;IACPC,SAAS,EAAE,EAAE;IACb+D,aAAa,EAAE,KAAK;IACpBH,UAAU,EAAE,QAAQ;IACpBC,cAAc,EAAE;EAClB,CAAC;EACDpD,QAAQ,EAAE;IACRvE,KAAK,EAAE,EAAE;IACT8H,MAAM,EAAE,EAAE;IACVhE,SAAS,EAAE;EACb,CAAC;EACDc,YAAY,EAAE;IACZmD,QAAQ,EAAE,UAAU;IACpBC,MAAM,EAAE,CAAC;IACTF,MAAM,EAAE;EACV,CAAC;EACDT,aAAa,EAAE;IACbS,MAAM,EAAE,GAAG;IACX9H,KAAK,EAAE;EACT,CAAC;EACDsF,QAAQ,EAAE;IACRuC,aAAa,EAAE,KAAK;IACpB7H,KAAK,EAAE,MAAM;IACb8H,MAAM,EAAE,EAAE;IACVJ,UAAU,EAAE;EACd,CAAC;EACD/B,MAAM,EAAE;IACN7B,SAAS,EAAE;EACb;AACF,CAAC,CAAC;AAEF,eAAetE,2BAA2B","ignoreList":[]}
|
|
@@ -34,7 +34,7 @@ const GroupChannelMessageList = props => {
|
|
|
34
34
|
const isNewLineExistInChannelRef = useRef(false);
|
|
35
35
|
const scrolledAwayFromBottomRef = useRef(false);
|
|
36
36
|
const [isVisibleUnreadMessageFloating, setIsVisibleUnreadMessageFloating] = useState(false);
|
|
37
|
-
const viewableMessages = useRef();
|
|
37
|
+
const viewableMessages = useRef(undefined);
|
|
38
38
|
const hasUserMarkedAsUnreadRef = useRef(false);
|
|
39
39
|
const [unreadFirstMessage, setUnreadFirstMessage] = useState(undefined);
|
|
40
40
|
const pendingBottomReachedRef = useRef(null);
|
|
@@ -190,7 +190,7 @@ const GroupChannelMessageList = props => {
|
|
|
190
190
|
useEffect(() => {
|
|
191
191
|
isNewLineExistInChannelRef.current = !!props.isNewLineExistInChannel && !!viewableMessages.current;
|
|
192
192
|
}, [props.isNewLineExistInChannel, viewableMessages.current]);
|
|
193
|
-
const unreadMessagesFloatingPropsRef = useRef();
|
|
193
|
+
const unreadMessagesFloatingPropsRef = useRef(undefined);
|
|
194
194
|
const updateUnreadMessagesFloatingProps = useFreshCallback(() => {
|
|
195
195
|
const canAutoMarkAsRead = !scrolledAwayFromBottomRef.current && !hasUserMarkedAsUnreadRef.current && (hasSeenNewLineRef.current || !isNewLineExistInChannelRef.current);
|
|
196
196
|
unreadMessagesFloatingPropsRef.current = {
|