@openpeepshq/rn-components 0.12.3 → 0.12.5

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.
Files changed (40) hide show
  1. package/package.json +3 -3
  2. package/src/components/CapabilityMatrix.tsx +44 -6
  3. package/src/components/conversations/ConversationMessageBubble.tsx +3 -6
  4. package/src/components/custom/common/popover.tsx +4 -1
  5. package/src/components/custom/modals/media/document-picker-sheet.tsx +10 -3
  6. package/src/components/custom/modals/media/image-picker-sheet.test.tsx +201 -0
  7. package/src/components/custom/modals/media/image-picker-sheet.tsx +27 -17
  8. package/src/components/custom/modals/media/send-media-sheet.tsx +4 -1
  9. package/src/components/groups/GroupMembersList.test.tsx +156 -0
  10. package/src/components/groups/GroupMembersList.tsx +4 -1
  11. package/src/components/jams/JamCallParticipant.tsx +6 -1
  12. package/src/components/jams/JamDesktopFooter.tsx +6 -1
  13. package/src/components/jams/JamFooter.tsx +6 -1
  14. package/src/components/jams/JamGuestForm.tsx +6 -1
  15. package/src/components/jams/JamObserverShell.tsx +4 -1
  16. package/src/components/jams/JamRoomIndicators.test.tsx +143 -0
  17. package/src/components/jams/JamRoomIndicators.tsx +15 -8
  18. package/src/components/jams/JamToolbarButton.tsx +7 -1
  19. package/src/components/post/feed/events/EventsCalendar.tsx +6 -2
  20. package/src/components/post/pieces/EventOccurrenceList.tsx +7 -2
  21. package/src/components/post/pieces/UnreadPostIndicator.tsx +4 -4
  22. package/src/components/post/post-form/ComposeAttachments.tsx +6 -2
  23. package/src/components/post/post-form/ResourceForm.tsx +16 -16
  24. package/src/components/post/post-form/VisibilitySheet.tsx +3 -1
  25. package/src/components/post/types/event/FullEvent.test.tsx +136 -15
  26. package/src/components/post/types/event/FullEvent.tsx +21 -5
  27. package/src/components/profile/ProfileSelector.test.tsx +115 -0
  28. package/src/components/profile/ProfileSelector.tsx +2 -2
  29. package/src/components/profile/ReportProfileOrPostModal.tsx +4 -1
  30. package/src/components/resources/CategoryPathPicker.tsx +117 -0
  31. package/src/components/resources/ResourceCard.test.tsx +12 -0
  32. package/src/components/resources/ResourceCard.tsx +8 -3
  33. package/src/components/resources/ResourceLibrary.test.tsx +334 -0
  34. package/src/components/resources/ResourceLibrary.tsx +5 -5
  35. package/src/components/resources/index.ts +2 -0
  36. package/src/pages/Welcome.tsx +4 -1
  37. package/src/theme/OpenPeepsThemeProvider.tsx +6 -5
  38. package/src/theme/color.ts +29 -0
  39. package/src/theme/useThemeOpacity.ts +30 -0
  40. package/src/theme/utils.ts +11 -22
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openpeepshq/rn-components",
3
- "version": "0.12.3",
3
+ "version": "0.12.5",
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/common": "^0.6.2",
146
- "@openpeepshq/react": "^0.11.1"
145
+ "@openpeepshq/common": "^0.6.4",
146
+ "@openpeepshq/react": "^0.11.2"
147
147
  },
