@openpeepshq/rn-components 0.13.1 → 0.14.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/README.md +2 -0
- package/package.json +3 -3
- package/src/components/icons/index.ts +2 -0
- package/src/components/jams/JamDeviceSelectors.tsx +2 -2
- package/src/components/jams/JamLobby.tsx +5 -3
- package/src/components/jams/JamParticipantConference.tsx +6 -1
- package/src/components/jams/JamRoomIndicators.test.tsx +80 -4
- package/src/components/jams/JamRoomIndicators.tsx +34 -1
- package/src/components/jams/JamVideoCall.tsx +5 -5
- package/src/components/layout/ContentHeader.tsx +6 -2
- package/src/components/layout/HeaderMobile.tsx +48 -22
- package/src/components/layout/PlusButton.tsx +1 -7
- package/src/components/layout/pageChrome.test.tsx +213 -0
- package/src/components/post/pieces/FeedPostStats.tsx +15 -11
- package/src/components/post/pieces/PollContent.tsx +1 -1
- package/src/components/post/pieces/PostMenu.test.tsx +333 -0
- package/src/components/post/pieces/PostMenu.tsx +19 -15
- package/src/components/post/post-form/ReplyModal.tsx +1 -1
- package/src/components/profile/ProfileCard.test.tsx +16 -1
- package/src/components/profile/ProfileCard.tsx +14 -3
- package/src/components/resources/ResourceLibrary.tsx +0 -1
- package/src/hooks/use-controlled-sheet.test.tsx +140 -0
- package/src/hooks/use-controlled-sheet.ts +25 -2
- package/src/pages/Explore.tsx +1 -3
- package/src/pages/conversations/Info.tsx +1 -1
- package/src/pages/conversations/New.tsx +1 -1
- package/src/pages/conversations/Show.tsx +21 -29
- package/src/pages/posts/Edit.tsx +1 -1
- package/src/pages/posts/New.tsx +1 -1
- package/src/pages/posts/Reply.tsx +2 -2
package/README.md
CHANGED
|
@@ -14,6 +14,8 @@ pnpm add @openpeepshq/rn-components
|
|
|
14
14
|
|
|
15
15
|
Wrap your app with **`OpenpeepsProvider`** from `@openpeepshq/rn-components` (and a credentials store + `baseUrl`) so `useOpenpeeps()` and theme code work. This re-exports the web provider from `@openpeepshq/react` with React Native `AppState` foreground handling wired in — do not import `OpenpeepsProvider` from `@openpeepshq/react` in native apps.
|
|
16
16
|
|
|
17
|
+
Also mount **`BottomSheetModalProvider`** from `@gorhom/bottom-sheet` **once at the app root** (e.g. inside your root navigator). Every sheet in this package (`BaseSheet`-based modals) is a gorhom `BottomSheetModal` and silently fails to present without it.
|
|
18
|
+
|
|
17
19
|
Configure **NativeWind** / Tailwind in the app (include this package in Tailwind `content`), load `src/global.css` from your entry, and supply **`react-native-config`** (or compatible env) for `BASE_URL` and related keys.
|
|
18
20
|
|
|
19
21
|
Wrap Metro with **`withOpenPeepsMetro`** (outside `withNativeWind`) so css-interop observables defer on React 19 and `react-native-sound` 0.11.x can `require()` RN 0.80+ `resolveAssetSource`. Hosts should not patch `react-native-css-interop` or `react-native-sound`.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openpeepshq/rn-components",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.14.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",
|
|
@@ -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/common": "^0.9.0",
|
|
146
|
+
"@openpeepshq/react": "^0.15.0"
|
|
147
147
|
},
|
|
148
148
|
"devDependencies": {
|
|
149
149
|
"@babel/core": "^7.26.7",
|
|
@@ -81,6 +81,7 @@ import {
|
|
|
81
81
|
Ban,
|
|
82
82
|
Mail,
|
|
83
83
|
Lock,
|
|
84
|
+
Menu,
|
|
84
85
|
UserCheck,
|
|
85
86
|
SendHorizonal,
|
|
86
87
|
MailCheck,
|
|
@@ -232,6 +233,7 @@ export const AudioLinesIcon = iconWithClassName(AudioLines);
|
|
|
232
233
|
export const BanIcon = iconWithClassName(Ban);
|
|
233
234
|
export const MailIcon = iconWithClassName(Mail);
|
|
234
235
|
export const LockIcon = iconWithClassName(Lock);
|
|
236
|
+
export const MenuIcon = iconWithClassName(Menu);
|
|
235
237
|
export const UserCheckIcon = iconWithClassName(UserCheck);
|
|
236
238
|
export const SendHorizonalIcon = iconWithClassName(SendHorizonal);
|
|
237
239
|
export const MailCheckIcon = iconWithClassName(MailCheck);
|
|
@@ -195,8 +195,8 @@ export const JamMicSelector = () => {
|
|
|
195
195
|
MediaDeviceFailure.PermissionDenied;
|
|
196
196
|
showMicToast(
|
|
197
197
|
denied
|
|
198
|
-
? t('jams.mic.lobbyProbeFailed')
|
|
199
|
-
: t('jams.mic.enableFailed')
|
|
198
|
+
? t('jams.device.mic.lobbyProbeFailed')
|
|
199
|
+
: t('jams.device.mic.enableFailed')
|
|
200
200
|
);
|
|
201
201
|
})
|
|
202
202
|
}
|
|
@@ -133,12 +133,14 @@ export const JamLobby = ({ onJoin }: JamLobbyProps) => {
|
|
|
133
133
|
permissionDeniedRef.current = true;
|
|
134
134
|
}
|
|
135
135
|
setError(
|
|
136
|
-
denied
|
|
136
|
+
denied
|
|
137
|
+
? t('jams.device.mic.lobbyProbeFailed')
|
|
138
|
+
: t('jams.device.mic.enableFailed')
|
|
137
139
|
);
|
|
138
140
|
if (firstDenial) {
|
|
139
141
|
Alert.alert(
|
|
140
|
-
t('jams.mic.permissionTitle'),
|
|
141
|
-
t('jams.mic.permissionMessage'),
|
|
142
|
+
t('jams.device.mic.permissionTitle'),
|
|
143
|
+
t('jams.device.mic.permissionMessage'),
|
|
142
144
|
[
|
|
143
145
|
{ text: t('common.actions.cancel'), style: 'cancel' },
|
|
144
146
|
{
|
|
@@ -22,7 +22,11 @@ import { JamDetailsDrawer } from './JamDetailsDrawer';
|
|
|
22
22
|
import { JamDesktopFooter } from './JamDesktopFooter';
|
|
23
23
|
import { JamFooter, type JamFooterProps } from './JamFooter';
|
|
24
24
|
import { JamPeopleDrawer } from './JamPeopleDrawer';
|
|
25
|
-
import {
|
|
25
|
+
import {
|
|
26
|
+
JamNetworkQuality,
|
|
27
|
+
JamObserverIndicator,
|
|
28
|
+
JamRecordingIndicator,
|
|
29
|
+
} from './JamRoomIndicators';
|
|
26
30
|
import { JamVideoLayout } from './JamVideoLayout';
|
|
27
31
|
|
|
28
32
|
type Drawer = 'chat' | 'people' | 'details' | null;
|
|
@@ -92,6 +96,7 @@ const JamParticipantConferenceInner = () => {
|
|
|
92
96
|
<View className="relative flex-1 overflow-hidden bg-background">
|
|
93
97
|
<JamNetworkQuality />
|
|
94
98
|
<JamRecordingIndicator />
|
|
99
|
+
<JamObserverIndicator />
|
|
95
100
|
<View className="relative min-h-0 w-full flex-1 overflow-hidden p-2">
|
|
96
101
|
<View className="min-h-0 flex-1 overflow-hidden">
|
|
97
102
|
<View className="shrink-0 flex-row items-center">
|
|
@@ -24,6 +24,8 @@ const { mapColors } = require('../../theme/defaults');
|
|
|
24
24
|
const mockViewProps: Array<{ style?: unknown; className?: string }> = [];
|
|
25
25
|
let mockQuality = 1; // livekit-client ConnectionQuality.Good
|
|
26
26
|
let mockIsDark = false;
|
|
27
|
+
let mockSessions = 0;
|
|
28
|
+
let mockSafeAreaTop = 36; // a typical status-bar inset
|
|
27
29
|
|
|
28
30
|
jest.mock('react-native', () => {
|
|
29
31
|
const View = (props: {
|
|
@@ -51,20 +53,39 @@ jest.mock('livekit-client', () => ({
|
|
|
51
53
|
|
|
52
54
|
jest.mock('react-i18next', () => ({
|
|
53
55
|
useTranslation: () => ({
|
|
54
|
-
|
|
55
|
-
|
|
56
|
+
// Plural branches mirror `jams.observers.present` in en.json, so the
|
|
57
|
+
// rendered text pins both the key/count usage and the plural choice.
|
|
58
|
+
t: (key: string, opts?: Record<string, unknown>) => {
|
|
59
|
+
if (key === 'jams.observers.present') {
|
|
60
|
+
const count = Number(opts?.count ?? 0);
|
|
61
|
+
const text =
|
|
62
|
+
count === 1
|
|
63
|
+
? '{{count}} external session is connected to this jam'
|
|
64
|
+
: '{{count}} external sessions are connected to this jam';
|
|
65
|
+
return text.replace(/\{\{(\w+)\}\}/g, (_m: string, n: string) =>
|
|
66
|
+
String(opts?.[n] ?? '')
|
|
67
|
+
);
|
|
68
|
+
}
|
|
69
|
+
return key.replace(/\{\{(\w+)\}\}/g, (_m: string, n: string) =>
|
|
56
70
|
String(opts?.[n] ?? '')
|
|
57
|
-
)
|
|
71
|
+
);
|
|
72
|
+
},
|
|
58
73
|
}),
|
|
59
74
|
}));
|
|
60
75
|
|
|
61
76
|
jest.mock('@openpeepshq/react', () => ({
|
|
62
77
|
useJamRecordingState: () => ({ isRecording: false }),
|
|
63
78
|
useJamRecordingElapsed: () => null,
|
|
79
|
+
useJamExternalSessions: () => mockSessions,
|
|
80
|
+
}));
|
|
81
|
+
|
|
82
|
+
jest.mock('react-native-safe-area-context', () => ({
|
|
83
|
+
useSafeAreaInsets: () => ({ top: mockSafeAreaTop, bottom: 0 }),
|
|
64
84
|
}));
|
|
65
85
|
|
|
66
86
|
jest.mock('../icons/index', () => ({
|
|
67
87
|
CircleIcon: () => React.createElement('CircleIcon'),
|
|
88
|
+
EyeOnIcon: () => React.createElement('EyeOnIcon'),
|
|
68
89
|
XIcon: () => React.createElement('XIcon'),
|
|
69
90
|
}));
|
|
70
91
|
|
|
@@ -92,7 +113,10 @@ jest.mock('./useParticipantConnection', () => ({
|
|
|
92
113
|
useConnectionQuality: () => mockQuality,
|
|
93
114
|
}));
|
|
94
115
|
|
|
95
|
-
const {
|
|
116
|
+
const {
|
|
117
|
+
JamNetworkQuality,
|
|
118
|
+
JamObserverIndicator,
|
|
119
|
+
} = require('./JamRoomIndicators');
|
|
96
120
|
|
|
97
121
|
const renderQuality = (quality: number, isDark: boolean) => {
|
|
98
122
|
mockViewProps.length = 0;
|
|
@@ -105,6 +129,21 @@ const renderQuality = (quality: number, isDark: boolean) => {
|
|
|
105
129
|
return { tree, banner: mockViewProps[mockViewProps.length - 1] };
|
|
106
130
|
};
|
|
107
131
|
|
|
132
|
+
const renderObserverPill = (sessions: number, safeAreaTop: number) => {
|
|
133
|
+
mockViewProps.length = 0;
|
|
134
|
+
mockSessions = sessions;
|
|
135
|
+
mockSafeAreaTop = safeAreaTop;
|
|
136
|
+
let tree!: ReactTestRenderer.ReactTestRenderer;
|
|
137
|
+
ReactTestRenderer.act(() => {
|
|
138
|
+
tree = ReactTestRenderer.create(React.createElement(JamObserverIndicator));
|
|
139
|
+
});
|
|
140
|
+
const texts = tree.root.findAllByType('ThemedText');
|
|
141
|
+
return {
|
|
142
|
+
pill: mockViewProps[mockViewProps.length - 1],
|
|
143
|
+
renderedText: texts.length ? texts[0].children.join('') : null,
|
|
144
|
+
};
|
|
145
|
+
};
|
|
146
|
+
|
|
108
147
|
describe('JamNetworkQuality banner background', () => {
|
|
109
148
|
it('renders an opaque inline background (light theme) when the connection is poor', () => {
|
|
110
149
|
const { banner } = renderQuality(2, false); // ConnectionQuality.Poor
|
|
@@ -141,3 +180,40 @@ describe('JamNetworkQuality banner background', () => {
|
|
|
141
180
|
expect(mockViewProps).toHaveLength(0);
|
|
142
181
|
});
|
|
143
182
|
});
|
|
183
|
+
|
|
184
|
+
describe('JamObserverIndicator pill', () => {
|
|
185
|
+
it('renders nothing when no external sessions are connected', () => {
|
|
186
|
+
const { pill, renderedText } = renderObserverPill(0, 36);
|
|
187
|
+
expect(pill).toBeUndefined();
|
|
188
|
+
expect(renderedText).toBeNull();
|
|
189
|
+
});
|
|
190
|
+
|
|
191
|
+
it('renders the singular copy with the inline primary background and a safe-area-aware top when one session is connected', () => {
|
|
192
|
+
mockIsDark = false;
|
|
193
|
+
const { pill, renderedText } = renderObserverPill(1, 36);
|
|
194
|
+
|
|
195
|
+
expect(renderedText).toBe('1 external session is connected to this jam');
|
|
196
|
+
expect(pill).toBeDefined();
|
|
197
|
+
// The pill background is the real primary color at 0.9 opacity (inline
|
|
198
|
+
// rgba, not a NativeWind `/90` class) and clears the safe-area top
|
|
199
|
+
// inset plus a 16px margin; pinned against the shipped light primary
|
|
200
|
+
// (#16161a).
|
|
201
|
+
expect(pill!.style).toEqual([
|
|
202
|
+
{ top: 52, right: 16 },
|
|
203
|
+
{ backgroundColor: 'rgba(22, 22, 26, 0.9)' },
|
|
204
|
+
]);
|
|
205
|
+
// Positioning lives in the inline style; the magic `top-14` class must
|
|
206
|
+
// not come back.
|
|
207
|
+
expect(pill!.className).not.toContain('top-14');
|
|
208
|
+
});
|
|
209
|
+
|
|
210
|
+
it('renders the plural copy when two sessions are connected', () => {
|
|
211
|
+
const { renderedText } = renderObserverPill(2, 0);
|
|
212
|
+
expect(renderedText).toBe('2 external sessions are connected to this jam');
|
|
213
|
+
});
|
|
214
|
+
|
|
215
|
+
it('adapts the top offset to the device safe-area inset', () => {
|
|
216
|
+
const { pill } = renderObserverPill(1, 59); // large status-bar inset
|
|
217
|
+
expect((pill!.style as Array<{ top?: number }>)[0].top).toBe(59 + 16);
|
|
218
|
+
});
|
|
219
|
+
});
|
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
import React, { useState } from 'react';
|
|
2
2
|
import { Pressable, Text, View } from 'react-native';
|
|
3
3
|
import { useLocalParticipant } from '@livekit/react-native';
|
|
4
|
+
import { useSafeAreaInsets } from 'react-native-safe-area-context';
|
|
4
5
|
import { ConnectionQuality } from 'livekit-client';
|
|
5
6
|
import { useTranslation } from 'react-i18next';
|
|
6
7
|
import {
|
|
7
8
|
useJamRecordingElapsed,
|
|
8
9
|
useJamRecordingState,
|
|
10
|
+
useJamExternalSessions,
|
|
9
11
|
} from '@openpeepshq/react';
|
|
10
|
-
import { CircleIcon, XIcon } from '../icons/index';
|
|
12
|
+
import { CircleIcon, EyeOnIcon, XIcon } from '../icons/index';
|
|
11
13
|
import { ThemedText } from '../ui/themed-text';
|
|
12
14
|
import { useThemeOpacity } from '../../theme/useThemeOpacity';
|
|
13
15
|
import { useConnectionQuality } from './useParticipantConnection';
|
|
@@ -41,6 +43,37 @@ export const JamRecordingIndicator = () => {
|
|
|
41
43
|
);
|
|
42
44
|
};
|
|
43
45
|
|
|
46
|
+
/**
|
|
47
|
+
* Eye pill shown to participants while hidden external sessions are
|
|
48
|
+
* connected, top-right. The jam screen has no top header, so the pill clears
|
|
49
|
+
* the safe-area top inset (notch/status bar) plus 16px of margin; toasts
|
|
50
|
+
* (rendered by the host app at the safe-area inset) then win the corner, as
|
|
51
|
+
* the transparency signal is lower priority than user feedback.
|
|
52
|
+
*/
|
|
53
|
+
export const JamObserverIndicator = () => {
|
|
54
|
+
const { t } = useTranslation();
|
|
55
|
+
const { background } = useThemeOpacity();
|
|
56
|
+
const insets = useSafeAreaInsets();
|
|
57
|
+
const sessions = useJamExternalSessions();
|
|
58
|
+
|
|
59
|
+
if (sessions <= 0) return null;
|
|
60
|
+
|
|
61
|
+
// NativeWind v4 can't apply `/N` opacity to CSS-variable colors (e.g.
|
|
62
|
+
// `bg-primary/90`), so the pill background uses an inline rgba style.
|
|
63
|
+
return (
|
|
64
|
+
<View
|
|
65
|
+
pointerEvents="none"
|
|
66
|
+
style={[{ top: insets.top + 16, right: 16 }, background('primary', 0.9)]}
|
|
67
|
+
className="z-50 flex-row items-center gap-2 rounded-full px-3 py-1"
|
|
68
|
+
>
|
|
69
|
+
<EyeOnIcon size={16} className="text-primary-foreground" />
|
|
70
|
+
<ThemedText className="text-sm font-medium text-primary-foreground">
|
|
71
|
+
{t('jams.observers.present', { count: sessions })}
|
|
72
|
+
</ThemedText>
|
|
73
|
+
</View>
|
|
74
|
+
);
|
|
75
|
+
};
|
|
76
|
+
|
|
44
77
|
/** Dismissable banner shown when the local connection quality degrades. */
|
|
45
78
|
export const JamNetworkQuality = () => {
|
|
46
79
|
const { t } = useTranslation();
|
|
@@ -107,8 +107,8 @@ export const JamVideoCall = ({
|
|
|
107
107
|
const showMicPermissionAlert = useCallback(() => {
|
|
108
108
|
showMicPermissionAlertModule(() =>
|
|
109
109
|
Alert.alert(
|
|
110
|
-
t('jams.mic.permissionTitle'),
|
|
111
|
-
t('jams.mic.permissionMessage'),
|
|
110
|
+
t('jams.device.mic.permissionTitle'),
|
|
111
|
+
t('jams.device.mic.permissionMessage'),
|
|
112
112
|
[
|
|
113
113
|
{ text: t('common.actions.cancel'), style: 'cancel' },
|
|
114
114
|
{ text: t('media.permissions.openSettings'), onPress: openSettings },
|
|
@@ -136,7 +136,7 @@ export const JamVideoCall = ({
|
|
|
136
136
|
return;
|
|
137
137
|
}
|
|
138
138
|
console.warn('[jams:mic] mic permission denied', error);
|
|
139
|
-
showMicToast(t('jams.mic.lobbyProbeFailed'));
|
|
139
|
+
showMicToast(t('jams.device.mic.lobbyProbeFailed'));
|
|
140
140
|
showMicPermissionAlert();
|
|
141
141
|
},
|
|
142
142
|
[t, showMicPermissionAlert]
|
|
@@ -153,8 +153,8 @@ export const JamVideoCall = ({
|
|
|
153
153
|
console.warn('[jams:mic] media device failure', kind, failure);
|
|
154
154
|
showMicToast(
|
|
155
155
|
failure === MediaDeviceFailure.PermissionDenied
|
|
156
|
-
? t('jams.mic.lobbyProbeFailed')
|
|
157
|
-
: t('jams.mic.enableFailed')
|
|
156
|
+
? t('jams.device.mic.lobbyProbeFailed')
|
|
157
|
+
: t('jams.device.mic.enableFailed')
|
|
158
158
|
);
|
|
159
159
|
if (failure === MediaDeviceFailure.PermissionDenied) {
|
|
160
160
|
showMicPermissionAlert();
|
|
@@ -5,12 +5,14 @@ import type { NativeStackNavigationProp } from '@react-navigation/native-stack';
|
|
|
5
5
|
import { useCurrentProfile } from '@openpeepshq/react';
|
|
6
6
|
import { goToParentOrBack } from '../navigation/parent-back';
|
|
7
7
|
import type { MainStackParamList } from '../navigation/types';
|
|
8
|
+
import { useTranslation } from 'react-i18next';
|
|
8
9
|
import { ChevronLeftIcon } from '../icons/index';
|
|
9
10
|
import { ThemedText } from '../ui/themed-text';
|
|
10
11
|
import { usePageChrome } from './pageChrome';
|
|
11
12
|
|
|
12
13
|
export const ContentHeader = () => {
|
|
13
14
|
const { header } = usePageChrome();
|
|
15
|
+
const { t } = useTranslation();
|
|
14
16
|
const navigation =
|
|
15
17
|
useNavigation<NativeStackNavigationProp<MainStackParamList>>();
|
|
16
18
|
const route = useRoute();
|
|
@@ -20,11 +22,13 @@ export const ContentHeader = () => {
|
|
|
20
22
|
const titleIsString = typeof title === 'string';
|
|
21
23
|
|
|
22
24
|
return (
|
|
23
|
-
<View className="border-border flex-row items-center justify-between border-b px-4
|
|
25
|
+
<View className="bg-background border-border h-16 flex-row items-center justify-between border-b px-4">
|
|
24
26
|
<View className="min-w-0 flex-1 flex-row items-center gap-2">
|
|
25
27
|
<Pressable
|
|
26
28
|
accessibilityRole="button"
|
|
27
|
-
accessibilityLabel=
|
|
29
|
+
accessibilityLabel={t('common.actions.back', {
|
|
30
|
+
defaultValue: 'Back',
|
|
31
|
+
})}
|
|
28
32
|
onPress={() => {
|
|
29
33
|
if (header?.onBack) {
|
|
30
34
|
header.onBack();
|
|
@@ -10,6 +10,7 @@ import { SafeAreaView } from 'react-native-safe-area-context';
|
|
|
10
10
|
import { useNavigation } from '@react-navigation/native';
|
|
11
11
|
import type { NativeStackNavigationProp } from '@react-navigation/native-stack';
|
|
12
12
|
import { useOpenpeeps } from '@openpeepshq/react';
|
|
13
|
+
import { useTranslation } from 'react-i18next';
|
|
13
14
|
import { useDrawer } from '../../contexts/drawer-context';
|
|
14
15
|
import { useWindowSize } from '../../hooks/index';
|
|
15
16
|
import { BASE_URL, isProduction } from '../../lib/constants';
|
|
@@ -19,10 +20,16 @@ import { Avatar, AvatarFallback, AvatarImage } from '../ui/avatar';
|
|
|
19
20
|
import { Button } from '../ui/button';
|
|
20
21
|
import { ThemedText } from '../ui/themed-text';
|
|
21
22
|
import { SvgImage } from '../ui/svg-image';
|
|
22
|
-
import { MessageSquareTextIcon, UserIcon } from '../icons/index';
|
|
23
|
+
import { MenuIcon, MessageSquareTextIcon, UserIcon } from '../icons/index';
|
|
23
24
|
import type { MainStackParamList } from '../navigation/types/index';
|
|
24
25
|
|
|
26
|
+
/**
|
|
27
|
+
* Mobile app bar, mirroring the web `HeaderMobile` (slim single row:
|
|
28
|
+
* avatar drawer trigger / small logo / messages shortcut, no theme
|
|
29
|
+
* background). Hidden on tablet widths, matching web's `md:hidden`.
|
|
30
|
+
*/
|
|
25
31
|
export const HeaderMobile = () => {
|
|
32
|
+
const { t } = useTranslation();
|
|
26
33
|
const { openDrawer } = useDrawer();
|
|
27
34
|
const { isMediumScreenOrLarger } = useWindowSize();
|
|
28
35
|
const { openpeepsApi, currentProfile } = useOpenpeeps();
|
|
@@ -31,6 +38,11 @@ export const HeaderMobile = () => {
|
|
|
31
38
|
const { data: serverInfo } = openpeepsApi.useServerInfo();
|
|
32
39
|
const { data: profileSettings } = openpeepsApi.useCurrentProfileSettings();
|
|
33
40
|
|
|
41
|
+
const menuLabel = t('navigation.openMenu', { defaultValue: 'Open menu' });
|
|
42
|
+
const messagesLabel = t('navigation.openMessages', {
|
|
43
|
+
defaultValue: 'Open messages',
|
|
44
|
+
});
|
|
45
|
+
|
|
34
46
|
// Mirrors web HeaderMobile: resolve branding per active theme mode. The
|
|
35
47
|
// system scheme must come from RN: getTheme's default cannot read it.
|
|
36
48
|
const systemColorScheme = useColorScheme();
|
|
@@ -39,22 +51,14 @@ export const HeaderMobile = () => {
|
|
|
39
51
|
? getTheme(serverInfo.communityConfig, profileSettings, systemScheme)
|
|
40
52
|
: undefined;
|
|
41
53
|
const logoUri = toAbsoluteMediaUrl(resolvedTheme?.logoSmall);
|
|
42
|
-
const backgroundUri = toAbsoluteMediaUrl(resolvedTheme?.background);
|
|
43
54
|
|
|
44
55
|
if (isMediumScreenOrLarger) {
|
|
45
56
|
return null;
|
|
46
57
|
}
|
|
47
58
|
|
|
48
59
|
return (
|
|
49
|
-
<View style={styles.header} className="
|
|
50
|
-
{
|
|
51
|
-
<SvgImage
|
|
52
|
-
uri={backgroundUri}
|
|
53
|
-
className="absolute inset-0"
|
|
54
|
-
resizeMode="cover"
|
|
55
|
-
/>
|
|
56
|
-
) : null}
|
|
57
|
-
<SafeAreaView edges={['top']}>
|
|
60
|
+
<View style={styles.header} className="bg-background">
|
|
61
|
+
<SafeAreaView edges={['top']} className="px-4 py-2">
|
|
58
62
|
{!isProduction && (
|
|
59
63
|
<View className="mb-2 w-full rounded-lg bg-white/50 p-2">
|
|
60
64
|
<ThemedText className="text-center text-destructive">
|
|
@@ -64,29 +68,51 @@ export const HeaderMobile = () => {
|
|
|
64
68
|
)}
|
|
65
69
|
<View className="flex-row items-center justify-between">
|
|
66
70
|
<Button
|
|
67
|
-
variant="
|
|
71
|
+
variant="ghost"
|
|
68
72
|
size="icon"
|
|
69
73
|
onPress={openDrawer}
|
|
70
|
-
|
|
74
|
+
accessibilityLabel={menuLabel}
|
|
75
|
+
className="native:px-0 active:bg-none"
|
|
71
76
|
>
|
|
72
|
-
|
|
73
|
-
{currentProfile
|
|
77
|
+
{currentProfile?.avatar ? (
|
|
78
|
+
<Avatar alt={currentProfile.displayName || 'Profile'}>
|
|
74
79
|
<AvatarImage source={{ uri: currentProfile.avatar }} />
|
|
75
|
-
|
|
76
|
-
|
|
80
|
+
</Avatar>
|
|
81
|
+
) : currentProfile ? (
|
|
82
|
+
<Avatar alt={currentProfile.displayName || 'Profile'}>
|
|
83
|
+
<AvatarFallback className="bg-muted">
|
|
77
84
|
<UserIcon size={20} className="text-muted-foreground" />
|
|
78
85
|
</AvatarFallback>
|
|
79
|
-
|
|
80
|
-
|
|
86
|
+
</Avatar>
|
|
87
|
+
) : (
|
|
88
|
+
<MenuIcon size={24} className="text-foreground" />
|
|
89
|
+
)}
|
|
81
90
|
</Button>
|
|
82
|
-
|
|
91
|
+
{logoUri ? (
|
|
92
|
+
<Button
|
|
93
|
+
variant="ghost"
|
|
94
|
+
onPress={() =>
|
|
95
|
+
navigation.navigate('TabNavigator', { screen: 'Home' })
|
|
96
|
+
}
|
|
97
|
+
accessibilityLabel={t('navigation.home', {
|
|
98
|
+
defaultValue: 'Home',
|
|
99
|
+
})}
|
|
100
|
+
// Pin the button height to the 40px icon-row (the default
|
|
101
|
+
// size variant is 48px tall on native) so the slim app bar
|
|
102
|
+
// matches web's single-row height.
|
|
103
|
+
className="native:h-10 native:px-4 active:bg-none"
|
|
104
|
+
>
|
|
105
|
+
<SvgImage uri={logoUri} className="h-6 w-36" />
|
|
106
|
+
</Button>
|
|
107
|
+
) : null}
|
|
83
108
|
<Button
|
|
84
|
-
variant="
|
|
109
|
+
variant="ghost"
|
|
85
110
|
size="icon"
|
|
86
111
|
onPress={() =>
|
|
87
112
|
navigation.navigate('TabNavigator', { screen: 'Messages' })
|
|
88
113
|
}
|
|
89
|
-
accessibilityLabel=
|
|
114
|
+
accessibilityLabel={messagesLabel}
|
|
115
|
+
className="native:px-0 active:bg-none"
|
|
90
116
|
>
|
|
91
117
|
<MessageSquareTextIcon
|
|
92
118
|
className="text-muted-foreground"
|
|
@@ -3,11 +3,6 @@ import { Pressable } from 'react-native';
|
|
|
3
3
|
import { PlusIcon } from '../icons/index';
|
|
4
4
|
import { usePageChrome } from './pageChrome';
|
|
5
5
|
|
|
6
|
-
// PlusButton is always fully round — it doesn't use the theme's buttonRadius
|
|
7
|
-
// setting (which is for regular buttons). On web, circular elements have a
|
|
8
|
-
// separate theme token; on RN we use a static 9999px (same as rounded-full).
|
|
9
|
-
const PLUS_BUTTON_RADIUS = 9999;
|
|
10
|
-
|
|
11
6
|
export const PlusButton = () => {
|
|
12
7
|
const { plus } = usePageChrome();
|
|
13
8
|
if (!plus || Array.isArray(plus)) return null;
|
|
@@ -25,8 +20,7 @@ export const PlusButton = () => {
|
|
|
25
20
|
accessibilityRole="button"
|
|
26
21
|
accessibilityLabel={plus.title || 'New'}
|
|
27
22
|
onPress={onPress}
|
|
28
|
-
|
|
29
|
-
className="bg-primary absolute bottom-10 right-6 z-20 size-16 items-center justify-center rounded-button"
|
|
23
|
+
className="bg-primary absolute bottom-10 right-6 z-20 size-16 items-center justify-center rounded-full"
|
|
30
24
|
>
|
|
31
25
|
<Icon size={24} className="text-primary-foreground" />
|
|
32
26
|
</Pressable>
|