stream-chat-react-native-core 5.39.6 → 5.40.0-beta.1
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/AttachmentPicker/components/AttachmentPickerSelectionBar.js +27 -0
- package/lib/commonjs/components/AttachmentPicker/components/AttachmentPickerSelectionBar.js.map +1 -1
- package/lib/commonjs/components/Channel/Channel.js +17 -4
- package/lib/commonjs/components/Channel/Channel.js.map +1 -1
- package/lib/commonjs/components/Channel/hooks/useCreateInputMessageInputContext.js +7 -1
- package/lib/commonjs/components/Channel/hooks/useCreateInputMessageInputContext.js.map +1 -1
- package/lib/commonjs/components/Channel/hooks/useCreateMessagesContext.js +5 -1
- package/lib/commonjs/components/Channel/hooks/useCreateMessagesContext.js.map +1 -1
- package/lib/commonjs/components/ChannelPreview/hooks/useLatestMessagePreview.js +46 -3
- package/lib/commonjs/components/ChannelPreview/hooks/useLatestMessagePreview.js.map +1 -1
- package/lib/commonjs/components/Chat/Chat.js +2 -0
- package/lib/commonjs/components/Chat/Chat.js.map +1 -1
- package/lib/commonjs/components/Chat/hooks/handleEventToSyncDB.js +10 -0
- package/lib/commonjs/components/Chat/hooks/handleEventToSyncDB.js.map +1 -1
- package/lib/commonjs/components/Message/Message.js +13 -0
- package/lib/commonjs/components/Message/Message.js.map +1 -1
- package/lib/commonjs/components/Message/MessageSimple/MessageContent.js +31 -15
- package/lib/commonjs/components/Message/MessageSimple/MessageContent.js.map +1 -1
- package/lib/commonjs/components/MessageInput/MessageInput.js +44 -1
- package/lib/commonjs/components/MessageInput/MessageInput.js.map +1 -1
- package/lib/commonjs/components/MessageInput/components/NativeAttachmentPicker.js +18 -1
- package/lib/commonjs/components/MessageInput/components/NativeAttachmentPicker.js.map +1 -1
- package/lib/commonjs/components/MessageOverlay/MessageOverlay.js +10 -0
- package/lib/commonjs/components/MessageOverlay/MessageOverlay.js.map +1 -1
- package/lib/commonjs/components/Poll/CreatePollContent.js +386 -0
- package/lib/commonjs/components/Poll/CreatePollContent.js.map +1 -0
- package/lib/commonjs/components/Poll/Poll.js +112 -0
- package/lib/commonjs/components/Poll/Poll.js.map +1 -0
- package/lib/commonjs/components/Poll/components/Button.js +513 -0
- package/lib/commonjs/components/Poll/components/Button.js.map +1 -0
- package/lib/commonjs/components/Poll/components/CreatePollIcon.js +23 -0
- package/lib/commonjs/components/Poll/components/CreatePollIcon.js.map +1 -0
- package/lib/commonjs/components/Poll/components/CreatePollOptions.js +281 -0
- package/lib/commonjs/components/Poll/components/CreatePollOptions.js.map +1 -0
- package/lib/commonjs/components/Poll/components/PollAnswersList.js +154 -0
- package/lib/commonjs/components/Poll/components/PollAnswersList.js.map +1 -0
- package/lib/commonjs/components/Poll/components/PollInputDialog.js +139 -0
- package/lib/commonjs/components/Poll/components/PollInputDialog.js.map +1 -0
- package/lib/commonjs/components/Poll/components/PollModalHeader.js +60 -0
- package/lib/commonjs/components/Poll/components/PollModalHeader.js.map +1 -0
- package/lib/commonjs/components/Poll/components/PollOption.js +209 -0
- package/lib/commonjs/components/Poll/components/PollOption.js.map +1 -0
- package/lib/commonjs/components/Poll/components/PollResults/PollOptionFullResults.js +123 -0
- package/lib/commonjs/components/Poll/components/PollResults/PollOptionFullResults.js.map +1 -0
- package/lib/commonjs/components/Poll/components/PollResults/PollResultItem.js +152 -0
- package/lib/commonjs/components/Poll/components/PollResults/PollResultItem.js.map +1 -0
- package/lib/commonjs/components/Poll/components/PollResults/PollResults.js +101 -0
- package/lib/commonjs/components/Poll/components/PollResults/PollResults.js.map +1 -0
- package/lib/commonjs/components/Poll/components/PollResults/index.js +37 -0
- package/lib/commonjs/components/Poll/components/PollResults/index.js.map +1 -0
- package/lib/commonjs/components/Poll/components/index.js +92 -0
- package/lib/commonjs/components/Poll/components/index.js.map +1 -0
- package/lib/commonjs/components/Poll/hooks/usePollAnswersPagination.js +129 -0
- package/lib/commonjs/components/Poll/hooks/usePollAnswersPagination.js.map +1 -0
- package/lib/commonjs/components/Poll/hooks/usePollOptionVotesPagination.js +140 -0
- package/lib/commonjs/components/Poll/hooks/usePollOptionVotesPagination.js.map +1 -0
- package/lib/commonjs/components/Poll/hooks/usePollState.js +103 -0
- package/lib/commonjs/components/Poll/hooks/usePollState.js.map +1 -0
- package/lib/commonjs/components/Poll/hooks/usePollStateStore.js +13 -0
- package/lib/commonjs/components/Poll/hooks/usePollStateStore.js.map +1 -0
- package/lib/commonjs/components/Poll/index.js +81 -0
- package/lib/commonjs/components/Poll/index.js.map +1 -0
- package/lib/commonjs/components/Reply/Reply.js +1 -1
- package/lib/commonjs/components/Reply/Reply.js.map +1 -1
- package/lib/commonjs/components/index.js +11 -0
- package/lib/commonjs/components/index.js.map +1 -1
- package/lib/commonjs/contexts/attachmentPickerContext/AttachmentPickerContext.js.map +1 -1
- package/lib/commonjs/contexts/index.js +11 -0
- package/lib/commonjs/contexts/index.js.map +1 -1
- package/lib/commonjs/contexts/messageInputContext/MessageInputContext.js +26 -3
- package/lib/commonjs/contexts/messageInputContext/MessageInputContext.js.map +1 -1
- package/lib/commonjs/contexts/messageInputContext/hooks/useCreateMessageInputContext.js +9 -1
- package/lib/commonjs/contexts/messageInputContext/hooks/useCreateMessageInputContext.js.map +1 -1
- package/lib/commonjs/contexts/messageOverlayContext/MessageOverlayContext.js.map +1 -1
- package/lib/commonjs/contexts/messagesContext/MessagesContext.js.map +1 -1
- package/lib/commonjs/contexts/overlayContext/OverlayContext.js.map +1 -1
- package/lib/commonjs/contexts/overlayContext/OverlayProvider.js +4 -0
- package/lib/commonjs/contexts/overlayContext/OverlayProvider.js.map +1 -1
- package/lib/commonjs/contexts/ownCapabilitiesContext/OwnCapabilitiesContext.js +3 -0
- package/lib/commonjs/contexts/ownCapabilitiesContext/OwnCapabilitiesContext.js.map +1 -1
- package/lib/commonjs/contexts/pollContext/createPollContentContext.js +33 -0
- package/lib/commonjs/contexts/pollContext/createPollContentContext.js.map +1 -0
- package/lib/commonjs/contexts/pollContext/index.js +26 -0
- package/lib/commonjs/contexts/pollContext/index.js.map +1 -0
- package/lib/commonjs/contexts/pollContext/pollContext.js +33 -0
- package/lib/commonjs/contexts/pollContext/pollContext.js.map +1 -0
- package/lib/commonjs/contexts/themeContext/utils/theme.js +126 -0
- package/lib/commonjs/contexts/themeContext/utils/theme.js.map +1 -1
- package/lib/commonjs/i18n/en.json +34 -0
- package/lib/commonjs/i18n/es.json +38 -0
- package/lib/commonjs/i18n/fr.json +38 -0
- package/lib/commonjs/i18n/he.json +38 -0
- package/lib/commonjs/i18n/hi.json +34 -0
- package/lib/commonjs/i18n/it.json +38 -0
- package/lib/commonjs/i18n/ja.json +34 -0
- package/lib/commonjs/i18n/ko.json +34 -0
- package/lib/commonjs/i18n/nl.json +34 -0
- package/lib/commonjs/i18n/pt-br.json +38 -0
- package/lib/commonjs/i18n/ru.json +42 -0
- package/lib/commonjs/i18n/tr.json +34 -0
- package/lib/commonjs/icons/Back.js +19 -0
- package/lib/commonjs/icons/Back.js.map +1 -0
- package/lib/commonjs/icons/DragHandle.js +21 -0
- package/lib/commonjs/icons/DragHandle.js.map +1 -0
- package/lib/commonjs/icons/PollThumbnail.js +19 -0
- package/lib/commonjs/icons/PollThumbnail.js.map +1 -0
- package/lib/commonjs/icons/SendPoll.js +19 -0
- package/lib/commonjs/icons/SendPoll.js.map +1 -0
- package/lib/commonjs/icons/index.js +44 -0
- package/lib/commonjs/icons/index.js.map +1 -1
- package/lib/commonjs/store/QuickSqliteClient.js +1 -1
- package/lib/commonjs/store/apis/index.js +11 -0
- package/lib/commonjs/store/apis/index.js.map +1 -1
- package/lib/commonjs/store/apis/updatePollMessage.js +50 -0
- package/lib/commonjs/store/apis/updatePollMessage.js.map +1 -0
- package/lib/commonjs/store/mappers/mapMessageToStorable.js +5 -1
- package/lib/commonjs/store/mappers/mapMessageToStorable.js.map +1 -1
- package/lib/commonjs/store/mappers/mapStorableToMessage.js +5 -1
- package/lib/commonjs/store/mappers/mapStorableToMessage.js.map +1 -1
- package/lib/commonjs/store/schema.js +2 -0
- package/lib/commonjs/store/schema.js.map +1 -1
- package/lib/commonjs/version.json +1 -1
- package/lib/module/components/AttachmentPicker/components/AttachmentPickerSelectionBar.js +27 -0
- package/lib/module/components/AttachmentPicker/components/AttachmentPickerSelectionBar.js.map +1 -1
- package/lib/module/components/Channel/Channel.js +17 -4
- package/lib/module/components/Channel/Channel.js.map +1 -1
- package/lib/module/components/Channel/hooks/useCreateInputMessageInputContext.js +7 -1
- package/lib/module/components/Channel/hooks/useCreateInputMessageInputContext.js.map +1 -1
- package/lib/module/components/Channel/hooks/useCreateMessagesContext.js +5 -1
- package/lib/module/components/Channel/hooks/useCreateMessagesContext.js.map +1 -1
- package/lib/module/components/ChannelPreview/hooks/useLatestMessagePreview.js +46 -3
- package/lib/module/components/ChannelPreview/hooks/useLatestMessagePreview.js.map +1 -1
- package/lib/module/components/Chat/Chat.js +2 -0
- package/lib/module/components/Chat/Chat.js.map +1 -1
- package/lib/module/components/Chat/hooks/handleEventToSyncDB.js +10 -0
- package/lib/module/components/Chat/hooks/handleEventToSyncDB.js.map +1 -1
- package/lib/module/components/Message/Message.js +13 -0
- package/lib/module/components/Message/Message.js.map +1 -1
- package/lib/module/components/Message/MessageSimple/MessageContent.js +31 -15
- package/lib/module/components/Message/MessageSimple/MessageContent.js.map +1 -1
- package/lib/module/components/MessageInput/MessageInput.js +44 -1
- package/lib/module/components/MessageInput/MessageInput.js.map +1 -1
- package/lib/module/components/MessageInput/components/NativeAttachmentPicker.js +18 -1
- package/lib/module/components/MessageInput/components/NativeAttachmentPicker.js.map +1 -1
- package/lib/module/components/MessageOverlay/MessageOverlay.js +10 -0
- package/lib/module/components/MessageOverlay/MessageOverlay.js.map +1 -1
- package/lib/module/components/Poll/CreatePollContent.js +386 -0
- package/lib/module/components/Poll/CreatePollContent.js.map +1 -0
- package/lib/module/components/Poll/Poll.js +112 -0
- package/lib/module/components/Poll/Poll.js.map +1 -0
- package/lib/module/components/Poll/components/Button.js +513 -0
- package/lib/module/components/Poll/components/Button.js.map +1 -0
- package/lib/module/components/Poll/components/CreatePollIcon.js +23 -0
- package/lib/module/components/Poll/components/CreatePollIcon.js.map +1 -0
- package/lib/module/components/Poll/components/CreatePollOptions.js +281 -0
- package/lib/module/components/Poll/components/CreatePollOptions.js.map +1 -0
- package/lib/module/components/Poll/components/PollAnswersList.js +154 -0
- package/lib/module/components/Poll/components/PollAnswersList.js.map +1 -0
- package/lib/module/components/Poll/components/PollInputDialog.js +139 -0
- package/lib/module/components/Poll/components/PollInputDialog.js.map +1 -0
- package/lib/module/components/Poll/components/PollModalHeader.js +60 -0
- package/lib/module/components/Poll/components/PollModalHeader.js.map +1 -0
- package/lib/module/components/Poll/components/PollOption.js +209 -0
- package/lib/module/components/Poll/components/PollOption.js.map +1 -0
- package/lib/module/components/Poll/components/PollResults/PollOptionFullResults.js +123 -0
- package/lib/module/components/Poll/components/PollResults/PollOptionFullResults.js.map +1 -0
- package/lib/module/components/Poll/components/PollResults/PollResultItem.js +152 -0
- package/lib/module/components/Poll/components/PollResults/PollResultItem.js.map +1 -0
- package/lib/module/components/Poll/components/PollResults/PollResults.js +101 -0
- package/lib/module/components/Poll/components/PollResults/PollResults.js.map +1 -0
- package/lib/module/components/Poll/components/PollResults/index.js +37 -0
- package/lib/module/components/Poll/components/PollResults/index.js.map +1 -0
- package/lib/module/components/Poll/components/index.js +92 -0
- package/lib/module/components/Poll/components/index.js.map +1 -0
- package/lib/module/components/Poll/hooks/usePollAnswersPagination.js +129 -0
- package/lib/module/components/Poll/hooks/usePollAnswersPagination.js.map +1 -0
- package/lib/module/components/Poll/hooks/usePollOptionVotesPagination.js +140 -0
- package/lib/module/components/Poll/hooks/usePollOptionVotesPagination.js.map +1 -0
- package/lib/module/components/Poll/hooks/usePollState.js +103 -0
- package/lib/module/components/Poll/hooks/usePollState.js.map +1 -0
- package/lib/module/components/Poll/hooks/usePollStateStore.js +13 -0
- package/lib/module/components/Poll/hooks/usePollStateStore.js.map +1 -0
- package/lib/module/components/Poll/index.js +81 -0
- package/lib/module/components/Poll/index.js.map +1 -0
- package/lib/module/components/Reply/Reply.js +1 -1
- package/lib/module/components/Reply/Reply.js.map +1 -1
- package/lib/module/components/index.js +11 -0
- package/lib/module/components/index.js.map +1 -1
- package/lib/module/contexts/attachmentPickerContext/AttachmentPickerContext.js.map +1 -1
- package/lib/module/contexts/index.js +11 -0
- package/lib/module/contexts/index.js.map +1 -1
- package/lib/module/contexts/messageInputContext/MessageInputContext.js +26 -3
- package/lib/module/contexts/messageInputContext/MessageInputContext.js.map +1 -1
- package/lib/module/contexts/messageInputContext/hooks/useCreateMessageInputContext.js +9 -1
- package/lib/module/contexts/messageInputContext/hooks/useCreateMessageInputContext.js.map +1 -1
- package/lib/module/contexts/messageOverlayContext/MessageOverlayContext.js.map +1 -1
- package/lib/module/contexts/messagesContext/MessagesContext.js.map +1 -1
- package/lib/module/contexts/overlayContext/OverlayContext.js.map +1 -1
- package/lib/module/contexts/overlayContext/OverlayProvider.js +4 -0
- package/lib/module/contexts/overlayContext/OverlayProvider.js.map +1 -1
- package/lib/module/contexts/ownCapabilitiesContext/OwnCapabilitiesContext.js +3 -0
- package/lib/module/contexts/ownCapabilitiesContext/OwnCapabilitiesContext.js.map +1 -1
- package/lib/module/contexts/pollContext/createPollContentContext.js +33 -0
- package/lib/module/contexts/pollContext/createPollContentContext.js.map +1 -0
- package/lib/module/contexts/pollContext/index.js +26 -0
- package/lib/module/contexts/pollContext/index.js.map +1 -0
- package/lib/module/contexts/pollContext/pollContext.js +33 -0
- package/lib/module/contexts/pollContext/pollContext.js.map +1 -0
- package/lib/module/contexts/themeContext/utils/theme.js +126 -0
- package/lib/module/contexts/themeContext/utils/theme.js.map +1 -1
- package/lib/module/i18n/en.json +34 -0
- package/lib/module/i18n/es.json +38 -0
- package/lib/module/i18n/fr.json +38 -0
- package/lib/module/i18n/he.json +38 -0
- package/lib/module/i18n/hi.json +34 -0
- package/lib/module/i18n/it.json +38 -0
- package/lib/module/i18n/ja.json +34 -0
- package/lib/module/i18n/ko.json +34 -0
- package/lib/module/i18n/nl.json +34 -0
- package/lib/module/i18n/pt-br.json +38 -0
- package/lib/module/i18n/ru.json +42 -0
- package/lib/module/i18n/tr.json +34 -0
- package/lib/module/icons/Back.js +19 -0
- package/lib/module/icons/Back.js.map +1 -0
- package/lib/module/icons/DragHandle.js +21 -0
- package/lib/module/icons/DragHandle.js.map +1 -0
- package/lib/module/icons/PollThumbnail.js +19 -0
- package/lib/module/icons/PollThumbnail.js.map +1 -0
- package/lib/module/icons/SendPoll.js +19 -0
- package/lib/module/icons/SendPoll.js.map +1 -0
- package/lib/module/icons/index.js +44 -0
- package/lib/module/icons/index.js.map +1 -1
- package/lib/module/store/QuickSqliteClient.js +1 -1
- package/lib/module/store/apis/index.js +11 -0
- package/lib/module/store/apis/index.js.map +1 -1
- package/lib/module/store/apis/updatePollMessage.js +50 -0
- package/lib/module/store/apis/updatePollMessage.js.map +1 -0
- package/lib/module/store/mappers/mapMessageToStorable.js +5 -1
- package/lib/module/store/mappers/mapMessageToStorable.js.map +1 -1
- package/lib/module/store/mappers/mapStorableToMessage.js +5 -1
- package/lib/module/store/mappers/mapStorableToMessage.js.map +1 -1
- package/lib/module/store/schema.js +2 -0
- package/lib/module/store/schema.js.map +1 -1
- package/lib/module/version.json +1 -1
- package/lib/typescript/components/AttachmentPicker/components/AttachmentPickerSelectionBar.d.ts.map +1 -1
- package/lib/typescript/components/Channel/Channel.d.ts +2 -2
- package/lib/typescript/components/Channel/Channel.d.ts.map +1 -1
- package/lib/typescript/components/Channel/hooks/useCreateInputMessageInputContext.d.ts +1 -1
- package/lib/typescript/components/Channel/hooks/useCreateInputMessageInputContext.d.ts.map +1 -1
- package/lib/typescript/components/Channel/hooks/useCreateMessagesContext.d.ts +1 -1
- package/lib/typescript/components/Channel/hooks/useCreateMessagesContext.d.ts.map +1 -1
- package/lib/typescript/components/ChannelPreview/hooks/useLatestMessagePreview.d.ts +5 -1
- package/lib/typescript/components/ChannelPreview/hooks/useLatestMessagePreview.d.ts.map +1 -1
- package/lib/typescript/components/Chat/Chat.d.ts.map +1 -1
- package/lib/typescript/components/Chat/hooks/handleEventToSyncDB.d.ts.map +1 -1
- package/lib/typescript/components/Message/Message.d.ts +1 -1
- package/lib/typescript/components/Message/Message.d.ts.map +1 -1
- package/lib/typescript/components/Message/MessageSimple/MessageContent.d.ts.map +1 -1
- package/lib/typescript/components/MessageInput/MessageInput.d.ts +1 -1
- package/lib/typescript/components/MessageInput/MessageInput.d.ts.map +1 -1
- package/lib/typescript/components/MessageInput/components/NativeAttachmentPicker.d.ts.map +1 -1
- package/lib/typescript/components/MessageOverlay/MessageOverlay.d.ts.map +1 -1
- package/lib/typescript/components/Poll/CreatePollContent.d.ts +6 -0
- package/lib/typescript/components/Poll/CreatePollContent.d.ts.map +1 -0
- package/lib/typescript/components/Poll/Poll.d.ts +13 -0
- package/lib/typescript/components/Poll/Poll.d.ts.map +1 -0
- package/lib/typescript/components/Poll/components/Button.d.ts +35 -0
- package/lib/typescript/components/Poll/components/Button.d.ts.map +1 -0
- package/lib/typescript/components/Poll/components/CreatePollIcon.d.ts +3 -0
- package/lib/typescript/components/Poll/components/CreatePollIcon.d.ts.map +1 -0
- package/lib/typescript/components/Poll/components/CreatePollOptions.d.ts +34 -0
- package/lib/typescript/components/Poll/components/CreatePollOptions.d.ts.map +1 -0
- package/lib/typescript/components/Poll/components/PollAnswersList.d.ts +15 -0
- package/lib/typescript/components/Poll/components/PollAnswersList.d.ts.map +1 -0
- package/lib/typescript/components/Poll/components/PollInputDialog.d.ts +10 -0
- package/lib/typescript/components/Poll/components/PollInputDialog.d.ts.map +1 -0
- package/lib/typescript/components/Poll/components/PollModalHeader.d.ts +7 -0
- package/lib/typescript/components/Poll/components/PollModalHeader.d.ts.map +1 -0
- package/lib/typescript/components/Poll/components/PollOption.d.ts +16 -0
- package/lib/typescript/components/Poll/components/PollOption.d.ts.map +1 -0
- package/lib/typescript/components/Poll/components/PollResults/PollOptionFullResults.d.ts +18 -0
- package/lib/typescript/components/Poll/components/PollResults/PollOptionFullResults.d.ts.map +1 -0
- package/lib/typescript/components/Poll/components/PollResults/PollResultItem.d.ts +9 -0
- package/lib/typescript/components/Poll/components/PollResults/PollResultItem.d.ts.map +1 -0
- package/lib/typescript/components/Poll/components/PollResults/PollResults.d.ts +10 -0
- package/lib/typescript/components/Poll/components/PollResults/PollResults.d.ts.map +1 -0
- package/lib/typescript/components/Poll/components/PollResults/index.d.ts +4 -0
- package/lib/typescript/components/Poll/components/PollResults/index.d.ts.map +1 -0
- package/lib/typescript/components/Poll/components/index.d.ts +9 -0
- package/lib/typescript/components/Poll/components/index.d.ts.map +1 -0
- package/lib/typescript/components/Poll/hooks/usePollAnswersPagination.d.ts +29 -0
- package/lib/typescript/components/Poll/hooks/usePollAnswersPagination.d.ts.map +1 -0
- package/lib/typescript/components/Poll/hooks/usePollOptionVotesPagination.d.ts +32 -0
- package/lib/typescript/components/Poll/hooks/usePollOptionVotesPagination.d.ts.map +1 -0
- package/lib/typescript/components/Poll/hooks/usePollState.d.ts +26 -0
- package/lib/typescript/components/Poll/hooks/usePollState.d.ts.map +1 -0
- package/lib/typescript/components/Poll/hooks/usePollStateStore.d.ts +3 -0
- package/lib/typescript/components/Poll/hooks/usePollStateStore.d.ts.map +1 -0
- package/lib/typescript/components/Poll/index.d.ts +8 -0
- package/lib/typescript/components/Poll/index.d.ts.map +1 -0
- package/lib/typescript/components/Reply/Reply.d.ts.map +1 -1
- package/lib/typescript/components/index.d.ts +1 -0
- package/lib/typescript/components/index.d.ts.map +1 -1
- package/lib/typescript/contexts/attachmentPickerContext/AttachmentPickerContext.d.ts +7 -1
- package/lib/typescript/contexts/attachmentPickerContext/AttachmentPickerContext.d.ts.map +1 -1
- package/lib/typescript/contexts/index.d.ts +1 -0
- package/lib/typescript/contexts/index.d.ts.map +1 -1
- package/lib/typescript/contexts/messageInputContext/MessageInputContext.d.ts +11 -2
- package/lib/typescript/contexts/messageInputContext/MessageInputContext.d.ts.map +1 -1
- package/lib/typescript/contexts/messageInputContext/hooks/useCreateMessageInputContext.d.ts +1 -1
- package/lib/typescript/contexts/messageInputContext/hooks/useCreateMessageInputContext.d.ts.map +1 -1
- package/lib/typescript/contexts/messageOverlayContext/MessageOverlayContext.d.ts +2 -1
- package/lib/typescript/contexts/messageOverlayContext/MessageOverlayContext.d.ts.map +1 -1
- package/lib/typescript/contexts/messagesContext/MessagesContext.d.ts +9 -1
- package/lib/typescript/contexts/messagesContext/MessagesContext.d.ts.map +1 -1
- package/lib/typescript/contexts/overlayContext/OverlayContext.d.ts +1 -1
- package/lib/typescript/contexts/overlayContext/OverlayContext.d.ts.map +1 -1
- package/lib/typescript/contexts/overlayContext/OverlayProvider.d.ts.map +1 -1
- package/lib/typescript/contexts/ownCapabilitiesContext/OwnCapabilitiesContext.d.ts +3 -0
- package/lib/typescript/contexts/ownCapabilitiesContext/OwnCapabilitiesContext.d.ts.map +1 -1
- package/lib/typescript/contexts/pollContext/createPollContentContext.d.ts +20 -0
- package/lib/typescript/contexts/pollContext/createPollContentContext.d.ts.map +1 -0
- package/lib/typescript/contexts/pollContext/index.d.ts +3 -0
- package/lib/typescript/contexts/pollContext/index.d.ts.map +1 -0
- package/lib/typescript/contexts/pollContext/pollContext.d.ts +14 -0
- package/lib/typescript/contexts/pollContext/pollContext.d.ts.map +1 -0
- package/lib/typescript/contexts/themeContext/utils/theme.d.ts +126 -0
- package/lib/typescript/contexts/themeContext/utils/theme.d.ts.map +1 -1
- package/lib/typescript/i18n/en.json +34 -0
- package/lib/typescript/i18n/es.json +38 -0
- package/lib/typescript/i18n/fr.json +38 -0
- package/lib/typescript/i18n/he.json +38 -0
- package/lib/typescript/i18n/hi.json +34 -0
- package/lib/typescript/i18n/it.json +38 -0
- package/lib/typescript/i18n/ja.json +34 -0
- package/lib/typescript/i18n/ko.json +34 -0
- package/lib/typescript/i18n/nl.json +34 -0
- package/lib/typescript/i18n/pt-br.json +38 -0
- package/lib/typescript/i18n/ru.json +42 -0
- package/lib/typescript/i18n/tr.json +34 -0
- package/lib/typescript/icons/Back.d.ts +4 -0
- package/lib/typescript/icons/Back.d.ts.map +1 -0
- package/lib/typescript/icons/DragHandle.d.ts +4 -0
- package/lib/typescript/icons/DragHandle.d.ts.map +1 -0
- package/lib/typescript/icons/PollThumbnail.d.ts +4 -0
- package/lib/typescript/icons/PollThumbnail.d.ts.map +1 -0
- package/lib/typescript/icons/SendPoll.d.ts +4 -0
- package/lib/typescript/icons/SendPoll.d.ts.map +1 -0
- package/lib/typescript/icons/index.d.ts +4 -0
- package/lib/typescript/icons/index.d.ts.map +1 -1
- package/lib/typescript/store/apis/index.d.ts +1 -0
- package/lib/typescript/store/apis/index.d.ts.map +1 -1
- package/lib/typescript/store/apis/updatePollMessage.d.ts +7 -0
- package/lib/typescript/store/apis/updatePollMessage.d.ts.map +1 -0
- package/lib/typescript/store/mappers/mapMessageToStorable.d.ts.map +1 -1
- package/lib/typescript/store/mappers/mapStorableToMessage.d.ts.map +1 -1
- package/lib/typescript/store/schema.d.ts +2 -0
- package/lib/typescript/store/schema.d.ts.map +1 -1
- package/lib/typescript/utils/i18n/Streami18n.d.ts +34 -0
- package/lib/typescript/utils/i18n/Streami18n.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/components/AttachmentPicker/components/AttachmentPickerSelectionBar.tsx +35 -2
- package/src/components/Channel/Channel.tsx +27 -4
- package/src/components/Channel/hooks/useCreateInputMessageInputContext.ts +16 -1
- package/src/components/Channel/hooks/useCreateMessagesContext.ts +5 -0
- package/src/components/ChannelPreview/hooks/useLatestMessagePreview.ts +63 -4
- package/src/components/Chat/Chat.tsx +2 -0
- package/src/components/Chat/hooks/handleEventToSyncDB.ts +19 -0
- package/src/components/Message/Message.tsx +15 -1
- package/src/components/Message/MessageSimple/MessageContent.tsx +16 -0
- package/src/components/MessageInput/MessageInput.tsx +58 -1
- package/src/components/MessageInput/__tests__/MessageInput.test.js +2 -0
- package/src/components/MessageInput/components/NativeAttachmentPicker.tsx +29 -2
- package/src/components/MessageOverlay/MessageOverlay.tsx +10 -0
- package/src/components/Poll/CreatePollContent.tsx +299 -0
- package/src/components/Poll/Poll.tsx +126 -0
- package/src/components/Poll/components/Button.tsx +465 -0
- package/src/components/Poll/components/CreatePollIcon.tsx +14 -0
- package/src/components/Poll/components/CreatePollOptions.tsx +351 -0
- package/src/components/Poll/components/PollAnswersList.tsx +134 -0
- package/src/components/Poll/components/PollInputDialog.tsx +117 -0
- package/src/components/Poll/components/PollModalHeader.tsx +42 -0
- package/src/components/Poll/components/PollOption.tsx +172 -0
- package/src/components/Poll/components/PollResults/PollOptionFullResults.tsx +108 -0
- package/src/components/Poll/components/PollResults/PollResultItem.tsx +115 -0
- package/src/components/Poll/components/PollResults/PollResults.tsx +79 -0
- package/src/components/Poll/components/PollResults/index.ts +3 -0
- package/src/components/Poll/components/index.ts +8 -0
- package/src/components/Poll/hooks/usePollAnswersPagination.ts +109 -0
- package/src/components/Poll/hooks/usePollOptionVotesPagination.ts +119 -0
- package/src/components/Poll/hooks/usePollState.ts +122 -0
- package/src/components/Poll/hooks/usePollStateStore.ts +13 -0
- package/src/components/Poll/index.ts +10 -0
- package/src/components/Reply/Reply.tsx +2 -0
- package/src/components/index.ts +1 -0
- package/src/contexts/attachmentPickerContext/AttachmentPickerContext.tsx +12 -1
- package/src/contexts/index.ts +1 -0
- package/src/contexts/messageInputContext/MessageInputContext.tsx +38 -10
- package/src/contexts/messageInputContext/__tests__/pickFile.test.tsx +4 -2
- package/src/contexts/messageInputContext/hooks/useCreateMessageInputContext.ts +9 -0
- package/src/contexts/messageOverlayContext/MessageOverlayContext.tsx +2 -1
- package/src/contexts/messagesContext/MessagesContext.tsx +15 -2
- package/src/contexts/overlayContext/OverlayContext.tsx +1 -0
- package/src/contexts/overlayContext/OverlayProvider.tsx +3 -0
- package/src/contexts/ownCapabilitiesContext/OwnCapabilitiesContext.tsx +3 -0
- package/src/contexts/pollContext/createPollContentContext.tsx +49 -0
- package/src/contexts/pollContext/index.ts +2 -0
- package/src/contexts/pollContext/pollContext.tsx +43 -0
- package/src/contexts/themeContext/utils/theme.ts +233 -0
- package/src/i18n/en.json +34 -0
- package/src/i18n/es.json +38 -0
- package/src/i18n/fr.json +38 -0
- package/src/i18n/he.json +38 -0
- package/src/i18n/hi.json +34 -0
- package/src/i18n/it.json +38 -0
- package/src/i18n/ja.json +34 -0
- package/src/i18n/ko.json +34 -0
- package/src/i18n/nl.json +34 -0
- package/src/i18n/pt-br.json +38 -0
- package/src/i18n/ru.json +42 -0
- package/src/i18n/tr.json +34 -0
- package/src/icons/Back.tsx +12 -0
- package/src/icons/DragHandle.tsx +9 -0
- package/src/icons/PollThumbnail.tsx +12 -0
- package/src/icons/SendPoll.tsx +12 -0
- package/src/icons/index.ts +4 -0
- package/src/store/QuickSqliteClient.ts +1 -1
- package/src/store/apis/index.ts +1 -0
- package/src/store/apis/updatePollMessage.ts +48 -0
- package/src/store/mappers/mapMessageToStorable.ts +4 -0
- package/src/store/mappers/mapStorableToMessage.ts +4 -0
- package/src/store/schema.ts +4 -0
- package/src/version.json +1 -1
|
@@ -0,0 +1,351 @@
|
|
|
1
|
+
import React, { Dispatch, SetStateAction, useCallback, useMemo } from 'react';
|
|
2
|
+
import { StyleSheet, Text, TextInput, TouchableOpacity, View } from 'react-native';
|
|
3
|
+
import { Gesture, GestureDetector } from 'react-native-gesture-handler';
|
|
4
|
+
import Animated, {
|
|
5
|
+
interpolate,
|
|
6
|
+
SharedValue,
|
|
7
|
+
useAnimatedReaction,
|
|
8
|
+
useAnimatedStyle,
|
|
9
|
+
useDerivedValue,
|
|
10
|
+
useSharedValue,
|
|
11
|
+
withDelay,
|
|
12
|
+
withSpring,
|
|
13
|
+
} from 'react-native-reanimated';
|
|
14
|
+
|
|
15
|
+
import { PollOptionData } from 'stream-chat';
|
|
16
|
+
|
|
17
|
+
import { useCreatePollContentContext, useTheme, useTranslationContext } from '../../../contexts';
|
|
18
|
+
import { DragHandle } from '../../../icons';
|
|
19
|
+
|
|
20
|
+
export type CurrentOptionPositionsCache = {
|
|
21
|
+
inverseIndexCache: {
|
|
22
|
+
[key: number]: number;
|
|
23
|
+
};
|
|
24
|
+
positionCache: {
|
|
25
|
+
[key: number]: {
|
|
26
|
+
updatedIndex: number;
|
|
27
|
+
updatedTop: number;
|
|
28
|
+
};
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
const OPTION_HEIGHT = 71;
|
|
33
|
+
|
|
34
|
+
export const CreatePollOption = ({
|
|
35
|
+
boundaries,
|
|
36
|
+
currentOptionPositions,
|
|
37
|
+
draggedItemId,
|
|
38
|
+
handleChangeText,
|
|
39
|
+
hasDuplicate,
|
|
40
|
+
index,
|
|
41
|
+
isDragging,
|
|
42
|
+
option,
|
|
43
|
+
}: {
|
|
44
|
+
boundaries: { maxBound: number; minBound: number };
|
|
45
|
+
currentOptionPositions: SharedValue<CurrentOptionPositionsCache>;
|
|
46
|
+
draggedItemId: SharedValue<number | null>;
|
|
47
|
+
handleChangeText: (newText: string, index: number) => void;
|
|
48
|
+
hasDuplicate: boolean;
|
|
49
|
+
index: number;
|
|
50
|
+
isDragging: SharedValue<1 | 0>;
|
|
51
|
+
option: PollOptionData;
|
|
52
|
+
}) => {
|
|
53
|
+
const { t } = useTranslationContext();
|
|
54
|
+
const { createPollOptionHeight = OPTION_HEIGHT } = useCreatePollContentContext();
|
|
55
|
+
const top = useSharedValue(index * createPollOptionHeight);
|
|
56
|
+
const isDraggingDerived = useDerivedValue(() => isDragging.value);
|
|
57
|
+
|
|
58
|
+
const draggedItemIdDerived = useDerivedValue(() => draggedItemId.value);
|
|
59
|
+
|
|
60
|
+
const isCurrentDraggingItem = useDerivedValue(
|
|
61
|
+
() => isDraggingDerived.value && draggedItemIdDerived.value === index,
|
|
62
|
+
);
|
|
63
|
+
|
|
64
|
+
const animatedStyles = useAnimatedStyle(() => ({
|
|
65
|
+
top: top.value,
|
|
66
|
+
transform: [
|
|
67
|
+
{
|
|
68
|
+
scale: isCurrentDraggingItem.value
|
|
69
|
+
? interpolate(isDraggingDerived.value, [0, 1], [1, 1.025])
|
|
70
|
+
: interpolate(isDraggingDerived.value, [0, 1], [1, 0.98]),
|
|
71
|
+
},
|
|
72
|
+
],
|
|
73
|
+
}));
|
|
74
|
+
const currentOptionPositionsDerived = useDerivedValue<CurrentOptionPositionsCache>(
|
|
75
|
+
() => currentOptionPositions.value,
|
|
76
|
+
);
|
|
77
|
+
|
|
78
|
+
// used for swapping with currentIndex
|
|
79
|
+
const newIndex = useSharedValue<number | null>(null);
|
|
80
|
+
|
|
81
|
+
// used for swapping with newIndex
|
|
82
|
+
const currentIndex = useSharedValue<number | null>(null);
|
|
83
|
+
|
|
84
|
+
useAnimatedReaction(
|
|
85
|
+
() => currentOptionPositionsDerived.value.positionCache[index].updatedIndex,
|
|
86
|
+
(currentValue, previousValue) => {
|
|
87
|
+
if (currentValue !== previousValue) {
|
|
88
|
+
top.value = withSpring(
|
|
89
|
+
currentOptionPositionsDerived.value.positionCache[index].updatedIndex *
|
|
90
|
+
createPollOptionHeight,
|
|
91
|
+
);
|
|
92
|
+
}
|
|
93
|
+
},
|
|
94
|
+
);
|
|
95
|
+
|
|
96
|
+
const gesture = Gesture.Pan()
|
|
97
|
+
.onStart(() => {
|
|
98
|
+
// start dragging
|
|
99
|
+
isDragging.value = withSpring(1);
|
|
100
|
+
|
|
101
|
+
// keep track of dragged item
|
|
102
|
+
draggedItemId.value = index;
|
|
103
|
+
|
|
104
|
+
// store dragged item id for future swap
|
|
105
|
+
currentIndex.value = currentOptionPositionsDerived.value.positionCache[index].updatedIndex;
|
|
106
|
+
})
|
|
107
|
+
.onUpdate((e) => {
|
|
108
|
+
const { inverseIndexCache, positionCache } = currentOptionPositionsDerived.value;
|
|
109
|
+
if (draggedItemIdDerived.value === null || currentIndex.value === null) {
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
const newTop = positionCache[draggedItemIdDerived.value].updatedTop + e.translationY;
|
|
113
|
+
// we add a small leeway to account for sharp animations which tend to bug out otherwise
|
|
114
|
+
if (newTop < boundaries.minBound - 10 || newTop > boundaries.maxBound + 10) {
|
|
115
|
+
// out of bounds, exit out of the animation early
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
|
+
top.value = newTop;
|
|
119
|
+
|
|
120
|
+
// calculate the new index where drag is headed to
|
|
121
|
+
newIndex.value = Math.floor((newTop + createPollOptionHeight / 2) / createPollOptionHeight);
|
|
122
|
+
|
|
123
|
+
// swap the items present at newIndex and currentIndex
|
|
124
|
+
if (newIndex.value !== currentIndex.value) {
|
|
125
|
+
// find id of the item that currently resides at newIndex
|
|
126
|
+
const newIndexItemKey = inverseIndexCache[newIndex.value];
|
|
127
|
+
|
|
128
|
+
// find id of the item that currently resides at currentIndex
|
|
129
|
+
const currentDragIndexItemKey = inverseIndexCache[currentIndex.value];
|
|
130
|
+
|
|
131
|
+
if (newIndexItemKey !== undefined && currentDragIndexItemKey !== undefined) {
|
|
132
|
+
// if we indeed have a candidate for a new index, we update our cache so that
|
|
133
|
+
// it can be reflected through animations
|
|
134
|
+
currentOptionPositions.value = {
|
|
135
|
+
inverseIndexCache: {
|
|
136
|
+
...inverseIndexCache,
|
|
137
|
+
[newIndex.value]: currentDragIndexItemKey,
|
|
138
|
+
[currentIndex.value]: newIndexItemKey,
|
|
139
|
+
},
|
|
140
|
+
positionCache: {
|
|
141
|
+
...positionCache,
|
|
142
|
+
[currentDragIndexItemKey]: {
|
|
143
|
+
...positionCache[currentDragIndexItemKey],
|
|
144
|
+
updatedIndex: newIndex.value,
|
|
145
|
+
},
|
|
146
|
+
[newIndexItemKey]: {
|
|
147
|
+
...positionCache[newIndexItemKey],
|
|
148
|
+
updatedIndex: currentIndex.value,
|
|
149
|
+
updatedTop: currentIndex.value * createPollOptionHeight,
|
|
150
|
+
},
|
|
151
|
+
},
|
|
152
|
+
};
|
|
153
|
+
|
|
154
|
+
// update new index as current index
|
|
155
|
+
currentIndex.value = newIndex.value;
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
})
|
|
159
|
+
.onEnd(() => {
|
|
160
|
+
const { inverseIndexCache, positionCache } = currentOptionPositionsDerived.value;
|
|
161
|
+
if (currentIndex.value === null || newIndex.value === null) {
|
|
162
|
+
return;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
top.value = withSpring(newIndex.value * createPollOptionHeight);
|
|
166
|
+
|
|
167
|
+
// find original id of the item that currently resides at currentIndex
|
|
168
|
+
const currentDragIndexItemKey = inverseIndexCache[currentIndex.value];
|
|
169
|
+
|
|
170
|
+
if (currentDragIndexItemKey !== undefined) {
|
|
171
|
+
// update the values for item whose drag we just stopped
|
|
172
|
+
currentOptionPositions.value = {
|
|
173
|
+
...currentOptionPositionsDerived.value,
|
|
174
|
+
positionCache: {
|
|
175
|
+
...positionCache,
|
|
176
|
+
[currentDragIndexItemKey]: {
|
|
177
|
+
...positionCache[currentDragIndexItemKey],
|
|
178
|
+
updatedTop: newIndex.value * createPollOptionHeight,
|
|
179
|
+
},
|
|
180
|
+
},
|
|
181
|
+
};
|
|
182
|
+
}
|
|
183
|
+
// stop dragging
|
|
184
|
+
isDragging.value = withDelay(200, withSpring(0));
|
|
185
|
+
});
|
|
186
|
+
|
|
187
|
+
const {
|
|
188
|
+
theme: {
|
|
189
|
+
colors: { accent_error, bg_user, black, text_low_emphasis },
|
|
190
|
+
poll: {
|
|
191
|
+
createContent: {
|
|
192
|
+
pollOptions: { optionStyle },
|
|
193
|
+
},
|
|
194
|
+
},
|
|
195
|
+
},
|
|
196
|
+
} = useTheme();
|
|
197
|
+
|
|
198
|
+
return (
|
|
199
|
+
<Animated.View
|
|
200
|
+
style={[
|
|
201
|
+
styles.optionWrapper,
|
|
202
|
+
optionStyle.wrapper,
|
|
203
|
+
{
|
|
204
|
+
backgroundColor: bg_user,
|
|
205
|
+
borderColor: hasDuplicate ? accent_error : bg_user,
|
|
206
|
+
position: 'absolute',
|
|
207
|
+
width: '100%',
|
|
208
|
+
},
|
|
209
|
+
animatedStyles,
|
|
210
|
+
]}
|
|
211
|
+
>
|
|
212
|
+
{hasDuplicate ? (
|
|
213
|
+
<Text
|
|
214
|
+
style={[
|
|
215
|
+
styles.optionValidationError,
|
|
216
|
+
{ color: accent_error },
|
|
217
|
+
optionStyle.validationErrorText,
|
|
218
|
+
]}
|
|
219
|
+
>
|
|
220
|
+
{t<string>('This is already an option')}
|
|
221
|
+
</Text>
|
|
222
|
+
) : null}
|
|
223
|
+
<TextInput
|
|
224
|
+
onChangeText={(newText) => handleChangeText(newText, index)}
|
|
225
|
+
placeholder={t<string>('Option')}
|
|
226
|
+
style={[styles.optionInput, { color: black }, optionStyle.input]}
|
|
227
|
+
value={option.text}
|
|
228
|
+
/>
|
|
229
|
+
<GestureDetector gesture={gesture}>
|
|
230
|
+
<Animated.View>
|
|
231
|
+
<DragHandle pathFill={text_low_emphasis} />
|
|
232
|
+
</Animated.View>
|
|
233
|
+
</GestureDetector>
|
|
234
|
+
</Animated.View>
|
|
235
|
+
);
|
|
236
|
+
};
|
|
237
|
+
|
|
238
|
+
const MemoizedCreatePollOption = React.memo(CreatePollOption);
|
|
239
|
+
|
|
240
|
+
export const CreatePollOptions = (props: {
|
|
241
|
+
currentOptionPositions: SharedValue<CurrentOptionPositionsCache>;
|
|
242
|
+
duplicates: string[];
|
|
243
|
+
pollOptions: PollOptionData[];
|
|
244
|
+
setPollOptions: Dispatch<SetStateAction<PollOptionData[]>>;
|
|
245
|
+
}) => {
|
|
246
|
+
const { t } = useTranslationContext();
|
|
247
|
+
const { createPollOptionHeight = OPTION_HEIGHT } = useCreatePollContentContext();
|
|
248
|
+
const { currentOptionPositions, duplicates = [], pollOptions, setPollOptions } = props;
|
|
249
|
+
const updateOption = useCallback(
|
|
250
|
+
(newText: string, index: number) => {
|
|
251
|
+
setPollOptions((prevOptions) =>
|
|
252
|
+
prevOptions.map((option, idx) => (idx === index ? { ...option, text: newText } : option)),
|
|
253
|
+
);
|
|
254
|
+
},
|
|
255
|
+
[setPollOptions],
|
|
256
|
+
);
|
|
257
|
+
|
|
258
|
+
// used to know if drag is happening or not
|
|
259
|
+
const isDragging = useSharedValue<0 | 1>(0);
|
|
260
|
+
// this will hold id for item which user started dragging
|
|
261
|
+
const draggedItemId = useSharedValue<number | null>(null);
|
|
262
|
+
|
|
263
|
+
const boundaries = useMemo(
|
|
264
|
+
() => ({ maxBound: (pollOptions.length - 1) * createPollOptionHeight, minBound: 0 }),
|
|
265
|
+
[createPollOptionHeight, pollOptions.length],
|
|
266
|
+
);
|
|
267
|
+
|
|
268
|
+
const {
|
|
269
|
+
theme: {
|
|
270
|
+
colors: { bg_user, black },
|
|
271
|
+
poll: {
|
|
272
|
+
createContent: {
|
|
273
|
+
pollOptions: { addOption, container, title },
|
|
274
|
+
},
|
|
275
|
+
},
|
|
276
|
+
},
|
|
277
|
+
} = useTheme();
|
|
278
|
+
|
|
279
|
+
return (
|
|
280
|
+
<View style={[styles.container, container]}>
|
|
281
|
+
<Text style={[styles.text, { color: black }, title]}>{t<string>('Options')}</Text>
|
|
282
|
+
<View style={{ height: createPollOptionHeight * pollOptions.length }}>
|
|
283
|
+
{pollOptions.map((option, index) => (
|
|
284
|
+
<MemoizedCreatePollOption
|
|
285
|
+
boundaries={boundaries}
|
|
286
|
+
currentOptionPositions={currentOptionPositions}
|
|
287
|
+
draggedItemId={draggedItemId}
|
|
288
|
+
handleChangeText={updateOption}
|
|
289
|
+
hasDuplicate={duplicates.includes(option.text)}
|
|
290
|
+
index={index}
|
|
291
|
+
isDragging={isDragging}
|
|
292
|
+
key={index}
|
|
293
|
+
option={option}
|
|
294
|
+
/>
|
|
295
|
+
))}
|
|
296
|
+
</View>
|
|
297
|
+
<TouchableOpacity
|
|
298
|
+
onPress={() => {
|
|
299
|
+
const newIndex = pollOptions.length;
|
|
300
|
+
currentOptionPositions.value = {
|
|
301
|
+
inverseIndexCache: {
|
|
302
|
+
...currentOptionPositions.value.inverseIndexCache,
|
|
303
|
+
[newIndex]: newIndex,
|
|
304
|
+
},
|
|
305
|
+
positionCache: {
|
|
306
|
+
...currentOptionPositions.value.positionCache,
|
|
307
|
+
[newIndex]: {
|
|
308
|
+
updatedIndex: newIndex,
|
|
309
|
+
updatedTop: newIndex * createPollOptionHeight,
|
|
310
|
+
},
|
|
311
|
+
},
|
|
312
|
+
};
|
|
313
|
+
setPollOptions([...pollOptions, { text: '' }]);
|
|
314
|
+
}}
|
|
315
|
+
style={[styles.addOptionWrapper, { backgroundColor: bg_user }, addOption.wrapper]}
|
|
316
|
+
>
|
|
317
|
+
<Text style={[styles.text, { color: black }, addOption.text]}>
|
|
318
|
+
{t<string>('Add an option')}
|
|
319
|
+
</Text>
|
|
320
|
+
</TouchableOpacity>
|
|
321
|
+
</View>
|
|
322
|
+
);
|
|
323
|
+
};
|
|
324
|
+
|
|
325
|
+
const styles = StyleSheet.create({
|
|
326
|
+
addOptionWrapper: {
|
|
327
|
+
borderRadius: 12,
|
|
328
|
+
marginTop: 8,
|
|
329
|
+
paddingHorizontal: 16,
|
|
330
|
+
paddingVertical: 18,
|
|
331
|
+
},
|
|
332
|
+
container: { marginVertical: 16 },
|
|
333
|
+
optionInput: {
|
|
334
|
+
flex: 1,
|
|
335
|
+
fontSize: 16,
|
|
336
|
+
paddingRight: 4,
|
|
337
|
+
paddingVertical: 0, // android is adding extra padding so we remove it
|
|
338
|
+
},
|
|
339
|
+
optionValidationError: { fontSize: 12, left: 16, position: 'absolute', top: 4 },
|
|
340
|
+
optionWrapper: {
|
|
341
|
+
alignItems: 'center',
|
|
342
|
+
borderRadius: 12,
|
|
343
|
+
borderWidth: 1,
|
|
344
|
+
flexDirection: 'row',
|
|
345
|
+
justifyContent: 'space-between',
|
|
346
|
+
marginTop: 8,
|
|
347
|
+
paddingHorizontal: 16,
|
|
348
|
+
paddingVertical: 18,
|
|
349
|
+
},
|
|
350
|
+
text: { fontSize: 16 },
|
|
351
|
+
});
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import React, { useMemo } from 'react';
|
|
2
|
+
import { FlatList, type FlatListProps, StyleSheet, Text, View } from 'react-native';
|
|
3
|
+
|
|
4
|
+
import { PollAnswer, VotingVisibility } from 'stream-chat';
|
|
5
|
+
|
|
6
|
+
import { AnswerListAddCommentButton } from './Button';
|
|
7
|
+
|
|
8
|
+
import {
|
|
9
|
+
PollContextProvider,
|
|
10
|
+
PollContextValue,
|
|
11
|
+
useTheme,
|
|
12
|
+
useTranslationContext,
|
|
13
|
+
} from '../../../contexts';
|
|
14
|
+
import { DefaultStreamChatGenerics } from '../../../types/types';
|
|
15
|
+
import { getDateString } from '../../../utils/i18n/getDateString';
|
|
16
|
+
import { Avatar } from '../../Avatar/Avatar';
|
|
17
|
+
import { usePollAnswersPagination } from '../hooks/usePollAnswersPagination';
|
|
18
|
+
import { usePollState } from '../hooks/usePollState';
|
|
19
|
+
|
|
20
|
+
export type PollAnswersListProps<
|
|
21
|
+
StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,
|
|
22
|
+
> = PollContextValue & {
|
|
23
|
+
additionalFlatListProps?: Partial<FlatListProps<PollAnswer<StreamChatGenerics>>>;
|
|
24
|
+
PollAnswersListContent?: React.ComponentType;
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
export const PollAnswerListItem = ({ answer }: { answer: PollAnswer }) => {
|
|
28
|
+
const { t, tDateTimeParser } = useTranslationContext();
|
|
29
|
+
const { voting_visibility } = usePollState();
|
|
30
|
+
|
|
31
|
+
const {
|
|
32
|
+
theme: {
|
|
33
|
+
colors: { bg_user, black },
|
|
34
|
+
poll: {
|
|
35
|
+
answersList: { item: itemStyle },
|
|
36
|
+
},
|
|
37
|
+
},
|
|
38
|
+
} = useTheme();
|
|
39
|
+
|
|
40
|
+
const dateString = useMemo(
|
|
41
|
+
() =>
|
|
42
|
+
getDateString({
|
|
43
|
+
date: answer.updated_at,
|
|
44
|
+
t,
|
|
45
|
+
tDateTimeParser,
|
|
46
|
+
timestampTranslationKey: 'timestamp/PollVote',
|
|
47
|
+
}),
|
|
48
|
+
[answer.updated_at, t, tDateTimeParser],
|
|
49
|
+
);
|
|
50
|
+
|
|
51
|
+
const isAnonymous = useMemo(
|
|
52
|
+
() => voting_visibility === VotingVisibility.anonymous,
|
|
53
|
+
[voting_visibility],
|
|
54
|
+
);
|
|
55
|
+
|
|
56
|
+
return (
|
|
57
|
+
<View style={[styles.listItemContainer, { backgroundColor: bg_user }, itemStyle.container]}>
|
|
58
|
+
<Text style={[styles.listItemAnswerText, { color: black }, itemStyle.answerText]}>
|
|
59
|
+
{answer.answer_text}
|
|
60
|
+
</Text>
|
|
61
|
+
<View style={[styles.listItemInfoContainer, itemStyle.infoContainer]}>
|
|
62
|
+
<View style={[styles.listItemUserInfoContainer, itemStyle.userInfoContainer]}>
|
|
63
|
+
{!isAnonymous && answer.user?.image ? (
|
|
64
|
+
<Avatar image={answer.user?.image as string} size={20} />
|
|
65
|
+
) : null}
|
|
66
|
+
<Text style={{ color: black, fontSize: 14, marginLeft: 2 }}>
|
|
67
|
+
{isAnonymous ? t<string>('Anonymous') : answer.user?.name}
|
|
68
|
+
</Text>
|
|
69
|
+
</View>
|
|
70
|
+
<Text style={{ color: black }}>{dateString}</Text>
|
|
71
|
+
</View>
|
|
72
|
+
</View>
|
|
73
|
+
);
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
const PollAnswerListItemComponent = ({ item }: { item: PollAnswer }) => (
|
|
77
|
+
<PollAnswerListItem answer={item} />
|
|
78
|
+
);
|
|
79
|
+
|
|
80
|
+
export const PollAnswersListContent = ({
|
|
81
|
+
additionalFlatListProps,
|
|
82
|
+
}: Pick<PollAnswersListProps, 'additionalFlatListProps'>) => {
|
|
83
|
+
const { hasNextPage, loadMore, pollAnswers } = usePollAnswersPagination();
|
|
84
|
+
const {
|
|
85
|
+
theme: {
|
|
86
|
+
colors: { white },
|
|
87
|
+
poll: {
|
|
88
|
+
answersList: { container },
|
|
89
|
+
},
|
|
90
|
+
},
|
|
91
|
+
} = useTheme();
|
|
92
|
+
|
|
93
|
+
return (
|
|
94
|
+
<View style={[styles.container, { backgroundColor: white }, container]}>
|
|
95
|
+
<FlatList
|
|
96
|
+
data={pollAnswers}
|
|
97
|
+
keyExtractor={(item) => `poll_answer_${item.id}`}
|
|
98
|
+
onEndReached={() => hasNextPage && loadMore()}
|
|
99
|
+
renderItem={PollAnswerListItemComponent}
|
|
100
|
+
{...additionalFlatListProps}
|
|
101
|
+
/>
|
|
102
|
+
<AnswerListAddCommentButton />
|
|
103
|
+
</View>
|
|
104
|
+
);
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
export const PollAnswersList = ({
|
|
108
|
+
additionalFlatListProps,
|
|
109
|
+
message,
|
|
110
|
+
poll,
|
|
111
|
+
PollAnswersListContent: PollAnswersListOverride,
|
|
112
|
+
}: PollAnswersListProps) => (
|
|
113
|
+
<PollContextProvider value={{ message, poll }}>
|
|
114
|
+
{PollAnswersListOverride ? (
|
|
115
|
+
<PollAnswersListOverride />
|
|
116
|
+
) : (
|
|
117
|
+
<PollAnswersListContent additionalFlatListProps={additionalFlatListProps} />
|
|
118
|
+
)}
|
|
119
|
+
</PollContextProvider>
|
|
120
|
+
);
|
|
121
|
+
|
|
122
|
+
const styles = StyleSheet.create({
|
|
123
|
+
container: { flex: 1, margin: 16 },
|
|
124
|
+
listItemAnswerText: { fontSize: 16, fontWeight: '500' },
|
|
125
|
+
listItemContainer: {
|
|
126
|
+
borderRadius: 12,
|
|
127
|
+
marginBottom: 8,
|
|
128
|
+
paddingBottom: 20,
|
|
129
|
+
paddingHorizontal: 16,
|
|
130
|
+
paddingTop: 12,
|
|
131
|
+
},
|
|
132
|
+
listItemInfoContainer: { flexDirection: 'row', justifyContent: 'space-between', marginTop: 24 },
|
|
133
|
+
listItemUserInfoContainer: { alignItems: 'center', flexDirection: 'row' },
|
|
134
|
+
});
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import React, { useState } from 'react';
|
|
2
|
+
import {
|
|
3
|
+
KeyboardAvoidingView,
|
|
4
|
+
Modal,
|
|
5
|
+
Platform,
|
|
6
|
+
StyleSheet,
|
|
7
|
+
Text,
|
|
8
|
+
TextInput,
|
|
9
|
+
TouchableOpacity,
|
|
10
|
+
View,
|
|
11
|
+
} from 'react-native';
|
|
12
|
+
|
|
13
|
+
import { useTheme, useTranslationContext } from '../../../contexts';
|
|
14
|
+
|
|
15
|
+
export type PollInputDialogProps = {
|
|
16
|
+
closeDialog: () => void;
|
|
17
|
+
onSubmit: (text: string) => void;
|
|
18
|
+
title: string;
|
|
19
|
+
visible: boolean;
|
|
20
|
+
initialValue?: string;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export const PollInputDialog = ({
|
|
24
|
+
closeDialog,
|
|
25
|
+
initialValue = '',
|
|
26
|
+
onSubmit,
|
|
27
|
+
title,
|
|
28
|
+
visible,
|
|
29
|
+
}: PollInputDialogProps) => {
|
|
30
|
+
const { t } = useTranslationContext();
|
|
31
|
+
const [dialogInput, setDialogInput] = useState(initialValue);
|
|
32
|
+
|
|
33
|
+
const {
|
|
34
|
+
theme: {
|
|
35
|
+
colors: { accent_dark_blue, black, white },
|
|
36
|
+
poll: {
|
|
37
|
+
inputDialog: {
|
|
38
|
+
button,
|
|
39
|
+
buttonContainer,
|
|
40
|
+
container,
|
|
41
|
+
input,
|
|
42
|
+
title: titleStyle,
|
|
43
|
+
transparentContainer,
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
},
|
|
47
|
+
} = useTheme();
|
|
48
|
+
|
|
49
|
+
return (
|
|
50
|
+
<Modal animationType='fade' onRequestClose={closeDialog} transparent={true} visible={visible}>
|
|
51
|
+
<KeyboardAvoidingView
|
|
52
|
+
behavior={Platform.OS === 'ios' ? 'padding' : 'height'}
|
|
53
|
+
style={[styles.transparentContainer, transparentContainer]}
|
|
54
|
+
>
|
|
55
|
+
<View style={[styles.container, { backgroundColor: white }, container]}>
|
|
56
|
+
<Text style={[styles.title, { color: black }, titleStyle]}>{title}</Text>
|
|
57
|
+
<TextInput
|
|
58
|
+
autoFocus={true}
|
|
59
|
+
onChangeText={setDialogInput}
|
|
60
|
+
placeholder={t<string>('Ask a question')}
|
|
61
|
+
style={[styles.input, { color: black }, input]}
|
|
62
|
+
value={dialogInput}
|
|
63
|
+
/>
|
|
64
|
+
<View style={[styles.buttonContainer, buttonContainer]}>
|
|
65
|
+
<TouchableOpacity onPress={closeDialog}>
|
|
66
|
+
<Text style={[styles.button, { color: accent_dark_blue }, button]}>
|
|
67
|
+
{t<string>('Cancel')}
|
|
68
|
+
</Text>
|
|
69
|
+
</TouchableOpacity>
|
|
70
|
+
<TouchableOpacity
|
|
71
|
+
onPress={() => {
|
|
72
|
+
onSubmit(dialogInput);
|
|
73
|
+
closeDialog();
|
|
74
|
+
}}
|
|
75
|
+
style={{ marginLeft: 32 }}
|
|
76
|
+
>
|
|
77
|
+
<Text style={[styles.button, { color: accent_dark_blue }, button]}>
|
|
78
|
+
{t<string>('SEND')}
|
|
79
|
+
</Text>
|
|
80
|
+
</TouchableOpacity>
|
|
81
|
+
</View>
|
|
82
|
+
</View>
|
|
83
|
+
</KeyboardAvoidingView>
|
|
84
|
+
</Modal>
|
|
85
|
+
);
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
const styles = StyleSheet.create({
|
|
89
|
+
button: { fontSize: 16, fontWeight: '500' },
|
|
90
|
+
buttonContainer: { flexDirection: 'row', justifyContent: 'flex-end', marginTop: 52 },
|
|
91
|
+
container: {
|
|
92
|
+
backgroundColor: 'white',
|
|
93
|
+
borderRadius: 16,
|
|
94
|
+
paddingBottom: 20,
|
|
95
|
+
paddingHorizontal: 16,
|
|
96
|
+
paddingTop: 32,
|
|
97
|
+
width: '80%',
|
|
98
|
+
},
|
|
99
|
+
input: {
|
|
100
|
+
alignItems: 'center',
|
|
101
|
+
borderColor: 'gray',
|
|
102
|
+
borderRadius: 18,
|
|
103
|
+
borderWidth: 1,
|
|
104
|
+
fontSize: 16,
|
|
105
|
+
height: 36,
|
|
106
|
+
marginTop: 16,
|
|
107
|
+
padding: 0,
|
|
108
|
+
paddingHorizontal: 16,
|
|
109
|
+
},
|
|
110
|
+
title: { fontSize: 17, fontWeight: '500', lineHeight: 20 },
|
|
111
|
+
transparentContainer: {
|
|
112
|
+
alignItems: 'center',
|
|
113
|
+
backgroundColor: 'rgba(0, 0, 0, 0.4)',
|
|
114
|
+
flex: 1,
|
|
115
|
+
justifyContent: 'center',
|
|
116
|
+
},
|
|
117
|
+
});
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { StyleSheet, Text, TouchableOpacity, View } from 'react-native';
|
|
3
|
+
|
|
4
|
+
import { useTheme } from '../../../contexts';
|
|
5
|
+
import { Back } from '../../../icons';
|
|
6
|
+
|
|
7
|
+
export type PollModalHeaderProps = {
|
|
8
|
+
onPress: () => void;
|
|
9
|
+
title: string;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export const PollModalHeader = ({ onPress, title }: PollModalHeaderProps) => {
|
|
13
|
+
const {
|
|
14
|
+
theme: {
|
|
15
|
+
colors: { black, text_high_emphasis, white },
|
|
16
|
+
poll: {
|
|
17
|
+
modalHeader: { container, title: titleStyle },
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
} = useTheme();
|
|
21
|
+
|
|
22
|
+
return (
|
|
23
|
+
<View style={[styles.container, { backgroundColor: white }, container]}>
|
|
24
|
+
<TouchableOpacity onPress={onPress}>
|
|
25
|
+
<Back height={24} pathFill={text_high_emphasis} viewBox='0 0 24 24' width={24} />
|
|
26
|
+
</TouchableOpacity>
|
|
27
|
+
<Text numberOfLines={1} style={[styles.title, { color: black }, titleStyle]}>
|
|
28
|
+
{title}
|
|
29
|
+
</Text>
|
|
30
|
+
</View>
|
|
31
|
+
);
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
const styles = StyleSheet.create({
|
|
35
|
+
container: {
|
|
36
|
+
alignItems: 'center',
|
|
37
|
+
flexDirection: 'row',
|
|
38
|
+
paddingHorizontal: 16,
|
|
39
|
+
paddingVertical: 18,
|
|
40
|
+
},
|
|
41
|
+
title: { fontSize: 16, fontWeight: '500', marginLeft: 32 },
|
|
42
|
+
});
|