148
148
  "devDependencies": {
149
149
  "@babel/core": "^7.26.7",
@@ -11,6 +11,8 @@ import {
11
11
  } from '@openpeepshq/react';
12
12
  import { ThemedText } from './ui/themed-text';
13
13
  import { cn } from '../lib/utils';
14
+ import { useThemeOpacity } from '../theme/useThemeOpacity';
15
+ import type { ColorName } from '../theme/types';
14
16
 
15
17
  export interface CapabilityMatrixColumn {
16
18
  key: string;
@@ -29,14 +31,35 @@ export interface CapabilityMatrixProps {
29
31
  defaultCapabilities?: MatrixCapabilities;
30
32
  }
31
33
 
34
+ // Border color classes use solid tokens; the implicit (wildcard) states need
35
+ // a 40% border and a faint tint, which NativeWind can't express on
36
+ // CSS-variable colors, so those are built as inline styles (see
37
+ // useThemeOpacity) via `cellBorder` / `cellBackground`.
32
38
  const cellClass: Record<CapabilityCellState, string> = {
33
- 'none': 'border-border bg-background',
34
- 'implicit-remove': 'border-destructive/40 bg-destructive/15',
35
- 'implicit-add': 'border-primary/40 bg-primary/10',
36
- 'specific-add': 'border-primary bg-primary/25',
37
- 'specific-remove': 'border-destructive bg-destructive/25',
39
+ 'none': 'border-border',
40
+ 'implicit-remove': '',
41
+ 'implicit-add': '',
42
+ 'specific-add': 'border-primary',
43
+ 'specific-remove': 'border-destructive',
38
44
  };
39
45
 
46
+ const cellBorder: Record<CapabilityCellState, [ColorName, number] | null> = {
47
+ 'none': null,
48
+ 'implicit-remove': ['destructive', 0.4],
49
+ 'implicit-add': ['primary', 0.4],
50
+ 'specific-add': null,
51
+ 'specific-remove': null,
52
+ };
53
+
54
+ const cellBackground: Record<CapabilityCellState, [ColorName, number] | null> =
55
+ {
56
+ 'none': null,
57
+ 'implicit-remove': ['destructive', 0.15],
58
+ 'implicit-add': ['primary', 0.1],
59
+ 'specific-add': ['primary', 0.25],
60
+ 'specific-remove': ['destructive', 0.25],
61
+ };
62
+
40
63
  const cellTextClass: Record<CapabilityCellState, string> = {
41
64
  'none': 'text-foreground',
42
65
  'implicit-remove': 'text-destructive',
@@ -70,6 +93,7 @@ export const CapabilityMatrix = ({
70
93
  defaultCapabilities,
71
94
  }: CapabilityMatrixProps) => {
72
95
  const { t } = useTranslation();
96
+ const { background, border } = useThemeOpacity();
73
97
  const options: CapabilityMatrixOptions = {
74
98
  editorKeys,
75
99
  columns: columns.map((column) => column.key),
@@ -93,6 +117,16 @@ export const CapabilityMatrix = ({
93
117
  column,
94
118
  cap
95
119
  ) !== state;
120
+ const borderStyle = cellBorder[state]
121
+ ? border(cellBorder[state][0], cellBorder[state][1])
122
+ : undefined;
123
+ const backgroundStyle = cellBackground[state]
124
+ ? background(cellBackground[state][0], cellBackground[state][1])
125
+ : undefined;
126
+ const cellStyle =
127
+ borderStyle || backgroundStyle
128
+ ? { ...borderStyle, ...backgroundStyle }
129
+ : undefined;
96
130
  return (
97
131
  <View key={column} style={styles.cell} className="items-center p-1">
98
132
  <Pressable
@@ -101,6 +135,7 @@ export const CapabilityMatrix = ({
101
135
  onPress={() =>
102
136
  onChange(cycleCapabilityCell(options, value, column, cap))
103
137
  }
138
+ style={cellStyle}
104
139
  className={cn(
105
140
  'h-7 w-7 items-center justify-center rounded border',
106
141
  cellClass[state],
@@ -170,7 +205,10 @@ export const CapabilityMatrix = ({
170
205
  const groupLabel = group.prefix.replace(/-$/, '');
171
206
  return (
172
207
  <React.Fragment key={group.wildcard}>
173
- <View className="flex-row items-center border-t border-border bg-muted/60">
208
+ <View
209
+ style={background('muted', 0.6)}
210
+ className="flex-row items-center border-t border-border"
211
+ >
174
212
  <View style={styles.label} className="p-2">
175
213
  <ThemedText
176
214
  className="text-xs font-medium"
@@ -3,10 +3,9 @@ import { View } from 'react-native';
3
3
  import { useTranslation } from 'react-i18next';
4
4
  import type { PublicPost } from '@openpeepshq/common/types';
5
5
  import { useCurrentProfile, usePostReactionToggle } from '@openpeepshq/react';
6
- import { useOpenPeepsTheme } from '../../theme/OpenPeepsThemeProvider';
6
+ import { useThemeOpacity } from '../../theme/useThemeOpacity';
7
7
  import { FeedPostContent } from '../post/FeedPostContent';
8
8
  import { UnreadPostIndicator } from '../post/pieces/UnreadPostIndicator';
9
- import { hexWithOpacity } from '../../theme/utils';
10
9
  import { Button } from '../ui/button';
11
10
  import { ThemedText } from '../ui/themed-text';
12
11
  import { ThumbsUpIcon } from '../icons/index';
@@ -21,7 +20,7 @@ export const ConversationMessageBubble = ({
21
20
  unread = false,
22
21
  }: ConversationMessageBubbleProps) => {
23
22
  const me = useCurrentProfile();
24
- const theme = useOpenPeepsTheme();
23
+ const { background } = useThemeOpacity();
25
24
  const { t } = useTranslation();
26
25
  const mine = message.profile.id === me?.id;
27
26
  const { iReacted, canReact, toggleReaction } = usePostReactionToggle(message);
@@ -29,9 +28,7 @@ export const ConversationMessageBubble = ({
29
28
 
30
29
  // NativeWind v4 can't apply `/N` opacity to CSS-variable colors (e.g.
31
30
  // `bg-primary/10`), so we use an inline rgba style for own-message bubbles.
32
- const bubbleStyle = mine
33
- ? { backgroundColor: hexWithOpacity(theme.colors.primary, 0.1) }
34
- : undefined;
31
+ const bubbleStyle = mine ? background('primary', 0.1) : undefined;
35
32
 
36
33
  return (
37
34
  <View
@@ -13,6 +13,7 @@ import { useSafeAreaInsets } from 'react-native-safe-area-context';
13
13
  import * as Slot from '@rn-primitives/slot';
14
14
  import { cn } from '../../../lib/utils';
15
15
  import { Button, buttonVariants } from '../../ui/button';
16
+ import { useThemeOpacity } from '../../../theme/useThemeOpacity';
16
17
 
17
18
  const windowWidth = Dimensions.get('window').width;
18
19
 
@@ -150,6 +151,7 @@ const PopoverContent = React.forwardRef<
150
151
  ref
151
152
  ) => {
152
153
  const insets = useSafeAreaInsets();
154
+ const { background } = useThemeOpacity();
153
155
  const {
154
156
  triggerPosition,
155
157
  setTriggerPosition,
@@ -177,7 +179,8 @@ const PopoverContent = React.forwardRef<
177
179
  setTriggerPosition(null);
178
180
  setContentLayout(null);
179
181
  }}
180
- className={cn('flex-1 bg-background/30', overlayClass)}
182
+ style={background('background', 0.3)}
183
+ className={cn('flex-1', overlayClass)}
181
184
  >
182
185
  {!!triggerPosition && (
183
186
  <Pressable
@@ -15,6 +15,7 @@ import {
15
15
  } from '@react-native-documents/picker';
16
16
  import { viewDocument } from '@react-native-documents/viewer';
17
17
  import { formatSize, MediaAttachment } from '@openpeepshq/common';
18
+ import { useThemeOpacity } from '../../../../theme/useThemeOpacity';
18
19
  import { useOpenpeeps } from '@openpeepshq/react';
19
20
  import { Button } from '../../../ui/button';
20
21
  import {
@@ -102,6 +103,7 @@ export const DocumentPickerSheet = forwardRef<
102
103
  const [editingDocUri, setEditingDocUri] = useState<string | null>(null);
103
104
  const [isConfirmLoading, setIsConfirmLoading] = useState(false);
104
105
  const { t } = useTranslation();
106
+ const { background, text } = useThemeOpacity();
105
107
  const { openpeepsApi } = useOpenpeeps();
106
108
  const createAttachment = openpeepsApi.createMediaAttachmentAction();
107
109
 
@@ -289,7 +291,10 @@ export const DocumentPickerSheet = forwardRef<
289
291
  <Text className="text-muted-foreground text-xs">
290
292
  {formatSize(doc.size || 0)}
291
293
  </Text>
292
- <Text className="text-muted-foreground/50 text-[10px] ml-2">
294
+ <Text
295
+ style={text('muted-foreground', 0.5)}
296
+ className="text-[10px] ml-2"
297
+ >
293
298
  {descriptions[doc.uri]?.trim()
294
299
  ? t('form.uploadEditModal.description.altText')
295
300
  : t('form.uploadEditModal.description.placeholder')}
@@ -303,7 +308,8 @@ export const DocumentPickerSheet = forwardRef<
303
308
  onPress={() => handlePreview(doc)}
304
309
  accessibilityRole="button"
305
310
  accessibilityLabel={t('form.preview')}
306
- className="p-2 bg-surface/50 rounded-full"
311
+ style={background('muted', 0.5)}
312
+ className="p-2 rounded-full"
307
313
  >
308
314
  <EyeOnIcon size={16} className="text-muted-foreground" />
309
315
  </TouchableOpacity>
@@ -313,7 +319,8 @@ export const DocumentPickerSheet = forwardRef<
313
319
  accessibilityLabel={t('posts.attachments.deleteTitle', {
314
320
  defaultValue: 'Delete attachment',
315
321
  })}
316
- className="p-2 bg-surface/50 rounded-full"
322
+ style={background('muted', 0.5)}
323
+ className="p-2 rounded-full"
317
324
  >
318
325
  <XIcon size={16} className="text-muted-foreground" />
319
326
  </TouchableOpacity>
@@ -0,0 +1,201 @@
1
+ /**
2
+ * Unit tests for the ImagePickerSheet error paths (#1789).
3
+ *
4
+ * The sheet is the single gate for image picks: every library/camera pick
5
+ * must go through the cropper, a crop failure must upload nothing and show
6
+ * the form.imageInput.cropError toast (the sheet closes so the retry
7
+ * surface is clean), and a cancel must be silent.
8
+ */
9
+
10
+ const React = require('react');
11
+ const ReactTestRenderer = require('react-test-renderer');
12
+
13
+ let mockTranslations: Record<string, string> = {};
14
+
15
+ const toastShow = jest.fn();
16
+ jest.mock('react-native-toast-message', () => ({
17
+ __esModule: true,
18
+ default: { show: (options: unknown) => toastShow(options) },
19
+ }));
20
+
21
+ jest.mock('react-native', () => ({
22
+ View: (props: { children?: unknown }) =>
23
+ React.createElement('View', null, props.children),
24
+ Text: (props: { children?: unknown }) =>
25
+ React.createElement('Text', null, props.children),
26
+ ActivityIndicator: () => React.createElement('ActivityIndicator'),
27
+ Platform: { OS: 'android' },
28
+ }));
29
+
30
+ jest.mock('react-i18next', () => ({
31
+ useTranslation: () => ({
32
+ t: (key: string) => mockTranslations[key] ?? key,
33
+ }),
34
+ }));
35
+
36
+ jest.mock('@openpeepshq/react', () => ({
37
+ useOpenpeeps: () => ({
38
+ openpeepsApi: {
39
+ createMediaAttachmentAction: () => jest.fn(),
40
+ },
41
+ }),
42
+ }));
43
+
44
+ jest.mock('../../../../theme/OpenPeepsThemeProvider', () => ({
45
+ useOpenPeepsTheme: () => ({
46
+ colors: { background: '#fff', foreground: '#000' },
47
+ isDark: false,
48
+ }),
49
+ }));
50
+
51
+ jest.mock('react-native-image-crop-picker', () => ({
52
+ __esModule: true,
53
+ default: {
54
+ openCropper: jest.fn(),
55
+ openCamera: jest.fn(),
56
+ openPicker: jest.fn(),
57
+ },
58
+ }));
59
+
60
+ jest.mock('react-native-image-picker', () => ({
61
+ launchCamera: jest.fn(),
62
+ launchImageLibrary: jest.fn(),
63
+ }));
64
+
65
+ jest.mock('../../../../lib/uploadMedia', () => ({
66
+ uploadMedia: jest.fn(),
67
+ }));
68
+
69
+ jest.mock('../../../../lib/bottom-sheet-ref', () => ({
70
+ bottomSheetClose: jest.fn(),
71
+ }));
72
+
73
+ jest.mock('../../../../lib/mediaUriHelpers', () => ({
74
+ dismissSheetForNativeModal: jest.fn(async () => {}),
75
+ isPickerCancelled: (error: unknown): boolean =>
76
+ (error as { code?: string })?.code === 'E_PICKER_CANCELLED',
77
+ toCropperPath: jest.fn(async (uri: string) => uri),
78
+ }));
79
+
80
+ jest.mock('../common', () => ({
81
+ BaseSheet: (props: { children?: unknown }) =>
82
+ React.createElement('BaseSheet', null, props.children),
83
+ }));
84
+
85
+ jest.mock('../../../ui/button', () => ({
86
+ Button: (props: {
87
+ children?: unknown;
88
+ onPress?: () => void;
89
+ disabled?: boolean;
90
+ }) =>
91
+ React.createElement(
92
+ 'Button',
93
+ { onPress: props.onPress, disabled: props.disabled },
94
+ props.children
95
+ ),
96
+ }));
97
+
98
+ jest.mock('../../../icons/index', () => ({
99
+ CameraIcon: () => React.createElement('CameraIcon'),
100
+ ImageIcon: () => React.createElement('ImageIcon'),
101
+ }));
102
+
103
+ import { ImagePickerSheet } from './image-picker-sheet';
104
+
105
+ const openCropper = require('react-native-image-crop-picker').default
106
+ .openCropper;
107
+ const launchImageLibrary =
108
+ require('react-native-image-picker').launchImageLibrary;
109
+ const uploadMedia = require('../../../../lib/uploadMedia').uploadMedia;
110
+ const bottomSheetClose =
111
+ require('../../../../lib/bottom-sheet-ref').bottomSheetClose;
112
+
113
+ const renderSheet = (onSelect: (attachments: unknown[]) => void) => {
114
+ let tree!: ReturnType<typeof ReactTestRenderer.create>;
115
+ ReactTestRenderer.act(() => {
116
+ tree = ReactTestRenderer.create(
117
+ React.createElement(ImagePickerSheet, {
118
+ ref: { current: null },
119
+ onSelect,
120
+ })
121
+ );
122
+ });
123
+ return tree;
124
+ };
125
+
126
+ // The Library button is the second outline Button in the sheet. Drain the
127
+ // pick promise chain inside act so the sheet's state updates stay wrapped.
128
+ const pressLibrary = async (
129
+ tree: ReturnType<typeof ReactTestRenderer.create>
130
+ ) => {
131
+ const buttons = tree.root.findAll(
132
+ (node) =>
133
+ typeof node.type === 'string' &&
134
+ node.type === 'Button' &&
135
+ !node.props.disabled
136
+ );
137
+ await ReactTestRenderer.act(async () => {
138
+ buttons[buttons.length - 1].props.onPress();
139
+ for (let i = 0; i < 15; i++) {
140
+ await Promise.resolve();
141
+ }
142
+ });
143
+ };
144
+
145
+ describe('ImagePickerSheet error paths', () => {
146
+ beforeEach(() => {
147
+ mockTranslations = { 'form.imageInput.cropError': 'Crop failed' };
148
+ toastShow.mockClear();
149
+ uploadMedia.mockClear();
150
+ bottomSheetClose.mockClear();
151
+ openCropper.mockReset();
152
+ launchImageLibrary.mockReset();
153
+ });
154
+
155
+ it('uploads nothing, toasts, and closes the sheet on a crop failure', async () => {
156
+ launchImageLibrary.mockResolvedValue({
157
+ didCancel: false,
158
+ assets: [{ uri: 'file:///tmp/pick.jpg' }],
159
+ });
160
+ openCropper.mockRejectedValue(new Error('cropper blew up'));
161
+
162
+ const tree = renderSheet(jest.fn());
163
+ await pressLibrary(tree);
164
+
165
+ expect(uploadMedia).not.toHaveBeenCalled();
166
+ expect(toastShow).toHaveBeenCalledWith(
167
+ expect.objectContaining({ text1: 'Crop failed' })
168
+ );
169
+ expect(bottomSheetClose).toHaveBeenCalled();
170
+ });
171
+
172
+ it('stays silent on a cancelled pick', async () => {
173
+ launchImageLibrary.mockResolvedValue({ didCancel: true, assets: [] });
174
+
175
+ const tree = renderSheet(jest.fn());
176
+ await pressLibrary(tree);
177
+
178
+ expect(toastShow).not.toHaveBeenCalled();
179
+ expect(openCropper).not.toHaveBeenCalled();
180
+ expect(uploadMedia).not.toHaveBeenCalled();
181
+ });
182
+
183
+ it('resolves exactly one asset and uploads exactly one attachment', async () => {
184
+ launchImageLibrary.mockResolvedValue({
185
+ didCancel: false,
186
+ assets: [{ uri: 'file:///tmp/pick.jpg' }],
187
+ });
188
+ openCropper.mockResolvedValue({ path: '/tmp/cropped.jpg' });
189
+ uploadMedia.mockResolvedValue({ id: 'att-1', type: 'image' });
190
+ const onSelect = jest.fn();
191
+
192
+ const tree = renderSheet(onSelect);
193
+ await pressLibrary(tree);
194
+
195
+ expect(uploadMedia).toHaveBeenCalledTimes(1);
196
+ expect(onSelect).toHaveBeenCalledWith([{ id: 'att-1', type: 'image' }]);
197
+ expect(launchImageLibrary).toHaveBeenCalledWith(
198
+ expect.objectContaining({ selectionLimit: 1 })
199
+ );
200
+ });
201
+ });
@@ -38,6 +38,14 @@ export const ImagePickerSheet = forwardRef<
38
38
  const createAttachment = openpeepsApi.createMediaAttachmentAction();
39
39
  const { colors, isDark } = useOpenPeepsTheme();
40
40
 
41
+ const onCropError = (error: unknown) => {
42
+ // Never bypass the cropper with an uncropped fallback upload.
43
+ console.error('Image crop failed:', error);
44
+ Toast.show({ type: 'error', text1: t('form.imageInput.cropError') });
45
+ // Retry surface: leave nothing interactive on top of the form (#1789).
46
+ bottomSheetClose(ref);
47
+ };
48
+
41
49
  const cropImage = async (uri: string) => {
42
50
  const path = await toCropperPath(uri);
43
51
  return ImagePicker.openCropper(
@@ -99,35 +107,35 @@ export const ImagePickerSheet = forwardRef<
99
107
  } catch (error) {
100
108
  if (!isPickerCancelled(error)) {
101
109
  console.error('iOS library pick failed:', error);
110
+ onCropError(error);
102
111
  }
103
112
  }
104
113
  return;
105
114
  }
106
115
 
116
+ // Single pick (parity with web, #1789) so the cropper can be shown for
117
+ // every image, including gallery resources.
107
118
  const result = await launchImageLibrary({
108
119
  mediaType: 'photo',
109
- selectionLimit: 0,
120
+ selectionLimit: 1,
110
121
  quality: 1,
111
122
  });
112
123
  if (result.didCancel || !result.assets?.length) {
113
124
  return;
114
125
  }
115
- const uris = result.assets
116
- .map((asset) => asset.uri)
117
- .filter((uri): uri is string => Boolean(uri));
118
- if (uris.length === 1) {
119
- try {
120
- const cropped = await cropImage(uris[0]);
121
- await finalize([cropped.path]);
122
- } catch (error) {
123
- if (isPickerCancelled(error)) {
124
- return;
125
- }
126
- await finalize(uris);
127
- }
126
+ const uri = result.assets[0]?.uri;
127
+ if (!uri) {
128
128
  return;
129
129
  }
130
- await finalize(uris);
130
+ try {
131
+ const cropped = await cropImage(uri);
132
+ await finalize([cropped.path]);
133
+ } catch (error) {
134
+ if (isPickerCancelled(error)) {
135
+ return;
136
+ }
137
+ onCropError(error);
138
+ }
131
139
  };
132
140
 
133
141
  const handleCamera = async () => {
@@ -145,7 +153,9 @@ export const ImagePickerSheet = forwardRef<
145
153
  }
146
154
  const result = await launchCamera({ mediaType: 'photo', quality: 1 });
147
155
  if (result.errorCode) {
148
- Toast.show({ type: 'error', text1: t('form.imageInput.camera.error') });
156
+ // No dedicated camera key exists; reuse the cropError copy so the
157
+ // toast resolves instead of rendering a missing key (i18n scan, #1789).
158
+ Toast.show({ type: 'error', text1: t('form.imageInput.cropError') });
149
159
  return;
150
160
  }
151
161
  const uri = result.assets?.[0]?.uri;
@@ -159,7 +169,7 @@ export const ImagePickerSheet = forwardRef<
159
169
  if (isPickerCancelled(error)) {
160
170
  return;
161
171
  }
162
- await finalize([uri]);
172
+ onCropError(error);
163
173
  }
164
174
  } catch (error) {
165
175
  if (!isPickerCancelled(error)) {
@@ -14,6 +14,7 @@ import { Button } from '../../../ui/button';
14
14
  import { CameraIcon, ImageIcon } from '../../../icons/index';
15
15
  import { launchCamera, launchImageLibrary } from 'react-native-image-picker';
16
16
  import { ThemedText } from '../../../ui/themed-text';
17
+ import { useThemeOpacity } from '../../../../theme/useThemeOpacity';
17
18
  import { useNewConversationStore } from '../../../../stores/useNewConversationStore';
18
19
  import { useOpenpeeps } from '@openpeepshq/react';
19
20
  import type { MediaAttachment, PostCreationData } from '@openpeepshq/common';
@@ -58,6 +59,7 @@ export const SendMediaSheet = forwardRef<BottomSheetModal, SendMediaSheetProps>(
58
59
  });
59
60
  const [currentImageIndex, setCurrentImageIndex] = useState(0);
60
61
  const { t } = useTranslation();
62
+ const { background } = useThemeOpacity();
61
63
 
62
64
  const addImages = (uris: string[]) =>
63
65
  setSelectedImages((prev) => [
@@ -161,7 +163,8 @@ export const SendMediaSheet = forwardRef<BottomSheetModal, SendMediaSheetProps>(
161
163
  prev.filter((img) => img !== uri)
162
164
  )
163
165
  }
164
- className="absolute top-4 right-8 w-8 h-8 rounded-full bg-background/50 items-center justify-center"
166
+ style={background('background', 0.5)}
167
+ className="absolute top-4 right-8 w-8 h-8 rounded-full items-center justify-center"
165
168
  >
166
169
  <ThemedText className="text-lg">×</ThemedText>
167
170
  </TouchableOpacity>
@@ -0,0 +1,156 @@
1
+ /**
2
+ * Regression tests for the GroupMembersList row geometry (issue #1666).
3
+ *
4
+ * The member row must mirror the web list's geometry: a 48 dp avatar slot
5
+ * (`size-12`, matching web's `Avatar size={3}`) and the standard `p-4` row
6
+ * padding. A previous pass shrank the avatar to `size-10` and cut the row
7
+ * padding to `py-2 pl-4 pr-1`, which moved the avatar away from web parity
8
+ * and shrank the dropdown-menu trigger's hit target.
9
+ */
10
+
11
+ const React = require('react');
12
+ const ReactTestRenderer = require('react-test-renderer');
13
+
14
+ jest.mock('react-native', () => ({
15
+ View: (props: { children?: unknown }) =>
16
+ React.createElement('View', props, props.children),
17
+ Pressable: (props: { children?: unknown }) =>
18
+ React.createElement('Pressable', props, props.children),
19
+ ActivityIndicator: () => null,
20
+ TextInput: () => null,
21
+ }));
22
+
23
+ jest.mock('react-i18next', () => ({
24
+ useTranslation: () => ({ t: (key: string) => key }),
25
+ }));
26
+
27
+ jest.mock('@react-navigation/native', () => ({
28
+ useNavigation: () => ({ navigate: jest.fn() }),
29
+ }));
30
+
31
+ jest.mock('@openpeepshq/common/lib', () => ({
32
+ // Mirrored from platform/common/src/lib — the built package ships ESM
33
+ // which Jest's node transform doesn't cover.
34
+ canChangeMemberRole: () => false,
35
+ canRemoveMember: () => false,
36
+ matchesQuery: () => true,
37
+ sortGroupMembers: (members: unknown) => members,
38
+ truncateText: (text: string) => text,
39
+ }));
40
+
41
+ jest.mock('@openpeepshq/react', () => ({
42
+ useCurrentProfile: () => null,
43
+ useOpenpeeps: () => ({
44
+ openpeepsApi: {
45
+ useGroupMembers: () => ({ data: MEMBERS, isLoading: false }),
46
+ },
47
+ }),
48
+ }));
49
+
50
+ jest.mock('../conversations/CreateNewConversationContext', () => ({
51
+ useCreateNewConversation: () => ({ openCreateConversation: jest.fn() }),
52
+ }));
53
+
54
+ jest.mock('../icons/index', () => ({
55
+ MessageSquareTextIcon: () => React.createElement('Icon'),
56
+ MoreHorizontalIcon: () => React.createElement('Icon'),
57
+ UserCogIcon: () => React.createElement('Icon'),
58
+ UserMinusIcon: () => React.createElement('Icon'),
59
+ }));
60
+
61
+ jest.mock('../profile/Avatar', () => ({
62
+ ProfileAvatar: (props: Record<string, unknown>) =>
63
+ React.createElement('ProfileAvatar', props),
64
+ }));
65
+
66
+ jest.mock('../ui/dropdown-menu', () => ({
67
+ DropdownMenu: (props: { children?: unknown }) =>
68
+ React.createElement('DropdownMenu', null, props.children),
69
+ DropdownMenuContent: (props: { children?: unknown }) =>
70
+ React.createElement('DropdownMenuContent', null, props.children),
71
+ DropdownMenuGroup: (props: { children?: unknown }) =>
72
+ React.createElement('DropdownMenuGroup', null, props.children),
73
+ DropdownMenuItem: (props: { children?: unknown }) =>
74
+ React.createElement('DropdownMenuItem', null, props.children),
75
+ DropdownMenuTrigger: (props: { children?: unknown }) =>
76
+ React.createElement('DropdownMenuTrigger', null, props.children),
77
+ }));
78
+
79
+ jest.mock('../ui/input', () => ({ Input: () => null }));
80
+
81
+ jest.mock('../ui/themed-text', () => ({
82
+ ThemedText: (props: Record<string, unknown>) =>
83
+ React.createElement('ThemedText', props, props.children),
84
+ }));
85
+
86
+ jest.mock('../../theme/useThemeOpacity', () => ({
87
+ useThemeOpacity: () => ({
88
+ themeOpacity: 1,
89
+ setThemeOpacity: jest.fn(),
90
+ }),
91
+ }));
92
+
93
+ jest.mock('./ChangeGroupRolesModal', () => ({
94
+ ChangeGroupRolesModal: () => null,
95
+ }));
96
+
97
+ jest.mock('./ConfirmMemberRemovalModal', () => ({
98
+ ConfirmMemberRemovalModal: () => null,
99
+ }));
100
+
101
+ import type { GroupMembersListProps } from './GroupMembersList';
102
+ import { GroupMembersList } from './GroupMembersList';
103
+
104
+ const MEMBERS = [
105
+ {
106
+ profile: {
107
+ id: 'p1',
108
+ handle: 'ada.example',
109
+ displayName: 'Ada Lovelace',
110
+ },
111
+ roles: [],
112
+ },
113
+ ];
114
+
115
+ const group = {
116
+ id: 'g1',
117
+ name: 'Test Group',
118
+ } as unknown as GroupMembersListProps['group'];
119
+
120
+ const renderList = () => {
121
+ let tree: ReturnType<typeof ReactTestRenderer.create>;
122
+ ReactTestRenderer.act(() => {
123
+ tree = ReactTestRenderer.create(
124
+ React.createElement(GroupMembersList, { group })
125
+ );
126
+ });
127
+ return tree;
128
+ };
129
+
130
+ describe('GroupMembersList row geometry (issue #1666)', () => {
131
+ it('renders the member avatar at web parity (size-12 = 48 dp, web Avatar size={3})', () => {
132
+ const tree = renderList();
133
+ const avatar = tree.root
134
+ .findAllByType('ProfileAvatar')
135
+ .find(
136
+ (node: { props: { className?: string } }) =>
137
+ typeof node.props.className === 'string'
138
+ );
139
+ expect(avatar).toBeDefined();
140
+ expect(avatar.props.className).toContain('size-12');
141
+ });
142
+
143
+ it('keeps the standard p-4 row padding so the menu trigger keeps its hit target', () => {
144
+ const tree = renderList();
145
+ const rows = tree.root
146
+ .findAllByType('View')
147
+ .filter(
148
+ (node: { props: { className?: string } }) =>
149
+ typeof node.props.className === 'string' &&
150
+ node.props.className.includes('border-b')
151
+ );
152
+ expect(rows.length).toBe(1);
153
+ expect(rows[0].props.className).toContain('p-4');
154
+ expect(rows[0].props.className).not.toContain('pr-1');
155
+ });
156
+ });