@openpeepshq/rn-components 0.4.0 → 0.5.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openpeepshq/rn-components",
3
- "version": "0.4.0",
3
+ "version": "0.5.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",
@@ -141,7 +141,7 @@
141
141
  "validator": "^13.15.23",
142
142
  "zustand": "^5.0.3",
143
143
  "@openpeepshq/common": "^0.2.0",
144
- "@openpeepshq/react": "^0.4.0"
144
+ "@openpeepshq/react": "^0.5.0"
145
145
  },
146
146
  "devDependencies": {
147
147
  "@babel/core": "^7.26.7",
@@ -1,8 +1,15 @@
1
1
  import React from 'react';
2
- import { getGroupAvatar, type Group } from '@openpeepshq/common';
2
+ import { View, Text } from 'react-native';
3
+ import { Group, getGroupAvatar } from '@openpeepshq/common';
4
+ import {
5
+ useOpenpeeps,
6
+ getInitials,
7
+ hueFromHandle,
8
+ initialsBackground,
9
+ } from '@openpeepshq/react';
10
+ import { useOpenPeepsTheme } from '../../theme/OpenPeepsThemeProvider';
3
11
  import { Avatar, AvatarImage } from '../ui/avatar';
4
12
  import { cn } from '../../lib/utils';
5
- import { useOpenpeeps } from '@openpeepshq/react';
6
13
 
7
14
  export const GroupAvatar = ({
8
15
  group,
@@ -12,17 +19,22 @@ export const GroupAvatar = ({
12
19
  className?: string;
13
20
  }) => {
14
21
  const { openpeepsApi } = useOpenpeeps();
22
+ const { isDark } = useOpenPeepsTheme();
15
23
  const { data: server } = openpeepsApi.useServerInfo();
16
24
 
17
25
  const isSmall = className?.includes('size-8');
18
26
  const sizeClass = isSmall ? 'h-8 w-8' : 'h-16 w-16';
19
27
  const roundedClass = 'rounded-full';
20
28
 
21
- const avatarSource = {
22
- uri:
23
- (server ? getGroupAvatar(group, server.communityConfig) : group.avatar) ??
24
- undefined,
25
- };
29
+ const avatarUri =
30
+ server && group
31
+ ? getGroupAvatar(group, server.communityConfig)
32
+ : group?.avatar;
33
+
34
+ const hue = hueFromHandle(group?.handle ?? '');
35
+ const backgroundColor = avatarUri
36
+ ? undefined
37
+ : initialsBackground(hue, isDark);
26
38
 
27
39
  return (
28
40
  <Avatar
@@ -34,11 +46,28 @@ export const GroupAvatar = ({
34
46
  className
35
47
  )}
36
48
  >
37
- <AvatarImage
38
- source={avatarSource}
39
- className={cn('h-full w-full', roundedClass)}
40
- resizeMode="cover"
41
- />
49
+ {avatarUri ? (
50
+ <AvatarImage
51
+ source={{ uri: avatarUri }}
52
+ className={cn('h-full w-full', roundedClass)}
53
+ resizeMode="cover"
54
+ />
55
+ ) : (
56
+ <View
57
+ className={cn(
58
+ 'flex h-full w-full items-center justify-center',
59
+ roundedClass
60
+ )}
61
+ style={{ backgroundColor }}
62
+ >
63
+ <Text
64
+ className="text-foreground font-medium"
65
+ style={{ fontSize: isSmall ? 14 : 24 }}
66
+ >
67
+ {getInitials(group?.displayName, group?.handle)}
68
+ </Text>
69
+ </View>
70
+ )}
42
71
  </Avatar>
43
72
  );
44
73
  };
@@ -26,6 +26,7 @@ import {
26
26
  MessageSquareTextIcon,
27
27
  UsersIcon,
28
28
  ScrollTextIcon,
29
+ BellIcon,
29
30
  } from '../icons';
30
31
  import { cn } from '../../lib/utils';
31
32
  import { useWindowSize } from '../../hooks';
@@ -61,7 +62,7 @@ const TabBarIcon = ({
61
62
  case TAB_ROUTES.MESSAGES:
62
63
  return <MessageSquareTextIcon className={iconClass} size={iconSize} />;
63
64
  case TAB_ROUTES.NOTIFICATIONS:
64
- return <MessageSquareTextIcon className={iconClass} size={iconSize} />;
65
+ return <BellIcon className={iconClass} size={iconSize} />;
65
66
  case TAB_ROUTES.ARTICLES:
66
67
  return <ScrollTextIcon className={iconClass} size={iconSize} />;
67
68
  default:
@@ -81,6 +82,7 @@ export const TabNavigator = () => {
81
82
  showAdmin: false,
82
83
  }).some((item) => item.id === 'jams');
83
84
  const unseenCounts = openpeepsApi.useUnseenPostCounts();
85
+ const notificationStats = openpeepsApi.useCurrentProfileNotificationStats();
84
86
 
85
87
  const unreadGroupPosts = Object.values(
86
88
  unseenCounts.data?.groups ?? {}
@@ -88,6 +90,7 @@ export const TabNavigator = () => {
88
90
  const unreadConversationThreads = Object.keys(
89
91
  unseenCounts.data?.direct ?? {}
90
92
  ).length;
93
+ const unreadNotifications = notificationStats.data?.unseen ?? 0;
91
94
 
92
95
  const display = isMediumScreenOrLarger ? 'none' : 'flex';
93
96
  return (
@@ -137,10 +140,9 @@ export const TabNavigator = () => {
137
140
  name={TAB_ROUTES.MESSAGES}
138
141
  component={ConversationsIndex}
139
142
  options={{
140
- tabBarBadge:
141
- unreadConversationThreads > 0
142
- ? formatBadgeCount(unreadConversationThreads)
143
- : undefined,
143
+ tabBarItemStyle: {
144
+ display: 'none',
145
+ },
144
146
  }}
145
147
  />
146
148
  {jamsEnabled && (
@@ -204,9 +206,10 @@ export const TabNavigator = () => {
204
206
  name={TAB_ROUTES.NOTIFICATIONS}
205
207
  component={Notifications}
206
208
  options={{
207
- tabBarItemStyle: {
208
- display: 'none',
209
- },
209
+ tabBarBadge:
210
+ unreadNotifications > 0
211
+ ? formatBadgeCount(unreadNotifications)
212
+ : undefined,
210
213
  }}
211
214
  />
212
215
  <Tab.Screen
@@ -10,11 +10,13 @@ import { useFeedPostActions } from '@openpeepshq/react';
10
10
  interface PostActionsProps {
11
11
  post: PublicPost;
12
12
  previewMode?: boolean;
13
+ compact?: boolean;
13
14
  }
14
15
 
15
16
  export const PostActions = ({
16
17
  post,
17
18
  previewMode = false,
19
+ compact = false,
18
20
  }: PostActionsProps) => {
19
21
  const { t } = useTranslation();
20
22
  const {