@sendbird/uikit-react-native 2.0.2 → 2.0.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.
Files changed (101) hide show
  1. package/README.md +2 -2
  2. package/lib/commonjs/components/MessageRenderer/MessageIncomingAvatar.js +2 -9
  3. package/lib/commonjs/components/MessageRenderer/MessageIncomingAvatar.js.map +1 -1
  4. package/lib/commonjs/components/UserActionBar.js +4 -7
  5. package/lib/commonjs/components/UserActionBar.js.map +1 -1
  6. package/lib/commonjs/containers/GroupChannelPreviewContainer.js +4 -23
  7. package/lib/commonjs/containers/GroupChannelPreviewContainer.js.map +1 -1
  8. package/lib/commonjs/containers/SendbirdUIKitContainer.js +7 -13
  9. package/lib/commonjs/containers/SendbirdUIKitContainer.js.map +1 -1
  10. package/lib/commonjs/contexts/{LocalizationCtx.js → Localization.js} +1 -1
  11. package/lib/commonjs/contexts/Localization.js.map +1 -0
  12. package/lib/commonjs/contexts/{PlatformServiceCtx.js → PlatformService.js} +1 -1
  13. package/lib/commonjs/contexts/PlatformService.js.map +1 -0
  14. package/lib/commonjs/contexts/{SendbirdChatCtx.js → SendbirdChat.js} +1 -1
  15. package/lib/commonjs/contexts/SendbirdChat.js.map +1 -0
  16. package/lib/commonjs/domain/groupChannelList/types.js.map +1 -1
  17. package/lib/commonjs/fragments/createGroupChannelFragment.js +1 -9
  18. package/lib/commonjs/fragments/createGroupChannelFragment.js.map +1 -1
  19. package/lib/commonjs/fragments/createGroupChannelListFragment.js +3 -2
  20. package/lib/commonjs/fragments/createGroupChannelListFragment.js.map +1 -1
  21. package/lib/commonjs/fragments/createGroupChannelMembersFragment.js +11 -11
  22. package/lib/commonjs/fragments/createGroupChannelMembersFragment.js.map +1 -1
  23. package/lib/commonjs/hooks/useContext.js +7 -17
  24. package/lib/commonjs/hooks/useContext.js.map +1 -1
  25. package/lib/commonjs/index.js +9 -32
  26. package/lib/commonjs/index.js.map +1 -1
  27. package/lib/commonjs/localization/StringSet.type.js +0 -6
  28. package/lib/commonjs/localization/StringSet.type.js.map +1 -1
  29. package/lib/commonjs/platform/createFileService.native.js.map +1 -1
  30. package/lib/commonjs/version.js +1 -1
  31. package/lib/commonjs/version.js.map +1 -1
  32. package/lib/module/components/MessageRenderer/MessageIncomingAvatar.js +3 -9
  33. package/lib/module/components/MessageRenderer/MessageIncomingAvatar.js.map +1 -1
  34. package/lib/module/components/UserActionBar.js +5 -8
  35. package/lib/module/components/UserActionBar.js.map +1 -1
  36. package/lib/module/containers/GroupChannelPreviewContainer.js +4 -23
  37. package/lib/module/containers/GroupChannelPreviewContainer.js.map +1 -1
  38. package/lib/module/containers/SendbirdUIKitContainer.js +4 -9
  39. package/lib/module/containers/SendbirdUIKitContainer.js.map +1 -1
  40. package/lib/module/contexts/{LocalizationCtx.js → Localization.js} +1 -1
  41. package/lib/module/contexts/Localization.js.map +1 -0
  42. package/lib/module/contexts/{PlatformServiceCtx.js → PlatformService.js} +1 -1
  43. package/lib/module/contexts/PlatformService.js.map +1 -0
  44. package/lib/module/contexts/{SendbirdChatCtx.js → SendbirdChat.js} +1 -1
  45. package/lib/module/contexts/SendbirdChat.js.map +1 -0
  46. package/lib/module/domain/groupChannelList/types.js.map +1 -1
  47. package/lib/module/fragments/createGroupChannelFragment.js +1 -9
  48. package/lib/module/fragments/createGroupChannelFragment.js.map +1 -1
  49. package/lib/module/fragments/createGroupChannelListFragment.js +3 -2
  50. package/lib/module/fragments/createGroupChannelListFragment.js.map +1 -1
  51. package/lib/module/fragments/createGroupChannelMembersFragment.js +9 -13
  52. package/lib/module/fragments/createGroupChannelMembersFragment.js.map +1 -1
  53. package/lib/module/hooks/useContext.js +3 -9
  54. package/lib/module/hooks/useContext.js.map +1 -1
  55. package/lib/module/index.js +4 -5
  56. package/lib/module/index.js.map +1 -1
  57. package/lib/module/localization/StringSet.type.js +0 -6
  58. package/lib/module/localization/StringSet.type.js.map +1 -1
  59. package/lib/module/platform/createFileService.native.js.map +1 -1
  60. package/lib/module/version.js +1 -1
  61. package/lib/module/version.js.map +1 -1
  62. package/lib/typescript/src/components/UserActionBar.d.ts +2 -4
  63. package/lib/typescript/src/containers/SendbirdUIKitContainer.d.ts +3 -7
  64. package/lib/typescript/src/contexts/{LocalizationCtx.d.ts → Localization.d.ts} +0 -0
  65. package/lib/typescript/src/contexts/{PlatformServiceCtx.d.ts → PlatformService.d.ts} +0 -0
  66. package/lib/typescript/src/contexts/{SendbirdChatCtx.d.ts → SendbirdChat.d.ts} +0 -0
  67. package/lib/typescript/src/domain/groupChannelList/types.d.ts +0 -2
  68. package/lib/typescript/src/hooks/useContext.d.ts +1 -2
  69. package/lib/typescript/src/index.d.ts +4 -5
  70. package/lib/typescript/src/localization/StringSet.type.d.ts +1 -6
  71. package/lib/typescript/src/platform/createFileService.native.d.ts +1 -1
  72. package/lib/typescript/src/version.d.ts +1 -1
  73. package/package.json +9 -9
  74. package/src/components/MessageRenderer/MessageIncomingAvatar.tsx +2 -9
  75. package/src/components/UserActionBar.tsx +4 -10
  76. package/src/containers/GroupChannelPreviewContainer.tsx +1 -20
  77. package/src/containers/SendbirdUIKitContainer.tsx +6 -26
  78. package/src/contexts/{LocalizationCtx.tsx → Localization.tsx} +0 -0
  79. package/src/contexts/{PlatformServiceCtx.tsx → PlatformService.tsx} +0 -0
  80. package/src/contexts/{SendbirdChatCtx.tsx → SendbirdChat.tsx} +0 -0
  81. package/src/domain/groupChannelList/types.ts +2 -2
  82. package/src/fragments/createGroupChannelFragment.tsx +8 -18
  83. package/src/fragments/createGroupChannelListFragment.tsx +3 -2
  84. package/src/fragments/createGroupChannelMembersFragment.tsx +25 -25
  85. package/src/hooks/useContext.ts +3 -10
  86. package/src/index.ts +4 -5
  87. package/src/localization/StringSet.type.ts +0 -12
  88. package/src/platform/createFileService.native.ts +1 -1
  89. package/src/version.ts +1 -1
  90. package/lib/commonjs/contexts/LocalizationCtx.js.map +0 -1
  91. package/lib/commonjs/contexts/PlatformServiceCtx.js.map +0 -1
  92. package/lib/commonjs/contexts/ProfileCardCtx.js +0 -119
  93. package/lib/commonjs/contexts/ProfileCardCtx.js.map +0 -1
  94. package/lib/commonjs/contexts/SendbirdChatCtx.js.map +0 -1
  95. package/lib/module/contexts/LocalizationCtx.js.map +0 -1
  96. package/lib/module/contexts/PlatformServiceCtx.js.map +0 -1
  97. package/lib/module/contexts/ProfileCardCtx.js +0 -97
  98. package/lib/module/contexts/ProfileCardCtx.js.map +0 -1
  99. package/lib/module/contexts/SendbirdChatCtx.js.map +0 -1
  100. package/lib/typescript/src/contexts/ProfileCardCtx.d.ts +0 -15
  101. package/src/contexts/ProfileCardCtx.tsx +0 -125
