@openpeepshq/rn-components 0.6.1 → 0.6.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +7 -6
- package/src/components/conversations/ConversationMessageBubble.tsx +11 -1
- package/src/components/custom/navigation/side-menu.tsx +2 -1
- package/src/components/icons/index.ts +8 -0
- package/src/components/index.ts +1 -0
- package/src/components/navigation/helpers.ts +3 -0
- package/src/components/navigation/main-navigator.tsx +4 -0
- package/src/components/navigation/nativeRouter.tsx +11 -0
- package/src/components/navigation/tab-navigator.tsx +13 -3
- package/src/components/navigation/types/main.ts +6 -0
- package/src/components/navigation/types/tabs.ts +2 -0
- package/src/components/post/CompactReplyParent.tsx +22 -0
- package/src/components/post/FeedPostContent.tsx +4 -0
- package/src/components/post/NewResourceButton.tsx +57 -0
- package/src/components/post/PostDetail.tsx +3 -0
- package/src/components/post/index.ts +1 -0
- package/src/components/post/pieces/PostMenu.tsx +15 -9
- package/src/components/post/post-form/PostTypeSwitcher.tsx +19 -1
- package/src/components/post/post-form/ResourceForm.tsx +221 -0
- package/src/components/post/post-form/index.ts +1 -0
- package/src/components/post/types/index.ts +1 -0
- package/src/components/post/types/resource/FullResource.tsx +177 -0
- package/src/components/resources/ResourceCard.tsx +289 -0
- package/src/components/resources/ResourceLibrary.tsx +369 -0
- package/src/components/resources/index.ts +4 -0
- package/src/global.css +42 -42
- package/src/pages/groups/Show.tsx +19 -1
- package/src/pages/index.ts +3 -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/theme/defaults.ts +21 -105
- package/src/theme/utils.ts +15 -9
- package/tailwind.config.js +31 -29
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openpeepshq/rn-components",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.2",
|
|
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",
|
|
@@ -48,14 +48,15 @@
|
|
|
48
48
|
],
|
|
49
49
|
"repository": {
|
|
50
50
|
"type": "git",
|
|
51
|
-
"url": "
|
|
51
|
+
"url": "https://code.openpeeps.org/openpeeps/openpeeps",
|
|
52
|
+
"directory": "platform/rn-components"
|
|
52
53
|
},
|
|
53
54
|
"author": "OpenPeeps Inc. <dev@allpeep.com> (https://allpeep.com)",
|
|
54
55
|
"license": "MIT",
|
|
55
56
|
"bugs": {
|
|
56
|
-
"url": "https://
|
|
57
|
+
"url": "https://code.openpeeps.org/openpeeps/openpeeps/issues"
|
|
57
58
|
},
|
|
58
|
-
"homepage": "https://
|
|
59
|
+
"homepage": "https://code.openpeeps.org/openpeeps/openpeeps#readme",
|
|
59
60
|
"dependencies": {
|
|
60
61
|
"@gorhom/bottom-sheet": "^5.2.9",
|
|
61
62
|
"@hookform/resolvers": "^5.4.2",
|
|
@@ -140,8 +141,8 @@
|
|
|
140
141
|
"timezones-list": "^3.1.0",
|
|
141
142
|
"validator": "^13.15.23",
|
|
142
143
|
"zustand": "^5.0.3",
|
|
143
|
-
"@openpeepshq/
|
|
144
|
-
"@openpeepshq/
|
|
144
|
+
"@openpeepshq/common": "^0.3.1",
|
|
145
|
+
"@openpeepshq/react": "^0.6.1"
|
|
145
146
|
},
|
|
146
147
|
"devDependencies": {
|
|
147
148
|
"@babel/core": "^7.26.7",
|
|
@@ -2,8 +2,10 @@ import React from 'react';
|
|
|
2
2
|
import { View } from 'react-native';
|
|
3
3
|
import type { PublicPost } from '@openpeepshq/common/types';
|
|
4
4
|
import { useCurrentProfile } from '@openpeepshq/react';
|
|
5
|
+
import { useOpenPeepsTheme } from '../../theme/OpenPeepsThemeProvider';
|
|
5
6
|
import { FeedPostContent } from '../post/FeedPostContent';
|
|
6
7
|
import { UnreadPostIndicator } from '../post/pieces/UnreadPostIndicator';
|
|
8
|
+
import { hexWithOpacity } from '../../theme/utils';
|
|
7
9
|
|
|
8
10
|
export interface ConversationMessageBubbleProps {
|
|
9
11
|
message: PublicPost;
|
|
@@ -15,8 +17,15 @@ export const ConversationMessageBubble = ({
|
|
|
15
17
|
unread = false,
|
|
16
18
|
}: ConversationMessageBubbleProps) => {
|
|
17
19
|
const me = useCurrentProfile();
|
|
20
|
+
const theme = useOpenPeepsTheme();
|
|
18
21
|
const mine = message.profile.id === me?.id;
|
|
19
22
|
|
|
23
|
+
// NativeWind v4 can't apply `/N` opacity to CSS-variable colors (e.g.
|
|
24
|
+
// `bg-primary/10`), so we use an inline rgba style for own-message bubbles.
|
|
25
|
+
const bubbleStyle = mine
|
|
26
|
+
? { backgroundColor: hexWithOpacity(theme.colors.primary, 0.1) }
|
|
27
|
+
: undefined;
|
|
28
|
+
|
|
20
29
|
return (
|
|
21
30
|
<View
|
|
22
31
|
className={`mt-4 w-full flex-row items-center gap-2 ${
|
|
@@ -25,8 +34,9 @@ export const ConversationMessageBubble = ({
|
|
|
25
34
|
>
|
|
26
35
|
<View
|
|
27
36
|
className={`w-[80%] rounded-t-xl p-3 ${
|
|
28
|
-
mine ? 'rounded-bl-xl bg-
|
|
37
|
+
mine ? 'rounded-bl-xl bg-surface-2' : 'rounded-br-xl bg-surface-2'
|
|
29
38
|
}`}
|
|
39
|
+
style={bubbleStyle}
|
|
30
40
|
>
|
|
31
41
|
<FeedPostContent post={message} />
|
|
32
42
|
</View>
|
|
@@ -19,6 +19,7 @@ import {
|
|
|
19
19
|
SettingsIcon,
|
|
20
20
|
UsersIcon,
|
|
21
21
|
XIcon,
|
|
22
|
+
LibraryIcon,
|
|
22
23
|
} from '../../icons/index';
|
|
23
24
|
import { ThemedText } from '../../ui/themed-text';
|
|
24
25
|
import { useWindowSize } from '../../../hooks/helper';
|
|
@@ -43,8 +44,8 @@ const menuIcons: Record<string, React.ComponentType<LucideProps>> = {
|
|
|
43
44
|
members: BookUserIcon,
|
|
44
45
|
bookmarks: BookmarkIcon,
|
|
45
46
|
settings: SettingsIcon,
|
|
47
|
+
resources: LibraryIcon,
|
|
46
48
|
};
|
|
47
|
-
|
|
48
49
|
interface SideMenuProps {
|
|
49
50
|
handleNavigation: ({
|
|
50
51
|
target,
|
|
@@ -11,6 +11,7 @@ import {
|
|
|
11
11
|
ChevronsUpDown,
|
|
12
12
|
EyeOff,
|
|
13
13
|
Eye,
|
|
14
|
+
ImageOff,
|
|
14
15
|
Home,
|
|
15
16
|
Newspaper,
|
|
16
17
|
PhoneCall,
|
|
@@ -116,6 +117,7 @@ import {
|
|
|
116
117
|
FileSpreadsheet,
|
|
117
118
|
FileChartPie,
|
|
118
119
|
ScrollText,
|
|
120
|
+
Library,
|
|
119
121
|
Bookmark,
|
|
120
122
|
BookmarkPlus,
|
|
121
123
|
BookmarkMinus,
|
|
@@ -136,6 +138,8 @@ import {
|
|
|
136
138
|
SendHorizontal,
|
|
137
139
|
SmilePlus,
|
|
138
140
|
LayoutGrid,
|
|
141
|
+
LayoutList,
|
|
142
|
+
ExternalLink,
|
|
139
143
|
PinOff,
|
|
140
144
|
} from 'lucide-react-native';
|
|
141
145
|
|
|
@@ -152,6 +156,7 @@ export const ChevronUpIcon = iconWithClassName(ChevronUp);
|
|
|
152
156
|
export const ChevronsUpDownIcon = iconWithClassName(ChevronsUpDown);
|
|
153
157
|
export const EyeOffIcon = iconWithClassName(EyeOff);
|
|
154
158
|
export const EyeOnIcon = iconWithClassName(Eye);
|
|
159
|
+
export const ImageOffIcon = iconWithClassName(ImageOff);
|
|
155
160
|
export const HomeIcon = iconWithClassName(Home);
|
|
156
161
|
export const NewspaperIcon = iconWithClassName(Newspaper);
|
|
157
162
|
export const PhoneCallIcon = iconWithClassName(PhoneCall);
|
|
@@ -258,6 +263,7 @@ export const FileSpreadsheetIcon = iconWithClassName(FileSpreadsheet);
|
|
|
258
263
|
export const FileChartPieIcon = iconWithClassName(FileChartPie);
|
|
259
264
|
export const GlobeIcon = iconWithClassName(Globe);
|
|
260
265
|
export const ScrollTextIcon = iconWithClassName(ScrollText);
|
|
266
|
+
export const LibraryIcon = iconWithClassName(Library);
|
|
261
267
|
export const BookmarkIcon = iconWithClassName(Bookmark);
|
|
262
268
|
export const BookmarkMinusIcon = iconWithClassName(BookmarkMinus);
|
|
263
269
|
export const BookmarkPlusIcon = iconWithClassName(BookmarkPlus);
|
|
@@ -277,5 +283,7 @@ export const WifiOffIcon = iconWithClassName(WifiOff);
|
|
|
277
283
|
export const VolumeXIcon = iconWithClassName(VolumeX);
|
|
278
284
|
export const SendHorizontalIcon = iconWithClassName(SendHorizontal);
|
|
279
285
|
export const LayoutGridIcon = iconWithClassName(LayoutGrid);
|
|
286
|
+
export const LayoutListIcon = iconWithClassName(LayoutList);
|
|
287
|
+
export const ExternalLinkIcon = iconWithClassName(ExternalLink);
|
|
280
288
|
export const PinOffIcon = iconWithClassName(PinOff);
|
|
281
289
|
export const SmilePlusIcon = iconWithClassName(SmilePlus);
|
package/src/components/index.ts
CHANGED
|
@@ -38,6 +38,8 @@ import {
|
|
|
38
38
|
EditGroupRoles,
|
|
39
39
|
NewArticle,
|
|
40
40
|
EditArticle,
|
|
41
|
+
NewResource,
|
|
42
|
+
EditResource,
|
|
41
43
|
EventsMy,
|
|
42
44
|
About,
|
|
43
45
|
CodeOfConduct,
|
|
@@ -156,6 +158,8 @@ export const MainNavigator = () => {
|
|
|
156
158
|
<Stack.Screen name="EditGroupRoles" component={EditGroupRoles} />
|
|
157
159
|
<Stack.Screen name="NewArticle" component={NewArticle} />
|
|
158
160
|
<Stack.Screen name="EditArticle" component={EditArticle} />
|
|
161
|
+
<Stack.Screen name="NewResource" component={NewResource} />
|
|
162
|
+
<Stack.Screen name="EditResource" component={EditResource} />
|
|
159
163
|
<Stack.Screen name="MyEvents" component={EventsMy} />
|
|
160
164
|
<Stack.Screen name="About" component={About} />
|
|
161
165
|
<Stack.Screen name="CodeOfConduct" component={CodeOfConduct} />
|
|
@@ -145,6 +145,17 @@ export const navigateToTarget = (target: NavTarget) => {
|
|
|
145
145
|
go('Main', { screen: 'TabNavigator', params: { screen: 'Articles' } });
|
|
146
146
|
}
|
|
147
147
|
break;
|
|
148
|
+
case 'resources':
|
|
149
|
+
if (target.view === 'new') go('Main', { screen: 'NewResource' });
|
|
150
|
+
else if (target.resourceId) {
|
|
151
|
+
go('Main', {
|
|
152
|
+
screen: 'EditResource',
|
|
153
|
+
params: { id: target.resourceId },
|
|
154
|
+
});
|
|
155
|
+
} else {
|
|
156
|
+
go('Main', { screen: 'TabNavigator', params: { screen: 'Resources' } });
|
|
157
|
+
}
|
|
158
|
+
break;
|
|
148
159
|
case 'about':
|
|
149
160
|
go('Main', { screen: 'About' });
|
|
150
161
|
break;
|
|
@@ -18,6 +18,7 @@ import {
|
|
|
18
18
|
Explore,
|
|
19
19
|
FeedsBookmarks,
|
|
20
20
|
ArticlesIndex,
|
|
21
|
+
ResourcesIndex,
|
|
21
22
|
} from '../../pages';
|
|
22
23
|
import {
|
|
23
24
|
HomeIcon,
|
|
@@ -27,6 +28,7 @@ import {
|
|
|
27
28
|
UsersIcon,
|
|
28
29
|
ScrollTextIcon,
|
|
29
30
|
BellIcon,
|
|
31
|
+
LibraryIcon,
|
|
30
32
|
} from '../icons';
|
|
31
33
|
import { cn } from '../../lib/utils';
|
|
32
34
|
import { useWindowSize } from '../../hooks';
|
|
@@ -65,6 +67,8 @@ const TabBarIcon = ({
|
|
|
65
67
|
return <BellIcon className={iconClass} size={iconSize} />;
|
|
66
68
|
case TAB_ROUTES.ARTICLES:
|
|
67
69
|
return <ScrollTextIcon className={iconClass} size={iconSize} />;
|
|
70
|
+
case TAB_ROUTES.RESOURCES:
|
|
71
|
+
return <LibraryIcon className={iconClass} size={iconSize} />;
|
|
68
72
|
default:
|
|
69
73
|
return null;
|
|
70
74
|
}
|
|
@@ -87,9 +91,6 @@ export const TabNavigator = () => {
|
|
|
87
91
|
const unreadGroupPosts = Object.values(
|
|
88
92
|
unseenCounts.data?.groups ?? {}
|
|
89
93
|
).reduce((sum, count) => sum + count, 0);
|
|
90
|
-
const unreadConversationThreads = Object.keys(
|
|
91
|
-
unseenCounts.data?.direct ?? {}
|
|
92
|
-
).length;
|
|
93
94
|
const unreadNotifications = notificationStats.data?.unseen ?? 0;
|
|
94
95
|
|
|
95
96
|
const display = isMediumScreenOrLarger ? 'none' : 'flex';
|
|
@@ -174,6 +175,15 @@ export const TabNavigator = () => {
|
|
|
174
175
|
},
|
|
175
176
|
}}
|
|
176
177
|
/>
|
|
178
|
+
<Tab.Screen
|
|
179
|
+
name={TAB_ROUTES.RESOURCES}
|
|
180
|
+
component={ResourcesIndex}
|
|
181
|
+
options={{
|
|
182
|
+
tabBarItemStyle: {
|
|
183
|
+
display: 'none',
|
|
184
|
+
},
|
|
185
|
+
}}
|
|
186
|
+
/>
|
|
177
187
|
<Tab.Screen
|
|
178
188
|
name={TAB_ROUTES.DIRECTORY}
|
|
179
189
|
component={Members}
|
|
@@ -87,6 +87,10 @@ export type MainStackParamList = {
|
|
|
87
87
|
EditArticle: {
|
|
88
88
|
id: string;
|
|
89
89
|
};
|
|
90
|
+
NewResource: undefined;
|
|
91
|
+
EditResource: {
|
|
92
|
+
id: string;
|
|
93
|
+
};
|
|
90
94
|
MyEvents: undefined;
|
|
91
95
|
About: undefined;
|
|
92
96
|
CodeOfConduct: undefined;
|
|
@@ -137,6 +141,8 @@ export const MAIN_ROUTES = {
|
|
|
137
141
|
EDIT_GROUP_ROLES: 'EditGroupRoles',
|
|
138
142
|
NEW_ARTICLE: 'NewArticle',
|
|
139
143
|
EDIT_ARTICLE: 'EditArticle',
|
|
144
|
+
NEW_RESOURCE: 'NewResource',
|
|
145
|
+
EDIT_RESOURCE: 'EditResource',
|
|
140
146
|
MY_EVENTS: 'MyEvents',
|
|
141
147
|
ABOUT: 'About',
|
|
142
148
|
CODE_OF_CONDUCT: 'CodeOfConduct',
|
|
@@ -16,6 +16,7 @@ export const TAB_ROUTES = {
|
|
|
16
16
|
HASHTAG_POSTS: 'HashtagPosts',
|
|
17
17
|
EXPLORE: 'Explore',
|
|
18
18
|
ARTICLES: 'Articles',
|
|
19
|
+
RESOURCES: 'Resources',
|
|
19
20
|
BOOKMARKS: 'Bookmarks',
|
|
20
21
|
} as const;
|
|
21
22
|
|
|
@@ -33,6 +34,7 @@ export type TabStackParamList = {
|
|
|
33
34
|
[TAB_ROUTES.MESSAGES]: undefined;
|
|
34
35
|
[TAB_ROUTES.EVENTS]: undefined;
|
|
35
36
|
[TAB_ROUTES.ARTICLES]: undefined;
|
|
37
|
+
[TAB_ROUTES.RESOURCES]: undefined;
|
|
36
38
|
[TAB_ROUTES.DIRECTORY]: undefined;
|
|
37
39
|
[TAB_ROUTES.SETTINGS]: undefined;
|
|
38
40
|
[TAB_ROUTES.GROUPS]: undefined;
|
|
@@ -103,6 +103,18 @@ const compactThumb = (post: CompactPost) => {
|
|
|
103
103
|
if (!article.image) return null;
|
|
104
104
|
return <CompactThumb src={article.image} />;
|
|
105
105
|
}
|
|
106
|
+
case 'resource': {
|
|
107
|
+
const attachments = attachmentsOf(post);
|
|
108
|
+
const visual = visualAttachment(attachments);
|
|
109
|
+
if (!visual) return null;
|
|
110
|
+
return (
|
|
111
|
+
<CompactThumb
|
|
112
|
+
src={visual.previewUrl ?? visual.url}
|
|
113
|
+
video={isVideo(visual)}
|
|
114
|
+
extra={Math.max(0, attachments.length - 1)}
|
|
115
|
+
/>
|
|
116
|
+
);
|
|
117
|
+
}
|
|
106
118
|
default:
|
|
107
119
|
return null;
|
|
108
120
|
}
|
|
@@ -199,6 +211,16 @@ const CompactTypeBody = ({ post }: { post: CompactPost }) => {
|
|
|
199
211
|
</ThemedText>
|
|
200
212
|
);
|
|
201
213
|
}
|
|
214
|
+
case 'resource': {
|
|
215
|
+
const title =
|
|
216
|
+
post.data?.type === 'resource' ? post.data.title.trim() : '';
|
|
217
|
+
if (!title) return null;
|
|
218
|
+
return (
|
|
219
|
+
<ThemedText className="text-sm font-medium" numberOfLines={2}>
|
|
220
|
+
{title}
|
|
221
|
+
</ThemedText>
|
|
222
|
+
);
|
|
223
|
+
}
|
|
202
224
|
default:
|
|
203
225
|
return null;
|
|
204
226
|
}
|
|
@@ -4,6 +4,7 @@ import { FeedNote } from './types/Note';
|
|
|
4
4
|
import { FeedPoll } from './types/Poll';
|
|
5
5
|
import { FeedEvent } from './types/Event';
|
|
6
6
|
import { FeedArticle } from './types/Article';
|
|
7
|
+
import { ResourceCard } from '../resources/ResourceCard';
|
|
7
8
|
import { View } from 'react-native';
|
|
8
9
|
import { ThemedText } from '../ui/themed-text';
|
|
9
10
|
import { useTranslation } from 'react-i18next';
|
|
@@ -44,5 +45,8 @@ export const FeedPostContent = ({ post }: FeedPostContentProps) => {
|
|
|
44
45
|
if (post.type === 'article') {
|
|
45
46
|
return <FeedArticle {...{ post }} />;
|
|
46
47
|
}
|
|
48
|
+
if (post.type === 'resource') {
|
|
49
|
+
return <ResourceCard post={post} />;
|
|
50
|
+
}
|
|
47
51
|
return null;
|
|
48
52
|
};
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { useMemo } from 'react';
|
|
2
|
+
import { useTranslation } from 'react-i18next';
|
|
3
|
+
import { useNavigation } from '@react-navigation/native';
|
|
4
|
+
import { NativeStackNavigationProp } from '@react-navigation/native-stack';
|
|
5
|
+
import {
|
|
6
|
+
canCreatePost,
|
|
7
|
+
type GroupWithMeta,
|
|
8
|
+
type ProfileWithMeta,
|
|
9
|
+
type VisibilityType,
|
|
10
|
+
} from '@openpeepshq/common';
|
|
11
|
+
import { getNewPostStores, useAuthData } from '@openpeepshq/react';
|
|
12
|
+
import { useSetPlusButtonActions } from '../layout';
|
|
13
|
+
import { MainStackParamList } from '../navigation/types';
|
|
14
|
+
|
|
15
|
+
export interface NewResourceButtonProps {
|
|
16
|
+
visibility: VisibilityType;
|
|
17
|
+
currentProfile?: ProfileWithMeta;
|
|
18
|
+
group?: GroupWithMeta;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/** Registers the RootLayout plus button for creating a resource. */
|
|
22
|
+
export const NewResourceButton = ({
|
|
23
|
+
visibility,
|
|
24
|
+
currentProfile,
|
|
25
|
+
group,
|
|
26
|
+
}: NewResourceButtonProps) => {
|
|
27
|
+
const { t } = useTranslation();
|
|
28
|
+
const authData = useAuthData();
|
|
29
|
+
const navigation =
|
|
30
|
+
useNavigation<NativeStackNavigationProp<MainStackParamList>>();
|
|
31
|
+
|
|
32
|
+
const profile = currentProfile ?? authData.profile;
|
|
33
|
+
const canPost =
|
|
34
|
+
!!profile && canCreatePost(authData, 'resource', visibility, group);
|
|
35
|
+
|
|
36
|
+
const plusActions = useMemo(
|
|
37
|
+
() =>
|
|
38
|
+
canPost
|
|
39
|
+
? {
|
|
40
|
+
title: t('resources.new', { defaultValue: 'New resource' }),
|
|
41
|
+
action: () => {
|
|
42
|
+
const stores = getNewPostStores();
|
|
43
|
+
stores.resource = {
|
|
44
|
+
...stores.resource,
|
|
45
|
+
visibility,
|
|
46
|
+
groupId: group?.id,
|
|
47
|
+
};
|
|
48
|
+
navigation.navigate('NewResource');
|
|
49
|
+
},
|
|
50
|
+
}
|
|
51
|
+
: undefined,
|
|
52
|
+
[canPost, group?.id, navigation, t, visibility]
|
|
53
|
+
);
|
|
54
|
+
|
|
55
|
+
useSetPlusButtonActions(plusActions);
|
|
56
|
+
return null;
|
|
57
|
+
};
|
|
@@ -7,6 +7,7 @@ import { FullNote } from './types/note/FullNote';
|
|
|
7
7
|
import { FullArticle } from './types/article/FullArticle';
|
|
8
8
|
import { FullPoll } from './types/poll/FullPoll';
|
|
9
9
|
import { FullEvent } from './types/event/FullEvent';
|
|
10
|
+
import { FullResource } from './types/resource/FullResource';
|
|
10
11
|
|
|
11
12
|
export interface PostDetailProps {
|
|
12
13
|
postId: string;
|
|
@@ -41,6 +42,8 @@ export const PostDetail = ({ postId, occurrence }: PostDetailProps) => {
|
|
|
41
42
|
switch (post.type) {
|
|
42
43
|
case 'article':
|
|
43
44
|
return <FullArticle post={post} />;
|
|
45
|
+
case 'resource':
|
|
46
|
+
return <FullResource post={post} />;
|
|
44
47
|
case 'event':
|
|
45
48
|
return <FullEvent post={post} occurrence={occurrence} />;
|
|
46
49
|
case 'question':
|
|
@@ -10,6 +10,7 @@ export * from './FullPostLayout';
|
|
|
10
10
|
export * from './helpers';
|
|
11
11
|
export * from './Markdown';
|
|
12
12
|
export * from './NewEventButton';
|
|
13
|
+
export * from './NewResourceButton';
|
|
13
14
|
export * from './NewNoteButton';
|
|
14
15
|
export * from './pieces';
|
|
15
16
|
export * from './PinnedPost';
|
|
@@ -14,12 +14,12 @@ import {
|
|
|
14
14
|
} from '../../icons/index';
|
|
15
15
|
import { PopupMenu, PopupMenuButton, PopupSeparator } from '../../ui';
|
|
16
16
|
import { useOpenpeeps } from '@openpeepshq/react';
|
|
17
|
-
import {
|
|
18
|
-
checkGroupCapabilities,
|
|
19
|
-
checkPostCapabilities,
|
|
20
|
-
} from '@openpeepshq/common';
|
|
17
|
+
import { checkGroupCapabilities } from '@openpeepshq/common';
|
|
21
18
|
import { checkRoleCapabilities } from '@openpeepshq/common/lib';
|
|
22
19
|
import type { PublicPost } from '@openpeepshq/common/types';
|
|
20
|
+
import { useNavigation } from '@react-navigation/native';
|
|
21
|
+
import { NativeStackNavigationProp } from '@react-navigation/native-stack';
|
|
22
|
+
import { MainStackParamList } from '../../navigation/types';
|
|
23
23
|
import { useEditPostModal } from '../post-form/EditPostModalContext';
|
|
24
24
|
import { useTranslation } from 'react-i18next';
|
|
25
25
|
import { BottomSheetModal } from '@gorhom/bottom-sheet';
|
|
@@ -27,8 +27,6 @@ import { DeletePostModal } from './modals/DeletePostModal';
|
|
|
27
27
|
import { ReportProfileOrPostModal } from '../../profile/ReportProfileOrPostModal';
|
|
28
28
|
import { RepostModal } from './modals/RepostModal';
|
|
29
29
|
import { ReactionsModal } from './modals/ReactionsModal';
|
|
30
|
-
import { BASE_URL } from '../../../lib/constants';
|
|
31
|
-
import { truncateText } from '../../../lib/utils';
|
|
32
30
|
import Toast from 'react-native-toast-message';
|
|
33
31
|
|
|
34
32
|
export interface PostMenuProps {
|
|
@@ -38,11 +36,13 @@ export interface PostMenuProps {
|
|
|
38
36
|
|
|
39
37
|
export const PostMenu = ({ post, deleteCallback }: PostMenuProps) => {
|
|
40
38
|
const { t } = useTranslation();
|
|
41
|
-
const { openpeepsApi
|
|
39
|
+
const { openpeepsApi } = useOpenpeeps();
|
|
42
40
|
const { data: currentProfile, refetch: refetchCurrentProfile } =
|
|
43
41
|
openpeepsApi.useCurrentProfile();
|
|
44
42
|
const deleteMessageModalRef = useRef<BottomSheetModal>(null);
|
|
45
43
|
const { openEditPost } = useEditPostModal();
|
|
44
|
+
const navigation =
|
|
45
|
+
useNavigation<NativeStackNavigationProp<MainStackParamList>>();
|
|
46
46
|
const reportProfileModalRef = useRef<BottomSheetModal>(null);
|
|
47
47
|
const reportPostModalRef = useRef<BottomSheetModal>(null);
|
|
48
48
|
|
|
@@ -253,7 +253,7 @@ export const PostMenu = ({ post, deleteCallback }: PostMenuProps) => {
|
|
|
253
253
|
useEffect(() => {
|
|
254
254
|
setIsFollowing(isCurrentProfileFollowing || false);
|
|
255
255
|
refetchBookmarkedIds();
|
|
256
|
-
}, [currentProfile, post, refetchBookmarkedIds]);
|
|
256
|
+
}, [currentProfile, isCurrentProfileFollowing, post, refetchBookmarkedIds]);
|
|
257
257
|
|
|
258
258
|
return (
|
|
259
259
|
<View key={post.id}>
|
|
@@ -347,7 +347,13 @@ export const PostMenu = ({ post, deleteCallback }: PostMenuProps) => {
|
|
|
347
347
|
title={t('common.actions.edit', { defaultValue: 'Edit' })}
|
|
348
348
|
text={t('common.actions.edit', { defaultValue: 'Edit' })}
|
|
349
349
|
icon={PencilIcon}
|
|
350
|
-
action={() =>
|
|
350
|
+
action={() => {
|
|
351
|
+
if (post.data?.type === 'resource') {
|
|
352
|
+
navigation.navigate('EditResource', { id: post.id });
|
|
353
|
+
return;
|
|
354
|
+
}
|
|
355
|
+
openEditPost(post);
|
|
356
|
+
}}
|
|
351
357
|
/>
|
|
352
358
|
</>
|
|
353
359
|
) : null}
|
|
@@ -8,6 +8,7 @@ import { NativeStackNavigationProp } from '@react-navigation/native-stack';
|
|
|
8
8
|
import {
|
|
9
9
|
CalendarDaysIcon,
|
|
10
10
|
ChartColumnBigIcon,
|
|
11
|
+
LibraryIcon,
|
|
11
12
|
NotebookIcon,
|
|
12
13
|
ScrollTextIcon,
|
|
13
14
|
} from '../../icons/index';
|
|
@@ -39,7 +40,7 @@ export const PostTypeSwitcher = ({
|
|
|
39
40
|
const me = useCurrentProfile();
|
|
40
41
|
const isOwner = Boolean(me?.roles?.some((role) => role.key === 'owner'));
|
|
41
42
|
|
|
42
|
-
const goto = (route: 'NewArticle' | 'NewEvent') => {
|
|
43
|
+
const goto = (route: 'NewArticle' | 'NewEvent' | 'NewResource') => {
|
|
43
44
|
const stores = getNewPostStores();
|
|
44
45
|
if (route === 'NewArticle') {
|
|
45
46
|
stores.article = {
|
|
@@ -48,6 +49,13 @@ export const PostTypeSwitcher = ({
|
|
|
48
49
|
visibility: visibility ?? stores.article.visibility,
|
|
49
50
|
groupId,
|
|
50
51
|
};
|
|
52
|
+
} else if (route === 'NewResource') {
|
|
53
|
+
stores.resource = {
|
|
54
|
+
...stores.resource,
|
|
55
|
+
type: 'resource',
|
|
56
|
+
visibility: visibility ?? stores.resource.visibility,
|
|
57
|
+
groupId,
|
|
58
|
+
};
|
|
51
59
|
} else {
|
|
52
60
|
stores.event = {
|
|
53
61
|
...stores.event,
|
|
@@ -102,6 +110,16 @@ export const PostTypeSwitcher = ({
|
|
|
102
110
|
<ScrollTextIcon className="text-foreground" size={20} />
|
|
103
111
|
</Button>
|
|
104
112
|
) : null}
|
|
113
|
+
{type !== 'resource' ? (
|
|
114
|
+
<Button
|
|
115
|
+
size="icon"
|
|
116
|
+
variant="ghost"
|
|
117
|
+
accessibilityLabel={t('posts.switcher.resource')}
|
|
118
|
+
onPress={() => goto('NewResource')}
|
|
119
|
+
>
|
|
120
|
+
<LibraryIcon className="text-foreground" size={20} />
|
|
121
|
+
</Button>
|
|
122
|
+
) : null}
|
|
105
123
|
</View>
|
|
106
124
|
);
|
|
107
125
|
};
|