@openpeepshq/rn-components 0.3.13 → 0.5.0
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/package.json +2 -2
- package/src/components/configuration/ConfigMenuButton.tsx +6 -2
- package/src/components/groups/GroupAvatar.tsx +41 -12
- package/src/components/navigation/nativeRouter.tsx +30 -0
- package/src/components/navigation/tab-navigator.tsx +11 -8
- package/src/components/notifications/NotificationWrapper.tsx +2 -2
- package/src/components/notifications/NotificationsList.tsx +15 -4
- package/src/components/post/FeedPost.tsx +4 -1
- package/src/components/post/NewEventButton.tsx +4 -0
- package/src/components/post/NewNoteButton.tsx +2 -0
- package/src/components/post/pieces/PostActions.tsx +2 -0
- package/src/components/post/pieces/PostMenu.tsx +315 -340
- package/src/components/post/pieces/ShareMenu.tsx +68 -67
- package/src/components/post/pieces/UnreadPostIndicator.tsx +15 -2
- package/src/components/post/types/Article.tsx +2 -2
- package/src/components/post/types/Note.tsx +2 -2
- package/src/components/post/types/Poll.tsx +4 -2
- package/src/components/post/types/article/CardArticle.tsx +1 -1
- package/src/components/post/types/event/CardEvent.tsx +1 -1
- package/src/components/post/types/event/FullEvent.tsx +1 -1
- package/src/components/post/types/event/ProfileEventRelationship.tsx +1 -1
- package/src/components/profile/Avatar.tsx +24 -8
- package/src/components/profile/FollowUnfollowButton.tsx +4 -2
- package/src/components/profile/ProfileCard.tsx +48 -18
- package/src/components/ui/badge.tsx +36 -0
- package/src/components/ui/index.ts +6 -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/lib/utils.ts +11 -23
- package/src/pages/Members.tsx +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openpeepshq/rn-components",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"description": "React Native community screens and shared UI (extracted from the Black Ambition app) for the OpenPeeps stack.",
|
|
5
5
|
"source": "./src/index.ts",
|
|
6
6
|
"main": "./src/index.ts",
|
|
@@ -141,7 +141,7 @@
|
|
|
141
141
|
"validator": "^13.15.23",
|
|
142
142
|
"zustand": "^5.0.3",
|
|
143
143
|
"@openpeepshq/common": "^0.2.0",
|
|
144
|
-
"@openpeepshq/react": "^0.
|
|
144
|
+
"@openpeepshq/react": "^0.5.0"
|
|
145
145
|
},
|
|
146
146
|
"devDependencies": {
|
|
147
147
|
"@babel/core": "^7.26.7",
|
|
@@ -6,7 +6,10 @@ import { ChevronRightIcon } from '../icons/index';
|
|
|
6
6
|
|
|
7
7
|
export interface ConfigMenuButtonProps {
|
|
8
8
|
translationPrefix: string;
|
|
9
|
-
|
|
9
|
+
/** URL path (web). On RN, use onPress instead — URL navigation is not supported. */
|
|
10
|
+
action?: string;
|
|
11
|
+
/** Click handler. */
|
|
12
|
+
onPress?: () => void;
|
|
10
13
|
titleFallback?: string;
|
|
11
14
|
descriptionFallback?: string;
|
|
12
15
|
}
|
|
@@ -19,9 +22,10 @@ export const ConfigMenuButton = ({
|
|
|
19
22
|
descriptionFallback,
|
|
20
23
|
}: ConfigMenuButtonProps) => {
|
|
21
24
|
const { t } = useTranslation();
|
|
25
|
+
const handlePress = onPress ?? (() => {});
|
|
22
26
|
return (
|
|
23
27
|
<Pressable
|
|
24
|
-
onPress={
|
|
28
|
+
onPress={handlePress}
|
|
25
29
|
className="py-2 mb-2 flex-row justify-between items-center gap-x-4"
|
|
26
30
|
>
|
|
27
31
|
<View className="flex-1">
|
|
@@ -1,8 +1,15 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { View, Text } from 'react-native';
|
|
3
|
+
import { Group, getGroupAvatar } from '@openpeepshq/common';
|
|
4
|
+
import {
|
|
5
|
+
useOpenpeeps,
|
|
6
|
+
getInitials,
|
|
7
|
+
hueFromHandle,
|
|
8
|
+
initialsBackground,
|
|
9
|
+
} from '@openpeepshq/react';
|
|
10
|
+
import { useOpenPeepsTheme } from '../../theme/OpenPeepsThemeProvider';
|
|
3
11
|
import { Avatar, AvatarImage } from '../ui/avatar';
|
|
4
12
|
import { cn } from '../../lib/utils';
|
|
5
|
-
import { useOpenpeeps } from '@openpeepshq/react';
|
|
6
13
|
|
|
7
14
|
export const GroupAvatar = ({
|
|
8
15
|
group,
|
|
@@ -12,17 +19,22 @@ export const GroupAvatar = ({
|
|
|
12
19
|
className?: string;
|
|
13
20
|
}) => {
|
|
14
21
|
const { openpeepsApi } = useOpenpeeps();
|
|
22
|
+
const { isDark } = useOpenPeepsTheme();
|
|
15
23
|
const { data: server } = openpeepsApi.useServerInfo();
|
|
16
24
|
|
|
17
25
|
const isSmall = className?.includes('size-8');
|
|
18
26
|
const sizeClass = isSmall ? 'h-8 w-8' : 'h-16 w-16';
|
|
19
27
|
const roundedClass = 'rounded-full';
|
|
20
28
|
|
|
21
|
-
const
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
29
|
+
const avatarUri =
|
|
30
|
+
server && group
|
|
31
|
+
? getGroupAvatar(group, server.communityConfig)
|
|
32
|
+
: group?.avatar;
|
|
33
|
+
|
|
34
|
+
const hue = hueFromHandle(group?.handle ?? '');
|
|
35
|
+
const backgroundColor = avatarUri
|
|
36
|
+
? undefined
|
|
37
|
+
: initialsBackground(hue, isDark);
|
|
26
38
|
|
|
27
39
|
return (
|
|
28
40
|
<Avatar
|
|
@@ -34,11 +46,28 @@ export const GroupAvatar = ({
|
|
|
34
46
|
className
|
|
35
47
|
)}
|
|
36
48
|
>
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
49
|
+
{avatarUri ? (
|
|
50
|
+
<AvatarImage
|
|
51
|
+
source={{ uri: avatarUri }}
|
|
52
|
+
className={cn('h-full w-full', roundedClass)}
|
|
53
|
+
resizeMode="cover"
|
|
54
|
+
/>
|
|
55
|
+
) : (
|
|
56
|
+
<View
|
|
57
|
+
className={cn(
|
|
58
|
+
'flex h-full w-full items-center justify-center',
|
|
59
|
+
roundedClass
|
|
60
|
+
)}
|
|
61
|
+
style={{ backgroundColor }}
|
|
62
|
+
>
|
|
63
|
+
<Text
|
|
64
|
+
className="text-foreground font-medium"
|
|
65
|
+
style={{ fontSize: isSmall ? 14 : 24 }}
|
|
66
|
+
>
|
|
67
|
+
{getInitials(group?.displayName, group?.handle)}
|
|
68
|
+
</Text>
|
|
69
|
+
</View>
|
|
70
|
+
)}
|
|
42
71
|
</Avatar>
|
|
43
72
|
);
|
|
44
73
|
};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { useMemo } from 'react';
|
|
2
|
+
import { Linking } from 'react-native';
|
|
2
3
|
import {
|
|
3
4
|
CommonActions,
|
|
4
5
|
createNavigationContainerRef,
|
|
@@ -188,6 +189,35 @@ export const navigateToTarget = (target: NavTarget) => {
|
|
|
188
189
|
go('Auth', { screen: 'Login' });
|
|
189
190
|
}
|
|
190
191
|
break;
|
|
192
|
+
case 'admin':
|
|
193
|
+
// RN has no admin screens — fall back to settings tab.
|
|
194
|
+
go('Main', { screen: 'TabNavigator', params: { screen: 'Settings' } });
|
|
195
|
+
break;
|
|
196
|
+
case 'docs':
|
|
197
|
+
// Docs are web-only; open in the system browser.
|
|
198
|
+
if (target.path) {
|
|
199
|
+
Linking.openURL(
|
|
200
|
+
target.path.startsWith('/') ? `${target.path}` : target.path
|
|
201
|
+
);
|
|
202
|
+
}
|
|
203
|
+
break;
|
|
204
|
+
case 'paymentSuccess':
|
|
205
|
+
go('Main', { screen: 'TabNavigator', params: { screen: 'Onboarding' } });
|
|
206
|
+
break;
|
|
207
|
+
case 'external':
|
|
208
|
+
Linking.openURL(target.href);
|
|
209
|
+
break;
|
|
210
|
+
case 'path':
|
|
211
|
+
// Try to open as a URL; if it's a local path, fall back to home.
|
|
212
|
+
if (
|
|
213
|
+
target.path.startsWith('http://') ||
|
|
214
|
+
target.path.startsWith('https://')
|
|
215
|
+
) {
|
|
216
|
+
Linking.openURL(target.path);
|
|
217
|
+
} else {
|
|
218
|
+
go('Main', { screen: 'TabNavigator', params: { screen: 'Home' } });
|
|
219
|
+
}
|
|
220
|
+
break;
|
|
191
221
|
default:
|
|
192
222
|
break;
|
|
193
223
|
}
|
|
@@ -26,6 +26,7 @@ import {
|
|
|
26
26
|
MessageSquareTextIcon,
|
|
27
27
|
UsersIcon,
|
|
28
28
|
ScrollTextIcon,
|
|
29
|
+
BellIcon,
|
|
29
30
|
} from '../icons';
|
|
30
31
|
import { cn } from '../../lib/utils';
|
|
31
32
|
import { useWindowSize } from '../../hooks';
|
|
@@ -61,7 +62,7 @@ const TabBarIcon = ({
|
|
|
61
62
|
case TAB_ROUTES.MESSAGES:
|
|
62
63
|
return <MessageSquareTextIcon className={iconClass} size={iconSize} />;
|
|
63
64
|
case TAB_ROUTES.NOTIFICATIONS:
|
|
64
|
-
return <
|
|
65
|
+
return <BellIcon className={iconClass} size={iconSize} />;
|
|
65
66
|
case TAB_ROUTES.ARTICLES:
|
|
66
67
|
return <ScrollTextIcon className={iconClass} size={iconSize} />;
|
|
67
68
|
default:
|
|
@@ -81,6 +82,7 @@ export const TabNavigator = () => {
|
|
|
81
82
|
showAdmin: false,
|
|
82
83
|
}).some((item) => item.id === 'jams');
|
|
83
84
|
const unseenCounts = openpeepsApi.useUnseenPostCounts();
|
|
85
|
+
const notificationStats = openpeepsApi.useCurrentProfileNotificationStats();
|
|
84
86
|
|
|
85
87
|
const unreadGroupPosts = Object.values(
|
|
86
88
|
unseenCounts.data?.groups ?? {}
|
|
@@ -88,6 +90,7 @@ export const TabNavigator = () => {
|
|
|
88
90
|
const unreadConversationThreads = Object.keys(
|
|
89
91
|
unseenCounts.data?.direct ?? {}
|
|
90
92
|
).length;
|
|
93
|
+
const unreadNotifications = notificationStats.data?.unseen ?? 0;
|
|
91
94
|
|
|
92
95
|
const display = isMediumScreenOrLarger ? 'none' : 'flex';
|
|
93
96
|
return (
|
|
@@ -137,10 +140,9 @@ export const TabNavigator = () => {
|
|
|
137
140
|
name={TAB_ROUTES.MESSAGES}
|
|
138
141
|
component={ConversationsIndex}
|
|
139
142
|
options={{
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
: undefined,
|
|
143
|
+
tabBarItemStyle: {
|
|
144
|
+
display: 'none',
|
|
145
|
+
},
|
|
144
146
|
}}
|
|
145
147
|
/>
|
|
146
148
|
{jamsEnabled && (
|
|
@@ -204,9 +206,10 @@ export const TabNavigator = () => {
|
|
|
204
206
|
name={TAB_ROUTES.NOTIFICATIONS}
|
|
205
207
|
component={Notifications}
|
|
206
208
|
options={{
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
209
|
+
tabBarBadge:
|
|
210
|
+
unreadNotifications > 0
|
|
211
|
+
? formatBadgeCount(unreadNotifications)
|
|
212
|
+
: undefined,
|
|
210
213
|
}}
|
|
211
214
|
/>
|
|
212
215
|
<Tab.Screen
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { View } from 'react-native';
|
|
2
2
|
import React from 'react';
|
|
3
|
-
import type { Group,
|
|
3
|
+
import type { Group, PublicProfile } from '@openpeepshq/common/types';
|
|
4
4
|
import { DotIcon, UsersIcon, UserIcon } from '../icons/index';
|
|
5
5
|
import { ThemedView } from '../ui/themed-view';
|
|
6
6
|
import { ProfileAvatar } from '../profile/Avatar';
|
|
7
7
|
import { GroupAvatar } from '../groups/GroupAvatar';
|
|
8
8
|
|
|
9
9
|
interface NotificationWrapperProps {
|
|
10
|
-
profile:
|
|
10
|
+
profile: PublicProfile;
|
|
11
11
|
seen?: boolean;
|
|
12
12
|
group?: Group | null;
|
|
13
13
|
showProfile?: boolean;
|
|
@@ -2,22 +2,33 @@ import { ScrollView, RefreshControl, ActivityIndicator } from 'react-native';
|
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import type { PublicNotification } from '@openpeepshq/common';
|
|
4
4
|
import { useFocusEffect } from '@react-navigation/native';
|
|
5
|
+
import { useOpenpeeps } from '@openpeepshq/react';
|
|
5
6
|
import { handleScroll } from '../../lib/utils';
|
|
6
7
|
import { EmptyStateContainer } from '../custom/common/empty-state-container';
|
|
7
8
|
import { NotificationItem } from './NotificationItem';
|
|
8
9
|
import { InfiniteQueryResult } from '../../types';
|
|
9
10
|
|
|
10
|
-
interface
|
|
11
|
-
query
|
|
11
|
+
export interface NotificationsListProps {
|
|
12
|
+
/** Supply your own query to control fetching externally. When omitted, the
|
|
13
|
+
* component fetches `useCurrentProfileNotifications` internally. */
|
|
14
|
+
query?: InfiniteQueryResult<PublicNotification>;
|
|
15
|
+
pageSize?: number;
|
|
12
16
|
isNotificationFeed?: boolean;
|
|
13
17
|
onRefresh?: () => Promise<unknown>;
|
|
14
18
|
}
|
|
15
19
|
|
|
16
20
|
export const NotificationsList = ({
|
|
17
|
-
query,
|
|
21
|
+
query: externalQuery,
|
|
22
|
+
pageSize = 15,
|
|
18
23
|
isNotificationFeed = true,
|
|
19
24
|
onRefresh,
|
|
20
|
-
}:
|
|
25
|
+
}: NotificationsListProps) => {
|
|
26
|
+
const { openpeepsApi } = useOpenpeeps();
|
|
27
|
+
const internalQuery = openpeepsApi.useCurrentProfileNotifications({
|
|
28
|
+
limit: pageSize,
|
|
29
|
+
});
|
|
30
|
+
const query = externalQuery ?? internalQuery;
|
|
31
|
+
|
|
21
32
|
const [refreshing, setRefreshing] = React.useState(false);
|
|
22
33
|
const refetchRef = React.useRef(query.refetch);
|
|
23
34
|
refetchRef.current = query.refetch;
|
|
@@ -3,6 +3,7 @@ import { useFeedPostPresentation } from '@openpeepshq/react';
|
|
|
3
3
|
import { useNavigation } from '@react-navigation/native';
|
|
4
4
|
import { NativeStackNavigationProp } from '@react-navigation/native-stack';
|
|
5
5
|
import { Pressable } from 'react-native';
|
|
6
|
+
import { cn } from '../../lib/utils';
|
|
6
7
|
import { MainStackParamList } from '../navigation/types/index';
|
|
7
8
|
import {
|
|
8
9
|
PostInfoHeader,
|
|
@@ -29,6 +30,7 @@ export interface FeedPostProps {
|
|
|
29
30
|
hideReply?: boolean;
|
|
30
31
|
previewMode?: boolean;
|
|
31
32
|
showMenu?: boolean;
|
|
33
|
+
className?: string;
|
|
32
34
|
}
|
|
33
35
|
|
|
34
36
|
export const FeedPost = ({
|
|
@@ -41,6 +43,7 @@ export const FeedPost = ({
|
|
|
41
43
|
hideReply,
|
|
42
44
|
previewMode = false,
|
|
43
45
|
showMenu = true,
|
|
46
|
+
className,
|
|
44
47
|
}: FeedPostProps) => {
|
|
45
48
|
const navigation =
|
|
46
49
|
useNavigation<NativeStackNavigationProp<MainStackParamList>>();
|
|
@@ -77,7 +80,7 @@ export const FeedPost = ({
|
|
|
77
80
|
<Pressable disabled={previewMode} onPress={handlePostPress}>
|
|
78
81
|
<ThemedView
|
|
79
82
|
ref={postViewRef}
|
|
80
|
-
className=
|
|
83
|
+
className={cn('relative border-b border-border p-4', className)}
|
|
81
84
|
>
|
|
82
85
|
<UnreadPostIndicator show={isUnread} />
|
|
83
86
|
{hasReactionHeader && (
|
|
@@ -16,6 +16,10 @@ export interface NewEventButtonProps {
|
|
|
16
16
|
visibility: VisibilityType;
|
|
17
17
|
currentProfile?: ProfileWithMeta;
|
|
18
18
|
group?: GroupWithMeta;
|
|
19
|
+
/** When false, only registers the floating plus button (no inline button). */
|
|
20
|
+
showButton?: boolean;
|
|
21
|
+
/** Optional custom navigation callback (replaces default screen navigation). */
|
|
22
|
+
onNavigate?: () => void;
|
|
19
23
|
}
|
|
20
24
|
|
|
21
25
|
/** Registers the RootLayout plus button for creating an event. */
|
|
@@ -14,6 +14,8 @@ export interface NewNoteButtonProps {
|
|
|
14
14
|
visibility: VisibilityType;
|
|
15
15
|
currentProfile?: ProfileWithMeta;
|
|
16
16
|
group?: GroupWithMeta;
|
|
17
|
+
/** When false, only registers the floating plus button (no inline feed button). */
|
|
18
|
+
inline?: boolean;
|
|
17
19
|
}
|
|
18
20
|
|
|
19
21
|
/** Registers the RootLayout plus button for creating a note. */
|
|
@@ -10,11 +10,13 @@ import { useFeedPostActions } from '@openpeepshq/react';
|
|
|
10
10
|
interface PostActionsProps {
|
|
11
11
|
post: PublicPost;
|
|
12
12
|
previewMode?: boolean;
|
|
13
|
+
compact?: boolean;
|
|
13
14
|
}
|
|
14
15
|
|
|
15
16
|
export const PostActions = ({
|
|
16
17
|
post,
|
|
17
18
|
previewMode = false,
|
|
19
|
+
compact = false,
|
|
18
20
|
}: PostActionsProps) => {
|
|
19
21
|
const { t } = useTranslation();
|
|
20
22
|
const {
|