@openpeepshq/rn-components 0.13.1 → 0.13.3
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/icons/index.ts +2 -0
- 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/profile/ProfileCard.test.tsx +16 -1
- package/src/components/profile/ProfileCard.tsx +14 -3
- package/src/pages/conversations/Show.tsx +21 -29
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openpeepshq/rn-components",
|
|
3
|
-
"version": "0.13.
|
|
3
|
+
"version": "0.13.3",
|
|
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.8.0",
|
|
146
|
+
"@openpeepshq/react": "^0.14.1"
|
|
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);
|
|
@@ -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>
|
|
@@ -19,6 +19,124 @@ import {
|
|
|
19
19
|
useSetPlusButtonActions,
|
|
20
20
|
} from './pageChrome';
|
|
21
21
|
|
|
22
|
+
// The two rebuilt layout components (HeaderMobile, ContentHeader) pull in
|
|
23
|
+
// navigation, i18n, drawer, window and theme hooks plus a few UI primitives.
|
|
24
|
+
// Mock that whole dependency surface so the real components can be rendered in
|
|
25
|
+
// the node test environment; the real pageChrome scaffolding above is reused
|
|
26
|
+
// (the provider is what ContentHeader reads its title / onBack from).
|
|
27
|
+
const React = require('react');
|
|
28
|
+
|
|
29
|
+
let mockServerInfo: unknown;
|
|
30
|
+
let mockTheme: unknown;
|
|
31
|
+
let mockCurrentProfile: unknown;
|
|
32
|
+
const mockNavigate = jest.fn();
|
|
33
|
+
const mockOpenDrawer = jest.fn();
|
|
34
|
+
const mockGoToParentOrBack = jest.fn();
|
|
35
|
+
const mockOnBack = jest.fn();
|
|
36
|
+
|
|
37
|
+
jest.mock('react-native', () => ({
|
|
38
|
+
Platform: { OS: 'ios' },
|
|
39
|
+
StatusBar: { currentHeight: 0 },
|
|
40
|
+
StyleSheet: { create: (s: Record<string, unknown>) => s },
|
|
41
|
+
View: (props: { children?: unknown }) =>
|
|
42
|
+
React.createElement('View', props, props.children),
|
|
43
|
+
Pressable: (props: { children?: unknown }) =>
|
|
44
|
+
React.createElement('Pressable', props, props.children),
|
|
45
|
+
useColorScheme: () => 'light',
|
|
46
|
+
}));
|
|
47
|
+
|
|
48
|
+
jest.mock('react-native-safe-area-context', () => ({
|
|
49
|
+
SafeAreaView: (props: { children?: unknown }) =>
|
|
50
|
+
React.createElement('SafeAreaView', props, props.children),
|
|
51
|
+
}));
|
|
52
|
+
|
|
53
|
+
jest.mock('@react-navigation/native', () => ({
|
|
54
|
+
useNavigation: () => ({ navigate: mockNavigate }),
|
|
55
|
+
useRoute: () => ({ name: 'Test', params: undefined }),
|
|
56
|
+
}));
|
|
57
|
+
|
|
58
|
+
jest.mock('@openpeepshq/react', () => ({
|
|
59
|
+
useOpenpeeps: () => ({
|
|
60
|
+
currentProfile: mockCurrentProfile,
|
|
61
|
+
openpeepsApi: {
|
|
62
|
+
useServerInfo: () => ({ data: mockServerInfo }),
|
|
63
|
+
useCurrentProfileSettings: () => ({ data: undefined }),
|
|
64
|
+
},
|
|
65
|
+
}),
|
|
66
|
+
useCurrentProfile: () => mockCurrentProfile,
|
|
67
|
+
}));
|
|
68
|
+
|
|
69
|
+
jest.mock('@openpeepshq/common', () => ({
|
|
70
|
+
getTheme: () => mockTheme,
|
|
71
|
+
}));
|
|
72
|
+
|
|
73
|
+
jest.mock('react-i18next', () => ({
|
|
74
|
+
useTranslation: () => ({ t: (key: string) => key }),
|
|
75
|
+
}));
|
|
76
|
+
|
|
77
|
+
jest.mock('../../contexts/drawer-context', () => ({
|
|
78
|
+
useDrawer: () => ({ openDrawer: mockOpenDrawer }),
|
|
79
|
+
}));
|
|
80
|
+
|
|
81
|
+
jest.mock('../../hooks/index', () => ({
|
|
82
|
+
useWindowSize: () => ({
|
|
83
|
+
windowWidth: 390,
|
|
84
|
+
windowHeight: 844,
|
|
85
|
+
isMediumScreenOrLarger: false,
|
|
86
|
+
}),
|
|
87
|
+
}));
|
|
88
|
+
|
|
89
|
+
jest.mock('../../lib/constants', () => ({
|
|
90
|
+
BASE_URL: 'https://example.test',
|
|
91
|
+
isProduction: true,
|
|
92
|
+
}));
|
|
93
|
+
|
|
94
|
+
jest.mock('../../lib/media-url', () => ({
|
|
95
|
+
toAbsoluteMediaUrl: (url?: string) => url,
|
|
96
|
+
}));
|
|
97
|
+
|
|
98
|
+
jest.mock('../navigation/parent-back', () => ({
|
|
99
|
+
goToParentOrBack: mockGoToParentOrBack,
|
|
100
|
+
}));
|
|
101
|
+
|
|
102
|
+
jest.mock('../ui/avatar', () => ({
|
|
103
|
+
Avatar: (props: { children?: unknown }) =>
|
|
104
|
+
React.createElement('Avatar', props, props.children),
|
|
105
|
+
AvatarFallback: (props: { children?: unknown }) =>
|
|
106
|
+
React.createElement('AvatarFallback', props, props.children),
|
|
107
|
+
AvatarImage: (props: { children?: unknown }) =>
|
|
108
|
+
React.createElement('AvatarImage', props, props.children),
|
|
109
|
+
}));
|
|
110
|
+
|
|
111
|
+
jest.mock('../ui/button', () => ({
|
|
112
|
+
Button: (props: { children?: unknown }) =>
|
|
113
|
+
React.createElement('Button', props, props.children),
|
|
114
|
+
}));
|
|
115
|
+
|
|
116
|
+
jest.mock('../ui/themed-text', () => ({
|
|
117
|
+
ThemedText: (props: { children?: unknown }) =>
|
|
118
|
+
React.createElement('ThemedText', props, props.children),
|
|
119
|
+
}));
|
|
120
|
+
|
|
121
|
+
jest.mock('../ui/svg-image', () => ({
|
|
122
|
+
SvgImage: (props: { children?: unknown }) =>
|
|
123
|
+
React.createElement('SvgImage', props, props.children),
|
|
124
|
+
}));
|
|
125
|
+
|
|
126
|
+
jest.mock('../icons/index', () => ({
|
|
127
|
+
MenuIcon: (props: Record<string, unknown>) =>
|
|
128
|
+
React.createElement('MenuIcon', props),
|
|
129
|
+
MessageSquareTextIcon: (props: Record<string, unknown>) =>
|
|
130
|
+
React.createElement('MessageSquareTextIcon', props),
|
|
131
|
+
UserIcon: (props: Record<string, unknown>) =>
|
|
132
|
+
React.createElement('UserIcon', props),
|
|
133
|
+
ChevronLeftIcon: (props: Record<string, unknown>) =>
|
|
134
|
+
React.createElement('ChevronLeftIcon', props),
|
|
135
|
+
}));
|
|
136
|
+
|
|
137
|
+
import { ContentHeader } from './ContentHeader';
|
|
138
|
+
import { HeaderMobile } from './HeaderMobile';
|
|
139
|
+
|
|
22
140
|
const MAX_RENDER_GUARD = 20;
|
|
23
141
|
|
|
24
142
|
const Text = ({ children }: { children?: ReactNode }) => (
|
|
@@ -145,3 +263,98 @@ test('page chrome hooks throw outside RootLayout', () => {
|
|
|
145
263
|
});
|
|
146
264
|
}).toThrow('Page chrome hooks must be used within RootLayout');
|
|
147
265
|
});
|
|
266
|
+
|
|
267
|
+
// The two rebuilt layout components (issue #1971). The existing tests above
|
|
268
|
+
// exercise the pageChrome context but never the components that render it;
|
|
269
|
+
// these pin their structure and navigation wiring so a regression in the
|
|
270
|
+
// consolidated chrome fails CI instead of only typechecking clean.
|
|
271
|
+
describe('rebuilt layout components (issue #1971)', () => {
|
|
272
|
+
beforeEach(() => {
|
|
273
|
+
mockNavigate.mockReset();
|
|
274
|
+
mockOpenDrawer.mockReset();
|
|
275
|
+
mockGoToParentOrBack.mockReset();
|
|
276
|
+
mockServerInfo = undefined;
|
|
277
|
+
mockTheme = undefined;
|
|
278
|
+
mockCurrentProfile = undefined;
|
|
279
|
+
});
|
|
280
|
+
|
|
281
|
+
const renderHeader = () => {
|
|
282
|
+
let tree!: ReactTestRenderer.ReactTestRenderer;
|
|
283
|
+
ReactTestRenderer.act(() => {
|
|
284
|
+
tree = ReactTestRenderer.create(<HeaderMobile />);
|
|
285
|
+
});
|
|
286
|
+
return tree;
|
|
287
|
+
};
|
|
288
|
+
|
|
289
|
+
const RegisterHeader = () => {
|
|
290
|
+
useSetPageHeader('Conversations', undefined, mockOnBack);
|
|
291
|
+
return null;
|
|
292
|
+
};
|
|
293
|
+
|
|
294
|
+
test('HeaderMobile: a guest (no current profile) renders the menu-icon trigger', () => {
|
|
295
|
+
const tree = renderHeader();
|
|
296
|
+
// currentProfile is undefined → the guest fallback MenuIcon is the drawer
|
|
297
|
+
// trigger (web renders an avatar for signed-in users, a menu icon for
|
|
298
|
+
// guests); no logo (server info / theme absent) so no navigation logo.
|
|
299
|
+
expect(tree.root.findAllByType('MenuIcon')).toHaveLength(1);
|
|
300
|
+
expect(tree.root.findAllByType('Avatar')).toHaveLength(0);
|
|
301
|
+
expect(tree.root.findAllByType('SvgImage')).toHaveLength(0);
|
|
302
|
+
// The menu trigger button carries the (mocked to its key) label.
|
|
303
|
+
const menuButtons = tree.root
|
|
304
|
+
.findAllByType('Button')
|
|
305
|
+
.filter(
|
|
306
|
+
(node: { props: Record<string, unknown> }) =>
|
|
307
|
+
node.props.accessibilityLabel === 'navigation.openMenu'
|
|
308
|
+
);
|
|
309
|
+
expect(menuButtons).toHaveLength(1);
|
|
310
|
+
tree.unmount();
|
|
311
|
+
});
|
|
312
|
+
|
|
313
|
+
test('HeaderMobile: the logo button navigates to Home (guest branch)', () => {
|
|
314
|
+
// A configured theme with a small logo renders the logo button.
|
|
315
|
+
mockServerInfo = { communityConfig: {} };
|
|
316
|
+
mockTheme = { logoSmall: '/logo.svg' };
|
|
317
|
+
const tree = renderHeader();
|
|
318
|
+
const logoButton = tree.root.find(
|
|
319
|
+
(node: { props?: Record<string, unknown> }) =>
|
|
320
|
+
node.props && node.props.accessibilityLabel === 'navigation.home'
|
|
321
|
+
);
|
|
322
|
+
expect(logoButton).toBeDefined();
|
|
323
|
+
ReactTestRenderer.act(() => {
|
|
324
|
+
logoButton.props.onPress();
|
|
325
|
+
});
|
|
326
|
+
expect(mockNavigate).toHaveBeenCalledWith('TabNavigator', {
|
|
327
|
+
screen: 'Home',
|
|
328
|
+
});
|
|
329
|
+
tree.unmount();
|
|
330
|
+
});
|
|
331
|
+
|
|
332
|
+
test('ContentHeader: renders the fixed h-16 bg-background row and the back button', () => {
|
|
333
|
+
let tree!: ReactTestRenderer.ReactTestRenderer;
|
|
334
|
+
ReactTestRenderer.act(() => {
|
|
335
|
+
tree = ReactTestRenderer.create(
|
|
336
|
+
<PageChromeProvider>
|
|
337
|
+
<ContentHeader />
|
|
338
|
+
<RegisterHeader />
|
|
339
|
+
</PageChromeProvider>
|
|
340
|
+
);
|
|
341
|
+
});
|
|
342
|
+
// The fixed-height background row renders.
|
|
343
|
+
const rows = tree.root.findAll(
|
|
344
|
+
(node: { type?: unknown; props: Record<string, unknown> }) =>
|
|
345
|
+
node.type === 'View' &&
|
|
346
|
+
node.props.className ===
|
|
347
|
+
'bg-background border-border h-16 flex-row items-center justify-between border-b px-4'
|
|
348
|
+
);
|
|
349
|
+
expect(rows).toHaveLength(1);
|
|
350
|
+
// The back button exposes the (mocked to its key) common.actions.back label.
|
|
351
|
+
const backButtons = tree.root
|
|
352
|
+
.findAllByType('Pressable')
|
|
353
|
+
.filter(
|
|
354
|
+
(node: { props: Record<string, unknown> }) =>
|
|
355
|
+
node.props.accessibilityLabel === 'common.actions.back'
|
|
356
|
+
);
|
|
357
|
+
expect(backButtons).toHaveLength(1);
|
|
358
|
+
tree.unmount();
|
|
359
|
+
});
|
|
360
|
+
});
|
|
@@ -83,13 +83,14 @@ const profile = {
|
|
|
83
83
|
bio: longBio,
|
|
84
84
|
} as unknown as ProfileCardProps['profile'];
|
|
85
85
|
|
|
86
|
-
const renderCard = () => {
|
|
86
|
+
const renderCard = (props: Partial<ProfileCardProps> = {}) => {
|
|
87
87
|
let tree: ReturnType<typeof ReactTestRenderer.create>;
|
|
88
88
|
ReactTestRenderer.act(() => {
|
|
89
89
|
tree = ReactTestRenderer.create(
|
|
90
90
|
React.createElement(ProfileCard, {
|
|
91
91
|
profile,
|
|
92
92
|
actionType: 'link' as const,
|
|
93
|
+
...props,
|
|
93
94
|
})
|
|
94
95
|
);
|
|
95
96
|
});
|
|
@@ -140,4 +141,18 @@ describe('ProfileCard layout guards (issue #2111)', () => {
|
|
|
140
141
|
// Follow/Unfollow action is rendered and not clipped away.
|
|
141
142
|
expect(tree.root.findByType('FollowUnfollowButton')).toBeDefined();
|
|
142
143
|
});
|
|
144
|
+
|
|
145
|
+
it('drops the default spacing with unspaced (issue #1971)', () => {
|
|
146
|
+
const spaced = renderCard();
|
|
147
|
+
const spacedRow = spaced.root.findByProps({
|
|
148
|
+
className: 'w-full flex-row items-center justify-between px-4 mb-8',
|
|
149
|
+
});
|
|
150
|
+
expect(spacedRow).toBeDefined();
|
|
151
|
+
|
|
152
|
+
const unspaced = renderCard({ unspaced: true });
|
|
153
|
+
const unspacedRow = unspaced.root.findByProps({
|
|
154
|
+
className: 'w-full flex-row items-center justify-between',
|
|
155
|
+
});
|
|
156
|
+
expect(unspacedRow).toBeDefined();
|
|
157
|
+
});
|
|
143
158
|
});
|
|
@@ -22,6 +22,12 @@ export interface ProfileCardProps {
|
|
|
22
22
|
actionType?: 'follow' | 'message' | 'unfollow' | 'link' | 'select';
|
|
23
23
|
handleSelectProfile?: () => void;
|
|
24
24
|
rightComponent?: React.ReactNode;
|
|
25
|
+
/**
|
|
26
|
+
* Drop the default bottom margin and horizontal padding for placements
|
|
27
|
+
* that manage their own spacing (e.g. a bordered strip), mirroring web's
|
|
28
|
+
* tight card-to-border spacing.
|
|
29
|
+
*/
|
|
30
|
+
unspaced?: boolean;
|
|
25
31
|
}
|
|
26
32
|
|
|
27
33
|
export const ProfileCard = ({
|
|
@@ -32,6 +38,7 @@ export const ProfileCard = ({
|
|
|
32
38
|
actionType = 'link',
|
|
33
39
|
handleSelectProfile,
|
|
34
40
|
rightComponent,
|
|
41
|
+
unspaced = false,
|
|
35
42
|
}: ProfileCardProps) => {
|
|
36
43
|
const navigation =
|
|
37
44
|
useNavigation<NativeStackNavigationProp<MainStackParamList>>();
|
|
@@ -59,9 +66,13 @@ export const ProfileCard = ({
|
|
|
59
66
|
|
|
60
67
|
return (
|
|
61
68
|
<View
|
|
62
|
-
className={
|
|
63
|
-
|
|
64
|
-
|
|
69
|
+
className={
|
|
70
|
+
unspaced
|
|
71
|
+
? 'w-full flex-row items-center justify-between'
|
|
72
|
+
: `w-full flex-row items-center justify-between px-4 ${
|
|
73
|
+
actionType === 'select' ? 'mb-1 py-1' : 'mb-8'
|
|
74
|
+
}`
|
|
75
|
+
}
|
|
65
76
|
>
|
|
66
77
|
<TouchableWithoutFeedback onPress={onPress}>
|
|
67
78
|
<View className="flex flex-row items-center gap-x-2 min-w-0 flex-1">
|
|
@@ -43,31 +43,7 @@ import {
|
|
|
43
43
|
DirectMessageSearch,
|
|
44
44
|
MessageInThread,
|
|
45
45
|
} from '../../components/conversations/index';
|
|
46
|
-
|
|
47
|
-
/**
|
|
48
|
-
* Shows handle + bio for a 1:1 conversation participant, without a
|
|
49
|
-
* duplicate avatar (the header already renders it).
|
|
50
|
-
*/
|
|
51
|
-
const ConversationParticipantDetail = ({
|
|
52
|
-
profile,
|
|
53
|
-
}: {
|
|
54
|
-
profile: import('@openpeepshq/common').Profile;
|
|
55
|
-
}) => {
|
|
56
|
-
const truncate = (text: string | null | undefined, max: number) =>
|
|
57
|
-
!text ? '' : text.length > max ? text.slice(0, max) + '…' : text;
|
|
58
|
-
return (
|
|
59
|
-
<View className="gap-y-1 p-3">
|
|
60
|
-
<ThemedText className="text-muted-foreground text-xs">
|
|
61
|
-
@{profile.handle}
|
|
62
|
-
</ThemedText>
|
|
63
|
-
{profile.bio ? (
|
|
64
|
-
<ThemedText className="text-sm">
|
|
65
|
-
{truncate(profile.bio, 100)}
|
|
66
|
-
</ThemedText>
|
|
67
|
-
) : null}
|
|
68
|
-
</View>
|
|
69
|
-
);
|
|
70
|
-
};
|
|
46
|
+
import { ProfileCard } from '../../components/profile/index';
|
|
71
47
|
|
|
72
48
|
const isMessageId = (value: string | undefined): value is string =>
|
|
73
49
|
!!value &&
|
|
@@ -122,6 +98,9 @@ export const ConversationShow = ({ route, navigation }: ConversationProps) => {
|
|
|
122
98
|
participants.length > 0
|
|
123
99
|
? participants.map((p) => p.displayName || `@${p.handle}`).join(', ')
|
|
124
100
|
: t('conversations.title', { defaultValue: 'Conversation' });
|
|
101
|
+
const openParticipantsLabel = t('conversations.participants.openList', {
|
|
102
|
+
defaultValue: 'View participants',
|
|
103
|
+
});
|
|
125
104
|
|
|
126
105
|
const resetForm = useCallback(() => {
|
|
127
106
|
setContent('');
|
|
@@ -210,6 +189,9 @@ export const ConversationShow = ({ route, navigation }: ConversationProps) => {
|
|
|
210
189
|
: t('conversations.search.toggle', {
|
|
211
190
|
defaultValue: 'Search this conversation',
|
|
212
191
|
});
|
|
192
|
+
const infoLabel = t('conversations.info.title', {
|
|
193
|
+
defaultValue: 'Conversation info',
|
|
194
|
+
});
|
|
213
195
|
|
|
214
196
|
useSetPageHeader(
|
|
215
197
|
isLoading ? undefined : (
|
|
@@ -237,6 +219,8 @@ export const ConversationShow = ({ route, navigation }: ConversationProps) => {
|
|
|
237
219
|
</TouchableOpacity>
|
|
238
220
|
<TouchableOpacity
|
|
239
221
|
onPress={() => navigation.navigate('ConversationInfo', { id })}
|
|
222
|
+
accessibilityRole="button"
|
|
223
|
+
accessibilityLabel={infoLabel}
|
|
240
224
|
className="rounded-md p-1.5"
|
|
241
225
|
>
|
|
242
226
|
<InfoIcon size={18} className="text-foreground" />
|
|
@@ -257,13 +241,19 @@ export const ConversationShow = ({ route, navigation }: ConversationProps) => {
|
|
|
257
241
|
<ThemedView className="flex-1">
|
|
258
242
|
<View className="flex-1">
|
|
259
243
|
{/* Section under the page header showing the participants,
|
|
260
|
-
mirroring the web conversation Show page. */}
|
|
261
|
-
<View className="border-b border-border">
|
|
244
|
+
mirroring the web conversation Show page (ProfileCard for 1:1). */}
|
|
245
|
+
<View className="border-b border-border p-4">
|
|
262
246
|
{participants.length === 1 && participants[0] ? (
|
|
263
|
-
<
|
|
247
|
+
<ProfileCard
|
|
248
|
+
profile={participants[0]}
|
|
249
|
+
showAction={false}
|
|
250
|
+
unspaced
|
|
251
|
+
/>
|
|
264
252
|
) : multipleParticipants ? (
|
|
265
253
|
<TouchableOpacity
|
|
266
254
|
onPress={() => setParticipantsOpen(true)}
|
|
255
|
+
accessibilityRole="button"
|
|
256
|
+
accessibilityLabel={openParticipantsLabel}
|
|
267
257
|
className="w-full flex-row items-center gap-2 p-3"
|
|
268
258
|
>
|
|
269
259
|
<View className="flex-row -space-x-2 shrink-0">
|
|
@@ -289,7 +279,9 @@ export const ConversationShow = ({ route, navigation }: ConversationProps) => {
|
|
|
289
279
|
<KeyboardAvoidingView
|
|
290
280
|
className="flex-1"
|
|
291
281
|
behavior={Platform.OS === 'ios' ? 'padding' : 'height'}
|
|
292
|
-
|
|
282
|
+
// iOS: total chrome above the composer (app bar row + h-16
|
|
283
|
+
// content header); re-measure when the shell chrome changes.
|
|
284
|
+
keyboardVerticalOffset={Platform.OS === 'ios' ? 74 : 0}
|
|
293
285
|
>
|
|
294
286
|
{searchOpen ? (
|
|
295
287
|
<View nativeID="conversation-message-search">
|