@@ -1 +0,0 @@
1
- {"version":3,"names":["React","useContext","useState","useSafeAreaInsets","Modal","OutlinedButton","ProfileCard","createStyleSheet","Logger","PASS","useIIFE","LocalizationContext","SendbirdChatContext","ProfileCardContext","createContext","ProfileCardProvider","children","onCreateChannel","onBeforeCreateChannel","chatContext","localizationContext","bottom","left","right","user","setUser","visible","setVisible","show","hide","Error","profileCardButton","isMe","currentUser","userId","undefined","onPressMessageButton","params","invitedUserIds","name","coverUrl","isDistinct","operatorUserIds","processedParams","channel","sdk","groupChannel","createChannel","warn","STRINGS","PROFILE_CARD","BUTTON_MESSAGE","Boolean","styles","modal","profileCardContainer","paddingLeft","paddingRight","paddingBottom","profileUrl","nickname","LABELS","USER_NO_NAME","BODY_LABEL","BODY","justifyContent","borderTopLeftRadius","borderTopRightRadius"],"sources":["ProfileCardCtx.tsx"],"sourcesContent":["import React, { useContext, useState } from 'react';\nimport { useSafeAreaInsets } from 'react-native-safe-area-context';\n\nimport { Modal, OutlinedButton, ProfileCard, createStyleSheet } from '@sendbird/uikit-react-native-foundation';\nimport type {\n SendbirdGroupChannel,\n SendbirdGroupChannelCreateParams,\n SendbirdMember,\n SendbirdUser,\n} from '@sendbird/uikit-utils';\nimport { Logger, PASS, useIIFE } from '@sendbird/uikit-utils';\n\nimport { LocalizationContext } from '../contexts/LocalizationCtx';\nimport { SendbirdChatContext } from '../contexts/SendbirdChatCtx';\n\ntype OnCreateChannel = (channel: SendbirdGroupChannel) => void;\ntype OnBeforeCreateChannel = (\n channelParams: SendbirdGroupChannelCreateParams,\n users: SendbirdUser[] | SendbirdMember[],\n) => SendbirdGroupChannelCreateParams | Promise<SendbirdGroupChannelCreateParams>;\n\nexport type ProfileCardContextType = {\n show(user: SendbirdUser | SendbirdMember): void;\n hide(): void;\n};\n\ntype Props = React.PropsWithChildren<{\n onCreateChannel?: OnCreateChannel;\n onBeforeCreateChannel?: OnBeforeCreateChannel;\n}>;\n\nexport const ProfileCardContext = React.createContext<ProfileCardContextType | null>(null);\nexport const ProfileCardProvider = ({ children, onCreateChannel, onBeforeCreateChannel = PASS }: Props) => {\n const chatContext = useContext(SendbirdChatContext);\n const localizationContext = useContext(LocalizationContext);\n const { bottom, left, right } = useSafeAreaInsets();\n\n const [user, setUser] = useState<SendbirdUser | SendbirdMember>();\n const [visible, setVisible] = useState(false);\n\n const show: ProfileCardContextType['show'] = (user) => {\n setUser(user);\n setVisible(true);\n };\n\n const hide: ProfileCardContextType['hide'] = () => {\n setVisible(false);\n };\n\n if (!chatContext) throw new Error('SendbirdChatContext is not provided');\n if (!localizationContext) throw new Error('LocalizationContext is not provided');\n\n const profileCardButton = useIIFE(() => {\n const isMe = chatContext.currentUser && user?.userId === chatContext.currentUser.userId;\n if (isMe) return undefined;\n\n const onPressMessageButton = async () => {\n if (user) {\n const params: SendbirdGroupChannelCreateParams = {\n invitedUserIds: [user.userId],\n name: '',\n coverUrl: '',\n isDistinct: false,\n };\n\n if (chatContext.currentUser) params.operatorUserIds = [chatContext.currentUser.userId];\n const processedParams = await onBeforeCreateChannel(params, [user]);\n\n hide();\n const channel = await chatContext.sdk.groupChannel.createChannel(processedParams);\n\n if (onCreateChannel) {\n onCreateChannel(channel);\n } else {\n Logger.warn(\n 'Please set `onCreateChannel` before message to user from profile card, see `profileCard` prop in the `SendbirdUIKitContainer` props',\n );\n }\n }\n };\n\n return (\n <OutlinedButton onPress={onPressMessageButton}>\n {localizationContext.STRINGS.PROFILE_CARD.BUTTON_MESSAGE}\n </OutlinedButton>\n );\n });\n\n return (\n <ProfileCardContext.Provider value={{ show, hide }}>\n {children}\n <Modal\n type={'slide'}\n onClose={hide}\n onDismiss={() => setUser(undefined)}\n visible={visible && Boolean(user)}\n backgroundStyle={styles.modal}\n >\n {user && (\n <ProfileCard\n containerStyle={[\n styles.profileCardContainer,\n { paddingLeft: left, paddingRight: right, paddingBottom: bottom },\n ]}\n uri={user.profileUrl}\n username={user.nickname || localizationContext.STRINGS.LABELS.USER_NO_NAME}\n bodyLabel={localizationContext.STRINGS.PROFILE_CARD.BODY_LABEL}\n body={localizationContext.STRINGS.PROFILE_CARD.BODY(user)}\n button={profileCardButton}\n />\n )}\n </Modal>\n </ProfileCardContext.Provider>\n );\n};\n\nconst styles = createStyleSheet({\n modal: {\n justifyContent: 'flex-end',\n },\n profileCardContainer: {\n borderTopLeftRadius: 8,\n borderTopRightRadius: 8,\n },\n});\n"],"mappings":"AAAA,OAAOA,KAAP,IAAgBC,UAAhB,EAA4BC,QAA5B,QAA4C,OAA5C;AACA,SAASC,iBAAT,QAAkC,gCAAlC;AAEA,SAASC,KAAT,EAAgBC,cAAhB,EAAgCC,WAAhC,EAA6CC,gBAA7C,QAAqE,yCAArE;AAOA,SAASC,MAAT,EAAiBC,IAAjB,EAAuBC,OAAvB,QAAsC,uBAAtC;AAEA,SAASC,mBAAT,QAAoC,6BAApC;AACA,SAASC,mBAAT,QAAoC,6BAApC;AAkBA,OAAO,MAAMC,kBAAkB,gBAAGb,KAAK,CAACc,aAAN,CAAmD,IAAnD,CAA3B;AACP,OAAO,MAAMC,mBAAmB,GAAG,QAAwE;EAAA,IAAvE;IAAEC,QAAF;IAAYC,eAAZ;IAA6BC,qBAAqB,GAAGT;EAArD,CAAuE;EACzG,MAAMU,WAAW,GAAGlB,UAAU,CAACW,mBAAD,CAA9B;EACA,MAAMQ,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B,CAAyCc,IAAzC,CAA8CxC,IAA9C,CARR;IASE,MAAM,EAAEO;EATV,EARJ,CAFF,CADF;AA0BD,CAlFM;AAoFP,MAAMsB,MAAM,GAAG9C,gBAAgB,CAAC;EAC9B+C,KAAK,EAAE;IACLW,cAAc,EAAE;EADX,CADuB;EAI9BV,oBAAoB,EAAE;IACpBW,mBAAmB,EAAE,CADD;IAEpBC,oBAAoB,EAAE;EAFF;AAJQ,CAAD,CAA/B"}
@@ -1 +0,0 @@
1
- {"version":3,"names":["React","useCallback","useEffect","useState","AppState","useAppFeatures","confirmAndMarkAsDelivered","useForceUpdate","SendbirdChatContext","createContext","SendbirdChatProvider","children","sdkInstance","enableAutoPushTokenRegistration","enableChannelListMessageReceiptStatus","enableChannelListTypingIndicator","currentUser","_setCurrentUser","forceUpdate","appFeatures","setCurrentUser","user","updateCurrentUserInfo","nickname","profile","Error","params","profileUrl","profileImage","markAsDeliveredWithChannel","channel","deliveryReceiptEnabled","listener","status","connectionState","setForegroundState","setBackgroundState","subscriber","addEventListener","remove","value","sdk","features","autoPushTokenRegistrationEnabled","channelListTypingIndicatorEnabled","channelListMessageReceiptStatusEnabled"],"sources":["SendbirdChatCtx.tsx"],"sourcesContent":["import React, { useCallback, useEffect, useState } from 'react';\nimport { AppState, AppStateStatus } from 'react-native';\n\nimport { useAppFeatures } from '@sendbird/uikit-chat-hooks';\nimport type {\n SendbirdChatSDK,\n SendbirdGroupChannel,\n SendbirdUser,\n SendbirdUserUpdateParams,\n} from '@sendbird/uikit-utils';\nimport { confirmAndMarkAsDelivered, useForceUpdate } from '@sendbird/uikit-utils';\n\nimport type { FileType } from '../platform/types';\n\ntype Props = React.PropsWithChildren<{\n sdkInstance: SendbirdChatSDK;\n\n enableAutoPushTokenRegistration: boolean;\n enableChannelListTypingIndicator: boolean;\n enableChannelListMessageReceiptStatus: boolean;\n}>;\n\ntype Context = {\n sdk: SendbirdChatSDK;\n currentUser?: SendbirdUser;\n setCurrentUser: React.Dispatch<React.SetStateAction<SendbirdUser | undefined>>;\n\n // helper functions\n updateCurrentUserInfo: (nickname?: string, profile?: string | FileType) => Promise<SendbirdUser>;\n markAsDeliveredWithChannel: (channel: SendbirdGroupChannel) => void;\n\n features: {\n // UIKit features\n autoPushTokenRegistrationEnabled: boolean;\n channelListTypingIndicatorEnabled: boolean;\n channelListMessageReceiptStatusEnabled: boolean;\n\n // Sendbird application features\n deliveryReceiptEnabled: boolean;\n broadcastChannelEnabled: boolean;\n superGroupChannelEnabled: boolean;\n reactionEnabled: boolean;\n };\n};\n\nexport const SendbirdChatContext = React.createContext<Context | null>(null);\nexport const SendbirdChatProvider = ({\n children,\n sdkInstance,\n enableAutoPushTokenRegistration,\n enableChannelListMessageReceiptStatus,\n enableChannelListTypingIndicator,\n}: Props) => {\n const [currentUser, _setCurrentUser] = useState<SendbirdUser>();\n const forceUpdate = useForceUpdate();\n const appFeatures = useAppFeatures(sdkInstance);\n\n const setCurrentUser: Context['setCurrentUser'] = useCallback((user) => {\n // NOTE: Sendbird SDK handle User object is always same object, so force update after setCurrentUser\n _setCurrentUser(user);\n forceUpdate();\n }, []);\n\n const updateCurrentUserInfo: Context['updateCurrentUserInfo'] = useCallback(\n async (nickname, profile) => {\n let user = currentUser;\n\n if (!user) throw new Error('Current user is not defined, please connect using `useConnection()` hook first');\n\n const params: SendbirdUserUpdateParams = { nickname };\n\n if (typeof profile === 'string') {\n params.profileUrl = profile;\n } else if (typeof profile === 'object') {\n params.profileImage = profile;\n } else {\n throw new Error(`Cannot update profile, not supported profile type(${typeof profile})`);\n }\n\n user = await sdkInstance.updateCurrentUserInfo(params);\n\n setCurrentUser(user);\n return user;\n },\n [sdkInstance, currentUser, setCurrentUser],\n );\n\n const markAsDeliveredWithChannel: Context['markAsDeliveredWithChannel'] = useCallback(\n (channel: SendbirdGroupChannel) => {\n if (appFeatures.deliveryReceiptEnabled) confirmAndMarkAsDelivered([channel]);\n },\n [sdkInstance, appFeatures.deliveryReceiptEnabled],\n );\n\n useEffect(() => {\n const listener = (status: AppStateStatus) => {\n // 'active' | 'background' | 'inactive' | 'unknown' | 'extension';\n if (status === 'active') sdkInstance.connectionState === 'CLOSED' && sdkInstance.setForegroundState();\n else if (status === 'background') sdkInstance.connectionState === 'OPEN' && sdkInstance.setBackgroundState();\n };\n\n const subscriber = AppState.addEventListener('change', listener);\n return () => subscriber.remove();\n }, [sdkInstance]);\n\n const value: Context = {\n sdk: sdkInstance,\n currentUser,\n setCurrentUser,\n\n updateCurrentUserInfo,\n markAsDeliveredWithChannel,\n\n features: {\n ...appFeatures,\n autoPushTokenRegistrationEnabled: enableAutoPushTokenRegistration,\n channelListTypingIndicatorEnabled: enableChannelListTypingIndicator,\n channelListMessageReceiptStatusEnabled: enableChannelListMessageReceiptStatus,\n },\n };\n\n return <SendbirdChatContext.Provider value={value}>{children}</SendbirdChatContext.Provider>;\n};\n"],"mappings":"AAAA,OAAOA,KAAP,IAAgBC,WAAhB,EAA6BC,SAA7B,EAAwCC,QAAxC,QAAwD,OAAxD;AACA,SAASC,QAAT,QAAyC,cAAzC;AAEA,SAASC,cAAT,QAA+B,4BAA/B;AAOA,SAASC,yBAAT,EAAoCC,cAApC,QAA0D,uBAA1D;AAmCA,OAAO,MAAMC,mBAAmB,gBAAGR,KAAK,CAACS,aAAN,CAAoC,IAApC,CAA5B;AACP,OAAO,MAAMC,oBAAoB,GAAG,QAMvB;EAAA,IANwB;IACnCC,QADmC;IAEnCC,WAFmC;IAGnCC,+BAHmC;IAInCC,qCAJmC;IAKnCC;EALmC,CAMxB;EACX,MAAM,CAACC,WAAD,EAAcC,eAAd,IAAiCd,QAAQ,EAA/C;EACA,MAAMe,WAAW,GAAGX,cAAc,EAAlC;EACA,MAAMY,WAAW,GAAGd,cAAc,CAACO,WAAD,CAAlC;EAEA,MAAMQ,cAAyC,GAAGnB,WAAW,CAAEoB,IAAD,IAAU;IACtE;IACAJ,eAAe,CAACI,IAAD,CAAf;;IACAH,WAAW;EACZ,CAJ4D,EAI1D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,EAA1C;IACnC,CAJD;;IAMA,MAAMC,UAAU,GAAGjC,QAAQ,CAACkC,gBAAT,CAA0B,QAA1B,EAAoCN,QAApC,CAAnB;IACA,OAAO,MAAMK,UAAU,CAACE,MAAX,EAAb;EACD,CATQ,EASN,CAAC3B,WAAD,CATM,CAAT;EAWA,MAAM4B,KAAc,GAAG;IACrBC,GAAG,EAAE7B,WADgB;IAErBI,WAFqB;IAGrBI,cAHqB;IAKrBE,qBALqB;IAMrBO,0BANqB;IAQrBa,QAAQ,EAAE,EACR,GAAGvB,WADK;MAERwB,gCAAgC,EAAE9B,+BAF1B;MAGR+B,iCAAiC,EAAE7B,gCAH3B;MAIR8B,sCAAsC,EAAE/B;IAJhC;EARW,CAAvB;EAgBA,oBAAO,oBAAC,mBAAD,CAAqB,QAArB;IAA8B,KAAK,EAAE0B;EAArC,GAA6C7B,QAA7C,CAAP;AACD,CA5EM"}
@@ -1,15 +0,0 @@
1
- import React from 'react';
2
- import type { SendbirdGroupChannel, SendbirdGroupChannelCreateParams, SendbirdMember, SendbirdUser } from '@sendbird/uikit-utils';
3
- declare type OnCreateChannel = (channel: SendbirdGroupChannel) => void;
4
- declare type OnBeforeCreateChannel = (channelParams: SendbirdGroupChannelCreateParams, users: SendbirdUser[] | SendbirdMember[]) => SendbirdGroupChannelCreateParams | Promise<SendbirdGroupChannelCreateParams>;
5
- export declare type ProfileCardContextType = {
6
- show(user: SendbirdUser | SendbirdMember): void;
7
- hide(): void;
8
- };
9
- declare type Props = React.PropsWithChildren<{
10
- onCreateChannel?: OnCreateChannel;
11
- onBeforeCreateChannel?: OnBeforeCreateChannel;
12
- }>;
13
- export declare const ProfileCardContext: React.Context<ProfileCardContextType | null>;
14
- export declare const ProfileCardProvider: ({ children, onCreateChannel, onBeforeCreateChannel }: Props) => JSX.Element;
15
- export {};
@@ -1,125 +0,0 @@
1
- import React, { useContext, useState } from 'react';
2
- import { useSafeAreaInsets } from 'react-native-safe-area-context';
3
-
4
- import { Modal, OutlinedButton, ProfileCard, createStyleSheet } from '@sendbird/uikit-react-native-foundation';
5
- import type {
6
- SendbirdGroupChannel,
7
- SendbirdGroupChannelCreateParams,
8
- SendbirdMember,
9
- SendbirdUser,
10
- } from '@sendbird/uikit-utils';
11
- import { Logger, PASS, useIIFE } from '@sendbird/uikit-utils';
12
-
13
- import { LocalizationContext } from '../contexts/LocalizationCtx';
14
- import { SendbirdChatContext } from '../contexts/SendbirdChatCtx';
15
-
16
- type OnCreateChannel = (channel: SendbirdGroupChannel) => void;
17
- type OnBeforeCreateChannel = (
18
- channelParams: SendbirdGroupChannelCreateParams,
19
- users: SendbirdUser[] | SendbirdMember[],
20
- ) => SendbirdGroupChannelCreateParams | Promise<SendbirdGroupChannelCreateParams>;
21
-
22
- export type ProfileCardContextType = {
23
- show(user: SendbirdUser | SendbirdMember): void;
24
- hide(): void;
25
- };
26
-
27
- type Props = React.PropsWithChildren<{
28
- onCreateChannel?: OnCreateChannel;
29
- onBeforeCreateChannel?: OnBeforeCreateChannel;
30
- }>;
31
-
32
- export const ProfileCardContext = React.createContext<ProfileCardContextType | null>(null);
33
- export const ProfileCardProvider = ({ children, onCreateChannel, onBeforeCreateChannel = PASS }: Props) => {
34
- const chatContext = useContext(SendbirdChatContext);
35
- const localizationContext = useContext(LocalizationContext);
36
- const { bottom, left, right } = useSafeAreaInsets();
37
-
38
- const [user, setUser] = useState<SendbirdUser | SendbirdMember>();
39
- const [visible, setVisible] = useState(false);
40
-
41
- const show: ProfileCardContextType['show'] = (user) => {
42
- setUser(user);
43
- setVisible(true);
44
- };
45
-
46
- const hide: ProfileCardContextType['hide'] = () => {
47
- setVisible(false);
48
- };
49
-
50
- if (!chatContext) throw new Error('SendbirdChatContext is not provided');
51
- if (!localizationContext) throw new Error('LocalizationContext is not provided');
52
-
53
- const profileCardButton = useIIFE(() => {
54
- const isMe = chatContext.currentUser && user?.userId === chatContext.currentUser.userId;
55
- if (isMe) return undefined;
56
-
57
- const onPressMessageButton = async () => {
58
- if (user) {
59
- const params: SendbirdGroupChannelCreateParams = {
60
- invitedUserIds: [user.userId],
61
- name: '',
62
- coverUrl: '',
63
- isDistinct: false,
64
- };
65
-
66
- if (chatContext.currentUser) params.operatorUserIds = [chatContext.currentUser.userId];
67
- const processedParams = await onBeforeCreateChannel(params, [user]);
68
-
69
- hide();
70
- const channel = await chatContext.sdk.groupChannel.createChannel(processedParams);
71
-
72
- if (onCreateChannel) {
73
- onCreateChannel(channel);
74
- } else {
75
- Logger.warn(
76
- 'Please set `onCreateChannel` before message to user from profile card, see `profileCard` prop in the `SendbirdUIKitContainer` props',
77
- );
78
- }
79
- }
80
- };
81
-
82
- return (
83
- <OutlinedButton onPress={onPressMessageButton}>
84
- {localizationContext.STRINGS.PROFILE_CARD.BUTTON_MESSAGE}
85
- </OutlinedButton>
86
- );
87
- });
88
-
89
- return (
90
- <ProfileCardContext.Provider value={{ show, hide }}>
91
- {children}
92
- <Modal
93
- type={'slide'}
94
- onClose={hide}
95
- onDismiss={() => setUser(undefined)}
96
- visible={visible && Boolean(user)}
97
- backgroundStyle={styles.modal}
98
- >
99
- {user && (
100
- <ProfileCard
101
- containerStyle={[
102
- styles.profileCardContainer,
103
- { paddingLeft: left, paddingRight: right, paddingBottom: bottom },
104
- ]}
105
- uri={user.profileUrl}
106
- username={user.nickname || localizationContext.STRINGS.LABELS.USER_NO_NAME}
107
- bodyLabel={localizationContext.STRINGS.PROFILE_CARD.BODY_LABEL}
108
- body={localizationContext.STRINGS.PROFILE_CARD.BODY(user)}
109
- button={profileCardButton}
110
- />
111
- )}
112
- </Modal>
113
- </ProfileCardContext.Provider>
114
- );
115
- };
116
-
117
- const styles = createStyleSheet({
118
- modal: {
119
- justifyContent: 'flex-end',
120
- },
121
- profileCardContainer: {
122
- borderTopLeftRadius: 8,
123
- borderTopRightRadius: 8,
124
- },
125
- });