@openpeepshq/rn-components 0.7.0 → 0.7.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/LICENSE.md +21 -0
- package/README.md +63 -0
- package/metro/css-interop-observable.js +41 -0
- package/metro/resolve-asset-source.js +19 -0
- package/metro.js +67 -0
- package/package.json +1 -1
- package/react-native.config.js +5 -0
- package/src/assets/audio/click-notification.wav +0 -0
- package/src/assets/images/audio-container.png +0 -0
- package/src/assets/images/black-ambition-2025-hero.png +0 -0
- package/src/assets/images/default-group-avatar.png +0 -0
- package/src/assets/images/event-placeholder.png +0 -0
- package/src/assets/images/group-header-placeholder.png +0 -0
- package/src/assets/images/jam-placeholder.png +0 -0
- package/src/assets/images/logo.webp +0 -0
- package/src/assets/images/profile-background-placeholder.png +0 -0
- package/src/assets/images/success.webp +0 -0
- package/src/assets/images/welcome-bg.webp +0 -0
- package/src/components/CapabilityMatrix.tsx +218 -0
- package/src/components/configuration/ConfigMenuButton.tsx +48 -0
- package/src/components/configuration/index.ts +1 -0
- package/src/components/conversations/ConversationMessageBubble.tsx +51 -0
- package/src/components/conversations/ConversationParticipantsModal.tsx +46 -0
- package/src/components/conversations/ConversationPreviewCard.tsx +158 -0
- package/src/components/conversations/ConversationProfileHeader.tsx +28 -0
- package/src/components/conversations/ConversationSettingsSheet.tsx +81 -0
- package/src/components/conversations/CreateNewConversationContext.tsx +71 -0
- package/src/components/conversations/DirectMessagesHeaderActions.tsx +24 -0
- package/src/components/conversations/MessageInThread.tsx +131 -0
- package/src/components/conversations/index.ts +8 -0
- package/src/components/custom/common/Loader.tsx +67 -0
- package/src/components/custom/common/agenda-tabs.tsx +47 -0
- package/src/components/custom/common/audio-player.tsx +219 -0
- package/src/components/custom/common/cached-image.tsx +34 -0
- package/src/components/custom/common/cached-video-player.tsx +497 -0
- package/src/components/custom/common/empty-state-container.tsx +58 -0
- package/src/components/custom/common/image-grid.tsx +95 -0
- package/src/components/custom/common/index.ts +12 -0
- package/src/components/custom/common/infinite-scroll-container.tsx +99 -0
- package/src/components/custom/common/media-upload-progress.tsx +109 -0
- package/src/components/custom/common/participant-avatar.tsx +34 -0
- package/src/components/custom/common/popover.tsx +268 -0
- package/src/components/custom/common/select.tsx +215 -0
- package/src/components/custom/date/formatter.ts +24 -0
- package/src/components/custom/date/index.ts +3 -0
- package/src/components/custom/date/timespan.tsx +49 -0
- package/src/components/custom/date/updating-date.tsx +31 -0
- package/src/components/custom/index.ts +4 -0
- package/src/components/custom/modals/common/base-sheet.tsx +104 -0
- package/src/components/custom/modals/common/index.ts +3 -0
- package/src/components/custom/modals/common/sheet-backdrop.tsx +14 -0
- package/src/components/custom/modals/common/sheet-footer.tsx +59 -0
- package/src/components/custom/modals/index.ts +3 -0
- package/src/components/custom/modals/media/alt-text-sheet.tsx +90 -0
- package/src/components/custom/modals/media/audio-picker-sheet.tsx +180 -0
- package/src/components/custom/modals/media/document-picker-sheet.tsx +384 -0
- package/src/components/custom/modals/media/image-picker-sheet.tsx +200 -0
- package/src/components/custom/modals/media/index.ts +7 -0
- package/src/components/custom/modals/media/record-audio-sheet.tsx +227 -0
- package/src/components/custom/modals/media/send-media-sheet.tsx +278 -0
- package/src/components/custom/modals/media/video-picker-sheet.tsx +109 -0
- package/src/components/custom/modals/settings/edit-notifications-sheet.tsx +184 -0
- package/src/components/custom/modals/settings/index.ts +1 -0
- package/src/components/custom/navigation/side-menu.tsx +223 -0
- package/src/components/form/HeaderAvatarInput.tsx +108 -0
- package/src/components/form/ImageInput.tsx +86 -0
- package/src/components/form/RadioSelect.tsx +58 -0
- package/src/components/form/TimeZoneSelect.tsx +97 -0
- package/src/components/form/index.ts +4 -0
- package/src/components/groups/AddGroupMemberModal.tsx +58 -0
- package/src/components/groups/AddGroupMembersButton.tsx +39 -0
- package/src/components/groups/ChangeGroupRolesModal.tsx +121 -0
- package/src/components/groups/ConfirmGroupExitModal.tsx +66 -0
- package/src/components/groups/ConfirmMemberRemovalModal.tsx +73 -0
- package/src/components/groups/DeleteGroupModal.tsx +68 -0
- package/src/components/groups/GroupAvatar.tsx +73 -0
- package/src/components/groups/GroupCapabilityMatrix.tsx +40 -0
- package/src/components/groups/GroupCard.tsx +84 -0
- package/src/components/groups/GroupFeed.tsx +25 -0
- package/src/components/groups/GroupForm.tsx +148 -0
- package/src/components/groups/GroupHeader.tsx +74 -0
- package/src/components/groups/GroupMembersList.tsx +194 -0
- package/src/components/groups/GroupNameFromId.tsx +17 -0
- package/src/components/groups/GroupNotificationSettingsModal.tsx +139 -0
- package/src/components/groups/GroupOptionsMenu.tsx +183 -0
- package/src/components/groups/GroupShareMenu.tsx +130 -0
- package/src/components/groups/JoinGroupButton.tsx +42 -0
- package/src/components/groups/index.ts +18 -0
- package/src/components/icons/iconWithClassName.ts +12 -0
- package/src/components/icons/index.ts +289 -0
- package/src/components/icons/types.ts +4 -0
- package/src/components/index.ts +12 -0
- package/src/components/jams/CreateNewJam.tsx +20 -0
- package/src/components/jams/CreateNewJamContext.tsx +36 -0
- package/src/components/jams/DeleteJamModal.tsx +69 -0
- package/src/components/jams/JamActionsFooter.tsx +85 -0
- package/src/components/jams/JamAnimatedEmoji.tsx +112 -0
- package/src/components/jams/JamCallParticipant.tsx +348 -0
- package/src/components/jams/JamCapacityGate.tsx +88 -0
- package/src/components/jams/JamCard.tsx +72 -0
- package/src/components/jams/JamChatDrawer.tsx +114 -0
- package/src/components/jams/JamChatMessage.tsx +86 -0
- package/src/components/jams/JamConference.tsx +69 -0
- package/src/components/jams/JamDesktopFooter.tsx +182 -0
- package/src/components/jams/JamDetailsDrawer.tsx +187 -0
- package/src/components/jams/JamDeviceSelectors.tsx +243 -0
- package/src/components/jams/JamDrawer.tsx +37 -0
- package/src/components/jams/JamFooter.tsx +241 -0
- package/src/components/jams/JamGuestForm.tsx +120 -0
- package/src/components/jams/JamLobby.tsx +203 -0
- package/src/components/jams/JamObserverShell.tsx +43 -0
- package/src/components/jams/JamParticipantConference.tsx +146 -0
- package/src/components/jams/JamPeopleDrawer.tsx +183 -0
- package/src/components/jams/JamReactionMenu.tsx +120 -0
- package/src/components/jams/JamRequestJoin.tsx +46 -0
- package/src/components/jams/JamRoom.tsx +194 -0
- package/src/components/jams/JamRoomIndicators.tsx +73 -0
- package/src/components/jams/JamRoomPanel.tsx +35 -0
- package/src/components/jams/JamToolbarButton.tsx +89 -0
- package/src/components/jams/JamVideoCall.tsx +50 -0
- package/src/components/jams/JamVideoLayout.tsx +401 -0
- package/src/components/jams/LeaveCloseButton.tsx +60 -0
- package/src/components/jams/LiveJamsSection.tsx +53 -0
- package/src/components/jams/index.ts +28 -0
- package/src/components/jams/useParticipantConnection.ts +43 -0
- package/src/components/layout/AuthLayout.tsx +156 -0
- package/src/components/layout/ContentHeader.tsx +62 -0
- package/src/components/layout/HeaderActionButton.tsx +23 -0
- package/src/components/layout/HeaderMobile.tsx +106 -0
- package/src/components/layout/PlusButton.tsx +34 -0
- package/src/components/layout/RootLayout.tsx +30 -0
- package/src/components/layout/index.ts +13 -0
- package/src/components/layout/pageChrome.test.tsx +147 -0
- package/src/components/layout/pageChrome.tsx +112 -0
- package/src/components/markdown/OpenpeepsMarkdown.tsx +129 -0
- package/src/components/markdown/extensions/codeBlock.tsx +63 -0
- package/src/components/markdown/extensions/codeInline.tsx +82 -0
- package/src/components/markdown/extensions/hashtag.tsx +77 -0
- package/src/components/markdown/extensions/html.test.tsx +172 -0
- package/src/components/markdown/extensions/html.tsx +116 -0
- package/src/components/markdown/extensions/mention.tsx +92 -0
- package/src/components/markdown/index.ts +2 -0
- package/src/components/markdown/theme.ts +59 -0
- package/src/components/markdown/utils.ts +34 -0
- package/src/components/navigation/Base.tsx +21 -0
- package/src/components/navigation/auth-navigator.tsx +47 -0
- package/src/components/navigation/helpers.ts +101 -0
- package/src/components/navigation/index.tsx +157 -0
- package/src/components/navigation/main-navigator.tsx +176 -0
- package/src/components/navigation/nativeRouter.tsx +255 -0
- package/src/components/navigation/parent-back.ts +139 -0
- package/src/components/navigation/side-menu-drawer.tsx +69 -0
- package/src/components/navigation/side-menu-wrapper.tsx +82 -0
- package/src/components/navigation/tab-navigator.tsx +254 -0
- package/src/components/navigation/types/auth.ts +23 -0
- package/src/components/navigation/types/index.ts +4 -0
- package/src/components/navigation/types/main.ts +156 -0
- package/src/components/navigation/types/root.ts +13 -0
- package/src/components/navigation/types/tabs.ts +51 -0
- package/src/components/notifications/NotificationErrorBoundary.tsx +40 -0
- package/src/components/notifications/NotificationHeaderActions.tsx +55 -0
- package/src/components/notifications/NotificationItem.tsx +80 -0
- package/src/components/notifications/NotificationWrapper.tsx +57 -0
- package/src/components/notifications/NotificationsList.tsx +103 -0
- package/src/components/notifications/index.ts +6 -0
- package/src/components/notifications/types/Announcement.tsx +51 -0
- package/src/components/notifications/types/DirectMessage.tsx +55 -0
- package/src/components/notifications/types/Follow.tsx +54 -0
- package/src/components/notifications/types/GroupMemberExit.tsx +52 -0
- package/src/components/notifications/types/JamModerator.tsx +38 -0
- package/src/components/notifications/types/JamSpeaker.tsx +38 -0
- package/src/components/notifications/types/JamStarted.tsx +39 -0
- package/src/components/notifications/types/Mention.tsx +56 -0
- package/src/components/notifications/types/NewGroupInvitation.tsx +53 -0
- package/src/components/notifications/types/NewGroupMember.tsx +57 -0
- package/src/components/notifications/types/NewGroupPost.tsx +41 -0
- package/src/components/notifications/types/NewProfile.tsx +53 -0
- package/src/components/notifications/types/PollEnded.tsx +55 -0
- package/src/components/notifications/types/PollVote.tsx +50 -0
- package/src/components/notifications/types/Reaction.tsx +49 -0
- package/src/components/notifications/types/Reply.tsx +52 -0
- package/src/components/notifications/types/Repost.tsx +49 -0
- package/src/components/notifications/types/Rsvp.tsx +48 -0
- package/src/components/notifications/types/RsvpCanceled.tsx +72 -0
- package/src/components/notifications/types/index.ts +19 -0
- package/src/components/post/CompactReplyParent.tsx +273 -0
- package/src/components/post/EventViewSwitch.tsx +42 -0
- package/src/components/post/Feed.tsx +110 -0
- package/src/components/post/FeedFormatSwitch.tsx +47 -0
- package/src/components/post/FeedPost.tsx +115 -0
- package/src/components/post/FeedPostContent.tsx +52 -0
- package/src/components/post/FullPostLayout.tsx +54 -0
- package/src/components/post/Markdown.tsx +8 -0
- package/src/components/post/NewEventButton.tsx +61 -0
- package/src/components/post/NewNoteButton.tsx +48 -0
- package/src/components/post/NewResourceButton.tsx +57 -0
- package/src/components/post/PinnedPost.tsx +42 -0
- package/src/components/post/PostDetail.tsx +55 -0
- package/src/components/post/ReplyBox.tsx +36 -0
- package/src/components/post/VideoPlayOverlay.tsx +23 -0
- package/src/components/post/feed/events/EventsCalendar.tsx +213 -0
- package/src/components/post/feed/events/EventsFeed.tsx +91 -0
- package/src/components/post/feed/events/EventsView.tsx +30 -0
- package/src/components/post/feed/events/index.ts +3 -0
- package/src/components/post/feed/threaded/ThreadPost.tsx +76 -0
- package/src/components/post/feed/threaded/ThreadedFeed.tsx +47 -0
- package/src/components/post/feed/threaded/index.ts +2 -0
- package/src/components/post/helpers.ts +54 -0
- package/src/components/post/index.ts +21 -0
- package/src/components/post/pieces/Attachments.tsx +153 -0
- package/src/components/post/pieces/AudioAttachment.tsx +57 -0
- package/src/components/post/pieces/DocumentAttachment.tsx +41 -0
- package/src/components/post/pieces/EventLocation.tsx +46 -0
- package/src/components/post/pieces/EventMenu.tsx +126 -0
- package/src/components/post/pieces/EventOccurrenceList.tsx +131 -0
- package/src/components/post/pieces/EventRsvpButton.tsx +177 -0
- package/src/components/post/pieces/EventRsvpList.tsx +277 -0
- package/src/components/post/pieces/EventRsvpScopeDialog.tsx +238 -0
- package/src/components/post/pieces/FeedPostStats.tsx +75 -0
- package/src/components/post/pieces/FeedThreadPreview.tsx +88 -0
- package/src/components/post/pieces/GalleryModal.tsx +115 -0
- package/src/components/post/pieces/ParticipantsCard.tsx +20 -0
- package/src/components/post/pieces/PollContent.tsx +219 -0
- package/src/components/post/pieces/PostActions.tsx +81 -0
- package/src/components/post/pieces/PostInfoHeader.tsx +52 -0
- package/src/components/post/pieces/PostMenu.tsx +477 -0
- package/src/components/post/pieces/PostReactionHeader.tsx +120 -0
- package/src/components/post/pieces/ShareMenu.tsx +127 -0
- package/src/components/post/pieces/UnreadPostIndicator.tsx +34 -0
- package/src/components/post/pieces/VideoPlayer.tsx +30 -0
- package/src/components/post/pieces/VisibilityDisplay.tsx +43 -0
- package/src/components/post/pieces/gallery/GalleryAudio.tsx +20 -0
- package/src/components/post/pieces/gallery/GalleryDocument.tsx +35 -0
- package/src/components/post/pieces/gallery/GalleryImage.tsx +15 -0
- package/src/components/post/pieces/gallery/GalleryVideo.tsx +39 -0
- package/src/components/post/pieces/gallery/index.ts +4 -0
- package/src/components/post/pieces/index.ts +24 -0
- package/src/components/post/pieces/modals/CancelEventModal.tsx +60 -0
- package/src/components/post/pieces/modals/DeleteEventModal.tsx +60 -0
- package/src/components/post/pieces/modals/DeletePostModal.tsx +54 -0
- package/src/components/post/pieces/modals/PostOptionsSheet.tsx +59 -0
- package/src/components/post/pieces/modals/ReactionsModal.tsx +45 -0
- package/src/components/post/pieces/modals/RepostModal.tsx +56 -0
- package/src/components/post/pieces/modals/index.ts +6 -0
- package/src/components/post/post-form/ArticleForm.tsx +101 -0
- package/src/components/post/post-form/ArticlePreviewSheet.tsx +24 -0
- package/src/components/post/post-form/AttachmentCard.tsx +119 -0
- package/src/components/post/post-form/ComposeAttachments.tsx +126 -0
- package/src/components/post/post-form/ComposePreviewLinks.tsx +21 -0
- package/src/components/post/post-form/DateSheet.tsx +154 -0
- package/src/components/post/post-form/DescriptionEditModal.tsx +58 -0
- package/src/components/post/post-form/EditPostModalContext.tsx +49 -0
- package/src/components/post/post-form/EventForm.tsx +416 -0
- package/src/components/post/post-form/EventTypeSwitcher.tsx +164 -0
- package/src/components/post/post-form/Footer.tsx +61 -0
- package/src/components/post/post-form/NewPostModalContext.tsx +77 -0
- package/src/components/post/post-form/OpenpeepsMarkdownInput.tsx +218 -0
- package/src/components/post/post-form/PollComposerFields.tsx +141 -0
- package/src/components/post/post-form/PostAudienceSelector.tsx +82 -0
- package/src/components/post/post-form/PostForm.tsx +187 -0
- package/src/components/post/post-form/PostTypeSwitcher.tsx +125 -0
- package/src/components/post/post-form/ReplyModal.tsx +40 -0
- package/src/components/post/post-form/ReplyModalContext.tsx +24 -0
- package/src/components/post/post-form/ResourceForm.tsx +241 -0
- package/src/components/post/post-form/VisibilitySelector.tsx +60 -0
- package/src/components/post/post-form/VisibilitySheet.tsx +239 -0
- package/src/components/post/post-form/constants.ts +47 -0
- package/src/components/post/post-form/index.ts +23 -0
- package/src/components/post/types/Article.tsx +55 -0
- package/src/components/post/types/Event.tsx +79 -0
- package/src/components/post/types/Note.tsx +29 -0
- package/src/components/post/types/Poll.tsx +34 -0
- package/src/components/post/types/article/CardArticle.tsx +44 -0
- package/src/components/post/types/article/FullArticle.tsx +56 -0
- package/src/components/post/types/article/index.ts +2 -0
- package/src/components/post/types/event/CardEvent.tsx +138 -0
- package/src/components/post/types/event/FullEvent.tsx +760 -0
- package/src/components/post/types/event/ProfileEventRelationship.tsx +56 -0
- package/src/components/post/types/event/index.ts +3 -0
- package/src/components/post/types/index.ts +9 -0
- package/src/components/post/types/note/FullNote.tsx +15 -0
- package/src/components/post/types/note/index.ts +1 -0
- package/src/components/post/types/poll/FullPoll.tsx +26 -0
- package/src/components/post/types/poll/index.ts +1 -0
- package/src/components/post/types/resource/FullResource.tsx +177 -0
- package/src/components/preview-link/AccessDenied.tsx +44 -0
- package/src/components/preview-link/LocalPreviewLink.tsx +40 -0
- package/src/components/preview-link/PreviewLink.tsx +27 -0
- package/src/components/preview-link/RemotePreviewLink.tsx +76 -0
- package/src/components/preview-link/helpers.ts +38 -0
- package/src/components/preview-link/index.ts +7 -0
- package/src/components/preview-link/local/GroupPreview.tsx +57 -0
- package/src/components/preview-link/local/JamPreview.tsx +40 -0
- package/src/components/preview-link/local/PostPreview.tsx +40 -0
- package/src/components/profile/Avatar.tsx +90 -0
- package/src/components/profile/AvatarWithName.tsx +18 -0
- package/src/components/profile/EditProfileForm.tsx +380 -0
- package/src/components/profile/FollowUnfollowButton.tsx +83 -0
- package/src/components/profile/ProfileActivitySummary.tsx +129 -0
- package/src/components/profile/ProfileBadge.tsx +52 -0
- package/src/components/profile/ProfileCard.tsx +122 -0
- package/src/components/profile/ProfileFromId.tsx +23 -0
- package/src/components/profile/ProfileHeader.tsx +107 -0
- package/src/components/profile/ProfileLink.tsx +35 -0
- package/src/components/profile/ProfilePageAction.tsx +193 -0
- package/src/components/profile/ProfilePieces.tsx +191 -0
- package/src/components/profile/ProfilePostsAndReplies.tsx +108 -0
- package/src/components/profile/ProfileSelector.tsx +210 -0
- package/src/components/profile/ProfileSheet.tsx +48 -0
- package/src/components/profile/ProfileStats.tsx +47 -0
- package/src/components/profile/ProfileWithActionCard.tsx +35 -0
- package/src/components/profile/ProfilesInput.tsx +81 -0
- package/src/components/profile/ReportProfileOrPostModal.tsx +228 -0
- package/src/components/profile/index.ts +19 -0
- package/src/components/resources/ResourceCard.tsx +289 -0
- package/src/components/resources/ResourceLibrary.tsx +371 -0
- package/src/components/resources/index.ts +4 -0
- package/src/components/ui/alert.tsx +87 -0
- package/src/components/ui/avatar.tsx +91 -0
- package/src/components/ui/badge.tsx +36 -0
- package/src/components/ui/bottom-sheet.tsx +253 -0
- package/src/components/ui/button.tsx +101 -0
- package/src/components/ui/calendar.tsx +117 -0
- package/src/components/ui/card.tsx +87 -0
- package/src/components/ui/checkbox.tsx +35 -0
- package/src/components/ui/combobox.tsx +229 -0
- package/src/components/ui/dropdown-menu.tsx +350 -0
- package/src/components/ui/form.tsx +716 -0
- package/src/components/ui/index.ts +49 -0
- package/src/components/ui/input.tsx +25 -0
- package/src/components/ui/label.tsx +33 -0
- package/src/components/ui/loading-spinner.tsx +24 -0
- package/src/components/ui/popup-menu-button.tsx +99 -0
- package/src/components/ui/popup-menu-section.tsx +21 -0
- package/src/components/ui/popup-menu-separator.tsx +10 -0
- package/src/components/ui/popup-menu.tsx +75 -0
- package/src/components/ui/progress.tsx +83 -0
- package/src/components/ui/radio-group.tsx +42 -0
- package/src/components/ui/select.tsx +200 -0
- package/src/components/ui/separator.tsx +28 -0
- package/src/components/ui/skeleton.tsx +39 -0
- package/src/components/ui/svg-image.tsx +89 -0
- package/src/components/ui/switch.tsx +95 -0
- package/src/components/ui/tabs.tsx +93 -0
- package/src/components/ui/text.tsx +28 -0
- package/src/components/ui/textarea.tsx +39 -0
- package/src/components/ui/themed-safe-area-view.tsx +25 -0
- package/src/components/ui/themed-text.tsx +28 -0
- package/src/components/ui/themed-view.tsx +24 -0
- package/src/components/ui/tooltip.tsx +41 -0
- package/src/contexts/drawer-context.tsx +38 -0
- package/src/contexts/openpeeps-provider.tsx +135 -0
- package/src/global.css +53 -0
- package/src/hooks/helper.ts +26 -0
- package/src/hooks/index.ts +5 -0
- package/src/hooks/use-cached-media-uri.ts +59 -0
- package/src/hooks/use-controlled-sheet.ts +16 -0
- package/src/hooks/use-notification-badge-reset.ts +93 -0
- package/src/hooks/use-post-view-ref.ts +65 -0
- package/src/i18n/index.ts +49 -0
- package/src/index.ts +42 -0
- package/src/lib/attachmentHelpers.ts +15 -0
- package/src/lib/auth.ts +17 -0
- package/src/lib/bottom-sheet-ref.ts +30 -0
- package/src/lib/constants.ts +14 -0
- package/src/lib/credentialsStore.ts +20 -0
- package/src/lib/downloadFile.ts +12 -0
- package/src/lib/livekit/useStableLiveKitRoom.ts +172 -0
- package/src/lib/media-permissions.ts +90 -0
- package/src/lib/media-url.ts +51 -0
- package/src/lib/mediaUriHelpers.ts +94 -0
- package/src/lib/notification-helpers.ts +17 -0
- package/src/lib/notifications-screen-state.ts +21 -0
- package/src/lib/polyfills/customEvent.ts +40 -0
- package/src/lib/post.ts +175 -0
- package/src/lib/push-notification-navigation.ts +11 -0
- package/src/lib/push-notifications-background.ts +13 -0
- package/src/lib/push-notifications.ts +247 -0
- package/src/lib/uploadMedia.ts +191 -0
- package/src/lib/utils.ts +247 -0
- package/src/nativewind-env.d.ts +1 -0
- package/src/pages/About.tsx +27 -0
- package/src/pages/CodeOfConduct.tsx +24 -0
- package/src/pages/Explore.tsx +297 -0
- package/src/pages/Members.tsx +118 -0
- package/src/pages/NotFound.tsx +36 -0
- package/src/pages/Notifications.tsx +39 -0
- package/src/pages/PostDetail.tsx +61 -0
- package/src/pages/Profile.tsx +77 -0
- package/src/pages/Tags.tsx +114 -0
- package/src/pages/VideoPlayer.tsx +16 -0
- package/src/pages/Welcome.tsx +214 -0
- package/src/pages/articles/Edit.tsx +72 -0
- package/src/pages/articles/Index.tsx +31 -0
- package/src/pages/articles/New.tsx +55 -0
- package/src/pages/auth/Login.tsx +148 -0
- package/src/pages/auth/Register.tsx +271 -0
- package/src/pages/auth/RegisterInvitation.tsx +8 -0
- package/src/pages/auth/RequestResetPassword.tsx +102 -0
- package/src/pages/auth/ResetPassword.tsx +48 -0
- package/src/pages/auth/Success.tsx +104 -0
- package/src/pages/auth/ValidateEmail.tsx +80 -0
- package/src/pages/auth/Welcome.tsx +64 -0
- package/src/pages/conversations/Index.tsx +168 -0
- package/src/pages/conversations/Info.tsx +99 -0
- package/src/pages/conversations/New.tsx +135 -0
- package/src/pages/conversations/NewDraft.tsx +102 -0
- package/src/pages/conversations/Show.tsx +261 -0
- package/src/pages/events/Edit.tsx +74 -0
- package/src/pages/events/Index.tsx +99 -0
- package/src/pages/events/My.tsx +60 -0
- package/src/pages/events/New.tsx +51 -0
- package/src/pages/feeds/Bookmarks.tsx +47 -0
- package/src/pages/feeds/Local.tsx +45 -0
- package/src/pages/feeds/My.tsx +37 -0
- package/src/pages/groups/Edit.tsx +58 -0
- package/src/pages/groups/EditInfo.tsx +79 -0
- package/src/pages/groups/EditRoles.tsx +84 -0
- package/src/pages/groups/Index.tsx +159 -0
- package/src/pages/groups/Info.tsx +197 -0
- package/src/pages/groups/Members.tsx +55 -0
- package/src/pages/groups/New.tsx +80 -0
- package/src/pages/groups/Show.tsx +212 -0
- package/src/pages/index.ts +66 -0
- package/src/pages/jams/Event.tsx +49 -0
- package/src/pages/jams/Index.tsx +137 -0
- package/src/pages/jams/My.tsx +4 -0
- package/src/pages/jams/New.tsx +121 -0
- package/src/pages/posts/Edit.tsx +157 -0
- package/src/pages/posts/New.tsx +334 -0
- package/src/pages/posts/Reply.tsx +351 -0
- package/src/pages/profile/Followers.tsx +45 -0
- package/src/pages/profile/Following.tsx +44 -0
- package/src/pages/resources/Edit.tsx +72 -0
- package/src/pages/resources/Index.tsx +25 -0
- package/src/pages/resources/New.tsx +55 -0
- package/src/pages/settings/AccessTokens.tsx +276 -0
- package/src/pages/settings/Account.tsx +272 -0
- package/src/pages/settings/Blocked.tsx +81 -0
- package/src/pages/settings/Feed.tsx +78 -0
- package/src/pages/settings/Index.tsx +75 -0
- package/src/pages/settings/Language.tsx +81 -0
- package/src/pages/settings/NotificationPreferences.tsx +131 -0
- package/src/pages/settings/Notifications.tsx +36 -0
- package/src/pages/settings/PublicProfile.tsx +20 -0
- package/src/pages/settings/PushEnabledDevices.tsx +151 -0
- package/src/pages/settings/Theme.tsx +106 -0
- package/src/pages/settings/Timezone.tsx +75 -0
- package/src/stores/useAppImagesStore.ts +15 -0
- package/src/stores/useLocalPostStore.ts +62 -0
- package/src/stores/useNewConversationStore.ts +39 -0
- package/src/theme/OpenPeepsThemeProvider.tsx +98 -0
- package/src/theme/defaults.ts +40 -0
- package/src/theme/types.ts +37 -0
- package/src/theme/utils.ts +62 -0
- package/src/types/env.d.ts +11 -0
- package/src/types/goto.ts +12 -0
- package/src/types/markdown-plugin.ts +17 -0
- package/src/types/react-native-convert-ph-asset.d.ts +24 -0
- package/src/types.ts +56 -0
- package/src/utils/media-cache.ts +178 -0
- package/tailwind.config.js +128 -0
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import React, {
|
|
2
|
+
createContext,
|
|
3
|
+
useCallback,
|
|
4
|
+
useContext,
|
|
5
|
+
useMemo,
|
|
6
|
+
type ReactNode,
|
|
7
|
+
} from 'react';
|
|
8
|
+
import type { GroupWithMeta, VisibilityType } from '@openpeepshq/common';
|
|
9
|
+
import { navigationRef } from '../../navigation/nativeRouter';
|
|
10
|
+
import {
|
|
11
|
+
postDataDefaults,
|
|
12
|
+
useLocalPostStore,
|
|
13
|
+
} from '../../../stores/useLocalPostStore';
|
|
14
|
+
|
|
15
|
+
export interface NewPostOptions {
|
|
16
|
+
visibility?: VisibilityType;
|
|
17
|
+
group?: GroupWithMeta;
|
|
18
|
+
initialContent?: string;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
interface NewPostModalContextValue {
|
|
22
|
+
openNewPost: (options?: NewPostOptions) => void;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const NewPostModalContext = createContext<NewPostModalContextValue | null>(
|
|
26
|
+
null
|
|
27
|
+
);
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Native counterpart of the web modal: seeds the composer store and opens the
|
|
31
|
+
* full-screen `NewPost` tab instead of rendering a dialog.
|
|
32
|
+
*/
|
|
33
|
+
export const NewPostModalProvider = ({ children }: { children: ReactNode }) => {
|
|
34
|
+
const setPostData = useLocalPostStore((state) => state.setPostData);
|
|
35
|
+
|
|
36
|
+
const openNewPost = useCallback(
|
|
37
|
+
(options?: NewPostOptions) => {
|
|
38
|
+
const base = postDataDefaults();
|
|
39
|
+
setPostData({
|
|
40
|
+
...base,
|
|
41
|
+
visibility: options?.group
|
|
42
|
+
? 'group'
|
|
43
|
+
: (options?.visibility ?? base.visibility),
|
|
44
|
+
groupId: options?.group?.id,
|
|
45
|
+
data: { type: 'note', content: options?.initialContent ?? '' },
|
|
46
|
+
});
|
|
47
|
+
if (!navigationRef.isReady()) return;
|
|
48
|
+
navigationRef.navigate('Main', {
|
|
49
|
+
screen: 'TabNavigator',
|
|
50
|
+
params: {
|
|
51
|
+
screen: 'NewPost',
|
|
52
|
+
params: {
|
|
53
|
+
originatorId: options?.group?.id,
|
|
54
|
+
triggeredFrom: options?.group ? 'group' : undefined,
|
|
55
|
+
withContent: !!options?.initialContent,
|
|
56
|
+
},
|
|
57
|
+
},
|
|
58
|
+
});
|
|
59
|
+
},
|
|
60
|
+
[setPostData]
|
|
61
|
+
);
|
|
62
|
+
|
|
63
|
+
const value = useMemo(() => ({ openNewPost }), [openNewPost]);
|
|
64
|
+
return (
|
|
65
|
+
<NewPostModalContext.Provider value={value}>
|
|
66
|
+
{children}
|
|
67
|
+
</NewPostModalContext.Provider>
|
|
68
|
+
);
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
export const useNewPostModal = () => {
|
|
72
|
+
const ctx = useContext(NewPostModalContext);
|
|
73
|
+
if (!ctx) {
|
|
74
|
+
throw new Error('useNewPostModal must be used within NewPostModalProvider');
|
|
75
|
+
}
|
|
76
|
+
return ctx;
|
|
77
|
+
};
|
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
import React, { useMemo, useRef, useState } from 'react';
|
|
2
|
+
import {
|
|
3
|
+
Linking,
|
|
4
|
+
Pressable,
|
|
5
|
+
ScrollView,
|
|
6
|
+
View,
|
|
7
|
+
type NativeSyntheticEvent,
|
|
8
|
+
type TextInputSelectionChangeEventData,
|
|
9
|
+
} from 'react-native';
|
|
10
|
+
import type { PublicProfile } from '@openpeepshq/common';
|
|
11
|
+
import { useOpenpeeps } from '@openpeepshq/react';
|
|
12
|
+
import { useTranslation } from 'react-i18next';
|
|
13
|
+
import { OpenpeepsMarkdown } from '../../markdown/index';
|
|
14
|
+
import { ProfileAvatar } from '../../profile/Avatar';
|
|
15
|
+
import { Button } from '../../ui/button';
|
|
16
|
+
import { Textarea } from '../../ui/textarea';
|
|
17
|
+
import { ThemedText } from '../../ui/themed-text';
|
|
18
|
+
import { toAbsoluteMediaUrl } from '../../../lib/media-url';
|
|
19
|
+
import { cn, maxContentLength } from '../../../lib/utils';
|
|
20
|
+
|
|
21
|
+
export interface OpenpeepsMarkdownInputProps {
|
|
22
|
+
value: string;
|
|
23
|
+
onChange: (value: string) => void;
|
|
24
|
+
/** Character budget; the counter turns red once exceeded. */
|
|
25
|
+
maxLength?: number;
|
|
26
|
+
placeholder?: string;
|
|
27
|
+
rows?: number;
|
|
28
|
+
/** Show the preview toggle button (mirrors web `previewButton`). */
|
|
29
|
+
previewButton?: boolean;
|
|
30
|
+
/** Extra classes for the textarea. */
|
|
31
|
+
className?: string;
|
|
32
|
+
testId?: string;
|
|
33
|
+
autoFocus?: boolean;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const mentionQueryFrom = (text: string, cursor: number) => {
|
|
37
|
+
const match = text.slice(0, cursor).match(/@([a-zA-Z0-9_-]*)$/);
|
|
38
|
+
return match ? (match[1] ?? '') : null;
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Markdown editor mirroring the web `OpenpeepsMarkdownInput`: a textarea
|
|
43
|
+
* with @-mention autocomplete, a preview toggle that renders the markdown,
|
|
44
|
+
* and a character counter.
|
|
45
|
+
*/
|
|
46
|
+
export const OpenpeepsMarkdownInput = ({
|
|
47
|
+
value,
|
|
48
|
+
onChange,
|
|
49
|
+
maxLength = maxContentLength,
|
|
50
|
+
placeholder,
|
|
51
|
+
rows = 5,
|
|
52
|
+
previewButton = true,
|
|
53
|
+
className,
|
|
54
|
+
testId,
|
|
55
|
+
autoFocus = false,
|
|
56
|
+
}: OpenpeepsMarkdownInputProps) => {
|
|
57
|
+
const { t } = useTranslation();
|
|
58
|
+
const { openpeepsApi } = useOpenpeeps();
|
|
59
|
+
const [query, setQuery] = useState('');
|
|
60
|
+
const [open, setOpen] = useState(false);
|
|
61
|
+
const [showPreview, setShowPreview] = useState(false);
|
|
62
|
+
const valueRef = useRef(value);
|
|
63
|
+
const cursorRef = useRef(value.length);
|
|
64
|
+
|
|
65
|
+
valueRef.current = value;
|
|
66
|
+
|
|
67
|
+
const profilesQuery = openpeepsApi.useSearchProfiles(query);
|
|
68
|
+
|
|
69
|
+
const profiles = useMemo(
|
|
70
|
+
() =>
|
|
71
|
+
(profilesQuery.data?.pages ?? [])
|
|
72
|
+
.flat()
|
|
73
|
+
.map((item) => item.data)
|
|
74
|
+
.slice(0, 6),
|
|
75
|
+
[profilesQuery.data]
|
|
76
|
+
);
|
|
77
|
+
|
|
78
|
+
const showMentions = open && query.length >= 1 && profiles.length > 0;
|
|
79
|
+
|
|
80
|
+
const updateMentionState = (text: string, cursor: number) => {
|
|
81
|
+
const mentionQuery = mentionQueryFrom(text, cursor);
|
|
82
|
+
if (mentionQuery !== null) {
|
|
83
|
+
setQuery(mentionQuery);
|
|
84
|
+
setOpen(true);
|
|
85
|
+
} else {
|
|
86
|
+
setOpen(false);
|
|
87
|
+
setQuery('');
|
|
88
|
+
}
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
const handleChange = (next: string) => {
|
|
92
|
+
onChange(next);
|
|
93
|
+
valueRef.current = next;
|
|
94
|
+
const cursor = Math.min(
|
|
95
|
+
next.length,
|
|
96
|
+
Math.max(0, cursorRef.current + (next.length - value.length))
|
|
97
|
+
);
|
|
98
|
+
cursorRef.current = cursor;
|
|
99
|
+
updateMentionState(next, cursor);
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
const handleSelectionChange = (
|
|
103
|
+
event: NativeSyntheticEvent<TextInputSelectionChangeEventData>
|
|
104
|
+
) => {
|
|
105
|
+
const cursor = event.nativeEvent.selection.start;
|
|
106
|
+
cursorRef.current = cursor;
|
|
107
|
+
updateMentionState(valueRef.current, cursor);
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
const insertMention = (profile: PublicProfile) => {
|
|
111
|
+
const cursor = cursorRef.current;
|
|
112
|
+
const before = value.slice(0, cursor);
|
|
113
|
+
const after = value.slice(cursor);
|
|
114
|
+
const replaced = before.replace(
|
|
115
|
+
/@([a-zA-Z0-9_-]*)$/,
|
|
116
|
+
`@${profile.handle} `
|
|
117
|
+
);
|
|
118
|
+
onChange(`${replaced}${after}`);
|
|
119
|
+
setOpen(false);
|
|
120
|
+
setQuery('');
|
|
121
|
+
};
|
|
122
|
+
|
|
123
|
+
const openMarkdownHelp = () => {
|
|
124
|
+
const url = toAbsoluteMediaUrl('/docs/user/markdown');
|
|
125
|
+
if (url) {
|
|
126
|
+
void Linking.openURL(url);
|
|
127
|
+
}
|
|
128
|
+
};
|
|
129
|
+
|
|
130
|
+
const overLimit = value.length > maxLength;
|
|
131
|
+
|
|
132
|
+
return (
|
|
133
|
+
<View className="relative w-full">
|
|
134
|
+
{showPreview ? (
|
|
135
|
+
<View className="min-h-[80px] rounded-md border border-border bg-background p-3">
|
|
136
|
+
<Button
|
|
137
|
+
size="sm"
|
|
138
|
+
variant="outline"
|
|
139
|
+
className="mb-3 self-start"
|
|
140
|
+
onPress={() => setShowPreview(false)}
|
|
141
|
+
>
|
|
142
|
+
<ThemedText>
|
|
143
|
+
{t('form.edit', { defaultValue: 'Back to Editing' })}
|
|
144
|
+
</ThemedText>
|
|
145
|
+
</Button>
|
|
146
|
+
<OpenpeepsMarkdown source={value} linkPreviewMode="none" />
|
|
147
|
+
</View>
|
|
148
|
+
) : (
|
|
149
|
+
<>
|
|
150
|
+
<View className="flex-row items-center gap-3 pb-2">
|
|
151
|
+
{previewButton ? (
|
|
152
|
+
<Button
|
|
153
|
+
size="sm"
|
|
154
|
+
variant="outline"
|
|
155
|
+
onPress={() => setShowPreview(true)}
|
|
156
|
+
>
|
|
157
|
+
<ThemedText>
|
|
158
|
+
{t('form.preview', { defaultValue: 'Preview' })}
|
|
159
|
+
</ThemedText>
|
|
160
|
+
</Button>
|
|
161
|
+
) : null}
|
|
162
|
+
<Pressable onPress={openMarkdownHelp} accessibilityRole="link">
|
|
163
|
+
<ThemedText className="text-sm text-primary">
|
|
164
|
+
{t('form.markdownHelp', { defaultValue: 'Formatting help' })}
|
|
165
|
+
</ThemedText>
|
|
166
|
+
</Pressable>
|
|
167
|
+
</View>
|
|
168
|
+
|
|
169
|
+
{showMentions ? (
|
|
170
|
+
<ScrollView
|
|
171
|
+
keyboardShouldPersistTaps="handled"
|
|
172
|
+
className="mb-2 max-h-48 rounded-md border border-border bg-surface"
|
|
173
|
+
nestedScrollEnabled
|
|
174
|
+
>
|
|
175
|
+
{profiles.map((profile) => (
|
|
176
|
+
<Pressable
|
|
177
|
+
key={profile.id}
|
|
178
|
+
className="flex-row items-center gap-x-2 px-3 py-2"
|
|
179
|
+
onPress={() => insertMention(profile)}
|
|
180
|
+
>
|
|
181
|
+
<ProfileAvatar profile={profile} className="size-8" />
|
|
182
|
+
<View>
|
|
183
|
+
<ThemedText className="font-semibold">
|
|
184
|
+
{profile.displayName || profile.handle}
|
|
185
|
+
</ThemedText>
|
|
186
|
+
<ThemedText className="text-sm text-muted-foreground">
|
|
187
|
+
@{profile.handle}
|
|
188
|
+
</ThemedText>
|
|
189
|
+
</View>
|
|
190
|
+
</Pressable>
|
|
191
|
+
))}
|
|
192
|
+
</ScrollView>
|
|
193
|
+
) : null}
|
|
194
|
+
|
|
195
|
+
<Textarea
|
|
196
|
+
autoFocus={autoFocus}
|
|
197
|
+
numberOfLines={rows}
|
|
198
|
+
value={value}
|
|
199
|
+
maxLength={maxLength}
|
|
200
|
+
placeholder={placeholder ?? t('posts.form.content')}
|
|
201
|
+
onChangeText={handleChange}
|
|
202
|
+
onSelectionChange={handleSelectionChange}
|
|
203
|
+
testID={testId}
|
|
204
|
+
className={cn('min-h-[80px]', className)}
|
|
205
|
+
/>
|
|
206
|
+
</>
|
|
207
|
+
)}
|
|
208
|
+
|
|
209
|
+
<View className="w-full px-2 pt-1">
|
|
210
|
+
<ThemedText
|
|
211
|
+
className={cn('text-right text-sm', overLimit && 'text-destructive')}
|
|
212
|
+
>
|
|
213
|
+
{value.length} / {maxLength}
|
|
214
|
+
</ThemedText>
|
|
215
|
+
</View>
|
|
216
|
+
</View>
|
|
217
|
+
);
|
|
218
|
+
};
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
import React, { useRef } from 'react';
|
|
2
|
+
import { View, TouchableOpacity } from 'react-native';
|
|
3
|
+
import { FormField, FormInput, FormCheckbox } from '../../ui/form';
|
|
4
|
+
import { Button } from '../../ui/button';
|
|
5
|
+
import { ThemedText } from '../../ui/themed-text';
|
|
6
|
+
import { UseFormReturn } from 'react-hook-form';
|
|
7
|
+
import { PlusIcon, MinusIcon } from '../../icons/index';
|
|
8
|
+
import { formatDateTime } from '../../../lib/utils';
|
|
9
|
+
import { useTranslation } from 'react-i18next';
|
|
10
|
+
import { POLL_OPTION_MAX_LENGTH, PostCreationData } from '@openpeepshq/common';
|
|
11
|
+
import { DateSheet } from './DateSheet';
|
|
12
|
+
import { BottomSheetModal } from '@gorhom/bottom-sheet';
|
|
13
|
+
|
|
14
|
+
interface PollFormProps {
|
|
15
|
+
form: UseFormReturn<PostCreationData>;
|
|
16
|
+
postData: PostCreationData;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export const PollComposerFields: React.FC<PollFormProps> = ({
|
|
20
|
+
form,
|
|
21
|
+
postData,
|
|
22
|
+
}) => {
|
|
23
|
+
const options =
|
|
24
|
+
postData.data.type === 'question' ? postData.data.options : [];
|
|
25
|
+
const expiresAt =
|
|
26
|
+
postData.data.type === 'question' ? postData.data.expiresAt : '';
|
|
27
|
+
const { t } = useTranslation();
|
|
28
|
+
const pollExpirationModalRef = useRef<BottomSheetModal>(null);
|
|
29
|
+
const handlePollExpirationModal = () => {
|
|
30
|
+
pollExpirationModalRef.current?.present();
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
return (
|
|
34
|
+
<View className="pt-4 w-full flex flex-col gap-4">
|
|
35
|
+
{options?.map((_, index) => (
|
|
36
|
+
<View key={index} className="flex-row gap-x-1 items-center w-full">
|
|
37
|
+
<FormField
|
|
38
|
+
control={form.control}
|
|
39
|
+
name={`data.options.${index}.content`}
|
|
40
|
+
render={({ field }) => (
|
|
41
|
+
<FormInput
|
|
42
|
+
containerClassName="flex-grow"
|
|
43
|
+
className="px-4 py-2 w-full rounded-lg"
|
|
44
|
+
maxLength={POLL_OPTION_MAX_LENGTH}
|
|
45
|
+
placeholder={t('posts.form.poll.option', { number: index + 1 })}
|
|
46
|
+
{...field}
|
|
47
|
+
/>
|
|
48
|
+
)}
|
|
49
|
+
/>
|
|
50
|
+
<View className="flex-0 w-10">
|
|
51
|
+
{index === options.length - 2 && options.length > 2 && (
|
|
52
|
+
<Button
|
|
53
|
+
onPress={() =>
|
|
54
|
+
form.setValue(
|
|
55
|
+
'data.options',
|
|
56
|
+
options.filter((_option, i) => i !== index)
|
|
57
|
+
)
|
|
58
|
+
}
|
|
59
|
+
variant={'ghost'}
|
|
60
|
+
size={'sm'}
|
|
61
|
+
>
|
|
62
|
+
<MinusIcon size={20} className="text-foreground" />
|
|
63
|
+
</Button>
|
|
64
|
+
)}
|
|
65
|
+
{index === options.length - 1 && (
|
|
66
|
+
<Button
|
|
67
|
+
onPress={() =>
|
|
68
|
+
form.setValue('data.options', [
|
|
69
|
+
...options,
|
|
70
|
+
{ type: 'note', content: '' },
|
|
71
|
+
])
|
|
72
|
+
}
|
|
73
|
+
variant={'ghost'}
|
|
74
|
+
size={'sm'}
|
|
75
|
+
>
|
|
76
|
+
<PlusIcon size={20} className="text-foreground" />
|
|
77
|
+
</Button>
|
|
78
|
+
)}
|
|
79
|
+
</View>
|
|
80
|
+
</View>
|
|
81
|
+
))}
|
|
82
|
+
|
|
83
|
+
<View className="mt-6">
|
|
84
|
+
<ThemedText className="text-base mb-2">
|
|
85
|
+
{t('posts.form.poll.duration')}
|
|
86
|
+
</ThemedText>
|
|
87
|
+
|
|
88
|
+
<TouchableOpacity
|
|
89
|
+
onPress={handlePollExpirationModal}
|
|
90
|
+
className="h-14 px-4 border border-input rounded-lg justify-center"
|
|
91
|
+
>
|
|
92
|
+
<ThemedText className="text-muted-foreground">
|
|
93
|
+
{expiresAt
|
|
94
|
+
? formatDateTime(new Date(expiresAt))
|
|
95
|
+
: t('posts.form.poll.expiresAt')}
|
|
96
|
+
</ThemedText>
|
|
97
|
+
</TouchableOpacity>
|
|
98
|
+
</View>
|
|
99
|
+
|
|
100
|
+
<View className="flex w-full h-[38px] mt-2 relative flex-row items-center gap-3 pr-7">
|
|
101
|
+
<FormField
|
|
102
|
+
control={form.control}
|
|
103
|
+
name="data.multiple"
|
|
104
|
+
render={({ field }) => (
|
|
105
|
+
<FormCheckbox
|
|
106
|
+
checked={!!field.value}
|
|
107
|
+
onCheckedChange={field.onChange}
|
|
108
|
+
{...field}
|
|
109
|
+
custom={false}
|
|
110
|
+
label={t('posts.form.poll.multipleChoice')}
|
|
111
|
+
/>
|
|
112
|
+
)}
|
|
113
|
+
/>
|
|
114
|
+
</View>
|
|
115
|
+
<View className="flex w-full h-[38px] mt-2 relative flex-row items-center gap-3 pr-7">
|
|
116
|
+
<FormField
|
|
117
|
+
control={form.control}
|
|
118
|
+
name="data.votersVisible"
|
|
119
|
+
render={({ field }) => (
|
|
120
|
+
<FormCheckbox
|
|
121
|
+
checked={!!field.value}
|
|
122
|
+
onCheckedChange={field.onChange}
|
|
123
|
+
{...field}
|
|
124
|
+
custom={false}
|
|
125
|
+
label={t('posts.form.poll.seeWhoVoted')}
|
|
126
|
+
/>
|
|
127
|
+
)}
|
|
128
|
+
/>
|
|
129
|
+
</View>
|
|
130
|
+
|
|
131
|
+
<DateSheet
|
|
132
|
+
ref={pollExpirationModalRef}
|
|
133
|
+
value={expiresAt}
|
|
134
|
+
onChange={(dateString) => {
|
|
135
|
+
form.setValue('data.expiresAt', new Date(dateString).toISOString());
|
|
136
|
+
}}
|
|
137
|
+
onClose={() => pollExpirationModalRef.current?.close()}
|
|
138
|
+
/>
|
|
139
|
+
</View>
|
|
140
|
+
);
|
|
141
|
+
};
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import React, { forwardRef } from 'react';
|
|
2
|
+
import {
|
|
3
|
+
View,
|
|
4
|
+
Text,
|
|
5
|
+
TouchableOpacity,
|
|
6
|
+
Image,
|
|
7
|
+
ImageSourcePropType,
|
|
8
|
+
} from 'react-native';
|
|
9
|
+
import { BottomSheetModal } from '@gorhom/bottom-sheet';
|
|
10
|
+
import { useOpenpeeps } from '@openpeepshq/react';
|
|
11
|
+
import { type GroupWithMeta, getGroupAvatar } from '@openpeepshq/common';
|
|
12
|
+
import { ThemedText } from '../../ui/themed-text';
|
|
13
|
+
import { BaseSheet, SheetFooter } from '../../custom/modals/common';
|
|
14
|
+
import { useTranslation } from 'react-i18next';
|
|
15
|
+
import { bottomSheetClose } from '../../../lib/bottom-sheet-ref';
|
|
16
|
+
|
|
17
|
+
interface GroupSelectionSheetProps {
|
|
18
|
+
onSelect: (group: GroupWithMeta) => void;
|
|
19
|
+
selectedGroup?: GroupWithMeta;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export const PostAudienceSelector = forwardRef<
|
|
23
|
+
BottomSheetModal,
|
|
24
|
+
GroupSelectionSheetProps
|
|
25
|
+
>(({ onSelect, selectedGroup }, ref) => {
|
|
26
|
+
const { openpeepsApi } = useOpenpeeps();
|
|
27
|
+
const { data: groups } = openpeepsApi.useGroups();
|
|
28
|
+
const { data: server } = openpeepsApi.useServerInfo();
|
|
29
|
+
const { t } = useTranslation();
|
|
30
|
+
|
|
31
|
+
return (
|
|
32
|
+
<BaseSheet ref={ref} scrollable>
|
|
33
|
+
<View className="flex-1 p-4">
|
|
34
|
+
<ThemedText className="text-xl font-bold text-center mb-6">
|
|
35
|
+
{t('groups.selection.title')}
|
|
36
|
+
</ThemedText>
|
|
37
|
+
|
|
38
|
+
{groups?.map((group) => (
|
|
39
|
+
<TouchableOpacity
|
|
40
|
+
key={group.id}
|
|
41
|
+
className="flex-row items-center justify-between py-3"
|
|
42
|
+
onPress={() => onSelect(group)}
|
|
43
|
+
>
|
|
44
|
+
<View className="flex-row items-center flex-1">
|
|
45
|
+
<Image
|
|
46
|
+
source={
|
|
47
|
+
(server
|
|
48
|
+
? getGroupAvatar(group, server.communityConfig)
|
|
49
|
+
: group.avatar) as ImageSourcePropType
|
|
50
|
+
}
|
|
51
|
+
className="w-12 h-12 rounded-full mr-3"
|
|
52
|
+
/>
|
|
53
|
+
<View className="flex-1">
|
|
54
|
+
<Text className="text-base font-semibold text-foreground">
|
|
55
|
+
{group.displayName}
|
|
56
|
+
</Text>
|
|
57
|
+
</View>
|
|
58
|
+
</View>
|
|
59
|
+
<View
|
|
60
|
+
className={`w-6 h-6 rounded-full items-center justify-center border-2 ${
|
|
61
|
+
selectedGroup?.id === group.id
|
|
62
|
+
? 'border-foreground'
|
|
63
|
+
: 'border-muted-foreground'
|
|
64
|
+
}`}
|
|
65
|
+
>
|
|
66
|
+
<View
|
|
67
|
+
className={`w-4 h-4 rounded-full ${
|
|
68
|
+
selectedGroup?.id === group.id && 'bg-primary'
|
|
69
|
+
}`}
|
|
70
|
+
/>
|
|
71
|
+
</View>
|
|
72
|
+
</TouchableOpacity>
|
|
73
|
+
))}
|
|
74
|
+
|
|
75
|
+
<SheetFooter
|
|
76
|
+
onCancel={() => bottomSheetClose(ref)}
|
|
77
|
+
onConfirm={() => bottomSheetClose(ref)}
|
|
78
|
+
/>
|
|
79
|
+
</View>
|
|
80
|
+
</BaseSheet>
|
|
81
|
+
);
|
|
82
|
+
});
|
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
import React, { useCallback, useEffect, useMemo, useRef } from 'react';
|
|
2
|
+
import { Pressable, View } from 'react-native';
|
|
3
|
+
import { UseFormReturn } from 'react-hook-form';
|
|
4
|
+
import { BottomSheetModal } from '@gorhom/bottom-sheet';
|
|
5
|
+
import { AudienceSetting, type PostCreationData } from '@openpeepshq/common';
|
|
6
|
+
import { audienceSummary, useOpenpeeps } from '@openpeepshq/react';
|
|
7
|
+
import { useTranslation } from 'react-i18next';
|
|
8
|
+
import { ProfileAvatar } from '../../profile/Avatar';
|
|
9
|
+
import { ThemedText } from '../../ui/themed-text';
|
|
10
|
+
import { Switch } from '../../ui/switch';
|
|
11
|
+
import { ChevronDownIcon, MegaphoneIcon } from '../../icons/index';
|
|
12
|
+
import { ComposeAttachments } from './ComposeAttachments';
|
|
13
|
+
import { ComposePreviewLinks } from './ComposePreviewLinks';
|
|
14
|
+
import { OpenpeepsMarkdownInput } from './OpenpeepsMarkdownInput';
|
|
15
|
+
import { PollComposerFields } from './PollComposerFields';
|
|
16
|
+
import { VisibilitySheet } from './VisibilitySheet';
|
|
17
|
+
|
|
18
|
+
interface PostFormProps {
|
|
19
|
+
autoFocus?: boolean;
|
|
20
|
+
canEditVisibility?: boolean;
|
|
21
|
+
postData: PostCreationData;
|
|
22
|
+
setPostData: (postData: PostCreationData) => void;
|
|
23
|
+
form: UseFormReturn<PostCreationData>;
|
|
24
|
+
showNotify?: boolean;
|
|
25
|
+
notify?: boolean;
|
|
26
|
+
onNotifyChange?: (value: boolean) => void;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export const PostForm = ({
|
|
30
|
+
autoFocus = false,
|
|
31
|
+
canEditVisibility = false,
|
|
32
|
+
postData,
|
|
33
|
+
setPostData,
|
|
34
|
+
form,
|
|
35
|
+
showNotify = false,
|
|
36
|
+
notify = false,
|
|
37
|
+
onNotifyChange,
|
|
38
|
+
}: PostFormProps) => {
|
|
39
|
+
const { currentProfile } = useOpenpeeps();
|
|
40
|
+
const { t } = useTranslation();
|
|
41
|
+
const visibilityModalRef = useRef<BottomSheetModal>(null);
|
|
42
|
+
const { subscribe } = form;
|
|
43
|
+
|
|
44
|
+
useEffect(
|
|
45
|
+
() =>
|
|
46
|
+
subscribe({
|
|
47
|
+
formState: {
|
|
48
|
+
values: true,
|
|
49
|
+
},
|
|
50
|
+
callback: ({ values }: { values: PostCreationData }) => {
|
|
51
|
+
setPostData(values);
|
|
52
|
+
},
|
|
53
|
+
}),
|
|
54
|
+
[subscribe, setPostData]
|
|
55
|
+
);
|
|
56
|
+
|
|
57
|
+
const handleAudienceSelect = useCallback(
|
|
58
|
+
(audienceSetting: AudienceSetting) => {
|
|
59
|
+
const newPostData = { ...postData, ...audienceSetting };
|
|
60
|
+
form.reset(newPostData);
|
|
61
|
+
setPostData(newPostData);
|
|
62
|
+
},
|
|
63
|
+
[postData, form, setPostData]
|
|
64
|
+
);
|
|
65
|
+
|
|
66
|
+
const selectedGroupName = useMemo(() => {
|
|
67
|
+
if (!postData.groupId) {
|
|
68
|
+
return undefined;
|
|
69
|
+
}
|
|
70
|
+
return currentProfile?.memberships?.find(
|
|
71
|
+
(membership) => membership.group.id === postData.groupId
|
|
72
|
+
)?.group.displayName;
|
|
73
|
+
}, [currentProfile?.memberships, postData.groupId]);
|
|
74
|
+
|
|
75
|
+
const content = form.watch('data.content') ?? '';
|
|
76
|
+
const isQuestion = postData.data.type === 'question';
|
|
77
|
+
const isNote = postData.data.type === 'note';
|
|
78
|
+
|
|
79
|
+
return (
|
|
80
|
+
<View className="px-4 pb-4">
|
|
81
|
+
{currentProfile ? (
|
|
82
|
+
<Pressable
|
|
83
|
+
disabled={!canEditVisibility}
|
|
84
|
+
accessibilityLabel={t('posts.form.changeAudience')}
|
|
85
|
+
onPress={() => visibilityModalRef.current?.present()}
|
|
86
|
+
className="mb-3 w-full flex-row items-center gap-3 rounded-md border border-border p-3"
|
|
87
|
+
>
|
|
88
|
+
<ProfileAvatar className="size-10" profile={currentProfile} />
|
|
89
|
+
<View className="min-w-0 flex-1">
|
|
90
|
+
<View className="flex-row items-center gap-1">
|
|
91
|
+
<ThemedText className="font-medium" numberOfLines={1}>
|
|
92
|
+
{currentProfile.displayName ?? currentProfile.handle}
|
|
93
|
+
</ThemedText>
|
|
94
|
+
{canEditVisibility ? (
|
|
95
|
+
<ChevronDownIcon size={16} className="text-muted-foreground" />
|
|
96
|
+
) : null}
|
|
97
|
+
</View>
|
|
98
|
+
<ThemedText className="text-sm text-muted-foreground">
|
|
99
|
+
{audienceSummary(
|
|
100
|
+
postData.visibility,
|
|
101
|
+
t,
|
|
102
|
+
selectedGroupName,
|
|
103
|
+
postData.audience?.length
|
|
104
|
+
)}
|
|
105
|
+
</ThemedText>
|
|
106
|
+
</View>
|
|
107
|
+
</Pressable>
|
|
108
|
+
) : null}
|
|
109
|
+
|
|
110
|
+
<OpenpeepsMarkdownInput
|
|
111
|
+
autoFocus={autoFocus}
|
|
112
|
+
value={content}
|
|
113
|
+
onChange={(text) => form.setValue('data.content', text)}
|
|
114
|
+
placeholder={
|
|
115
|
+
isQuestion
|
|
116
|
+
? t('posts.form.poll.question')
|
|
117
|
+
: t('posts.form.note.placeholder')
|
|
118
|
+
}
|
|
119
|
+
/>
|
|
120
|
+
|
|
121
|
+
<ComposePreviewLinks content={content} />
|
|
122
|
+
|
|
123
|
+
{isNote && (postData.data.attachments?.length ?? 0) > 0 ? (
|
|
124
|
+
<ComposeAttachments
|
|
125
|
+
attachments={postData.data.attachments ?? []}
|
|
126
|
+
removeAttachment={(index) => {
|
|
127
|
+
const newPostData = {
|
|
128
|
+
...postData,
|
|
129
|
+
data: {
|
|
130
|
+
...postData.data,
|
|
131
|
+
attachments: postData.data.attachments?.filter(
|
|
132
|
+
(_, i) => i !== index
|
|
133
|
+
),
|
|
134
|
+
},
|
|
135
|
+
};
|
|
136
|
+
form.reset(newPostData);
|
|
137
|
+
setPostData(newPostData);
|
|
138
|
+
}}
|
|
139
|
+
updateAttachment={(index, attachment) => {
|
|
140
|
+
const newPostData = {
|
|
141
|
+
...postData,
|
|
142
|
+
data: {
|
|
143
|
+
...postData.data,
|
|
144
|
+
attachments: postData.data.attachments?.map((item, i) =>
|
|
145
|
+
i === index ? attachment : item
|
|
146
|
+
),
|
|
147
|
+
},
|
|
148
|
+
};
|
|
149
|
+
form.reset(newPostData);
|
|
150
|
+
setPostData(newPostData);
|
|
151
|
+
}}
|
|
152
|
+
/>
|
|
153
|
+
) : null}
|
|
154
|
+
|
|
155
|
+
{isQuestion ? (
|
|
156
|
+
<PollComposerFields form={form} postData={postData} />
|
|
157
|
+
) : null}
|
|
158
|
+
|
|
159
|
+
{showNotify ? (
|
|
160
|
+
<View className="flex-row items-center justify-between py-3">
|
|
161
|
+
<View className="flex-row items-center gap-2">
|
|
162
|
+
<MegaphoneIcon size={20} className="text-foreground" />
|
|
163
|
+
<ThemedText className="text-base">
|
|
164
|
+
{t('posts.form.notifyEveryone')}
|
|
165
|
+
</ThemedText>
|
|
166
|
+
</View>
|
|
167
|
+
<Switch
|
|
168
|
+
checked={notify}
|
|
169
|
+
onCheckedChange={onNotifyChange ?? (() => undefined)}
|
|
170
|
+
/>
|
|
171
|
+
</View>
|
|
172
|
+
) : null}
|
|
173
|
+
|
|
174
|
+
<VisibilitySheet
|
|
175
|
+
type="post"
|
|
176
|
+
ref={visibilityModalRef}
|
|
177
|
+
showDirect
|
|
178
|
+
audienceSetting={{
|
|
179
|
+
visibility: postData.visibility,
|
|
180
|
+
groupId: postData.groupId || undefined,
|
|
181
|
+
audience: postData.audience || [],
|
|
182
|
+
}}
|
|
183
|
+
onSubmit={handleAudienceSelect}
|
|
184
|
+
/>
|
|
185
|
+
</View>
|
|
186
|
+
);
|
|
187
|
+
};
|