@openpeepshq/rn-components 0.3.9 → 0.3.12
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/conversations/ConversationMessageBubble.tsx +1 -1
- package/src/components/custom/common/index.ts +0 -1
- package/src/components/custom/index.ts +0 -1
- package/src/components/custom/navigation/side-menu.tsx +2 -2
- package/src/components/groups/GroupOptionsMenu.tsx +13 -5
- package/src/components/index.ts +1 -0
- package/src/components/jams/CreateNewJam.tsx +11 -10
- package/src/components/jams/JamActionsFooter.tsx +37 -51
- package/src/components/jams/JamCard.tsx +5 -5
- package/src/components/jams/JamLobby.tsx +2 -1
- package/src/components/layout/AuthLayout.tsx +120 -0
- package/src/components/layout/ContentHeader.tsx +62 -0
- package/src/components/layout/HeaderActionButton.tsx +23 -0
- package/src/components/layout/HeaderMobile.tsx +96 -0
- package/src/components/layout/PlusButton.tsx +26 -0
- package/src/components/layout/RootLayout.tsx +30 -0
- package/src/components/layout/index.ts +13 -0
- package/src/components/layout/pageChrome.tsx +75 -0
- package/src/components/navigation/auth-navigator.tsx +2 -2
- package/src/components/navigation/main-navigator.tsx +17 -1
- package/src/components/navigation/parent-back.ts +139 -0
- package/src/components/navigation/tab-navigator.tsx +2 -0
- package/src/components/notifications/types/JamStarted.tsx +8 -6
- package/src/components/notifications/types/Reply.tsx +7 -10
- package/src/components/post/NewEventButton.tsx +23 -16
- package/src/components/post/NewNoteButton.tsx +15 -13
- package/src/components/post/pieces/EventRsvpButton.tsx +22 -18
- package/src/components/post/pieces/ParticipantsCard.tsx +4 -20
- package/src/components/post/types/Article.tsx +3 -1
- package/src/components/post/types/event/CardEvent.tsx +1 -1
- package/src/components/post/types/event/FullEvent.tsx +156 -37
- package/src/components/profile/ProfileCard.tsx +9 -2
- package/src/components/profile/ProfileFromId.tsx +1 -1
- package/src/components/ui/button.tsx +1 -1
- package/src/pages/About.tsx +3 -5
- package/src/pages/CodeOfConduct.tsx +7 -7
- package/src/pages/Explore.tsx +87 -127
- package/src/pages/Members.tsx +31 -39
- package/src/pages/Notifications.tsx +6 -13
- package/src/pages/PostDetail.tsx +22 -16
- package/src/pages/Profile.tsx +3 -2
- package/src/pages/Tags.tsx +72 -13
- package/src/pages/Welcome.tsx +3 -8
- package/src/pages/articles/Edit.tsx +18 -15
- package/src/pages/articles/Index.tsx +11 -21
- package/src/pages/articles/New.tsx +18 -15
- package/src/pages/conversations/Index.tsx +44 -68
- package/src/pages/conversations/Info.tsx +6 -5
- package/src/pages/conversations/New.tsx +14 -13
- package/src/pages/conversations/NewDraft.tsx +5 -5
- package/src/pages/conversations/Show.tsx +24 -22
- package/src/pages/events/Edit.tsx +14 -13
- package/src/pages/events/Index.tsx +28 -32
- package/src/pages/events/My.tsx +7 -7
- package/src/pages/events/New.tsx +14 -13
- package/src/pages/feeds/Bookmarks.tsx +3 -9
- package/src/pages/feeds/Local.tsx +3 -10
- package/src/pages/feeds/My.tsx +3 -9
- package/src/pages/groups/Edit.tsx +6 -7
- package/src/pages/groups/EditInfo.tsx +20 -17
- package/src/pages/groups/EditRoles.tsx +18 -19
- package/src/pages/groups/Index.tsx +82 -119
- package/src/pages/groups/Info.tsx +22 -23
- package/src/pages/groups/Members.tsx +9 -8
- package/src/pages/groups/New.tsx +18 -15
- package/src/pages/groups/Show.tsx +6 -5
- package/src/pages/jams/Index.tsx +8 -26
- package/src/pages/jams/New.tsx +14 -11
- package/src/pages/posts/Edit.tsx +20 -17
- package/src/pages/posts/New.tsx +30 -29
- package/src/pages/posts/Reply.tsx +20 -16
- package/src/pages/profile/Followers.tsx +9 -10
- package/src/pages/profile/Following.tsx +9 -10
- package/src/pages/settings/AccessTokens.tsx +6 -5
- package/src/pages/settings/Account.tsx +13 -12
- package/src/pages/settings/Blocked.tsx +5 -5
- package/src/pages/settings/Feed.tsx +13 -12
- package/src/pages/settings/Index.tsx +3 -11
- package/src/pages/settings/Language.tsx +36 -37
- package/src/pages/settings/NotificationPreferences.tsx +10 -12
- package/src/pages/settings/Notifications.tsx +10 -9
- package/src/pages/settings/PublicProfile.tsx +6 -6
- package/src/pages/settings/PushEnabledDevices.tsx +10 -9
- package/src/pages/settings/Theme.tsx +13 -12
- package/src/pages/settings/Timezone.tsx +27 -28
- package/src/theme/OpenPeepsThemeProvider.tsx +23 -12
- package/src/theme/utils.ts +10 -5
- package/tailwind.config.js +6 -0
- package/src/components/custom/common/plus-fab.tsx +0 -23
- package/src/components/custom/headers/generic-header.tsx +0 -88
- package/src/components/custom/headers/index.ts +0 -2
- package/src/components/custom/headers/tab-screens-header.tsx +0 -199
- package/src/components/navigation/auth-wrapper.tsx +0 -107
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openpeepshq/rn-components",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.12",
|
|
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",
|
|
@@ -140,8 +140,8 @@
|
|
|
140
140
|
"timezones-list": "^3.1.0",
|
|
141
141
|
"validator": "^13.15.23",
|
|
142
142
|
"zustand": "^5.0.3",
|
|
143
|
-
"@openpeepshq/
|
|
144
|
-
"@openpeepshq/
|
|
143
|
+
"@openpeepshq/common": "^0.2.0",
|
|
144
|
+
"@openpeepshq/react": "^0.3.3"
|
|
145
145
|
},
|
|
146
146
|
"devDependencies": {
|
|
147
147
|
"@babel/core": "^7.26.7",
|
|
@@ -101,8 +101,8 @@ export const SideMenu = ({
|
|
|
101
101
|
<View className="w-full flex-row items-center justify-between">
|
|
102
102
|
<Image
|
|
103
103
|
source={{ uri: logoSmall! }}
|
|
104
|
-
className="-mt-2"
|
|
105
|
-
resizeMode="
|
|
104
|
+
className="-mt-2 h-12 w-48"
|
|
105
|
+
resizeMode="contain"
|
|
106
106
|
/>
|
|
107
107
|
{!isMediumScreenOrLarger && (
|
|
108
108
|
<View className="md:hidden">
|
|
@@ -9,8 +9,7 @@ import {
|
|
|
9
9
|
groupMembershipHasRole,
|
|
10
10
|
} from '@openpeepshq/common/lib';
|
|
11
11
|
import {
|
|
12
|
-
|
|
13
|
-
invalidateUnseenCounts,
|
|
12
|
+
markGroupPostsRead,
|
|
14
13
|
useAuthData,
|
|
15
14
|
useCurrentProfile,
|
|
16
15
|
useNavigate,
|
|
@@ -79,11 +78,20 @@ export const GroupOptionsMenu = ({ group }: GroupOptionsMenuProps) => {
|
|
|
79
78
|
};
|
|
80
79
|
|
|
81
80
|
const handleMarkAllRead = async () => {
|
|
82
|
-
adjustUnseenCounts(queryClient, client, { clearGroup: group.id });
|
|
83
81
|
try {
|
|
84
|
-
await
|
|
82
|
+
await markGroupPostsRead(
|
|
83
|
+
queryClient,
|
|
84
|
+
client,
|
|
85
|
+
group.id,
|
|
86
|
+
markGroupPostsSeen
|
|
87
|
+
);
|
|
88
|
+
Toast.show({
|
|
89
|
+
type: 'success',
|
|
90
|
+
text1: t('groups.markAllRead.success', {
|
|
91
|
+
defaultValue: 'Group posts marked as read',
|
|
92
|
+
}),
|
|
93
|
+
});
|
|
85
94
|
} catch {
|
|
86
|
-
await invalidateUnseenCounts(queryClient, client);
|
|
87
95
|
Toast.show({ type: 'error', text1: t('groups.markAllRead.error') });
|
|
88
96
|
}
|
|
89
97
|
};
|
package/src/components/index.ts
CHANGED
|
@@ -1,19 +1,20 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { useMemo } from 'react';
|
|
2
2
|
import { useTranslation } from 'react-i18next';
|
|
3
|
-
import {
|
|
4
|
-
import { PhoneCallIcon } from '../icons/index';
|
|
3
|
+
import { useSetPlusButtonActions } from '../layout';
|
|
5
4
|
import { useCreateNewJam } from './CreateNewJamContext';
|
|
6
5
|
|
|
7
6
|
export const CreateNewJam = () => {
|
|
8
7
|
const { t } = useTranslation();
|
|
9
8
|
const { openCreateJam } = useCreateNewJam();
|
|
10
9
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
</PlusFab>
|
|
10
|
+
const plusActions = useMemo(
|
|
11
|
+
() => ({
|
|
12
|
+
title: t('jams.create.title'),
|
|
13
|
+
action: openCreateJam,
|
|
14
|
+
}),
|
|
15
|
+
[openCreateJam, t]
|
|
18
16
|
);
|
|
17
|
+
|
|
18
|
+
useSetPlusButtonActions(plusActions);
|
|
19
|
+
return null;
|
|
19
20
|
};
|
|
@@ -39,59 +39,45 @@ export const JamActionsFooter = ({ jamPost }: JamActionsFooterProps) => {
|
|
|
39
39
|
const isModerator = jam?.moderators.includes(currentProfile?.id as string);
|
|
40
40
|
|
|
41
41
|
return (
|
|
42
|
-
<View className="">
|
|
43
|
-
<View className="
|
|
44
|
-
<
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
42
|
+
<View className="w-full gap-y-2">
|
|
43
|
+
<View className="flex-row items-center">
|
|
44
|
+
<Button
|
|
45
|
+
variant={'ghost'}
|
|
46
|
+
size={'icon'}
|
|
47
|
+
onPress={() => {
|
|
48
|
+
Share.share({
|
|
49
|
+
message: t('posts.actions.shareMessage'),
|
|
50
|
+
url: `${BASE_URL}/events/${jamPost.id}/jam`,
|
|
51
|
+
});
|
|
52
|
+
}}
|
|
53
|
+
>
|
|
54
|
+
<ShareIcon className="text-foreground" size={18} />
|
|
55
|
+
</Button>
|
|
56
|
+
{jamPost.profile.id === currentProfile?.id && (
|
|
57
|
+
<Button variant={'ghost'} size={'icon'} onPress={handleDeletePress}>
|
|
58
|
+
<Trash2Icon className="text-foreground" size={18} />
|
|
56
59
|
</Button>
|
|
57
|
-
|
|
58
|
-
<>
|
|
59
|
-
{/* <Button variant={'ghost'} size={'icon'} onPress={() => {}}>
|
|
60
|
-
<PencilLineIcon className="text-foreground" size={18} />
|
|
61
|
-
</Button> */}
|
|
62
|
-
|
|
63
|
-
<Button
|
|
64
|
-
variant={'ghost'}
|
|
65
|
-
size={'icon'}
|
|
66
|
-
onPress={handleDeletePress}
|
|
67
|
-
>
|
|
68
|
-
<Trash2Icon className="text-foreground" size={18} />
|
|
69
|
-
</Button>
|
|
70
|
-
</>
|
|
71
|
-
)}
|
|
72
|
-
</View>
|
|
73
|
-
{livekitEnabled === false ? (
|
|
74
|
-
<ThemedText className="text-destructive text-sm flex-1">
|
|
75
|
-
{t('jams.unavailable.message')}
|
|
76
|
-
</ThemedText>
|
|
77
|
-
) : livekitEnabled && (jamState?.active || isModerator) ? (
|
|
78
|
-
<Button
|
|
79
|
-
variant={'outline'}
|
|
80
|
-
onPress={() => {
|
|
81
|
-
navigation.navigate('JamSession', {
|
|
82
|
-
jamId: jamPost.id,
|
|
83
|
-
});
|
|
84
|
-
}}
|
|
85
|
-
className={`${isModerator ? 'flex-1' : ''}`}
|
|
86
|
-
>
|
|
87
|
-
<ThemedText>
|
|
88
|
-
{!jamState?.active
|
|
89
|
-
? t('jams.start.submit')
|
|
90
|
-
: t('jams.join.submit')}
|
|
91
|
-
</ThemedText>
|
|
92
|
-
</Button>
|
|
93
|
-
) : null}
|
|
60
|
+
)}
|
|
94
61
|
</View>
|
|
62
|
+
{livekitEnabled === false ? (
|
|
63
|
+
<ThemedText className="text-destructive text-sm">
|
|
64
|
+
{t('jams.unavailable.message')}
|
|
65
|
+
</ThemedText>
|
|
66
|
+
) : livekitEnabled && (jamState?.active || isModerator) ? (
|
|
67
|
+
<Button
|
|
68
|
+
variant={'outline'}
|
|
69
|
+
className="w-full"
|
|
70
|
+
onPress={() => {
|
|
71
|
+
navigation.navigate('JamSession', {
|
|
72
|
+
jamId: jamPost.id,
|
|
73
|
+
});
|
|
74
|
+
}}
|
|
75
|
+
>
|
|
76
|
+
<ThemedText numberOfLines={1}>
|
|
77
|
+
{!jamState?.active ? t('jams.start.submit') : t('jams.join.submit')}
|
|
78
|
+
</ThemedText>
|
|
79
|
+
</Button>
|
|
80
|
+
) : null}
|
|
95
81
|
|
|
96
82
|
<DeleteJamModal ref={deleteJamSheetRef} />
|
|
97
83
|
</View>
|
|
@@ -20,15 +20,15 @@ export const JamCard = ({ jamPost, type = 'upcoming' }: JamCardProps) => {
|
|
|
20
20
|
jamEvent && (
|
|
21
21
|
<>
|
|
22
22
|
{jamPost.data?.type === 'event' && (
|
|
23
|
-
<View className="
|
|
24
|
-
<View className="size-24">
|
|
23
|
+
<View className="mb-4 w-full flex-row gap-x-4">
|
|
24
|
+
<View className="size-24 shrink-0">
|
|
25
25
|
<Image
|
|
26
26
|
source={require('../../assets/images/jam-placeholder.png')}
|
|
27
|
-
className="
|
|
27
|
+
className="h-full w-full rounded-md"
|
|
28
28
|
/>
|
|
29
29
|
</View>
|
|
30
|
-
<View className=" flex flex-col gap-y-3
|
|
31
|
-
<View className="flex flex-
|
|
30
|
+
<View className="min-w-0 flex-1 flex-col gap-y-3">
|
|
31
|
+
<View className="flex-row flex-wrap items-center gap-x-1">
|
|
32
32
|
<ThemedText>Happening</ThemedText>
|
|
33
33
|
<UpdatingDate date={jamEvent?.start} />
|
|
34
34
|
</View>
|
|
@@ -183,10 +183,11 @@ export const JamLobby = ({ onJoin }: JamLobbyProps) => {
|
|
|
183
183
|
<View className="w-full items-center px-5 pb-4">
|
|
184
184
|
<Button
|
|
185
185
|
accessibilityLabel={t('jams.join.submit')}
|
|
186
|
+
className="min-w-[10rem]"
|
|
186
187
|
disabled={submitting}
|
|
187
188
|
onPress={handleJoin}
|
|
188
189
|
>
|
|
189
|
-
<ThemedText className="text-primary-foreground">
|
|
190
|
+
<ThemedText numberOfLines={1} className="text-primary-foreground">
|
|
190
191
|
{jamActive ? t('jams.join.ctaJoin') : t('jams.join.ctaStart')}
|
|
191
192
|
</ThemedText>
|
|
192
193
|
</Button>
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import React, { type ReactNode } from 'react';
|
|
2
|
+
import { Image, ImageBackground, View } from 'react-native';
|
|
3
|
+
import { KeyboardAwareScrollView } from 'react-native-keyboard-aware-scroll-view';
|
|
4
|
+
import { getTheme } from '@openpeepshq/common';
|
|
5
|
+
import { useOpenpeeps } from '@openpeepshq/react';
|
|
6
|
+
import { useWindowSize } from '../../hooks/index';
|
|
7
|
+
import { BASE_URL, isProduction } from '../../lib/constants';
|
|
8
|
+
import { toAbsoluteMediaUrl } from '../../lib/media-url';
|
|
9
|
+
import { ThemedText } from '../ui/themed-text';
|
|
10
|
+
|
|
11
|
+
export interface AuthLayoutProps {
|
|
12
|
+
children?: ReactNode;
|
|
13
|
+
description?: ReactNode;
|
|
14
|
+
noRedirect?: boolean;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
const DevBanner = () =>
|
|
18
|
+
!isProduction ? (
|
|
19
|
+
<View className="absolute top-64 z-10 ml-8 mr-8 w-auto rounded-lg bg-white/80 p-4">
|
|
20
|
+
<ThemedText className="text-center text-destructive">
|
|
21
|
+
Test Backend ({BASE_URL})
|
|
22
|
+
</ThemedText>
|
|
23
|
+
</View>
|
|
24
|
+
) : null;
|
|
25
|
+
|
|
26
|
+
const Logo = ({ uri }: { uri?: string }) => {
|
|
27
|
+
if (!uri) return null;
|
|
28
|
+
return (
|
|
29
|
+
<Image
|
|
30
|
+
source={{ uri }}
|
|
31
|
+
className="absolute left-2 top-16 z-10 h-[26px] w-[206px] max-w-fit"
|
|
32
|
+
resizeMode="contain"
|
|
33
|
+
/>
|
|
34
|
+
);
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
const AuthImage = ({ children }: { children?: ReactNode }) => {
|
|
38
|
+
const { openpeepsApi } = useOpenpeeps();
|
|
39
|
+
const { data: serverInfo, isLoading } = openpeepsApi.useServerInfo();
|
|
40
|
+
const resolvedTheme = serverInfo
|
|
41
|
+
? getTheme(serverInfo.communityConfig)
|
|
42
|
+
: undefined;
|
|
43
|
+
const authBackgroundUri = toAbsoluteMediaUrl(resolvedTheme?.backgroundAuth);
|
|
44
|
+
const resolvedLogoUri = toAbsoluteMediaUrl(resolvedTheme?.logoSmall);
|
|
45
|
+
|
|
46
|
+
const content = (
|
|
47
|
+
<>
|
|
48
|
+
<Logo uri={resolvedLogoUri} />
|
|
49
|
+
<DevBanner />
|
|
50
|
+
{children}
|
|
51
|
+
</>
|
|
52
|
+
);
|
|
53
|
+
|
|
54
|
+
if (authBackgroundUri && !isLoading) {
|
|
55
|
+
return (
|
|
56
|
+
<ImageBackground
|
|
57
|
+
source={{ uri: authBackgroundUri }}
|
|
58
|
+
className="w-full flex-1 justify-end"
|
|
59
|
+
>
|
|
60
|
+
{content}
|
|
61
|
+
</ImageBackground>
|
|
62
|
+
);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
return (
|
|
66
|
+
<View className="bg-background w-full flex-1 justify-end">{content}</View>
|
|
67
|
+
);
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
const NarrowAuthLayout = ({
|
|
71
|
+
children,
|
|
72
|
+
description,
|
|
73
|
+
}: {
|
|
74
|
+
children?: ReactNode;
|
|
75
|
+
description?: ReactNode;
|
|
76
|
+
}) => (
|
|
77
|
+
<AuthImage>
|
|
78
|
+
<View className="bg-background w-full min-h-[400px] px-2 pb-10 pt-4">
|
|
79
|
+
{description}
|
|
80
|
+
{children}
|
|
81
|
+
</View>
|
|
82
|
+
</AuthImage>
|
|
83
|
+
);
|
|
84
|
+
|
|
85
|
+
const WideAuthLayout = ({
|
|
86
|
+
children,
|
|
87
|
+
description,
|
|
88
|
+
}: {
|
|
89
|
+
children?: ReactNode;
|
|
90
|
+
description?: ReactNode;
|
|
91
|
+
}) => (
|
|
92
|
+
<View className="flex flex-1 flex-row">
|
|
93
|
+
<View className="flex-1">
|
|
94
|
+
<AuthImage />
|
|
95
|
+
</View>
|
|
96
|
+
<View className="flex flex-1 justify-center p-6">
|
|
97
|
+
{description}
|
|
98
|
+
{children}
|
|
99
|
+
</View>
|
|
100
|
+
</View>
|
|
101
|
+
);
|
|
102
|
+
|
|
103
|
+
export const AuthLayout = ({ children, description }: AuthLayoutProps) => {
|
|
104
|
+
const { isMediumScreenOrLarger } = useWindowSize();
|
|
105
|
+
|
|
106
|
+
return (
|
|
107
|
+
<KeyboardAwareScrollView
|
|
108
|
+
contentContainerClassName="grow"
|
|
109
|
+
className="bg-background flex w-full"
|
|
110
|
+
>
|
|
111
|
+
{isMediumScreenOrLarger ? (
|
|
112
|
+
<WideAuthLayout description={description}>{children}</WideAuthLayout>
|
|
113
|
+
) : (
|
|
114
|
+
<NarrowAuthLayout description={description}>
|
|
115
|
+
{children}
|
|
116
|
+
</NarrowAuthLayout>
|
|
117
|
+
)}
|
|
118
|
+
</KeyboardAwareScrollView>
|
|
119
|
+
);
|
|
120
|
+
};
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Pressable, View } from 'react-native';
|
|
3
|
+
import { useNavigation, useRoute } from '@react-navigation/native';
|
|
4
|
+
import type { NativeStackNavigationProp } from '@react-navigation/native-stack';
|
|
5
|
+
import { useCurrentProfile } from '@openpeepshq/react';
|
|
6
|
+
import { goToParentOrBack } from '../navigation/parent-back';
|
|
7
|
+
import type { MainStackParamList } from '../navigation/types';
|
|
8
|
+
import { ChevronLeftIcon } from '../icons/index';
|
|
9
|
+
import { ThemedText } from '../ui/themed-text';
|
|
10
|
+
import { usePageChrome } from './pageChrome';
|
|
11
|
+
|
|
12
|
+
export const ContentHeader = () => {
|
|
13
|
+
const { header } = usePageChrome();
|
|
14
|
+
const navigation =
|
|
15
|
+
useNavigation<NativeStackNavigationProp<MainStackParamList>>();
|
|
16
|
+
const route = useRoute();
|
|
17
|
+
const me = useCurrentProfile();
|
|
18
|
+
|
|
19
|
+
const title = header?.title;
|
|
20
|
+
const titleIsString = typeof title === 'string';
|
|
21
|
+
|
|
22
|
+
return (
|
|
23
|
+
<View className="border-border flex-row items-center justify-between border-b px-4 py-2">
|
|
24
|
+
<View className="min-w-0 flex-1 flex-row items-center gap-2">
|
|
25
|
+
<Pressable
|
|
26
|
+
accessibilityRole="button"
|
|
27
|
+
accessibilityLabel="Back"
|
|
28
|
+
onPress={() => {
|
|
29
|
+
if (header?.onBack) {
|
|
30
|
+
header.onBack();
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
goToParentOrBack({
|
|
34
|
+
navigation,
|
|
35
|
+
routeName: route.name,
|
|
36
|
+
params: route.params as Record<string, unknown> | undefined,
|
|
37
|
+
profileHandle: me?.handle,
|
|
38
|
+
});
|
|
39
|
+
}}
|
|
40
|
+
className="items-center justify-center p-2"
|
|
41
|
+
>
|
|
42
|
+
<ChevronLeftIcon size={28} className="text-foreground" />
|
|
43
|
+
</Pressable>
|
|
44
|
+
{titleIsString ? (
|
|
45
|
+
<ThemedText
|
|
46
|
+
className="min-w-0 flex-1 text-xl font-semibold"
|
|
47
|
+
numberOfLines={1}
|
|
48
|
+
>
|
|
49
|
+
{title}
|
|
50
|
+
</ThemedText>
|
|
51
|
+
) : (
|
|
52
|
+
title
|
|
53
|
+
)}
|
|
54
|
+
</View>
|
|
55
|
+
{header?.actions ? (
|
|
56
|
+
<View className="ml-2 shrink-0 flex-row items-center">
|
|
57
|
+
{header.actions}
|
|
58
|
+
</View>
|
|
59
|
+
) : null}
|
|
60
|
+
</View>
|
|
61
|
+
);
|
|
62
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { ActivityIndicator } from 'react-native';
|
|
3
|
+
import { Button } from '../ui/button';
|
|
4
|
+
import { ThemedText } from '../ui/themed-text';
|
|
5
|
+
|
|
6
|
+
export const HeaderActionButton = ({
|
|
7
|
+
title,
|
|
8
|
+
onPress,
|
|
9
|
+
disabled,
|
|
10
|
+
loading,
|
|
11
|
+
}: {
|
|
12
|
+
title: string;
|
|
13
|
+
onPress: () => void;
|
|
14
|
+
disabled?: boolean;
|
|
15
|
+
loading?: boolean;
|
|
16
|
+
}) => (
|
|
17
|
+
<Button disabled={disabled} onPress={onPress}>
|
|
18
|
+
{loading ? <ActivityIndicator size="small" /> : null}
|
|
19
|
+
<ThemedText className="text-primary-foreground text-base font-semibold">
|
|
20
|
+
{title}
|
|
21
|
+
</ThemedText>
|
|
22
|
+
</Button>
|
|
23
|
+
);
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import {
|
|
3
|
+
Image,
|
|
4
|
+
ImageBackground,
|
|
5
|
+
Platform,
|
|
6
|
+
StatusBar,
|
|
7
|
+
StyleSheet,
|
|
8
|
+
View,
|
|
9
|
+
} from 'react-native';
|
|
10
|
+
import { SafeAreaView } from 'react-native-safe-area-context';
|
|
11
|
+
import { useNavigation } from '@react-navigation/native';
|
|
12
|
+
import type { NativeStackNavigationProp } from '@react-navigation/native-stack';
|
|
13
|
+
import { useOpenpeeps } from '@openpeepshq/react';
|
|
14
|
+
import { useDrawer } from '../../contexts/drawer-context';
|
|
15
|
+
import { useWindowSize } from '../../hooks/index';
|
|
16
|
+
import { BASE_URL, isProduction } from '../../lib/constants';
|
|
17
|
+
import { useAppImagesStore } from '../../stores/useAppImagesStore';
|
|
18
|
+
import { Avatar, AvatarFallback, AvatarImage } from '../ui/avatar';
|
|
19
|
+
import { Button } from '../ui/button';
|
|
20
|
+
import { ThemedText } from '../ui/themed-text';
|
|
21
|
+
import { MessageSquareTextIcon, UserIcon } from '../icons/index';
|
|
22
|
+
import type { MainStackParamList } from '../navigation/types/index';
|
|
23
|
+
|
|
24
|
+
export const HeaderMobile = () => {
|
|
25
|
+
const { openDrawer } = useDrawer();
|
|
26
|
+
const { isMediumScreenOrLarger } = useWindowSize();
|
|
27
|
+
const { currentProfile } = useOpenpeeps();
|
|
28
|
+
const navigation =
|
|
29
|
+
useNavigation<NativeStackNavigationProp<MainStackParamList>>();
|
|
30
|
+
const { background, logoSmall } = useAppImagesStore();
|
|
31
|
+
|
|
32
|
+
if (isMediumScreenOrLarger) {
|
|
33
|
+
return null;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
return (
|
|
37
|
+
<ImageBackground
|
|
38
|
+
resizeMode="cover"
|
|
39
|
+
source={{ uri: background! }}
|
|
40
|
+
style={styles.header}
|
|
41
|
+
className="px-4 pb-3"
|
|
42
|
+
>
|
|
43
|
+
<SafeAreaView edges={['top']}>
|
|
44
|
+
{!isProduction && (
|
|
45
|
+
<View className="mb-2 w-full rounded-lg bg-white/50 p-2">
|
|
46
|
+
<ThemedText className="text-center text-destructive">
|
|
47
|
+
Test Backend ({BASE_URL})
|
|
48
|
+
</ThemedText>
|
|
49
|
+
</View>
|
|
50
|
+
)}
|
|
51
|
+
<View className="flex-row items-center justify-between">
|
|
52
|
+
<Button
|
|
53
|
+
variant="outline"
|
|
54
|
+
size="icon"
|
|
55
|
+
onPress={openDrawer}
|
|
56
|
+
className="native:px-0 active:bg-none rounded-full bg-black"
|
|
57
|
+
>
|
|
58
|
+
<Avatar alt={(currentProfile?.displayName as string) || 'Profile'}>
|
|
59
|
+
{currentProfile?.avatar ? (
|
|
60
|
+
<AvatarImage source={{ uri: currentProfile.avatar }} />
|
|
61
|
+
) : (
|
|
62
|
+
<AvatarFallback className="-bottom-2 -right-2 h-6 w-6 bg-black">
|
|
63
|
+
<UserIcon size={20} className="text-muted-foreground" />
|
|
64
|
+
</AvatarFallback>
|
|
65
|
+
)}
|
|
66
|
+
</Avatar>
|
|
67
|
+
</Button>
|
|
68
|
+
<Image
|
|
69
|
+
source={{ uri: logoSmall! }}
|
|
70
|
+
resizeMode="contain"
|
|
71
|
+
className="h-[64px] w-[216px]"
|
|
72
|
+
/>
|
|
73
|
+
<Button
|
|
74
|
+
variant="outline"
|
|
75
|
+
size="icon"
|
|
76
|
+
onPress={() =>
|
|
77
|
+
navigation.navigate('TabNavigator', { screen: 'Messages' })
|
|
78
|
+
}
|
|
79
|
+
accessibilityLabel="Messages"
|
|
80
|
+
>
|
|
81
|
+
<MessageSquareTextIcon
|
|
82
|
+
className="text-muted-foreground"
|
|
83
|
+
size={18}
|
|
84
|
+
/>
|
|
85
|
+
</Button>
|
|
86
|
+
</View>
|
|
87
|
+
</SafeAreaView>
|
|
88
|
+
</ImageBackground>
|
|
89
|
+
);
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
const styles = StyleSheet.create({
|
|
93
|
+
header: {
|
|
94
|
+
paddingTop: Platform.OS === 'android' ? StatusBar.currentHeight : 0,
|
|
95
|
+
},
|
|
96
|
+
});
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Pressable } from 'react-native';
|
|
3
|
+
import { PlusIcon } from '../icons/index';
|
|
4
|
+
import { usePageChrome } from './pageChrome';
|
|
5
|
+
|
|
6
|
+
export const PlusButton = () => {
|
|
7
|
+
const { plus } = usePageChrome();
|
|
8
|
+
if (!plus || Array.isArray(plus)) return null;
|
|
9
|
+
|
|
10
|
+
const onPress = () => {
|
|
11
|
+
if (typeof plus.action === 'function') {
|
|
12
|
+
void plus.action();
|
|
13
|
+
}
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
return (
|
|
17
|
+
<Pressable
|
|
18
|
+
accessibilityRole="button"
|
|
19
|
+
accessibilityLabel={plus.title || 'New'}
|
|
20
|
+
onPress={onPress}
|
|
21
|
+
className="bg-foreground absolute bottom-10 right-6 z-20 size-16 items-center justify-center rounded-full"
|
|
22
|
+
>
|
|
23
|
+
<PlusIcon size={24} className="text-background" />
|
|
24
|
+
</Pressable>
|
|
25
|
+
);
|
|
26
|
+
};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import React, { type ReactNode } from 'react';
|
|
2
|
+
import { View } from 'react-native';
|
|
3
|
+
import { ThemedView } from '../ui/themed-view';
|
|
4
|
+
import { ContentHeader } from './ContentHeader';
|
|
5
|
+
import { HeaderMobile } from './HeaderMobile';
|
|
6
|
+
import { PageChromeProvider } from './pageChrome';
|
|
7
|
+
import { PlusButton } from './PlusButton';
|
|
8
|
+
|
|
9
|
+
export const RootLayout = ({ children }: { children: ReactNode }) => (
|
|
10
|
+
<PageChromeProvider>
|
|
11
|
+
<ThemedView className="flex-1">
|
|
12
|
+
<HeaderMobile />
|
|
13
|
+
<ContentHeader />
|
|
14
|
+
<View className="min-h-0 flex-1">{children}</View>
|
|
15
|
+
<PlusButton />
|
|
16
|
+
</ThemedView>
|
|
17
|
+
</PageChromeProvider>
|
|
18
|
+
);
|
|
19
|
+
|
|
20
|
+
export const withRootLayout = <P extends object>(
|
|
21
|
+
Screen: React.ComponentType<P>
|
|
22
|
+
) => {
|
|
23
|
+
const Wrapped = (props: P) => (
|
|
24
|
+
<RootLayout>
|
|
25
|
+
<Screen {...props} />
|
|
26
|
+
</RootLayout>
|
|
27
|
+
);
|
|
28
|
+
Wrapped.displayName = `withRootLayout(${Screen.displayName ?? Screen.name})`;
|
|
29
|
+
return Wrapped;
|
|
30
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export { HeaderActionButton } from './HeaderActionButton';
|
|
2
|
+
export { AuthLayout } from './AuthLayout';
|
|
3
|
+
export type { AuthLayoutProps } from './AuthLayout';
|
|
4
|
+
export { ContentHeader } from './ContentHeader';
|
|
5
|
+
export { HeaderMobile } from './HeaderMobile';
|
|
6
|
+
export {
|
|
7
|
+
PageChromeProvider,
|
|
8
|
+
usePageChrome,
|
|
9
|
+
useSetPageHeader,
|
|
10
|
+
useSetPlusButtonActions,
|
|
11
|
+
} from './pageChrome';
|
|
12
|
+
export { PlusButton } from './PlusButton';
|
|
13
|
+
export { RootLayout, withRootLayout } from './RootLayout';
|