@cometchat/chat-uikit-react-native 4.0.1 → 4.0.2
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/README.md +1 -1
- package/android/.gradle/7.4/checksums/checksums.lock +0 -0
- package/android/.gradle/7.4/checksums/md5-checksums.bin +0 -0
- package/android/.gradle/7.4/checksums/sha1-checksums.bin +0 -0
- package/android/.gradle/7.4/dependencies-accessors/dependencies-accessors.lock +0 -0
- package/android/.gradle/7.4/fileChanges/last-build.bin +0 -0
- package/android/.gradle/7.4/fileHashes/fileHashes.lock +0 -0
- package/android/.gradle/7.4/gc.properties +0 -0
- package/android/.gradle/buildOutputCleanup/buildOutputCleanup.lock +0 -0
- package/android/.gradle/buildOutputCleanup/cache.properties +2 -0
- package/android/.gradle/vcs-1/gc.properties +0 -0
- package/android/.idea/gradle.xml +13 -0
- package/android/.idea/misc.xml +9 -0
- package/android/.idea/vcs.xml +6 -0
- package/android/src/main/java/com/reactnativecometchatuikit/{RNSoundModule.java → CometChatSoundModule.java} +22 -22
- package/android/src/main/java/com/reactnativecometchatuikit/CometchatUiKitPackage.java +1 -1
- package/ios/{RNSound.h → CometChatSoundModule.h} +1 -1
- package/ios/{RNSound.m → CometChatSoundModule.m} +2 -2
- package/lib/CometChatConversations/ConversationsConfiguration.d.ts +1 -0
- package/lib/CometChatDetails/DetailsConfiguration.d.ts +1 -0
- package/lib/CometChatGroupMembers/GroupMemberConfiguration.d.ts +1 -0
- package/lib/CometChatGroups/GroupsConfiguration.d.ts +1 -0
- package/lib/CometChatMessageComposer/CometChatMessageComposer.js +1 -7
- package/lib/CometChatMessageComposer/CometChatMessageComposer.js.map +1 -1
- package/lib/CometChatMessageHeader/MessageHeaderConfiguration.d.ts +1 -0
- package/lib/CometChatMessageList/CometChatMessageList.js +18 -49
- package/lib/CometChatMessageList/CometChatMessageList.js.map +1 -1
- package/lib/CometChatMessageList/MessageListConfiguration.d.ts +1 -0
- package/lib/CometChatMessages/MessagesConfiguration.d.ts +1 -0
- package/lib/CometChatTabs/TabItems.d.ts +1 -0
- package/lib/CometChatThreadedMessages/ThreadedMessagesConfiguration.d.ts +1 -0
- package/lib/calls/CometChatCallDetails/CallDetailsConfiguration.d.ts +1 -0
- package/lib/calls/CometChatCallHistory/CallHistoryConfiguration.d.ts +1 -0
- package/lib/calls/CometChatIncomingCall/CometChatIncomingCall.js +3 -3
- package/lib/calls/CometChatIncomingCall/CometChatIncomingCall.js.map +1 -1
- package/lib/extensions/ImageModeration/ImageModerationDecorator.d.ts +1 -0
- package/lib/extensions/ImageModeration/ImageModerationFilter.js +4 -4
- package/lib/extensions/ImageModeration/ImageModerationFilter.js.map +1 -1
- package/lib/extensions/LinkPreview/LinkPreviewExtentionDecorator.d.ts +1 -0
- package/lib/extensions/MessageTranslation/MessageTranslationDecorator.d.ts +1 -0
- package/lib/extensions/SmartReplies/SmartRepliesDecorator.js +1 -1
- package/lib/extensions/SmartReplies/SmartRepliesDecorator.js.map +1 -1
- package/lib/extensions/Stickers/StickersExtensionDecorator.d.ts +1 -1
- package/lib/extensions/Stickers/StickersExtensionDecorator.js +2 -4
- package/lib/extensions/Stickers/StickersExtensionDecorator.js.map +1 -1
- package/lib/extensions/TextModeration/TextModerationExtensionDecorator.d.ts +1 -0
- package/lib/index.d.ts +0 -13
- package/lib/index.js +0 -14
- package/lib/index.js.map +1 -1
- package/lib/shared/CometChatUiKit/CometChatUIKit.d.ts +0 -2
- package/lib/shared/CometChatUiKit/CometChatUIKit.js +2 -13
- package/lib/shared/CometChatUiKit/CometChatUIKit.js.map +1 -1
- package/lib/shared/CometChatUiKit/UIKitSettings.d.ts +1 -5
- package/lib/shared/CometChatUiKit/UIKitSettings.js +1 -3
- package/lib/shared/CometChatUiKit/UIKitSettings.js.map +1 -1
- package/lib/shared/events/CometChatUIEventHandler/CometChatUIEventHandler.js +0 -2
- package/lib/shared/events/CometChatUIEventHandler/CometChatUIEventHandler.js.map +1 -1
- package/lib/shared/events/CometChatUIEventHandler/Listener.d.ts +1 -3
- package/lib/shared/events/CometChatUIEventHandler/Listener.js +1 -4
- package/lib/shared/events/CometChatUIEventHandler/Listener.js.map +1 -1
- package/lib/shared/events/CometChatUIEvents.d.ts +1 -2
- package/lib/shared/events/CometChatUIEvents.js +0 -1
- package/lib/shared/events/CometChatUIEvents.js.map +1 -1
- package/lib/shared/framework/DataSource.d.ts +2 -1
- package/lib/shared/framework/DataSourceDecorator.d.ts +2 -1
- package/lib/shared/framework/DataSourceDecorator.js +2 -2
- package/lib/shared/framework/DataSourceDecorator.js.map +1 -1
- package/lib/shared/framework/MessageDataSource.d.ts +1 -1
- package/lib/shared/framework/MessageDataSource.js +2 -2
- package/lib/shared/framework/MessageDataSource.js.map +1 -1
- package/lib/shared/helper/types/index.d.ts +1 -0
- package/lib/shared/modals/CometChatDetailsOption.d.ts +1 -0
- package/lib/shared/modals/CometChatMessageOption.d.ts +1 -0
- package/lib/shared/modals/CometChatMessageTemplate.d.ts +1 -0
- package/lib/shared/resources/CometChatLocalize/CometChatLocalize.d.ts +153 -230
- package/lib/shared/resources/CometChatLocalize/resources/ar/translation.json +0 -4
- package/lib/shared/resources/CometChatLocalize/resources/de/translation.json +0 -4
- package/lib/shared/resources/CometChatLocalize/resources/en/translation.json +0 -4
- package/lib/shared/resources/CometChatLocalize/resources/es/translation.json +0 -4
- package/lib/shared/resources/CometChatLocalize/resources/fr/translation.json +0 -4
- package/lib/shared/resources/CometChatLocalize/resources/hi/translation.json +0 -4
- package/lib/shared/resources/CometChatLocalize/resources/lt/translation.json +0 -4
- package/lib/shared/resources/CometChatLocalize/resources/ms/translation.json +0 -4
- package/lib/shared/resources/CometChatLocalize/resources/pt/translation.json +0 -4
- package/lib/shared/resources/CometChatLocalize/resources/ru/translation.json +0 -4
- package/lib/shared/resources/CometChatLocalize/resources/sv/translation.json +0 -4
- package/lib/shared/resources/CometChatLocalize/resources/zh/translation.json +0 -4
- package/lib/shared/resources/CometChatLocalize/resources/zh-tw/translation.json +0 -4
- package/package.json +2 -2
- package/src/AI/AIConversationStarter/AIConversationStarterDecorator.tsx +3 -4
- package/src/CometChatConversations/CometChatConversations.tsx +56 -46
- package/src/CometChatMessageHeader/listners.ts +5 -4
- package/src/CometChatMessageInformation/CometChatMessageInformation.tsx +35 -35
- package/src/CometChatMessageList/CometChatMessageList.tsx +251 -142
- package/src/CometChatMessages/CometChatMessages.tsx +4 -3
- package/src/CometChatTabs/CometChatTabs.tsx +1 -1
- package/src/extensions/SmartReplies/SmartRepliesDecorator.tsx +3 -9
- package/src/index.ts +59 -17
- package/src/shared/CometChatUiKit/CometChatUIKit.ts +98 -10
- package/src/shared/constants/UIKitConstants.ts +81 -47
- package/src/shared/events/CometChatUIEventHandler/CometChatUIEventHandler.ts +46 -2
- package/src/shared/events/CometChatUIEventHandler/Listener.ts +61 -2
- package/src/shared/events/ListenerInitializer.ts +73 -0
- package/src/shared/events/messages.ts +14 -0
- package/src/shared/framework/DataSource.ts +11 -0
- package/src/shared/framework/DataSourceDecorator.tsx +35 -0
- package/src/shared/framework/MessageDataSource.tsx +83 -3
- package/src/shared/index.ts +44 -0
- package/src/shared/modals/InteractiveData/InteractiveActions/APIAction.ts +118 -0
- package/src/shared/modals/InteractiveData/InteractiveActions/CustomAction.ts +19 -0
- package/src/shared/modals/InteractiveData/InteractiveActions/URLNavigationAction.ts +34 -0
- package/src/shared/modals/InteractiveData/InteractiveActions/index.ts +3 -0
- package/src/shared/modals/InteractiveData/InteractiveData/InteractiveCardData.ts +69 -0
- package/src/shared/modals/InteractiveData/InteractiveData/InteractiveFormData.ts +119 -0
- package/src/shared/modals/InteractiveData/InteractiveData/index.ts +2 -0
- package/src/shared/modals/InteractiveData/InteractiveElements/BaseInputElement.ts +102 -0
- package/src/shared/modals/InteractiveData/InteractiveElements/BaseInteractiveElement.ts +45 -0
- package/src/shared/modals/InteractiveData/InteractiveElements/ButtonElement.ts +61 -0
- package/src/shared/modals/InteractiveData/InteractiveElements/CheckboxElement.ts +75 -0
- package/src/shared/modals/InteractiveData/InteractiveElements/DropdownElement.ts +83 -0
- package/src/shared/modals/InteractiveData/InteractiveElements/LabelElement.ts +32 -0
- package/src/shared/modals/InteractiveData/InteractiveElements/OptionElement.ts +39 -0
- package/src/shared/modals/InteractiveData/InteractiveElements/RadioButtonElement.ts +76 -0
- package/src/shared/modals/InteractiveData/InteractiveElements/SingleSelectElement.ts +76 -0
- package/src/shared/modals/InteractiveData/InteractiveElements/TextInputElement.ts +101 -0
- package/src/shared/modals/InteractiveData/InteractiveElements/index.ts +10 -0
- package/src/shared/modals/InteractiveData/InteractiveEntities/ActionEntity.ts +41 -0
- package/src/shared/modals/InteractiveData/InteractiveEntities/ElementEntity.ts +64 -0
- package/src/shared/modals/InteractiveData/InteractiveEntities/index.ts +2 -0
- package/src/shared/modals/InteractiveData/InteractiveMessage/CardMessage.ts +142 -0
- package/src/shared/modals/InteractiveData/InteractiveMessage/CustomInteractiveMessage.ts +38 -0
- package/src/shared/modals/InteractiveData/InteractiveMessage/FormMessage.ts +152 -0
- package/src/shared/modals/InteractiveData/InteractiveMessage/index.ts +3 -0
- package/src/shared/modals/InteractiveData/index.ts +28 -0
- package/src/shared/modals/index.ts +19 -0
- package/src/shared/resources/CometChatLocalize/resources/ar/translation.json +4 -1
- package/src/shared/resources/CometChatLocalize/resources/de/translation.json +4 -1
- package/src/shared/resources/CometChatLocalize/resources/en/translation.json +4 -1
- package/src/shared/resources/CometChatLocalize/resources/es/translation.json +4 -1
- package/src/shared/resources/CometChatLocalize/resources/fr/translation.json +4 -1
- package/src/shared/resources/CometChatLocalize/resources/hi/translation.json +4 -1
- package/src/shared/resources/CometChatLocalize/resources/lt/translation.json +4 -1
- package/src/shared/resources/CometChatLocalize/resources/ms/translation.json +4 -1
- package/src/shared/resources/CometChatLocalize/resources/pt/translation.json +4 -1
- package/src/shared/resources/CometChatLocalize/resources/ru/translation.json +4 -1
- package/src/shared/resources/CometChatLocalize/resources/sv/translation.json +4 -1
- package/src/shared/resources/CometChatLocalize/resources/zh/translation.json +4 -1
- package/src/shared/resources/CometChatLocalize/resources/zh-tw/translation.json +4 -1
- package/src/shared/resources/CometChatSoundManager/CometChatSoundManager.js +2 -2
- package/src/shared/resources/CometChatSoundManager/sound.js +35 -35
- package/src/shared/utils/InteractiveMessageUtils.ts +20 -0
- package/src/shared/utils/NetworkUtils.tsx +20 -0
- package/src/shared/utils/conversationUtils.ts +9 -6
- package/src/shared/views/CometChatButton/CometChatButton.tsx +32 -22
- package/src/shared/views/CometChatCardBubble/CardBubbleStyle.tsx +47 -0
- package/src/shared/views/CometChatCardBubble/CometChatCardBubble.tsx +173 -0
- package/src/shared/views/CometChatCardBubble/index.tsx +1 -0
- package/src/shared/views/CometChatCheckBox/CheckBoxStyle.tsx +43 -0
- package/src/shared/views/CometChatCheckBox/CometChatCheckBox.tsx +79 -0
- package/src/shared/views/CometChatDate/CometChatDate.tsx +2 -3
- package/src/shared/views/CometChatDropDown/CometChatDropDown.tsx +126 -0
- package/src/shared/views/CometChatDropDown/DropDownStyle.tsx +39 -0
- package/src/shared/views/CometChatDropDown/resources/downArrowIcon.png +0 -0
- package/src/shared/views/CometChatDropDown/resources/index.js +5 -0
- package/src/shared/views/CometChatFormBubble/CometChatFormBubble.tsx +464 -0
- package/src/shared/views/CometChatFormBubble/FormBubbleStyle.tsx +91 -0
- package/src/shared/views/CometChatFormBubble/index.tsx +1 -0
- package/src/shared/views/CometChatImageBubble/CometChatImageBubble.tsx +13 -5
- package/src/shared/views/CometChatImageBubble/ImageBubbleStyle.ts +14 -3
- package/src/shared/views/CometChatLabel/CometChatLabel.tsx +27 -0
- package/src/shared/views/CometChatLabel/LabelStyle.ts +19 -0
- package/src/shared/views/CometChatMessageBubble/CometChatMessageBubble.tsx +5 -4
- package/src/shared/views/CometChatQuickView/CometChatQuickView.tsx +66 -0
- package/src/shared/views/CometChatQuickView/QuickViewStyle.ts +55 -0
- package/src/shared/views/CometChatRadioButton/CometChatRadioButton.tsx +67 -0
- package/src/shared/views/CometChatRadioButton/RadioButtonStyle.tsx +38 -0
- package/src/shared/views/CometChatSingleSelect/CometChatSingleSelect.tsx +63 -0
- package/src/shared/views/CometChatSingleSelect/SingleStyle.tsx +35 -0
- package/src/shared/views/CometChatTextInput/CometChatTextInput.tsx +67 -0
- package/src/shared/views/CometChatTextInput/TextInputStyle.tsx +26 -0
- package/src/shared/views/index.ts +7 -1
- package/lib/AI/AIConversationStarter/AIConversationStarter.d.ts +0 -12
- package/lib/AI/AIConversationStarter/AIConversationStarter.js +0 -31
- package/lib/AI/AIConversationStarter/AIConversationStarter.js.map +0 -1
- package/lib/AI/AIConversationStarter/AIConversationStarterDecorator.d.ts +0 -25
- package/lib/AI/AIConversationStarter/AIConversationStarterDecorator.js +0 -175
- package/lib/AI/AIConversationStarter/AIConversationStarterDecorator.js.map +0 -1
- package/lib/AI/AIConversationStarter/AIConversationStarterStyle.d.ts +0 -4
- package/lib/AI/AIConversationStarter/AIConversationStarterStyle.js +0 -8
- package/lib/AI/AIConversationStarter/AIConversationStarterStyle.js.map +0 -1
- package/lib/AI/AIConversationStarter/configuration.d.ts +0 -14
- package/lib/AI/AIConversationStarter/configuration.js +0 -16
- package/lib/AI/AIConversationStarter/configuration.js.map +0 -1
- package/lib/AI/AIConversationStarter/style.d.ts +0 -31
- package/lib/AI/AIConversationStarter/style.js +0 -62
- package/lib/AI/AIConversationStarter/style.js.map +0 -1
- package/lib/AI/AIEnabler.d.ts +0 -10
- package/lib/AI/AIEnabler.js +0 -102
- package/lib/AI/AIEnabler.js.map +0 -1
- package/lib/AI/AIEnablerDecorator.d.ts +0 -43
- package/lib/AI/AIEnablerDecorator.js +0 -251
- package/lib/AI/AIEnablerDecorator.js.map +0 -1
- package/lib/AI/AIExtensionDataSource.d.ts +0 -6
- package/lib/AI/AIExtensionDataSource.js +0 -10
- package/lib/AI/AIExtensionDataSource.js.map +0 -1
- package/lib/AI/AISmartReplies/AISmartReplies.d.ts +0 -10
- package/lib/AI/AISmartReplies/AISmartReplies.js +0 -23
- package/lib/AI/AISmartReplies/AISmartReplies.js.map +0 -1
- package/lib/AI/AISmartReplies/AISmartRepliesDecorator.d.ts +0 -7
- package/lib/AI/AISmartReplies/AISmartRepliesDecorator.js +0 -12
- package/lib/AI/AISmartReplies/AISmartRepliesDecorator.js.map +0 -1
- package/lib/AI/AISmartReplies/AISmartRepliesStyle.d.ts +0 -12
- package/lib/AI/AISmartReplies/AISmartRepliesStyle.js +0 -15
- package/lib/AI/AISmartReplies/AISmartRepliesStyle.js.map +0 -1
- package/lib/AI/AISmartReplies/configuration.d.ts +0 -14
- package/lib/AI/AISmartReplies/configuration.js +0 -16
- package/lib/AI/AISmartReplies/configuration.js.map +0 -1
- package/lib/AI/CardView.d.ts +0 -19
- package/lib/AI/CardView.js +0 -45
- package/lib/AI/CardView.js.map +0 -1
- package/lib/AI/CardViewStyle.d.ts +0 -29
- package/lib/AI/CardViewStyle.js +0 -36
- package/lib/AI/CardViewStyle.js.map +0 -1
- package/lib/AI/configuration.d.ts +0 -14
- package/lib/AI/configuration.js +0 -16
- package/lib/AI/configuration.js.map +0 -1
- package/lib/AI/resources/index.d.ts +0 -5
- package/lib/AI/resources/index.js +0 -6
- package/lib/AI/resources/index.js.map +0 -1
- package/lib/AI/style.d.ts +0 -115
- package/lib/AI/style.js +0 -139
- package/lib/AI/style.js.map +0 -1
- package/lib/AI/utils.d.ts +0 -38
- package/lib/AI/utils.js +0 -28
- package/lib/AI/utils.js.map +0 -1
|
@@ -0,0 +1,464 @@
|
|
|
1
|
+
import React, { useContext, useEffect, useRef, useCallback } from "react";
|
|
2
|
+
import { View, Text, NativeModules } from "react-native";
|
|
3
|
+
import { CometChatContextType } from "../../base/Types";
|
|
4
|
+
import { CometChatContext } from "../../CometChatContext";
|
|
5
|
+
|
|
6
|
+
// Style Components import
|
|
7
|
+
import { FormBubbleStyle, FormBubbleStyleInterface } from "./FormBubbleStyle";
|
|
8
|
+
|
|
9
|
+
import { APIAction, ButtonElement, CheckboxElement, DropdownElement, ElementEntity, FormMessage, LabelElement, OptionElement, RadioButtonElement, SingleSelectElement, TextInputElement, URLNavigationAction } from '../../modals/InteractiveData';
|
|
10
|
+
import { ButtonAction, ElementType, HTTPSRequestMethods, goalType } from "../../constants/UIKitConstants";
|
|
11
|
+
import CometChatDropdown from "../CometChatDropDown/CometChatDropDown";
|
|
12
|
+
import { CometChatNetworkUtils } from "../../utils/NetworkUtils";
|
|
13
|
+
import { CometChat } from "@cometchat/chat-sdk-react-native";
|
|
14
|
+
import CometChatTextInput from "../CometChatTextInput/CometChatTextInput";
|
|
15
|
+
import CometChatCheckBox from "../CometChatCheckBox/CometChatCheckBox";
|
|
16
|
+
import CometChatRadioButton from "../CometChatRadioButton/CometChatRadioButton";
|
|
17
|
+
import CometChatSingleSelect from "../CometChatSingleSelect/CometChatSingleSelect";
|
|
18
|
+
import CometChatQuickView from "../CometChatQuickView/CometChatQuickView";
|
|
19
|
+
import { localize } from "../../resources";
|
|
20
|
+
import { memo } from "react";
|
|
21
|
+
import { ButtonStyle, CometChatButton } from "../CometChatButton";
|
|
22
|
+
import CometChatLabel from "../CometChatLabel/CometChatLabel";
|
|
23
|
+
|
|
24
|
+
const WebView = NativeModules['WebViewManager'];
|
|
25
|
+
export interface CometChatFormBubbleInterface {
|
|
26
|
+
message: FormMessage, // Expect JSON object
|
|
27
|
+
style?: FormBubbleStyleInterface,
|
|
28
|
+
onSubmitClick?: (data: any) => void
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
let allRequiredFields = [];
|
|
32
|
+
|
|
33
|
+
export const CometChatFormBubble = memo((props: CometChatFormBubbleInterface) => {
|
|
34
|
+
|
|
35
|
+
const {
|
|
36
|
+
message,
|
|
37
|
+
onSubmitClick,
|
|
38
|
+
style
|
|
39
|
+
} = props;
|
|
40
|
+
|
|
41
|
+
const { theme } = useContext<CometChatContextType>(CometChatContext);
|
|
42
|
+
|
|
43
|
+
const [currentRequiredFields, setCurrentRequiredFields] = React.useState<string[]>([]);
|
|
44
|
+
const [bodyData, setBodyData] = React.useState({});
|
|
45
|
+
const [hasInteractionCompleted, setHasInteractionCompleted] = React.useState(false);
|
|
46
|
+
const [interactedElements, setInteractedElements] = React.useState<CometChat.Interaction[]>([]);
|
|
47
|
+
const [interactionGoal, setInteractionGoal] = React.useState<CometChat.InteractionGoal>(undefined);
|
|
48
|
+
const [loaderButton, setLoaderButton] = React.useState<string>("");
|
|
49
|
+
const [loggedInUser, setLoggedInUser] = React.useState<CometChat.User>(null);
|
|
50
|
+
|
|
51
|
+
const _style = new FormBubbleStyle({
|
|
52
|
+
wrapperPadding: 3,
|
|
53
|
+
titleFont: theme.typography.heading,
|
|
54
|
+
titleColor: theme.palette.getAccent(),
|
|
55
|
+
goalCompletionTextColor: theme.palette.getAccent600(),
|
|
56
|
+
backgroundColor: theme.palette.getBackgroundColor(),
|
|
57
|
+
wrapperBackground: theme.palette.getSecondary(),
|
|
58
|
+
wrapperBorderRadius: 10,
|
|
59
|
+
buttonStyle: new ButtonStyle({
|
|
60
|
+
backgroundColor: theme.palette.getPrimary(),
|
|
61
|
+
border: { borderWidth: 1, borderColor: theme.palette.getAccent200() },
|
|
62
|
+
textColor: theme.palette.getBackgroundColor(),
|
|
63
|
+
textFont: theme.typography.text1,
|
|
64
|
+
height: 35,
|
|
65
|
+
borderRadius: 5,
|
|
66
|
+
}),
|
|
67
|
+
// Add relevant style properties
|
|
68
|
+
...style
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
const {
|
|
72
|
+
backgroundColor,
|
|
73
|
+
border,
|
|
74
|
+
borderRadius,
|
|
75
|
+
goalCompletionTextColor,
|
|
76
|
+
goalCompletionTextFont,
|
|
77
|
+
titleColor,
|
|
78
|
+
titleFont,
|
|
79
|
+
wrapperBackground,
|
|
80
|
+
wrapperBorderRadius,
|
|
81
|
+
wrapperPadding,
|
|
82
|
+
buttonStyle,
|
|
83
|
+
checkboxStyle,
|
|
84
|
+
dropdownStyle,
|
|
85
|
+
labelStyle,
|
|
86
|
+
quickViewStyle,
|
|
87
|
+
radioButtonStyle,
|
|
88
|
+
singleSelectStyle,
|
|
89
|
+
textInputStyle,
|
|
90
|
+
// Extract style properties
|
|
91
|
+
} = _style;
|
|
92
|
+
|
|
93
|
+
useEffect(() => {
|
|
94
|
+
CometChat.getLoggedinUser()
|
|
95
|
+
.then(u => {
|
|
96
|
+
setLoggedInUser(u);
|
|
97
|
+
})
|
|
98
|
+
.catch(e => {
|
|
99
|
+
console.log("Error while getting loggedInUser");
|
|
100
|
+
setLoggedInUser(null);
|
|
101
|
+
});
|
|
102
|
+
setInteractedElements(message.getInteractions() || []);
|
|
103
|
+
setInteractionGoal(message.getInteractionGoal() || undefined);
|
|
104
|
+
let formFields = {};
|
|
105
|
+
message.getFormFields().forEach((field) => {
|
|
106
|
+
formFields[field.getElementId()] = (field?.getDefaultValue && field?.getDefaultValue()) || "";
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
setBodyData(formFields);
|
|
110
|
+
|
|
111
|
+
}, []);
|
|
112
|
+
|
|
113
|
+
useEffect(() => {
|
|
114
|
+
let hasInteractionCompleted: boolean = checkHasInteractionCompleted();
|
|
115
|
+
setHasInteractionCompleted(hasInteractionCompleted);
|
|
116
|
+
}, [interactedElements, interactionGoal])
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
const _renderTextInput = (data: TextInputElement) => {
|
|
120
|
+
!data.getOptional() && allRequiredFields.push(data.getElementId());
|
|
121
|
+
|
|
122
|
+
function onChange(text: string) {
|
|
123
|
+
setBodyData({ ...bodyData, [data.getElementId()]: text });
|
|
124
|
+
if (text.length > 0) {
|
|
125
|
+
removeFromRequiredList(data.getElementId());
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
return (
|
|
130
|
+
<CometChatTextInput
|
|
131
|
+
data={data}
|
|
132
|
+
showError={currentRequiredFields.includes(data.getElementId())}
|
|
133
|
+
onChange={onChange}
|
|
134
|
+
style={textInputStyle}
|
|
135
|
+
defaultValue={bodyData[data.getElementId()]}
|
|
136
|
+
/>
|
|
137
|
+
)
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
const _renderCheckBox = (data: CheckboxElement) => {
|
|
141
|
+
!data.getOptional() && allRequiredFields.push(data.getElementId());
|
|
142
|
+
|
|
143
|
+
function onChange(option: OptionElement) {
|
|
144
|
+
let _cloneBodydata = { ...bodyData };
|
|
145
|
+
_cloneBodydata[data.getElementId()] = _cloneBodydata[data.getElementId()] || [];
|
|
146
|
+
let indexOfOption = _cloneBodydata[data.getElementId()].indexOf(option.getValue());
|
|
147
|
+
if (indexOfOption > -1) {
|
|
148
|
+
_cloneBodydata[data.getElementId()].splice(indexOfOption, 1);
|
|
149
|
+
} else {
|
|
150
|
+
_cloneBodydata[data.getElementId()].push(option.getValue());
|
|
151
|
+
}
|
|
152
|
+
setBodyData({ ..._cloneBodydata });
|
|
153
|
+
|
|
154
|
+
if (_cloneBodydata[data.getElementId()].length > 0) {
|
|
155
|
+
removeFromRequiredList(data.getElementId());
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
return (
|
|
160
|
+
<CometChatCheckBox
|
|
161
|
+
data={data}
|
|
162
|
+
showError={currentRequiredFields.includes(data.getElementId())}
|
|
163
|
+
onChange={onChange}
|
|
164
|
+
selectedOptions={bodyData[data.getElementId()] || []}
|
|
165
|
+
style={checkboxStyle}
|
|
166
|
+
/>
|
|
167
|
+
);
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
const _renderRadio = (data: RadioButtonElement) => {
|
|
171
|
+
!data.getOptional() && allRequiredFields.push(data.getElementId());
|
|
172
|
+
function onChange(value: string) {
|
|
173
|
+
setBodyData({ ...bodyData, [data.getElementId()]: value });
|
|
174
|
+
removeFromRequiredList(data.getElementId());
|
|
175
|
+
}
|
|
176
|
+
return (
|
|
177
|
+
<CometChatRadioButton
|
|
178
|
+
data={data}
|
|
179
|
+
onChange={onChange}
|
|
180
|
+
selectedOption={bodyData[data.getElementId()]}
|
|
181
|
+
showError={currentRequiredFields.includes(data.getElementId())}
|
|
182
|
+
style={radioButtonStyle}
|
|
183
|
+
/>
|
|
184
|
+
);
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
const _renderSingleElement = (data: SingleSelectElement) => {
|
|
188
|
+
!data.getOptional() && allRequiredFields.push(data.getElementId());
|
|
189
|
+
function onChange(value: string) {
|
|
190
|
+
setBodyData({ ...bodyData, [data.getElementId()]: value });
|
|
191
|
+
removeFromRequiredList(data.getElementId());
|
|
192
|
+
}
|
|
193
|
+
return (
|
|
194
|
+
<CometChatSingleSelect
|
|
195
|
+
data={data}
|
|
196
|
+
onChange={onChange}
|
|
197
|
+
selectedOption={bodyData[data.getElementId()]}
|
|
198
|
+
showError={currentRequiredFields.includes(data.getElementId())}
|
|
199
|
+
style={singleSelectStyle}
|
|
200
|
+
/>
|
|
201
|
+
);
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
const _returnDropDown = (data: DropdownElement) => {
|
|
205
|
+
!data.getOptional() && allRequiredFields.push(data.getElementId());
|
|
206
|
+
|
|
207
|
+
function onChange(value: string) {
|
|
208
|
+
setBodyData({ ...bodyData, [data.getElementId()]: value });
|
|
209
|
+
removeFromRequiredList(data.getElementId());
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
return <CometChatDropdown
|
|
213
|
+
options={data.getOptions()}
|
|
214
|
+
onOptionChange={onChange}
|
|
215
|
+
data={data}
|
|
216
|
+
showError={currentRequiredFields.includes(data.getElementId())}
|
|
217
|
+
selectedOption={bodyData[data.getElementId()]}
|
|
218
|
+
style={dropdownStyle}
|
|
219
|
+
/>
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
const _renderButton = (data: ButtonElement, isSubmitElement?: boolean) => {
|
|
223
|
+
function onClick() {
|
|
224
|
+
console.log("ElemId", data.getElementId(), interactedElements)
|
|
225
|
+
_handleButtonClick(data.getAction(), data.getElementId(), isSubmitElement);
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
function isDisabled() {
|
|
229
|
+
let isSender = message.getSender()?.getUid() == loggedInUser?.['uid'];
|
|
230
|
+
let allowInteraction = isSender ? message?.["data"]?.["allowSenderInteraction"] : true;
|
|
231
|
+
|
|
232
|
+
let disableAfterInteracted: boolean;
|
|
233
|
+
if (data.getDisableAfterInteracted()) {
|
|
234
|
+
disableAfterInteracted = interactedElements?.some(
|
|
235
|
+
(element) => element.getElementId() === data.getElementId()
|
|
236
|
+
);
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
return (disableAfterInteracted || !allowInteraction);
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
return (
|
|
243
|
+
<View style={{ opacity: isDisabled() ? .7 : 1, marginVertical: 5 }}>
|
|
244
|
+
<CometChatButton
|
|
245
|
+
onPress={isDisabled() ? () => { } : onClick}
|
|
246
|
+
text={data.getButtonText()}
|
|
247
|
+
style={buttonStyle}
|
|
248
|
+
isLoading={loaderButton === data.getElementId()}
|
|
249
|
+
/>
|
|
250
|
+
</View>
|
|
251
|
+
);
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
|
|
255
|
+
const _renderLabel = (data: LabelElement) => {
|
|
256
|
+
return (
|
|
257
|
+
<CometChatLabel
|
|
258
|
+
text={data.getText()}
|
|
259
|
+
style={labelStyle}
|
|
260
|
+
/>
|
|
261
|
+
);
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
const renderField = (field: ElementEntity) => {
|
|
265
|
+
|
|
266
|
+
switch (field.getElementType()) {
|
|
267
|
+
case ElementType.label:
|
|
268
|
+
// Render label
|
|
269
|
+
return _renderLabel(field as LabelElement);
|
|
270
|
+
case ElementType.text:
|
|
271
|
+
// Render text input
|
|
272
|
+
return _renderTextInput(field as TextInputElement);
|
|
273
|
+
case ElementType.dropdown:
|
|
274
|
+
// Render dropdown
|
|
275
|
+
return _returnDropDown(field as DropdownElement);
|
|
276
|
+
case ElementType.checkbox:
|
|
277
|
+
// Render checkbox
|
|
278
|
+
return _renderCheckBox(field as CheckboxElement);
|
|
279
|
+
case ElementType.radio:
|
|
280
|
+
// Render radio button
|
|
281
|
+
return _renderRadio(field as RadioButtonElement);
|
|
282
|
+
case ElementType.singleSelect:
|
|
283
|
+
// Render radio button
|
|
284
|
+
return _renderSingleElement(field as SingleSelectElement);
|
|
285
|
+
case ElementType.button:
|
|
286
|
+
// Render button
|
|
287
|
+
return _renderButton(field as ButtonElement);
|
|
288
|
+
|
|
289
|
+
// Handle other cases
|
|
290
|
+
default:
|
|
291
|
+
return null;
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
const filledRequiredFields = () => {
|
|
296
|
+
let _requiredFields = [];
|
|
297
|
+
for (let key in bodyData) {
|
|
298
|
+
if ((Array.isArray(bodyData[key]) && bodyData[key].length === 0) || !bodyData[key]) {
|
|
299
|
+
if (allRequiredFields.includes(key)) {
|
|
300
|
+
_requiredFields.push(key);
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
if (_requiredFields.length > 0) {
|
|
306
|
+
setCurrentRequiredFields(_requiredFields);
|
|
307
|
+
return false;
|
|
308
|
+
} else {
|
|
309
|
+
return true;
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
function _handleButtonClick(action: ButtonElement["action"], elementId: string, isSubmitElement?: boolean) {
|
|
314
|
+
if (isSubmitElement && onSubmitClick) {
|
|
315
|
+
const dataKey = (action as APIAction)?.getDataKey() || "CometChatData"
|
|
316
|
+
let payload: any = (action as APIAction).getPayload() || {}
|
|
317
|
+
if (!(typeof payload === "object")) {
|
|
318
|
+
payload = {}
|
|
319
|
+
}
|
|
320
|
+
payload[dataKey] = { ...bodyData };
|
|
321
|
+
onSubmitClick(payload)
|
|
322
|
+
return;
|
|
323
|
+
}
|
|
324
|
+
switch (action.getActionType()) {
|
|
325
|
+
case ButtonAction.apiAction:
|
|
326
|
+
if (filledRequiredFields()) {
|
|
327
|
+
const dataKey = (action as APIAction)?.getDataKey() || "CometChatData"
|
|
328
|
+
let payload: any = (action as APIAction).getPayload() || {}
|
|
329
|
+
if (!(typeof payload === "object")) {
|
|
330
|
+
payload = {}
|
|
331
|
+
}
|
|
332
|
+
payload[dataKey] = { ...bodyData };
|
|
333
|
+
setLoaderButton(elementId)
|
|
334
|
+
CometChatNetworkUtils.fetcher({
|
|
335
|
+
url: action.getURL(),
|
|
336
|
+
method: (action as APIAction).getMethod() || HTTPSRequestMethods.POST,
|
|
337
|
+
body: { ...payload, cometchatSenderUid: loggedInUser?.['uid'] || "" },
|
|
338
|
+
headers: (action as APIAction).getHeaders(),
|
|
339
|
+
})
|
|
340
|
+
.then((response) => {
|
|
341
|
+
if (response.status === 200) {
|
|
342
|
+
markAsInteracted(elementId);
|
|
343
|
+
}
|
|
344
|
+
})
|
|
345
|
+
.catch((error) => {
|
|
346
|
+
setLoaderButton("")
|
|
347
|
+
console.log("CometChatNetworkUtils.fetcher error", error);
|
|
348
|
+
});
|
|
349
|
+
}
|
|
350
|
+
break;
|
|
351
|
+
case ButtonAction.urlNavigation:
|
|
352
|
+
const url = (action as URLNavigationAction)?.getURL();
|
|
353
|
+
WebView.openUrl(url);
|
|
354
|
+
markAsInteracted(elementId);
|
|
355
|
+
break;
|
|
356
|
+
case ButtonAction.custom:
|
|
357
|
+
markAsInteracted(elementId);
|
|
358
|
+
break;
|
|
359
|
+
default:
|
|
360
|
+
break;
|
|
361
|
+
}
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
const checkHasInteractionCompleted = () => {
|
|
365
|
+
let completed = false;
|
|
366
|
+
let neededInteractionElement = interactionGoal?.getElementIds() || [];
|
|
367
|
+
let neededInteractionElementCondition: string = interactionGoal?.getType() || "";
|
|
368
|
+
let _interactedElements = [...interactedElements] || [];
|
|
369
|
+
|
|
370
|
+
switch (neededInteractionElementCondition) {
|
|
371
|
+
case goalType.anyOf:
|
|
372
|
+
completed = _interactedElements.find((element: CometChat.Interaction) =>
|
|
373
|
+
neededInteractionElement.includes(element.getElementId())
|
|
374
|
+
)
|
|
375
|
+
? true
|
|
376
|
+
: false;
|
|
377
|
+
break;
|
|
378
|
+
case goalType.anyAction:
|
|
379
|
+
completed = _interactedElements.length > 0 ? true : false;
|
|
380
|
+
break;
|
|
381
|
+
case goalType.allOf:
|
|
382
|
+
completed = neededInteractionElement.every((element) =>
|
|
383
|
+
_interactedElements.find(
|
|
384
|
+
(interaction: CometChat.Interaction) =>
|
|
385
|
+
interaction.getElementId() === element
|
|
386
|
+
)
|
|
387
|
+
)
|
|
388
|
+
? true
|
|
389
|
+
: false;
|
|
390
|
+
break;
|
|
391
|
+
case goalType.none:
|
|
392
|
+
completed = false;
|
|
393
|
+
break;
|
|
394
|
+
default:
|
|
395
|
+
completed = false;
|
|
396
|
+
break;
|
|
397
|
+
}
|
|
398
|
+
return completed;
|
|
399
|
+
};
|
|
400
|
+
|
|
401
|
+
function markAsInteracted(elementId: string) {
|
|
402
|
+
CometChat.markAsInteracted(message?.getId(), elementId).then(
|
|
403
|
+
(response) => {
|
|
404
|
+
const interaction = new CometChat.Interaction(
|
|
405
|
+
elementId,
|
|
406
|
+
new Date().getTime()
|
|
407
|
+
);
|
|
408
|
+
let clonedInteractedElements = [...interactedElements];
|
|
409
|
+
clonedInteractedElements.push(interaction);
|
|
410
|
+
setInteractedElements(clonedInteractedElements);
|
|
411
|
+
setLoaderButton("")
|
|
412
|
+
}
|
|
413
|
+
)
|
|
414
|
+
.catch((error) => {
|
|
415
|
+
console.log("error while markAsInteracted", error);
|
|
416
|
+
});
|
|
417
|
+
}
|
|
418
|
+
|
|
419
|
+
const removeFromRequiredList = (elementId: string) => {
|
|
420
|
+
if (currentRequiredFields.includes(elementId)) {
|
|
421
|
+
setCurrentRequiredFields(currentRequiredFields.filter((field) => field !== elementId));
|
|
422
|
+
}
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
return <View
|
|
426
|
+
style={{
|
|
427
|
+
padding: wrapperPadding,
|
|
428
|
+
flex: 1,
|
|
429
|
+
borderRadius: wrapperBorderRadius,
|
|
430
|
+
backgroundColor: wrapperBackground,
|
|
431
|
+
}}
|
|
432
|
+
>
|
|
433
|
+
{hasInteractionCompleted ?
|
|
434
|
+
<View style={{ padding: 5 }}>
|
|
435
|
+
<CometChatQuickView
|
|
436
|
+
title={message.getSender()?.getName()}
|
|
437
|
+
subtitle={message.getTitle()}
|
|
438
|
+
quickViewStyle={quickViewStyle}
|
|
439
|
+
/>
|
|
440
|
+
<Text style={[{ marginTop: 10, color: goalCompletionTextColor }, goalCompletionTextFont]}>{message.getGoalCompletionText() || localize("FORM_COMPLETION_MESSAGE")}</Text>
|
|
441
|
+
</View>
|
|
442
|
+
:
|
|
443
|
+
<View style={{
|
|
444
|
+
backgroundColor: backgroundColor,
|
|
445
|
+
padding: 10, borderRadius: borderRadius, ...border
|
|
446
|
+
}}>
|
|
447
|
+
{Boolean(message.getTitle()) && <Text
|
|
448
|
+
style={[{ marginBottom: 15, marginTop: 10, color: titleColor }, titleFont]}
|
|
449
|
+
>{message.getTitle()}</Text>}
|
|
450
|
+
|
|
451
|
+
{
|
|
452
|
+
message.getFormFields().map((item) => {
|
|
453
|
+
return renderField(item)
|
|
454
|
+
})
|
|
455
|
+
}
|
|
456
|
+
{message.getSubmitElement() && _renderButton(message.getSubmitElement() as ButtonElement, true)}
|
|
457
|
+
</View>
|
|
458
|
+
}
|
|
459
|
+
</View>
|
|
460
|
+
})
|
|
461
|
+
|
|
462
|
+
CometChatFormBubble.defaultProps = {
|
|
463
|
+
message: {}
|
|
464
|
+
}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { BaseStyle, FontStyle } from "../../base";
|
|
2
|
+
import { ButtonStyleInterface } from "../CometChatButton";
|
|
3
|
+
import { CheckBoxStyleInterface } from "../CometChatCheckBox/CheckBoxStyle";
|
|
4
|
+
import { DropDownStyleInterface } from "../CometChatDropDown/DropDownStyle";
|
|
5
|
+
import { LabelStyleInterface } from "../CometChatLabel/LabelStyle";
|
|
6
|
+
import { QuickViewStyleInterface } from "../CometChatQuickView/QuickViewStyle";
|
|
7
|
+
import { RadioButtonStyleInterface } from "../CometChatRadioButton/RadioButtonStyle";
|
|
8
|
+
import { SingleSelectStyleInterface } from "../CometChatSingleSelect/SingleStyle";
|
|
9
|
+
import { TextInputStyleInterface } from "../CometChatTextInput/TextInputStyle";
|
|
10
|
+
|
|
11
|
+
export interface FormBubbleStyleInterface extends BaseStyle {
|
|
12
|
+
titleFont?: FontStyle;
|
|
13
|
+
titleColor?: string;
|
|
14
|
+
wrapperBackground?: string;
|
|
15
|
+
wrapperBorderRadius?: number;
|
|
16
|
+
wrapperPadding?: number;
|
|
17
|
+
goalCompletionTextFont?: FontStyle;
|
|
18
|
+
goalCompletionTextColor?: string;
|
|
19
|
+
textInputStyle?: TextInputStyleInterface;
|
|
20
|
+
quickViewStyle?: QuickViewStyleInterface;
|
|
21
|
+
radioButtonStyle?: RadioButtonStyleInterface;
|
|
22
|
+
checkboxStyle?: CheckBoxStyleInterface;
|
|
23
|
+
dropdownStyle?: DropDownStyleInterface;
|
|
24
|
+
labelStyle?: LabelStyleInterface;
|
|
25
|
+
buttonStyle?: ButtonStyleInterface;
|
|
26
|
+
singleSelectStyle?: SingleSelectStyleInterface;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export class FormBubbleStyle extends BaseStyle {
|
|
30
|
+
titleFont?: FontStyle;
|
|
31
|
+
titleColor?: string;
|
|
32
|
+
wrapperBackground?: string;
|
|
33
|
+
wrapperBorderRadius?: number;
|
|
34
|
+
wrapperPadding?: number;
|
|
35
|
+
goalCompletionTextFont?: FontStyle;
|
|
36
|
+
goalCompletionTextColor?: string;
|
|
37
|
+
textInputStyle?: TextInputStyleInterface;
|
|
38
|
+
quickViewStyle?: QuickViewStyleInterface;
|
|
39
|
+
radioButtonStyle?: RadioButtonStyleInterface;
|
|
40
|
+
checkboxStyle?: CheckBoxStyleInterface;
|
|
41
|
+
dropdownStyle?: DropDownStyleInterface;
|
|
42
|
+
labelStyle?: LabelStyleInterface;
|
|
43
|
+
buttonStyle?: ButtonStyleInterface;
|
|
44
|
+
singleSelectStyle?: SingleSelectStyleInterface;
|
|
45
|
+
|
|
46
|
+
constructor({
|
|
47
|
+
height = "auto",
|
|
48
|
+
width = "auto",
|
|
49
|
+
backgroundColor,
|
|
50
|
+
border,
|
|
51
|
+
borderRadius,
|
|
52
|
+
titleFont,
|
|
53
|
+
titleColor,
|
|
54
|
+
wrapperBackground,
|
|
55
|
+
wrapperBorderRadius,
|
|
56
|
+
wrapperPadding,
|
|
57
|
+
goalCompletionTextFont,
|
|
58
|
+
goalCompletionTextColor,
|
|
59
|
+
textInputStyle,
|
|
60
|
+
quickViewStyle,
|
|
61
|
+
radioButtonStyle,
|
|
62
|
+
checkboxStyle,
|
|
63
|
+
dropdownStyle,
|
|
64
|
+
labelStyle,
|
|
65
|
+
buttonStyle,
|
|
66
|
+
singleSelectStyle,
|
|
67
|
+
}: FormBubbleStyleInterface) {
|
|
68
|
+
super({
|
|
69
|
+
backgroundColor,
|
|
70
|
+
border,
|
|
71
|
+
borderRadius,
|
|
72
|
+
height,
|
|
73
|
+
width
|
|
74
|
+
});
|
|
75
|
+
this.titleFont = titleFont;
|
|
76
|
+
this.titleColor = titleColor;
|
|
77
|
+
this.wrapperBackground = wrapperBackground;
|
|
78
|
+
this.wrapperBorderRadius = wrapperBorderRadius;
|
|
79
|
+
this.wrapperPadding = wrapperPadding;
|
|
80
|
+
this.goalCompletionTextFont = goalCompletionTextFont;
|
|
81
|
+
this.goalCompletionTextColor = goalCompletionTextColor;
|
|
82
|
+
this.textInputStyle = textInputStyle;
|
|
83
|
+
this.quickViewStyle = quickViewStyle;
|
|
84
|
+
this.radioButtonStyle = radioButtonStyle;
|
|
85
|
+
this.checkboxStyle = checkboxStyle;
|
|
86
|
+
this.dropdownStyle = dropdownStyle;
|
|
87
|
+
this.labelStyle = labelStyle;
|
|
88
|
+
this.buttonStyle = buttonStyle;
|
|
89
|
+
this.singleSelectStyle = singleSelectStyle;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { CometChatFormBubble, CometChatFormBubbleInterface } from './CometChatFormBubble'
|
|
@@ -30,6 +30,11 @@ export interface CometChatImageBubbleInterface {
|
|
|
30
30
|
* style object of type ImageBubbleStyleInterface
|
|
31
31
|
*/
|
|
32
32
|
style?: ImageBubbleStyleInterface
|
|
33
|
+
/**
|
|
34
|
+
* resizeMode of image
|
|
35
|
+
* @default "cover"
|
|
36
|
+
*/
|
|
37
|
+
resizeMode?: 'cover' | 'contain' | 'stretch' | 'repeat' | 'center'
|
|
33
38
|
}
|
|
34
39
|
|
|
35
40
|
export const CometChatImageBubble = (props: CometChatImageBubbleInterface) => {
|
|
@@ -38,7 +43,8 @@ export const CometChatImageBubble = (props: CometChatImageBubbleInterface) => {
|
|
|
38
43
|
imageUrl,
|
|
39
44
|
onPress,
|
|
40
45
|
placeHolderImage,
|
|
41
|
-
style
|
|
46
|
+
style,
|
|
47
|
+
resizeMode,
|
|
42
48
|
} = props;
|
|
43
49
|
|
|
44
50
|
const _style = new ImageBubbleStyle(style || {});
|
|
@@ -50,7 +56,8 @@ export const CometChatImageBubble = (props: CometChatImageBubbleInterface) => {
|
|
|
50
56
|
border,
|
|
51
57
|
borderRadius,
|
|
52
58
|
height,
|
|
53
|
-
width
|
|
59
|
+
width,
|
|
60
|
+
aspectRatio
|
|
54
61
|
} = _style
|
|
55
62
|
|
|
56
63
|
const getFileName = (url: string) => {
|
|
@@ -67,8 +74,8 @@ export const CometChatImageBubble = (props: CometChatImageBubbleInterface) => {
|
|
|
67
74
|
}
|
|
68
75
|
|
|
69
76
|
Platform.OS == 'ios' ?
|
|
70
|
-
FileManager.openFile(url.current, getFileName(url.current), (s) => {}) :
|
|
71
|
-
ImageManager.openImage(url.current, s => {});
|
|
77
|
+
FileManager.openFile(url.current, getFileName(url.current), (s) => { }) :
|
|
78
|
+
ImageManager.openImage(url.current, s => { });
|
|
72
79
|
}
|
|
73
80
|
|
|
74
81
|
useEffect(() => {
|
|
@@ -92,10 +99,11 @@ export const CometChatImageBubble = (props: CometChatImageBubbleInterface) => {
|
|
|
92
99
|
return (
|
|
93
100
|
<View onTouchEnd={openImage}>
|
|
94
101
|
<Image
|
|
95
|
-
resizeMode={Platform.OS == "android" ? "cover" : "contain"}
|
|
102
|
+
resizeMode={resizeMode || (Platform.OS == "android" ? "cover" : "contain")}
|
|
96
103
|
loadingIndicatorSource={placeHolderImage}
|
|
97
104
|
source={thumbnailUrl ?? imageUrl} style={{
|
|
98
105
|
height, width,
|
|
106
|
+
aspectRatio,
|
|
99
107
|
backgroundColor,
|
|
100
108
|
borderRadius,
|
|
101
109
|
...border
|
|
@@ -1,23 +1,34 @@
|
|
|
1
1
|
import { BaseStyle, BaseStyleInterface } from "../../base";
|
|
2
2
|
|
|
3
3
|
export interface ImageBubbleStyleInterface extends Omit<BaseStyleInterface, "border"> {
|
|
4
|
-
border?: {borderWidth: number, borderColor: string}
|
|
4
|
+
border?: {borderWidth: number, borderColor: string};
|
|
5
|
+
/**
|
|
6
|
+
* The aspect ratio for the image. Can only be used when either height or width is provided. If both values are provided, then the aspectRatio value will be ignored.
|
|
7
|
+
* @type number
|
|
8
|
+
* @example 1.77 or 16/9 for horizontal image
|
|
9
|
+
* @example 0.8 or 4/5 for vertical image
|
|
10
|
+
* @example 1 for square image
|
|
11
|
+
**/
|
|
12
|
+
aspectRatio?: number;
|
|
5
13
|
}
|
|
6
14
|
|
|
7
15
|
export class ImageBubbleStyle extends BaseStyle {
|
|
16
|
+
aspectRatio: number;
|
|
8
17
|
constructor({
|
|
9
18
|
backgroundColor = "transparent",
|
|
10
19
|
border = {borderWidth: 0, borderColor: "rgb(0,0,0)"},
|
|
11
20
|
borderRadius,
|
|
12
21
|
height = "auto",
|
|
13
|
-
width = "auto"
|
|
22
|
+
width = "auto",
|
|
23
|
+
aspectRatio,
|
|
14
24
|
}: ImageBubbleStyleInterface) {
|
|
15
25
|
super({
|
|
16
26
|
backgroundColor,
|
|
17
27
|
border,
|
|
18
28
|
borderRadius,
|
|
19
29
|
height,
|
|
20
|
-
width
|
|
30
|
+
width,
|
|
21
31
|
});
|
|
32
|
+
this.aspectRatio = aspectRatio;
|
|
22
33
|
}
|
|
23
34
|
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { View, Text } from 'react-native'
|
|
3
|
+
import { LabelStyle, LabelStyleInterface } from './LabelStyle';
|
|
4
|
+
export interface CometChatCardBubbleInterface {
|
|
5
|
+
text: string,
|
|
6
|
+
style?: LabelStyleInterface,
|
|
7
|
+
}
|
|
8
|
+
const CometChatLabel = (props: CometChatCardBubbleInterface) => {
|
|
9
|
+
const {
|
|
10
|
+
text,
|
|
11
|
+
style,
|
|
12
|
+
} = props;
|
|
13
|
+
const _style = new LabelStyle({
|
|
14
|
+
...style,
|
|
15
|
+
})
|
|
16
|
+
const {
|
|
17
|
+
labelColor,
|
|
18
|
+
labelFont,
|
|
19
|
+
} = _style;
|
|
20
|
+
return (
|
|
21
|
+
<View style={{ padding: 10 }}>
|
|
22
|
+
<Text style={[labelFont, { color: labelColor }]}>{text}</Text>
|
|
23
|
+
</View>
|
|
24
|
+
)
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
export default CometChatLabel
|