@openpeepshq/rn-components 0.7.1 → 0.7.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
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openpeepshq/rn-components",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.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",
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React, { useMemo, useState } from 'react';
|
|
2
2
|
import type { ReactNode } from 'react';
|
|
3
|
-
import { Pressable, View } from 'react-native';
|
|
3
|
+
import { Linking, Pressable, View } from 'react-native';
|
|
4
4
|
import { useTranslation } from 'react-i18next';
|
|
5
5
|
import type {
|
|
6
6
|
MediaAttachmentData,
|
|
@@ -81,6 +81,12 @@ export const ResourceCard = ({
|
|
|
81
81
|
: null;
|
|
82
82
|
const thumbnail = visuals[0];
|
|
83
83
|
const thumbSrc = thumbnail ? (thumbnail.previewUrl ?? thumbnail.url) : null;
|
|
84
|
+
const downloadUrl =
|
|
85
|
+
resource && resource.resourceKind === 'file'
|
|
86
|
+
? (resource.attachments ?? []).find(
|
|
87
|
+
(att) => attachmentMediaKind(att) === 'file'
|
|
88
|
+
)?.url
|
|
89
|
+
: null;
|
|
84
90
|
|
|
85
91
|
const metaText = useMemo(() => {
|
|
86
92
|
if (!resource) return null;
|
|
@@ -167,13 +173,12 @@ export const ResourceCard = ({
|
|
|
167
173
|
</View>
|
|
168
174
|
<View className="flex-row items-center gap-2">
|
|
169
175
|
{resource.resourceKind !== 'link' && actionLabel ? (
|
|
170
|
-
actionLabel === 'Download' &&
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
</ThemedText>
|
|
176
|
+
actionLabel === 'Download' && downloadUrl ? (
|
|
177
|
+
<Pressable onPress={() => Linking.openURL(downloadUrl)}>
|
|
178
|
+
<ThemedText className="text-primary text-xs font-medium">
|
|
179
|
+
{actionLabel}
|
|
180
|
+
</ThemedText>
|
|
181
|
+
</Pressable>
|
|
177
182
|
) : (
|
|
178
183
|
<ThemedText className="text-muted-foreground text-xs">
|
|
179
184
|
{actionLabel}
|
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
import React, { useMemo, useState } from 'react';
|
|
2
2
|
import { Pressable, View, ScrollView } from 'react-native';
|
|
3
3
|
import { useTranslation } from 'react-i18next';
|
|
4
|
+
import { useNavigation } from '@react-navigation/native';
|
|
5
|
+
import { NativeStackNavigationProp } from '@react-navigation/native-stack';
|
|
4
6
|
import type { ResourceKind } from '@openpeepshq/common/types';
|
|
5
7
|
import { RESOURCE_KINDS } from '@openpeepshq/common/lib';
|
|
6
8
|
import type { CategoryNode } from '@openpeepshq/common/lib';
|
|
7
9
|
import { useResourceLibrary } from '@openpeepshq/react';
|
|
10
|
+
import { MainStackParamList } from '../navigation/types/index';
|
|
8
11
|
import { Input } from '../ui/input';
|
|
9
12
|
import { LoadingSpinner } from '../ui/loading-spinner';
|
|
10
13
|
import { ThemedText } from '../ui/themed-text';
|
|
@@ -94,6 +97,8 @@ const Tree = ({
|
|
|
94
97
|
|
|
95
98
|
export const ResourceLibrary = ({ groupId }: ResourceLibraryProps) => {
|
|
96
99
|
const { t } = useTranslation();
|
|
100
|
+
const navigation =
|
|
101
|
+
useNavigation<NativeStackNavigationProp<MainStackParamList>>();
|
|
97
102
|
const library = useResourceLibrary(groupId);
|
|
98
103
|
const [expanded, setExpanded] = useState<Set<string>>(new Set());
|
|
99
104
|
|
|
@@ -356,13 +361,24 @@ export const ResourceLibrary = ({ groupId }: ResourceLibraryProps) => {
|
|
|
356
361
|
) : library.view === 'list' ? (
|
|
357
362
|
<View className="divide-border">
|
|
358
363
|
{library.posts.map((post) => (
|
|
359
|
-
<
|
|
364
|
+
<Pressable
|
|
365
|
+
key={post.id}
|
|
366
|
+
onPress={() => navigation.navigate('Post', { id: post.id })}
|
|
367
|
+
className="border-b border-border"
|
|
368
|
+
>
|
|
369
|
+
<ResourceCard post={post} layout="list" />
|
|
370
|
+
</Pressable>
|
|
360
371
|
))}
|
|
361
372
|
</View>
|
|
362
373
|
) : (
|
|
363
374
|
<ScrollView horizontal={false} contentContainerClassName="gap-4 p-4">
|
|
364
375
|
{library.posts.map((post) => (
|
|
365
|
-
<
|
|
376
|
+
<Pressable
|
|
377
|
+
key={post.id}
|
|
378
|
+
onPress={() => navigation.navigate('Post', { id: post.id })}
|
|
379
|
+
>
|
|
380
|
+
<ResourceCard post={post} layout="card" />
|
|
381
|
+
</Pressable>
|
|
366
382
|
))}
|
|
367
383
|
</ScrollView>
|
|
368
384
|
)}
|