@openpeepshq/rn-components 0.8.3 → 0.8.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openpeepshq/rn-components",
3
- "version": "0.8.3",
3
+ "version": "0.8.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",
@@ -143,7 +143,7 @@
143
143
  "validator": "^13.15.23",
144
144
  "zustand": "^5.0.3",
145
145
  "@openpeepshq/common": "^0.4.0",
146
- "@openpeepshq/react": "^0.8.4"
146
+ "@openpeepshq/react": "^0.8.5"
147
147
  },
148
148
  "devDependencies": {
149
149
  "@babel/core": "^7.26.7",
@@ -104,7 +104,7 @@ export const EditNotificationsSheet = forwardRef<
104
104
  };
105
105
 
106
106
  return (
107
- <BaseSheet ref={ref} key={name}>
107
+ <BaseSheet ref={ref} key={name} scrollable>
108
108
  <View className="flex-1 p-4">
109
109
  <View className="w-full">
110
110
  <ThemedText className="text-center text-xl font-semibold mb-6">
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- import { View } from 'react-native';
2
+ import { Image, View } from 'react-native';
3
3
  import type { MediaAttachmentData } from '@openpeepshq/common/types';
4
4
  import { AudioPlayer } from '../../custom/common/audio-player';
5
5
  import { ThemedText } from '../../ui/themed-text';
@@ -12,6 +12,8 @@ export const isAudioAttachment = (
12
12
 
13
13
  export interface AudioAttachmentProps {
14
14
  src?: string;
15
+ /** Waveform/thumbnail image rendered above the player when available. */
16
+ previewUrl?: string;
15
17
  label?: string;
16
18
  size?: number;
17
19
  /** Only the visible carousel item keeps its player active. */
@@ -30,6 +32,7 @@ const formatBytes = (bytes?: number): string | undefined => {
30
32
 
31
33
  export const AudioAttachment = ({
32
34
  src,
35
+ previewUrl,
33
36
  label,
34
37
  size,
35
38
  isActive = true,
@@ -39,6 +42,13 @@ export const AudioAttachment = ({
39
42
  const sizeLabel = formatBytes(size);
40
43
  return (
41
44
  <View className={cn('w-full gap-1 rounded-md bg-muted p-3', className)}>
45
+ {previewUrl ? (
46
+ <Image
47
+ source={{ uri: previewUrl }}
48
+ resizeMode="cover"
49
+ className="mb-1 h-40 w-full rounded-md"
50
+ />
51
+ ) : null}
42
52
  {label ? (
43
53
  <View className="flex-row items-center gap-2">
44
54
  <ThemedText className="flex-1 text-sm font-medium" numberOfLines={1}>
@@ -61,6 +61,7 @@ export const GalleryModal = ({
61
61
  <AudioAttachment
62
62
  key={attachment.url}
63
63
  src={attachment.url}
64
+ previewUrl={attachment.previewUrl ?? undefined}
64
65
  label={attachment.filename ?? attachment.description}
65
66
  size={attachment.meta?.size}
66
67
  />
@@ -12,6 +12,7 @@ export const GalleryAudio = ({ attachment, isActive }: GalleryAudioProps) => (
12
12
  <View className="size-full items-center justify-center rounded-none bg-muted p-4">
13
13
  <AudioAttachment
14
14
  src={attachment.url}
15
+ previewUrl={attachment.previewUrl ?? undefined}
15
16
  label={attachment.filename ?? attachment.description}
16
17
  size={attachment.meta?.size}
17
18
  isActive={isActive}
@@ -129,6 +129,7 @@ export const FullResource = ({ post }: FullResourceProps) => {
129
129
  preview={
130
130
  <AudioAttachment
131
131
  src={audioAtt.url}
132
+ previewUrl={audioAtt.previewUrl ?? undefined}
132
133
  label={audioAtt.filename ?? audioAtt.description}
133
134
  size={audioAtt.meta?.size}
134
135
  />
@@ -13,6 +13,17 @@ import { Avatar, AvatarImage } from '../ui/avatar';
13
13
  import { UserXIcon } from '../icons/index';
14
14
  import { cn } from '../../lib/utils';
15
15
 
16
+ /** Tailwind spacing unit in dp (size-N / w-N → N × 4). */
17
+ const TAILWIND_UNIT = 4;
18
+ /** Initials and deleted-icon scale with the avatar instead of preset buckets. */
19
+ const FONT_RATIO = 0.375;
20
+ const ICON_RATIO = 0.4375;
21
+
22
+ const avatarPxFromClassName = (className?: string): number => {
23
+ const match = className?.match(/(?:^|\s)(?:size-|w-)(\d+)(?=\s|$)/);
24
+ return match ? Number(match[1]) * TAILWIND_UNIT : 64;
25
+ };
26
+
16
27
  export const ProfileAvatar = ({
17
28
  profile,
18
29
  className,
@@ -23,9 +34,9 @@ export const ProfileAvatar = ({
23
34
  const { t } = useTranslation();
24
35
  const { isDark } = useOpenPeepsTheme();
25
36
 
26
- const isSmall = className?.includes('size-8');
27
- const sizeClass = isSmall ? 'h-8 w-8' : 'h-16 w-16';
28
- const iconSize = isSmall ? 16 : 28;
37
+ const px = avatarPxFromClassName(className);
38
+ const iconSize = Math.max(12, Math.round(px * ICON_RATIO));
39
+ const fontSize = Math.max(10, Math.round(px * FONT_RATIO));
29
40
  const roundedClass = 'rounded-full';
30
41
  const deleted = isDeletedProfile(profile);
31
42
 
@@ -36,16 +47,18 @@ export const ProfileAvatar = ({
36
47
  const backgroundColor =
37
48
  !deleted && !avatarSource ? initialsBackground(hue, isDark) : undefined;
38
49
 
50
+ const rootClassName = cn(
51
+ 'border border-muted-foreground overflow-hidden',
52
+ roundedClass,
53
+ className
54
+ );
55
+
39
56
  if (deleted || !avatarSource) {
40
57
  return (
41
58
  <Avatar
42
59
  alt={t('profile.header.avatarAlt')}
43
- className={cn(
44
- 'border border-muted-foreground overflow-hidden',
45
- sizeClass,
46
- roundedClass,
47
- className
48
- )}
60
+ className={rootClassName}
61
+ style={{ width: px, height: px }}
49
62
  >
50
63
  <View
51
64
  className={cn(
@@ -57,10 +70,7 @@ export const ProfileAvatar = ({
57
70
  {deleted ? (
58
71
  <UserXIcon size={iconSize} className="text-muted-foreground" />
59
72
  ) : (
60
- <Text
61
- className="text-foreground font-medium"
62
- style={{ fontSize: isSmall ? 14 : 24 }}
63
- >
73
+ <Text className="text-foreground font-medium" style={{ fontSize }}>
64
74
  {getInitials(profile?.displayName, profile?.handle)}
65
75
  </Text>
66
76
  )}
@@ -72,12 +82,8 @@ export const ProfileAvatar = ({
72
82
  return (
73
83
  <Avatar
74
84
  alt={t('profile.header.avatarAlt')}
75
- className={cn(
76
- 'border border-muted-foreground overflow-hidden',
77
- sizeClass,
78
- roundedClass,
79
- className
80
- )}
85
+ className={rootClassName}
86
+ style={{ width: px, height: px }}
81
87
  >
82
88
  <AvatarImage
83
89
  source={avatarSource}
@@ -119,6 +119,14 @@ export const ResourceCard = ({
119
119
  attachmentMediaKind(att) === 'video' ||
120
120
  attachmentMediaKind(att) === 'audio'
121
121
  );
122
+ // File resources show their filename (with extension) so users can tell
123
+ // what they're about to download; other kinds show the size.
124
+ if (resource.resourceKind === 'file') {
125
+ const size = fileAtt?.meta?.size;
126
+ const filename = fileAtt?.filename;
127
+ if (filename && size) return `${filename} · ${formatSize(size)}`;
128
+ return filename ?? (size ? formatSize(size) : null);
129
+ }
122
130
  const size = fileAtt?.meta?.size;
123
131
  if (size) return formatSize(size);
124
132
  return null;
@@ -205,7 +205,7 @@ export const ConversationShow = ({ route, navigation }: ConversationProps) => {
205
205
  <DropdownMenu>
206
206
  <KeyboardAvoidingView
207
207
  className="flex-1"
208
- behavior={Platform.OS === 'ios' ? 'padding' : undefined}
208
+ behavior={Platform.OS === 'ios' ? 'padding' : 'height'}
209
209
  keyboardVerticalOffset={Platform.OS === 'ios' ? 90 : 0}
210
210
  >
211
211
  <ScrollView