@openpeepshq/rn-components 0.6.6 → 0.6.8
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 +3 -3
- package/src/components/custom/common/cached-video-player.tsx +5 -1
- package/src/components/custom/navigation/side-menu.tsx +23 -9
- package/src/components/jams/JamFooter.tsx +5 -5
- package/src/components/jams/JamRoomIndicators.tsx +13 -2
- package/src/components/layout/HeaderMobile.tsx +24 -9
- package/src/components/post/pieces/VideoPlayer.tsx +7 -1
- package/src/components/post/types/event/CardEvent.tsx +57 -32
- package/src/components/post/types/event/FullEvent.tsx +221 -32
- package/src/pages/settings/Theme.tsx +14 -10
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openpeepshq/rn-components",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.8",
|
|
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",
|
|
@@ -142,8 +142,8 @@
|
|
|
142
142
|
"timezones-list": "^3.1.0",
|
|
143
143
|
"validator": "^13.15.23",
|
|
144
144
|
"zustand": "^5.0.3",
|
|
145
|
-
"@openpeepshq/
|
|
146
|
-
"@openpeepshq/
|
|
145
|
+
"@openpeepshq/react": "^0.6.3",
|
|
146
|
+
"@openpeepshq/common": "^0.3.2"
|
|
147
147
|
},
|
|
148
148
|
"devDependencies": {
|
|
149
149
|
"@babel/core": "^7.26.7",
|
|
@@ -37,6 +37,7 @@ import { Button } from '../../ui/button';
|
|
|
37
37
|
interface CachedVideoPlayerProps {
|
|
38
38
|
url: string;
|
|
39
39
|
title?: string;
|
|
40
|
+
autoPlay?: boolean;
|
|
40
41
|
}
|
|
41
42
|
|
|
42
43
|
const HLS_POLL_INTERVAL_MS = 5_000;
|
|
@@ -45,6 +46,7 @@ type LocalStreamState = 'loading' | 'processing' | 'ready' | 'error';
|
|
|
45
46
|
|
|
46
47
|
export const CachedVideoPlayer: React.FC<CachedVideoPlayerProps> = ({
|
|
47
48
|
url,
|
|
49
|
+
autoPlay = true,
|
|
48
50
|
}) => {
|
|
49
51
|
const navigation = useNavigation();
|
|
50
52
|
const { t: tr } = useTranslation();
|
|
@@ -227,7 +229,9 @@ export const CachedVideoPlayer: React.FC<CachedVideoPlayerProps> = ({
|
|
|
227
229
|
const onLoad = (data: OnLoadData) => {
|
|
228
230
|
setDuration(data.duration || 0);
|
|
229
231
|
setHasEnded(false);
|
|
230
|
-
|
|
232
|
+
if (autoPlay) {
|
|
233
|
+
setIsPaused(false);
|
|
234
|
+
}
|
|
231
235
|
};
|
|
232
236
|
|
|
233
237
|
const onProgress = (data: OnProgressData) => {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { ScrollView } from 'react-native';
|
|
2
|
+
import { ScrollView, useColorScheme } from 'react-native';
|
|
3
3
|
import { Separator } from '../../ui/separator';
|
|
4
4
|
import { Image, TouchableOpacity, View } from 'react-native';
|
|
5
5
|
import { Button } from '../../ui/button';
|
|
@@ -23,8 +23,8 @@ import {
|
|
|
23
23
|
} from '../../icons/index';
|
|
24
24
|
import { ThemedText } from '../../ui/themed-text';
|
|
25
25
|
import { useWindowSize } from '../../../hooks/helper';
|
|
26
|
-
import {
|
|
27
|
-
import { formatBadgeCount } from '@openpeepshq/common';
|
|
26
|
+
import { toAbsoluteMediaUrl } from '../../../lib/media-url';
|
|
27
|
+
import { formatBadgeCount, getTheme } from '@openpeepshq/common';
|
|
28
28
|
import { buildMainNavItems, useOpenpeeps } from '@openpeepshq/react';
|
|
29
29
|
import { useTranslation } from 'react-i18next';
|
|
30
30
|
import { ProfileAvatar } from '../../profile/Avatar';
|
|
@@ -67,11 +67,23 @@ export const SideMenu = ({
|
|
|
67
67
|
}: SideMenuProps) => {
|
|
68
68
|
const { openpeepsApi, currentProfile } = useOpenpeeps();
|
|
69
69
|
const { isMediumScreenOrLarger } = useWindowSize();
|
|
70
|
-
const { logoSmall } = useAppImagesStore();
|
|
71
70
|
const logout = openpeepsApi.logoutAction();
|
|
72
71
|
const { data: serverInfo } = openpeepsApi.useServerInfo();
|
|
72
|
+
const { data: profileSettings } = openpeepsApi.useCurrentProfileSettings();
|
|
73
73
|
const unseenCounts = openpeepsApi.useUnseenPostCounts();
|
|
74
74
|
|
|
75
|
+
// Mirrors web SideBar: resolve the logo per active theme mode instead of
|
|
76
|
+
// the image store, which could hold relative URLs RN cannot load. The
|
|
77
|
+
// system scheme must come from RN: getTheme's default cannot read it.
|
|
78
|
+
const systemColorScheme = useColorScheme();
|
|
79
|
+
const systemScheme = systemColorScheme === 'dark' ? 'dark' : 'light';
|
|
80
|
+
const logoUri = serverInfo
|
|
81
|
+
? toAbsoluteMediaUrl(
|
|
82
|
+
getTheme(serverInfo.communityConfig, profileSettings, systemScheme)
|
|
83
|
+
.logoSmall
|
|
84
|
+
)
|
|
85
|
+
: undefined;
|
|
86
|
+
|
|
75
87
|
const unreadGroupPosts = Object.values(
|
|
76
88
|
unseenCounts.data?.groups ?? {}
|
|
77
89
|
).reduce((sum, count) => sum + count, 0);
|
|
@@ -100,11 +112,13 @@ export const SideMenu = ({
|
|
|
100
112
|
<View className="sm:w-56 md:w-80 bg-background flex-1">
|
|
101
113
|
<TouchableOpacity onPress={onProfilePress} className="mt-12 mb-6 px-4">
|
|
102
114
|
<View className="w-full flex-row items-center justify-between">
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
115
|
+
{logoUri ? (
|
|
116
|
+
<Image
|
|
117
|
+
source={{ uri: logoUri }}
|
|
118
|
+
className="-mt-2 h-12 w-48"
|
|
119
|
+
resizeMode="contain"
|
|
120
|
+
/>
|
|
121
|
+
) : null}
|
|
108
122
|
{!isMediumScreenOrLarger && (
|
|
109
123
|
<View className="md:hidden">
|
|
110
124
|
<Button onPress={close} variant={'outline'} size={'icon'}>
|
|
@@ -95,6 +95,7 @@ const MobileMenu = ({
|
|
|
95
95
|
isModerator,
|
|
96
96
|
recordingEnabled,
|
|
97
97
|
isRecording,
|
|
98
|
+
recordingLabel,
|
|
98
99
|
busy,
|
|
99
100
|
onClose,
|
|
100
101
|
onOpenChat,
|
|
@@ -106,6 +107,7 @@ const MobileMenu = ({
|
|
|
106
107
|
isModerator: boolean;
|
|
107
108
|
recordingEnabled: boolean;
|
|
108
109
|
isRecording: boolean;
|
|
110
|
+
recordingLabel: string;
|
|
109
111
|
busy: boolean;
|
|
110
112
|
onClose: () => void;
|
|
111
113
|
onOpenChat: () => void;
|
|
@@ -145,11 +147,7 @@ const MobileMenu = ({
|
|
|
145
147
|
{isModerator && recordingEnabled ? (
|
|
146
148
|
<MenuEntry
|
|
147
149
|
icon={isRecording ? CircleStopIcon : DiscIcon}
|
|
148
|
-
label={
|
|
149
|
-
isRecording
|
|
150
|
-
? t('jams.recording.stopTitle')
|
|
151
|
-
: t('events.recordingInProgress')
|
|
152
|
-
}
|
|
150
|
+
label={recordingLabel}
|
|
153
151
|
disabled={busy}
|
|
154
152
|
onPress={run(onToggleRecording)}
|
|
155
153
|
/>
|
|
@@ -176,6 +174,7 @@ export const JamFooter = ({
|
|
|
176
174
|
const {
|
|
177
175
|
isModerator,
|
|
178
176
|
isRecording,
|
|
177
|
+
recordingLabel,
|
|
179
178
|
recordingEnabled,
|
|
180
179
|
busy,
|
|
181
180
|
sendReactionEmoji,
|
|
@@ -201,6 +200,7 @@ export const JamFooter = ({
|
|
|
201
200
|
isModerator={isModerator}
|
|
202
201
|
recordingEnabled={recordingEnabled}
|
|
203
202
|
isRecording={isRecording}
|
|
203
|
+
recordingLabel={recordingLabel}
|
|
204
204
|
busy={busy}
|
|
205
205
|
onClose={() => setMobileMenuOpen(false)}
|
|
206
206
|
onOpenChat={onToggleChat}
|
|
@@ -3,22 +3,32 @@ import { Pressable, View } from 'react-native';
|
|
|
3
3
|
import { useLocalParticipant } from '@livekit/react-native';
|
|
4
4
|
import { ConnectionQuality } from 'livekit-client';
|
|
5
5
|
import { useTranslation } from 'react-i18next';
|
|
6
|
-
import {
|
|
6
|
+
import {
|
|
7
|
+
useJamRecordingElapsed,
|
|
8
|
+
useJamRecordingState,
|
|
9
|
+
} from '@openpeepshq/react';
|
|
7
10
|
import { CircleIcon, XIcon } from '../icons/index';
|
|
8
11
|
import { ThemedText } from '../ui/themed-text';
|
|
12
|
+
import { useOpenPeepsTheme } from '../../theme/OpenPeepsThemeProvider';
|
|
13
|
+
import { hexWithOpacity } from '../../theme/utils';
|
|
9
14
|
import { useConnectionQuality } from './useParticipantConnection';
|
|
10
15
|
|
|
11
16
|
/** Red "recording" pill shown to every participant while egress is active. */
|
|
12
17
|
export const JamRecordingIndicator = () => {
|
|
13
18
|
const { t } = useTranslation();
|
|
19
|
+
const { colors } = useOpenPeepsTheme();
|
|
14
20
|
const { isRecording } = useJamRecordingState();
|
|
21
|
+
const elapsed = useJamRecordingElapsed();
|
|
15
22
|
|
|
16
23
|
if (!isRecording) return null;
|
|
17
24
|
|
|
25
|
+
// NativeWind v4 can't apply `/N` opacity to CSS-variable colors (e.g.
|
|
26
|
+
// `bg-destructive/90`), so the pill background uses an inline rgba style.
|
|
18
27
|
return (
|
|
19
28
|
<View
|
|
20
29
|
pointerEvents="none"
|
|
21
|
-
|
|
30
|
+
style={{ backgroundColor: hexWithOpacity(colors.destructive, 0.9) }}
|
|
31
|
+
className="absolute left-4 top-4 z-50 flex-row items-center gap-2 rounded-full px-3 py-1"
|
|
22
32
|
>
|
|
23
33
|
<CircleIcon
|
|
24
34
|
size={12}
|
|
@@ -26,6 +36,7 @@ export const JamRecordingIndicator = () => {
|
|
|
26
36
|
/>
|
|
27
37
|
<ThemedText className="text-sm font-medium text-destructive-foreground">
|
|
28
38
|
{t('events.recordingInProgress')}
|
|
39
|
+
{elapsed ? ` ${elapsed}` : ''}
|
|
29
40
|
</ThemedText>
|
|
30
41
|
</View>
|
|
31
42
|
);
|
|
@@ -6,6 +6,7 @@ import {
|
|
|
6
6
|
StatusBar,
|
|
7
7
|
StyleSheet,
|
|
8
8
|
View,
|
|
9
|
+
useColorScheme,
|
|
9
10
|
} from 'react-native';
|
|
10
11
|
import { SafeAreaView } from 'react-native-safe-area-context';
|
|
11
12
|
import { useNavigation } from '@react-navigation/native';
|
|
@@ -14,7 +15,8 @@ import { useOpenpeeps } from '@openpeepshq/react';
|
|
|
14
15
|
import { useDrawer } from '../../contexts/drawer-context';
|
|
15
16
|
import { useWindowSize } from '../../hooks/index';
|
|
16
17
|
import { BASE_URL, isProduction } from '../../lib/constants';
|
|
17
|
-
import {
|
|
18
|
+
import { toAbsoluteMediaUrl } from '../../lib/media-url';
|
|
19
|
+
import { getTheme } from '@openpeepshq/common';
|
|
18
20
|
import { Avatar, AvatarFallback, AvatarImage } from '../ui/avatar';
|
|
19
21
|
import { Button } from '../ui/button';
|
|
20
22
|
import { ThemedText } from '../ui/themed-text';
|
|
@@ -24,10 +26,21 @@ import type { MainStackParamList } from '../navigation/types/index';
|
|
|
24
26
|
export const HeaderMobile = () => {
|
|
25
27
|
const { openDrawer } = useDrawer();
|
|
26
28
|
const { isMediumScreenOrLarger } = useWindowSize();
|
|
27
|
-
const { currentProfile } = useOpenpeeps();
|
|
29
|
+
const { openpeepsApi, currentProfile } = useOpenpeeps();
|
|
28
30
|
const navigation =
|
|
29
31
|
useNavigation<NativeStackNavigationProp<MainStackParamList>>();
|
|
30
|
-
const {
|
|
32
|
+
const { data: serverInfo } = openpeepsApi.useServerInfo();
|
|
33
|
+
const { data: profileSettings } = openpeepsApi.useCurrentProfileSettings();
|
|
34
|
+
|
|
35
|
+
// Mirrors web HeaderMobile: resolve branding per active theme mode. The
|
|
36
|
+
// system scheme must come from RN: getTheme's default cannot read it.
|
|
37
|
+
const systemColorScheme = useColorScheme();
|
|
38
|
+
const systemScheme = systemColorScheme === 'dark' ? 'dark' : 'light';
|
|
39
|
+
const resolvedTheme = serverInfo
|
|
40
|
+
? getTheme(serverInfo.communityConfig, profileSettings, systemScheme)
|
|
41
|
+
: undefined;
|
|
42
|
+
const logoUri = toAbsoluteMediaUrl(resolvedTheme?.logoSmall);
|
|
43
|
+
const backgroundUri = toAbsoluteMediaUrl(resolvedTheme?.background);
|
|
31
44
|
|
|
32
45
|
if (isMediumScreenOrLarger) {
|
|
33
46
|
return null;
|
|
@@ -36,7 +49,7 @@ export const HeaderMobile = () => {
|
|
|
36
49
|
return (
|
|
37
50
|
<ImageBackground
|
|
38
51
|
resizeMode="cover"
|
|
39
|
-
source={{ uri:
|
|
52
|
+
source={backgroundUri ? { uri: backgroundUri } : undefined}
|
|
40
53
|
style={styles.header}
|
|
41
54
|
className="px-4 pb-3"
|
|
42
55
|
>
|
|
@@ -65,11 +78,13 @@ export const HeaderMobile = () => {
|
|
|
65
78
|
)}
|
|
66
79
|
</Avatar>
|
|
67
80
|
</Button>
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
81
|
+
{logoUri ? (
|
|
82
|
+
<Image
|
|
83
|
+
source={{ uri: logoUri }}
|
|
84
|
+
resizeMode="contain"
|
|
85
|
+
className="h-[64px] w-[216px]"
|
|
86
|
+
/>
|
|
87
|
+
) : null}
|
|
73
88
|
<Button
|
|
74
89
|
variant="outline"
|
|
75
90
|
size="icon"
|
|
@@ -7,18 +7,24 @@ import { cn } from '../../../lib/utils';
|
|
|
7
7
|
export interface VideoPlayerProps {
|
|
8
8
|
attachment: MediaAttachmentData;
|
|
9
9
|
title?: string;
|
|
10
|
+
autoPlay?: boolean;
|
|
10
11
|
className?: string;
|
|
11
12
|
}
|
|
12
13
|
|
|
13
14
|
export const VideoPlayer = ({
|
|
14
15
|
attachment,
|
|
15
16
|
title,
|
|
17
|
+
autoPlay,
|
|
16
18
|
className,
|
|
17
19
|
}: VideoPlayerProps) => {
|
|
18
20
|
if (!attachment.url) return null;
|
|
19
21
|
return (
|
|
20
22
|
<View className={cn('w-full', className)}>
|
|
21
|
-
<CachedVideoPlayer
|
|
23
|
+
<CachedVideoPlayer
|
|
24
|
+
url={attachment.url}
|
|
25
|
+
title={title}
|
|
26
|
+
autoPlay={autoPlay}
|
|
27
|
+
/>
|
|
22
28
|
</View>
|
|
23
29
|
);
|
|
24
30
|
};
|
|
@@ -1,14 +1,18 @@
|
|
|
1
1
|
import { View, Image, TouchableOpacity, ActivityIndicator } from 'react-native';
|
|
2
|
-
import React
|
|
2
|
+
import React from 'react';
|
|
3
3
|
import { ThemedText } from '../../../ui/themed-text';
|
|
4
|
-
import { Event, PublicPost
|
|
4
|
+
import { Event, PublicPost } from '@openpeepshq/common';
|
|
5
5
|
import { truncateText } from '../../../../lib/utils';
|
|
6
|
-
import { formatEventRecurrence } from '@openpeepshq/common/lib';
|
|
7
|
-
import {
|
|
6
|
+
import { canModerateJam, formatEventRecurrence } from '@openpeepshq/common/lib';
|
|
7
|
+
import {
|
|
8
|
+
useOpenpeeps,
|
|
9
|
+
useCurrentProfile,
|
|
10
|
+
useServerInfo,
|
|
11
|
+
} from '@openpeepshq/react';
|
|
8
12
|
import { useNavigation } from '@react-navigation/native';
|
|
9
13
|
import { NativeStackNavigationProp } from '@react-navigation/native-stack';
|
|
10
14
|
import { MainStackParamList } from '../../../navigation/types/index';
|
|
11
|
-
import {
|
|
15
|
+
import { Button } from '../../../ui/button';
|
|
12
16
|
import { Timespan } from '../../../custom/date/index';
|
|
13
17
|
import { EventLocation } from '../../pieces/EventLocation';
|
|
14
18
|
import { ProfileEventRelationship } from './ProfileEventRelationship';
|
|
@@ -24,6 +28,8 @@ export interface CardEventProps {
|
|
|
24
28
|
export const CardEvent = ({ post, showEventDate = true }: CardEventProps) => {
|
|
25
29
|
const { openpeepsApi } = useOpenpeeps();
|
|
26
30
|
const { t } = useTranslation();
|
|
31
|
+
const me = useCurrentProfile();
|
|
32
|
+
const livekitEnabled = useServerInfo().jams.livekit.enabled;
|
|
27
33
|
|
|
28
34
|
const event = post.data as Event;
|
|
29
35
|
const jam = event.jam;
|
|
@@ -34,9 +40,7 @@ export const CardEvent = ({ post, showEventDate = true }: CardEventProps) => {
|
|
|
34
40
|
);
|
|
35
41
|
const navigation =
|
|
36
42
|
useNavigation<NativeStackNavigationProp<MainStackParamList>>();
|
|
37
|
-
const
|
|
38
|
-
return calculateEffectiveRsvps(post, occurrenceId) || [];
|
|
39
|
-
}, [post, occurrenceId]);
|
|
43
|
+
const attendeesLength = jamState?.participants.length ?? 0;
|
|
40
44
|
|
|
41
45
|
return (
|
|
42
46
|
<TouchableOpacity
|
|
@@ -81,32 +85,53 @@ export const CardEvent = ({ post, showEventDate = true }: CardEventProps) => {
|
|
|
81
85
|
<EventLocation post={post} truncate={true} />
|
|
82
86
|
<ProfileEventRelationship post={post} />
|
|
83
87
|
</View>
|
|
84
|
-
{jam && (
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
88
|
+
{jam && me && livekitEnabled ? (
|
|
89
|
+
isLoading ? (
|
|
90
|
+
<ActivityIndicator size="small" />
|
|
91
|
+
) : jamState?.active ? (
|
|
92
|
+
<View className="flex flex-row items-center gap-x-2 text-xs text-muted-foreground">
|
|
93
|
+
<View className="w-12">
|
|
94
|
+
<ParticipantsCard jamState={jamState} />
|
|
95
|
+
</View>
|
|
96
|
+
<ThemedText>
|
|
97
|
+
{attendeesLength}{' '}
|
|
98
|
+
{attendeesLength === 1
|
|
99
|
+
? t('events.jam.attendee', { defaultValue: 'attendee' })
|
|
100
|
+
: t('events.jam.attendees', {
|
|
101
|
+
defaultValue: 'attendees',
|
|
102
|
+
})}
|
|
103
|
+
</ThemedText>
|
|
104
|
+
<Button
|
|
105
|
+
variant="default"
|
|
106
|
+
size="sm"
|
|
107
|
+
onPress={() =>
|
|
108
|
+
navigation.navigate('JamSession', {
|
|
109
|
+
jamId: post.id,
|
|
110
|
+
occurrence: occurrenceId,
|
|
111
|
+
})
|
|
91
112
|
}
|
|
92
|
-
text-muted-foreground text-xs ${
|
|
93
|
-
(jamState?.participants?.length ?? 0) > 0 ? '-mt-4' : ''
|
|
94
|
-
}`}
|
|
95
113
|
>
|
|
96
|
-
<
|
|
97
|
-
{
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
114
|
+
<ThemedText numberOfLines={1}>
|
|
115
|
+
{t('jam.join.submit', { defaultValue: 'Join Jam' })}
|
|
116
|
+
</ThemedText>
|
|
117
|
+
</Button>
|
|
118
|
+
</View>
|
|
119
|
+
) : canModerateJam(me, post) ? (
|
|
120
|
+
<Button
|
|
121
|
+
className="mt-2 w-full"
|
|
122
|
+
onPress={() =>
|
|
123
|
+
navigation.navigate('JamSession', {
|
|
124
|
+
jamId: post.id,
|
|
125
|
+
occurrence: occurrenceId,
|
|
126
|
+
})
|
|
127
|
+
}
|
|
128
|
+
>
|
|
129
|
+
<ThemedText numberOfLines={1}>
|
|
130
|
+
{t('jam.start.submit', { defaultValue: 'Start Jam' })}
|
|
131
|
+
</ThemedText>
|
|
132
|
+
</Button>
|
|
133
|
+
) : null
|
|
134
|
+
) : null}
|
|
110
135
|
</View>
|
|
111
136
|
</TouchableOpacity>
|
|
112
137
|
);
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
import React, { useMemo, useRef } from 'react';
|
|
2
|
-
import { useOpenpeeps } from '@openpeepshq/react';
|
|
1
|
+
import React, { useMemo, useRef, useState } from 'react';
|
|
2
|
+
import { useOpenpeeps, useServerInfo } from '@openpeepshq/react';
|
|
3
3
|
import {
|
|
4
4
|
MoreVerticalIcon,
|
|
5
5
|
ShareIcon,
|
|
6
|
+
DownloadIcon,
|
|
7
|
+
Trash2Icon,
|
|
6
8
|
MapPinIcon,
|
|
7
9
|
LinkIcon,
|
|
8
10
|
PhoneCallIcon,
|
|
@@ -19,7 +21,8 @@ import {
|
|
|
19
21
|
DropdownMenuTrigger,
|
|
20
22
|
} from '../../../ui/dropdown-menu';
|
|
21
23
|
import { ThemedText } from '../../../ui/themed-text';
|
|
22
|
-
import { Image, View } from 'react-native';
|
|
24
|
+
import { Image, TouchableOpacity, View } from 'react-native';
|
|
25
|
+
|
|
23
26
|
import {
|
|
24
27
|
Event,
|
|
25
28
|
PublicPost,
|
|
@@ -76,6 +79,9 @@ import {
|
|
|
76
79
|
} from '../../index';
|
|
77
80
|
import { ReportProfileOrPostModal } from '../../../profile/index';
|
|
78
81
|
import { OpenpeepsMarkdown } from '../../../markdown/index';
|
|
82
|
+
import { downloadDocument } from '../../../../lib/downloadFile';
|
|
83
|
+
import { useControlledSheet } from '../../../../hooks/use-controlled-sheet';
|
|
84
|
+
import { BaseSheet, SheetFooter } from '../../../custom/modals/common';
|
|
79
85
|
export interface FullEventProps {
|
|
80
86
|
post: PublicPost;
|
|
81
87
|
occurrence?: string;
|
|
@@ -125,13 +131,15 @@ export const FullEvent: React.FC<FullEventProps> = ({ post, occurrence }) => {
|
|
|
125
131
|
navigation.navigate('SelectPrivateMessageMembers');
|
|
126
132
|
};
|
|
127
133
|
|
|
128
|
-
const
|
|
129
|
-
const livekitEnabled =
|
|
134
|
+
const serverInfo = useServerInfo();
|
|
135
|
+
const livekitEnabled = serverInfo.jams.livekit.enabled;
|
|
130
136
|
const myEvent = currentProfile?.id === post?.profile?.id;
|
|
131
137
|
const iAmModerator = canModerateJam(currentProfile, post);
|
|
132
138
|
const canExportAttendees = canViewJamAttendees(currentProfile, post);
|
|
133
139
|
const canViewRecordings = canAccessJamRecordings(currentProfile, post);
|
|
134
140
|
const jamAttendeesQuery = openpeepsApi.useJamAttendance(post.id);
|
|
141
|
+
const jamStateQuery = openpeepsApi.useJamState(post.id, occurrence);
|
|
142
|
+
const jamState = event.jam ? jamStateQuery.data : undefined;
|
|
135
143
|
const recordingsQuery = openpeepsApi.usePostRecordings(
|
|
136
144
|
post.id,
|
|
137
145
|
!!event.jam && canViewRecordings
|
|
@@ -347,19 +355,41 @@ export const FullEvent: React.FC<FullEventProps> = ({ post, occurrence }) => {
|
|
|
347
355
|
<EventRsvpButton post={post as PublicPost} recurrenceId={occurrence} />
|
|
348
356
|
{event.jam && (myEvent || iAmModerator) ? (
|
|
349
357
|
livekitEnabled ? (
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
358
|
+
jamState?.active ? (
|
|
359
|
+
<Button
|
|
360
|
+
className="mt-2 w-full"
|
|
361
|
+
onPress={() =>
|
|
362
|
+
navigation.navigate('JamSession', {
|
|
363
|
+
jamId: post.id,
|
|
364
|
+
occurrence: occurrence,
|
|
365
|
+
})
|
|
366
|
+
}
|
|
367
|
+
>
|
|
368
|
+
<ThemedText numberOfLines={1}>
|
|
369
|
+
{t('jam.join.submit', { defaultValue: 'Join Jam' })}
|
|
370
|
+
</ThemedText>
|
|
371
|
+
</Button>
|
|
372
|
+
) : (
|
|
373
|
+
<Button
|
|
374
|
+
className="mt-2 w-full"
|
|
375
|
+
onPress={() =>
|
|
376
|
+
navigation.navigate('JamSession', {
|
|
377
|
+
jamId: post.id,
|
|
378
|
+
occurrence: occurrence,
|
|
379
|
+
})
|
|
380
|
+
}
|
|
381
|
+
>
|
|
382
|
+
<ThemedText numberOfLines={1}>
|
|
383
|
+
{t('events.jam.start', { defaultValue: 'Start jam' })}
|
|
384
|
+
</ThemedText>
|
|
385
|
+
</Button>
|
|
386
|
+
)
|
|
360
387
|
) : (
|
|
361
388
|
<ThemedText className="mt-2 text-sm text-destructive">
|
|
362
|
-
{t('jams.unavailable.message'
|
|
389
|
+
{t('jams.unavailable.message', {
|
|
390
|
+
defaultValue:
|
|
391
|
+
'Jams are unavailable because LiveKit is not connected.',
|
|
392
|
+
})}
|
|
363
393
|
</ThemedText>
|
|
364
394
|
)
|
|
365
395
|
) : null}
|
|
@@ -489,22 +519,12 @@ export const FullEvent: React.FC<FullEventProps> = ({ post, occurrence }) => {
|
|
|
489
519
|
</ThemedText>
|
|
490
520
|
) : recordingsQuery.data?.length ? (
|
|
491
521
|
recordingsQuery.data.map((recording: JamRecording) => (
|
|
492
|
-
<
|
|
493
|
-
|
|
494
|
-
{
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
{recording.status === 'active'
|
|
499
|
-
? t('events.recordingInProgress', {
|
|
500
|
-
defaultValue: 'Recording in progress…',
|
|
501
|
-
})
|
|
502
|
-
: t('events.recordingProcessing', {
|
|
503
|
-
defaultValue: 'Processing recording…',
|
|
504
|
-
})}
|
|
505
|
-
</ThemedText>
|
|
506
|
-
)}
|
|
507
|
-
</View>
|
|
522
|
+
<JamRecordingItem
|
|
523
|
+
key={recording.id}
|
|
524
|
+
post={post}
|
|
525
|
+
recording={recording}
|
|
526
|
+
canManage={canViewRecordings}
|
|
527
|
+
/>
|
|
508
528
|
))
|
|
509
529
|
) : (
|
|
510
530
|
<ThemedText className="py-4 text-sm text-muted-foreground">
|
|
@@ -520,6 +540,175 @@ export const FullEvent: React.FC<FullEventProps> = ({ post, occurrence }) => {
|
|
|
520
540
|
);
|
|
521
541
|
};
|
|
522
542
|
|
|
543
|
+
const JamRecordingItem = ({
|
|
544
|
+
post,
|
|
545
|
+
recording,
|
|
546
|
+
canManage,
|
|
547
|
+
}: {
|
|
548
|
+
post: PublicPost;
|
|
549
|
+
recording: JamRecording;
|
|
550
|
+
canManage: boolean;
|
|
551
|
+
}) => {
|
|
552
|
+
const { t } = useTranslation();
|
|
553
|
+
const { openpeepsApi } = useOpenpeeps();
|
|
554
|
+
const [confirmOpen, setConfirmOpen] = useState(false);
|
|
555
|
+
const confirmSheetRef = useControlledSheet(confirmOpen);
|
|
556
|
+
|
|
557
|
+
const attachment = recording.attachment;
|
|
558
|
+
const publishReply = openpeepsApi.publishRecordingReplyAction({
|
|
559
|
+
id: post.id,
|
|
560
|
+
recordingId: recording.id,
|
|
561
|
+
});
|
|
562
|
+
const deleteRecording = openpeepsApi.deleteRecordingAction({
|
|
563
|
+
id: post.id,
|
|
564
|
+
recordingId: recording.id,
|
|
565
|
+
});
|
|
566
|
+
|
|
567
|
+
const handleDelete = async () => {
|
|
568
|
+
try {
|
|
569
|
+
await deleteRecording();
|
|
570
|
+
setConfirmOpen(false);
|
|
571
|
+
Toast.show({
|
|
572
|
+
type: 'success',
|
|
573
|
+
text1: t('events.deleteRecordingSuccess', {
|
|
574
|
+
defaultValue: 'Recording deleted',
|
|
575
|
+
}),
|
|
576
|
+
});
|
|
577
|
+
} catch {
|
|
578
|
+
Toast.show({
|
|
579
|
+
type: 'error',
|
|
580
|
+
text1: t('events.deleteRecordingError', {
|
|
581
|
+
defaultValue: 'Failed to delete recording',
|
|
582
|
+
}),
|
|
583
|
+
});
|
|
584
|
+
}
|
|
585
|
+
};
|
|
586
|
+
|
|
587
|
+
return (
|
|
588
|
+
<View className="flex-col gap-2 py-4">
|
|
589
|
+
<UpdatingDate date={recording.createdAt} />
|
|
590
|
+
{recording.status === 'completed' && attachment ? (
|
|
591
|
+
<>
|
|
592
|
+
<VideoPlayer
|
|
593
|
+
attachment={attachment}
|
|
594
|
+
autoPlay={false}
|
|
595
|
+
className="aspect-video w-full rounded-md"
|
|
596
|
+
/>
|
|
597
|
+
<TouchableOpacity
|
|
598
|
+
onPress={() => downloadDocument(attachment.url)}
|
|
599
|
+
className="self-start"
|
|
600
|
+
>
|
|
601
|
+
<View className="flex-row items-center gap-1">
|
|
602
|
+
<DownloadIcon size={16} className="text-foreground" />
|
|
603
|
+
<ThemedText className="text-sm text-primary underline">
|
|
604
|
+
{t('events.downloadRecording', {
|
|
605
|
+
defaultValue: 'Download recording',
|
|
606
|
+
})}
|
|
607
|
+
</ThemedText>
|
|
608
|
+
</View>
|
|
609
|
+
</TouchableOpacity>
|
|
610
|
+
</>
|
|
611
|
+
) : (
|
|
612
|
+
<ThemedText className="text-sm text-muted-foreground">
|
|
613
|
+
{recording.status === 'active'
|
|
614
|
+
? t('events.recordingInProgress', {
|
|
615
|
+
defaultValue: 'Recording in progress…',
|
|
616
|
+
})
|
|
617
|
+
: t('events.recordingProcessing', {
|
|
618
|
+
defaultValue: 'Processing recording…',
|
|
619
|
+
})}
|
|
620
|
+
</ThemedText>
|
|
621
|
+
)}
|
|
622
|
+
<View className="flex-row flex-wrap items-center gap-2">
|
|
623
|
+
{canManage && recording.status === 'completed' && attachment ? (
|
|
624
|
+
recording.replyPostId ? (
|
|
625
|
+
<ThemedText className="text-sm text-muted-foreground">
|
|
626
|
+
{t('events.recordingReplyPosted', {
|
|
627
|
+
defaultValue: 'Posted to discussion',
|
|
628
|
+
})}
|
|
629
|
+
</ThemedText>
|
|
630
|
+
) : (
|
|
631
|
+
<Button
|
|
632
|
+
variant="outline"
|
|
633
|
+
className="self-start"
|
|
634
|
+
onPress={async () => {
|
|
635
|
+
try {
|
|
636
|
+
await publishReply();
|
|
637
|
+
Toast.show({
|
|
638
|
+
type: 'success',
|
|
639
|
+
text1: t('events.postRecordingReplySuccess', {
|
|
640
|
+
defaultValue: 'Recording posted to discussion',
|
|
641
|
+
}),
|
|
642
|
+
});
|
|
643
|
+
} catch {
|
|
644
|
+
Toast.show({
|
|
645
|
+
type: 'error',
|
|
646
|
+
text1: t('events.postRecordingReplyError', {
|
|
647
|
+
defaultValue: 'Failed to post recording to discussion',
|
|
648
|
+
}),
|
|
649
|
+
});
|
|
650
|
+
}
|
|
651
|
+
}}
|
|
652
|
+
>
|
|
653
|
+
<ThemedText className="font-semibold">
|
|
654
|
+
{t('events.postRecordingReply', {
|
|
655
|
+
defaultValue: 'Post to discussion',
|
|
656
|
+
})}
|
|
657
|
+
</ThemedText>
|
|
658
|
+
</Button>
|
|
659
|
+
)
|
|
660
|
+
) : null}
|
|
661
|
+
{canManage &&
|
|
662
|
+
recording.status !== 'active' &&
|
|
663
|
+
recording.status !== 'requested' ? (
|
|
664
|
+
<>
|
|
665
|
+
<Button
|
|
666
|
+
variant="outline"
|
|
667
|
+
className="self-start"
|
|
668
|
+
onPress={() => setConfirmOpen(true)}
|
|
669
|
+
>
|
|
670
|
+
<View className="flex-row items-center gap-1">
|
|
671
|
+
<Trash2Icon size={16} className="text-foreground" />
|
|
672
|
+
<ThemedText className="font-semibold">
|
|
673
|
+
{t('events.deleteRecording', {
|
|
674
|
+
defaultValue: 'Delete recording',
|
|
675
|
+
})}
|
|
676
|
+
</ThemedText>
|
|
677
|
+
</View>
|
|
678
|
+
</Button>
|
|
679
|
+
<BaseSheet
|
|
680
|
+
ref={confirmSheetRef}
|
|
681
|
+
onDismiss={() => setConfirmOpen(false)}
|
|
682
|
+
>
|
|
683
|
+
<View className="flex-1 p-4">
|
|
684
|
+
<ThemedText className="mb-6 text-center text-xl font-semibold">
|
|
685
|
+
{t('events.deleteRecording', {
|
|
686
|
+
defaultValue: 'Delete recording',
|
|
687
|
+
})}
|
|
688
|
+
</ThemedText>
|
|
689
|
+
<ThemedText className="mb-6 text-center text-base text-muted-foreground">
|
|
690
|
+
{t('events.deleteRecordingConfirm', {
|
|
691
|
+
defaultValue: 'Delete this recording permanently?',
|
|
692
|
+
})}
|
|
693
|
+
</ThemedText>
|
|
694
|
+
<SheetFooter
|
|
695
|
+
onCancel={() => setConfirmOpen(false)}
|
|
696
|
+
cancelText={t('common.cancel')}
|
|
697
|
+
onConfirm={() => void handleDelete()}
|
|
698
|
+
confirmText={t('events.deleteRecording', {
|
|
699
|
+
defaultValue: 'Delete recording',
|
|
700
|
+
})}
|
|
701
|
+
confirmVariant="destructive"
|
|
702
|
+
/>
|
|
703
|
+
</View>
|
|
704
|
+
</BaseSheet>
|
|
705
|
+
</>
|
|
706
|
+
) : null}
|
|
707
|
+
</View>
|
|
708
|
+
</View>
|
|
709
|
+
);
|
|
710
|
+
};
|
|
711
|
+
|
|
523
712
|
export const FullEventActions: React.FC<{
|
|
524
713
|
post: PublicPost;
|
|
525
714
|
occurrence?: string;
|
|
@@ -6,12 +6,13 @@ import { ThemedText } from '../../components/ui/themed-text';
|
|
|
6
6
|
import { ThemedView } from '../../components/ui/themed-view';
|
|
7
7
|
import Toast from 'react-native-toast-message';
|
|
8
8
|
import { KeyboardAwareScrollView } from 'react-native-keyboard-aware-scroll-view';
|
|
9
|
-
import { Pressable } from 'react-native';
|
|
9
|
+
import { Pressable, useColorScheme } from 'react-native';
|
|
10
10
|
import { useTranslation } from 'react-i18next';
|
|
11
11
|
import { RadioGroup, RadioGroupItem } from '../../components/ui/radio-group';
|
|
12
12
|
import { getTheme, THEME_OPTIONS } from '@openpeepshq/common';
|
|
13
13
|
import { useOpenPeepsTheme } from '../../theme/OpenPeepsThemeProvider';
|
|
14
14
|
import { useAppImagesStore } from '../../stores/useAppImagesStore';
|
|
15
|
+
import { toAbsoluteMediaUrl } from '../../lib/media-url';
|
|
15
16
|
|
|
16
17
|
type ThemeSettingsProps = MainScreenProps<'ThemeSettings'>;
|
|
17
18
|
|
|
@@ -21,6 +22,8 @@ export const ThemeSettings: React.FC<ThemeSettingsProps> = ({}) => {
|
|
|
21
22
|
const { refresh } = useOpenPeepsTheme();
|
|
22
23
|
const { t } = useTranslation();
|
|
23
24
|
const { setBackground, setLogoSmall } = useAppImagesStore();
|
|
25
|
+
const systemColorScheme = useColorScheme();
|
|
26
|
+
const systemScheme = systemColorScheme === 'dark' ? 'dark' : 'light';
|
|
24
27
|
|
|
25
28
|
const handleSubmit = async () => {
|
|
26
29
|
if (!theme) {
|
|
@@ -38,15 +41,16 @@ export const ThemeSettings: React.FC<ThemeSettingsProps> = ({}) => {
|
|
|
38
41
|
text1: t('settings.theme.updateSuccess'),
|
|
39
42
|
});
|
|
40
43
|
await refresh();
|
|
41
|
-
const userTheme = getTheme(
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
44
|
+
const userTheme = getTheme(
|
|
45
|
+
serverInfo.communityConfig,
|
|
46
|
+
{
|
|
47
|
+
theme,
|
|
48
|
+
} as Parameters<typeof getTheme>[1],
|
|
49
|
+
systemScheme
|
|
50
|
+
);
|
|
51
|
+
// Absolute URIs only: RN Image cannot load path-relative URLs.
|
|
52
|
+
setBackground(toAbsoluteMediaUrl(userTheme.background) ?? null);
|
|
53
|
+
setLogoSmall(toAbsoluteMediaUrl(userTheme.logoSmall) ?? null);
|
|
50
54
|
} catch {
|
|
51
55
|
Toast.show({
|
|
52
56
|
type: 'error',
|