@openpeepshq/rn-components 0.3.9 → 0.3.12

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 (94) hide show
  1. package/package.json +3 -3
  2. package/src/components/conversations/ConversationMessageBubble.tsx +1 -1
  3. package/src/components/custom/common/index.ts +0 -1
  4. package/src/components/custom/index.ts +0 -1
  5. package/src/components/custom/navigation/side-menu.tsx +2 -2
  6. package/src/components/groups/GroupOptionsMenu.tsx +13 -5
  7. package/src/components/index.ts +1 -0
  8. package/src/components/jams/CreateNewJam.tsx +11 -10
  9. package/src/components/jams/JamActionsFooter.tsx +37 -51
  10. package/src/components/jams/JamCard.tsx +5 -5
  11. package/src/components/jams/JamLobby.tsx +2 -1
  12. package/src/components/layout/AuthLayout.tsx +120 -0
  13. package/src/components/layout/ContentHeader.tsx +62 -0
  14. package/src/components/layout/HeaderActionButton.tsx +23 -0
  15. package/src/components/layout/HeaderMobile.tsx +96 -0
  16. package/src/components/layout/PlusButton.tsx +26 -0
  17. package/src/components/layout/RootLayout.tsx +30 -0
  18. package/src/components/layout/index.ts +13 -0
  19. package/src/components/layout/pageChrome.tsx +75 -0
  20. package/src/components/navigation/auth-navigator.tsx +2 -2
  21. package/src/components/navigation/main-navigator.tsx +17 -1
  22. package/src/components/navigation/parent-back.ts +139 -0
  23. package/src/components/navigation/tab-navigator.tsx +2 -0
  24. package/src/components/notifications/types/JamStarted.tsx +8 -6
  25. package/src/components/notifications/types/Reply.tsx +7 -10
  26. package/src/components/post/NewEventButton.tsx +23 -16
  27. package/src/components/post/NewNoteButton.tsx +15 -13
  28. package/src/components/post/pieces/EventRsvpButton.tsx +22 -18
  29. package/src/components/post/pieces/ParticipantsCard.tsx +4 -20
  30. package/src/components/post/types/Article.tsx +3 -1
  31. package/src/components/post/types/event/CardEvent.tsx +1 -1
  32. package/src/components/post/types/event/FullEvent.tsx +156 -37
  33. package/src/components/profile/ProfileCard.tsx +9 -2
  34. package/src/components/profile/ProfileFromId.tsx +1 -1
  35. package/src/components/ui/button.tsx +1 -1
  36. package/src/pages/About.tsx +3 -5
  37. package/src/pages/CodeOfConduct.tsx +7 -7
  38. package/src/pages/Explore.tsx +87 -127
  39. package/src/pages/Members.tsx +31 -39
  40. package/src/pages/Notifications.tsx +6 -13
  41. package/src/pages/PostDetail.tsx +22 -16
  42. package/src/pages/Profile.tsx +3 -2
  43. package/src/pages/Tags.tsx +72 -13
  44. package/src/pages/Welcome.tsx +3 -8
  45. package/src/pages/articles/Edit.tsx +18 -15
  46. package/src/pages/articles/Index.tsx +11 -21
  47. package/src/pages/articles/New.tsx +18 -15
  48. package/src/pages/conversations/Index.tsx +44 -68
  49. package/src/pages/conversations/Info.tsx +6 -5
  50. package/src/pages/conversations/New.tsx +14 -13
  51. package/src/pages/conversations/NewDraft.tsx +5 -5
  52. package/src/pages/conversations/Show.tsx +24 -22
  53. package/src/pages/events/Edit.tsx +14 -13
  54. package/src/pages/events/Index.tsx +28 -32
  55. package/src/pages/events/My.tsx +7 -7
  56. package/src/pages/events/New.tsx +14 -13
  57. package/src/pages/feeds/Bookmarks.tsx +3 -9
  58. package/src/pages/feeds/Local.tsx +3 -10
  59. package/src/pages/feeds/My.tsx +3 -9
  60. package/src/pages/groups/Edit.tsx +6 -7
  61. package/src/pages/groups/EditInfo.tsx +20 -17
  62. package/src/pages/groups/EditRoles.tsx +18 -19
  63. package/src/pages/groups/Index.tsx +82 -119
  64. package/src/pages/groups/Info.tsx +22 -23
  65. package/src/pages/groups/Members.tsx +9 -8
  66. package/src/pages/groups/New.tsx +18 -15
  67. package/src/pages/groups/Show.tsx +6 -5
  68. package/src/pages/jams/Index.tsx +8 -26
  69. package/src/pages/jams/New.tsx +14 -11
  70. package/src/pages/posts/Edit.tsx +20 -17
  71. package/src/pages/posts/New.tsx +30 -29
  72. package/src/pages/posts/Reply.tsx +20 -16
  73. package/src/pages/profile/Followers.tsx +9 -10
  74. package/src/pages/profile/Following.tsx +9 -10
  75. package/src/pages/settings/AccessTokens.tsx +6 -5
  76. package/src/pages/settings/Account.tsx +13 -12
  77. package/src/pages/settings/Blocked.tsx +5 -5
  78. package/src/pages/settings/Feed.tsx +13 -12
  79. package/src/pages/settings/Index.tsx +3 -11
  80. package/src/pages/settings/Language.tsx +36 -37
  81. package/src/pages/settings/NotificationPreferences.tsx +10 -12
  82. package/src/pages/settings/Notifications.tsx +10 -9
  83. package/src/pages/settings/PublicProfile.tsx +6 -6
  84. package/src/pages/settings/PushEnabledDevices.tsx +10 -9
  85. package/src/pages/settings/Theme.tsx +13 -12
  86. package/src/pages/settings/Timezone.tsx +27 -28
  87. package/src/theme/OpenPeepsThemeProvider.tsx +23 -12
  88. package/src/theme/utils.ts +10 -5
  89. package/tailwind.config.js +6 -0
  90. package/src/components/custom/common/plus-fab.tsx +0 -23
  91. package/src/components/custom/headers/generic-header.tsx +0 -88
  92. package/src/components/custom/headers/index.ts +0 -2
  93. package/src/components/custom/headers/tab-screens-header.tsx +0 -199
  94. package/src/components/navigation/auth-wrapper.tsx +0 -107
@@ -1,10 +1,10 @@
1
1
  import React from 'react';
2
2
  import { View } from 'react-native';
3
3
  import { useTranslation } from 'react-i18next';
4
- import { GenericHeader } from '../../components/custom/index';
4
+ import { useSetPageHeader } from '../../components/layout';
5
5
  import { ConfigMenuButton } from '../../components/configuration/index';
6
6
  import { MainScreenProps } from '../../components/navigation/types/index';
7
- import { ThemedSafeAreaView } from '../../components/ui/themed-safe-area-view';
7
+ import { ThemedView } from '../../components/ui/themed-view';
8
8
 
9
9
  type NotificationSettingsProps = MainScreenProps<'NotificationSettings'>;
10
10
 
@@ -13,13 +13,14 @@ export const NotificationSettings: React.FC<NotificationSettingsProps> = ({
13
13
  }) => {
14
14
  const { t } = useTranslation();
15
15
 
16
+ useSetPageHeader(
17
+ t('settings.notifications.title', {
18
+ defaultValue: 'Notifications',
19
+ })
20
+ );
21
+
16
22
  return (
17
- <ThemedSafeAreaView className="flex-1">
18
- <GenericHeader
19
- title={t('settings.notifications.title', {
20
- defaultValue: 'Notifications',
21
- })}
22
- />
23
+ <ThemedView className="flex-1">
23
24
  <View className="p-4">
24
25
  <ConfigMenuButton
25
26
  translationPrefix="settings.notifications.preferences"
@@ -30,6 +31,6 @@ export const NotificationSettings: React.FC<NotificationSettingsProps> = ({
30
31
  onPress={() => navigation.navigate('PushEnabledDevices')}
31
32
  />
32
33
  </View>
33
- </ThemedSafeAreaView>
34
+ </ThemedView>
34
35
  );
35
36
  };
@@ -1,9 +1,8 @@
1
1
  import React from 'react';
2
2
  import { MainScreenProps } from '../../components/navigation/types/index';
3
3
  import { useOpenpeeps } from '@openpeepshq/react';
4
- import { GenericHeader } from '../../components/custom/index';
5
-
6
- import { ThemedSafeAreaView } from '../../components/ui/themed-safe-area-view';
4
+ import { useSetPageHeader } from '../../components/layout';
5
+ import { ThemedView } from '../../components/ui/themed-view';
7
6
 
8
7
  import { EditProfileForm } from '../../components/profile/index';
9
8
  type EditProfileProps = MainScreenProps<'EditProfile'>;
@@ -11,10 +10,11 @@ type EditProfileProps = MainScreenProps<'EditProfile'>;
11
10
  export const PublicProfileSettings: React.FC<EditProfileProps> = () => {
12
11
  const { currentProfile } = useOpenpeeps();
13
12
 
13
+ useSetPageHeader('Edit Profile');
14
+
14
15
  return (
15
- <ThemedSafeAreaView className="flex-1">
16
- <GenericHeader title="Edit Profile" />
16
+ <ThemedView className="flex-1">
17
17
  <EditProfileForm handle={currentProfile?.handle as string} />
18
- </ThemedSafeAreaView>
18
+ </ThemedView>
19
19
  );
20
20
  };
@@ -9,7 +9,7 @@ import {
9
9
  pushSubscriptionIsMobile,
10
10
  } from '@openpeepshq/common/lib';
11
11
  import { usePushEnabledDevices } from '@openpeepshq/react';
12
- import { GenericHeader } from '../../components/custom/index';
12
+ import { useSetPageHeader } from '../../components/layout';
13
13
  import {
14
14
  LaptopIcon,
15
15
  SmartphoneIcon,
@@ -18,8 +18,8 @@ import {
18
18
  import { MainScreenProps } from '../../components/navigation/types/index';
19
19
  import { Button } from '../../components/ui/button';
20
20
  import { Text } from '../../components/ui/text';
21
- import { ThemedSafeAreaView } from '../../components/ui/themed-safe-area-view';
22
21
  import { ThemedText } from '../../components/ui/themed-text';
22
+ import { ThemedView } from '../../components/ui/themed-view';
23
23
 
24
24
  type PushEnabledDevicesProps = MainScreenProps<'PushEnabledDevices'>;
25
25
 
@@ -45,13 +45,14 @@ export const PushEnabledDevices: React.FC<PushEnabledDevicesProps> = () => {
45
45
  clearStatus();
46
46
  }, [status, clearStatus]);
47
47
 
48
+ useSetPageHeader(
49
+ t('settings.notifications.pushEnabledDevices.title', {
50
+ defaultValue: 'Push-enabled devices',
51
+ })
52
+ );
53
+
48
54
  return (
49
- <ThemedSafeAreaView className="flex-1">
50
- <GenericHeader
51
- title={t('settings.notifications.pushEnabledDevices.title', {
52
- defaultValue: 'Push-enabled devices',
53
- })}
54
- />
55
+ <ThemedView className="flex-1">
55
56
  <ScrollView contentContainerClassName="p-4">
56
57
  {subscriptions.length === 0 ? (
57
58
  <View className="w-full items-center justify-center p-4">
@@ -145,6 +146,6 @@ export const PushEnabledDevices: React.FC<PushEnabledDevicesProps> = () => {
145
146
  </View>
146
147
  )}
147
148
  </ScrollView>
148
- </ThemedSafeAreaView>
149
+ </ThemedView>
149
150
  );
150
151
  };
@@ -1,6 +1,6 @@
1
1
  import { MainScreenProps } from '../../components/navigation/types/index';
2
2
  import { useServerInfo, useThemePreference } from '@openpeepshq/react';
3
- import { GenericHeader } from '../../components/custom/index';
3
+ import { HeaderActionButton, useSetPageHeader } from '../../components/layout';
4
4
  import React from 'react';
5
5
  import { ThemedText } from '../../components/ui/themed-text';
6
6
  import { ThemedView } from '../../components/ui/themed-view';
@@ -8,7 +8,6 @@ import Toast from 'react-native-toast-message';
8
8
  import { KeyboardAwareScrollView } from 'react-native-keyboard-aware-scroll-view';
9
9
  import { Pressable } from 'react-native';
10
10
  import { useTranslation } from 'react-i18next';
11
- import { ThemedSafeAreaView } from '../../components/ui/themed-safe-area-view';
12
11
  import { RadioGroup, RadioGroupItem } from '../../components/ui/radio-group';
13
12
  import { getTheme, THEME_OPTIONS } from '@openpeepshq/common';
14
13
  import { useOpenPeepsTheme } from '../../theme/OpenPeepsThemeProvider';
@@ -56,16 +55,18 @@ export const ThemeSettings: React.FC<ThemeSettingsProps> = ({}) => {
56
55
  }
57
56
  };
58
57
 
58
+ useSetPageHeader(
59
+ t('settings.theme.title'),
60
+ <HeaderActionButton
61
+ title={submitting ? t('common.form.loading') : t('common.form.save')}
62
+ onPress={() => void handleSubmit()}
63
+ disabled={submitting}
64
+ loading={submitting}
65
+ />
66
+ );
67
+
59
68
  return (
60
- <ThemedSafeAreaView className="flex-1">
61
- <GenericHeader
62
- title={t('settings.theme.title')}
63
- rightButtonTitle={
64
- submitting ? t('common.form.loading') : t('common.form.save')
65
- }
66
- onRightButtonPress={handleSubmit}
67
- rightButtonDisabled={submitting}
68
- />
69
+ <ThemedView className="flex-1">
69
70
  <ThemedView className="flex-1">
70
71
  <KeyboardAwareScrollView
71
72
  contentContainerClassName="grow"
@@ -96,6 +97,6 @@ export const ThemeSettings: React.FC<ThemeSettingsProps> = ({}) => {
96
97
  </ThemedView>
97
98
  </KeyboardAwareScrollView>
98
99
  </ThemedView>
99
- </ThemedSafeAreaView>
100
+ </ThemedView>
100
101
  );
101
102
  };
@@ -4,10 +4,9 @@ import { useTranslation } from 'react-i18next';
4
4
  import Toast from 'react-native-toast-message';
5
5
  import { BottomSheetModal } from '@gorhom/bottom-sheet';
6
6
  import { useTimezonePreference } from '@openpeepshq/react';
7
- import { GenericHeader } from '../../components/custom/index';
7
+ import { HeaderActionButton, useSetPageHeader } from '../../components/layout';
8
8
  import { TimeZoneSelect } from '../../components/form/index';
9
9
  import { MainScreenProps } from '../../components/navigation/types/index';
10
- import { ThemedSafeAreaView } from '../../components/ui/themed-safe-area-view';
11
10
  import { ThemedText } from '../../components/ui/themed-text';
12
11
  import { ThemedView } from '../../components/ui/themed-view';
13
12
  import { ChevronRightIcon } from '../../components/icons/index';
@@ -35,42 +34,42 @@ export const TimezoneSettings: React.FC<TimezoneSettingsProps> = () => {
35
34
  clearStatus();
36
35
  }, [status, clearStatus]);
37
36
 
38
- if (!profile) return null;
39
-
40
37
  const label =
41
38
  timeZone === communityDefaultTimeZone
42
39
  ? `${timeZone} ${t('settings.timezone.communityDefault')}`
43
40
  : timeZone;
44
41
 
42
+ useSetPageHeader(
43
+ t('settings.timezone.title'),
44
+ <HeaderActionButton
45
+ title={saving ? t('common.form.loading') : t('common.form.save')}
46
+ onPress={() => void save()}
47
+ disabled={saving}
48
+ loading={saving}
49
+ />
50
+ );
51
+
52
+ if (!profile) return null;
53
+
45
54
  return (
46
- <ThemedSafeAreaView className="flex-1">
47
- <GenericHeader
48
- title={t('settings.timezone.title')}
49
- rightButtonTitle={
50
- saving ? t('common.form.loading') : t('common.form.save')
51
- }
52
- onRightButtonPress={() => void save()}
53
- rightButtonDisabled={saving}
54
- />
55
- <ThemedView className="flex-1 p-4">
56
- <ThemedText className="text-lg text-muted-foreground mb-4">
57
- {t('settings.timezone.timezoneDescription')}
58
- </ThemedText>
59
- <Pressable
60
- onPress={() => bottomSheetPresent(sheetRef)}
61
- className="py-3 flex-row justify-between items-center border-b border-border"
62
- >
63
- <View className="flex-1">
64
- <ThemedText className="text-lg">{label}</ThemedText>
65
- </View>
66
- <ChevronRightIcon className="text-foreground" />
67
- </Pressable>
68
- </ThemedView>
55
+ <ThemedView className="flex-1 p-4">
56
+ <ThemedText className="mb-4 text-lg text-muted-foreground">
57
+ {t('settings.timezone.timezoneDescription')}
58
+ </ThemedText>
59
+ <Pressable
60
+ onPress={() => bottomSheetPresent(sheetRef)}
61
+ className="flex-row items-center justify-between border-b border-border py-3"
62
+ >
63
+ <View className="flex-1">
64
+ <ThemedText className="text-lg">{label}</ThemedText>
65
+ </View>
66
+ <ChevronRightIcon className="text-foreground" />
67
+ </Pressable>
69
68
  <TimeZoneSelect
70
69
  ref={sheetRef}
71
70
  initialTimeZone={timeZone}
72
71
  onDone={(next) => next && setTimeZone(next)}
73
72
  />
74
- </ThemedSafeAreaView>
73
+ </ThemedView>
75
74
  );
76
75
  };
@@ -21,28 +21,39 @@ export const OpenPeepsThemeProvider = ({
21
21
  const { data: profileSettings, refetch: refetchProfileSettings } =
22
22
  openpeepsApi.useCurrentProfileSettings();
23
23
 
24
- const theme = useMemo(() => {
24
+ const resolvedTheme = useMemo(() => {
25
25
  const schemeForTheme =
26
26
  systemColorScheme === 'dark' || systemColorScheme === 'light'
27
27
  ? systemColorScheme
28
28
  : undefined;
29
- const userTheme = getTheme(
29
+ return getTheme(
30
30
  serverInfo?.communityConfig ??
31
31
  ({ theme: { base: 'OpenpeepsDark' } } as CommunityConfig),
32
32
  profileSettings,
33
33
  schemeForTheme ?? 'light'
34
34
  );
35
- return buildTheme(userTheme.dark, userTheme.primaryHex, () => {
36
- refetchProfileSettings();
37
- });
38
- }, [
39
- profileSettings,
40
- refetchProfileSettings,
41
- serverInfo?.communityConfig,
42
- systemColorScheme,
43
- ]);
35
+ }, [profileSettings, serverInfo?.communityConfig, systemColorScheme]);
44
36
 
45
- const themeVars = useMemo(() => getThemeVars(theme.colors), [theme.colors]);
37
+ const theme = useMemo(
38
+ () =>
39
+ buildTheme(resolvedTheme.dark, resolvedTheme.primaryHex, () => {
40
+ refetchProfileSettings();
41
+ }),
42
+ [refetchProfileSettings, resolvedTheme.dark, resolvedTheme.primaryHex]
43
+ );
44
+
45
+ const themeVars = useMemo(
46
+ () =>
47
+ getThemeVars(theme.colors, {
48
+ buttonRadius: resolvedTheme.buttonRadius,
49
+ radius: resolvedTheme.radius,
50
+ }),
51
+ [
52
+ resolvedTheme.buttonRadius,
53
+ resolvedTheme.radius,
54
+ theme.colors,
55
+ ]
56
+ );
46
57
 
47
58
  useEffect(() => {
48
59
  // nativewind maps colorScheme.set('system') to Appearance.setColorScheme(null),
@@ -2,12 +2,17 @@ import { vars } from 'nativewind';
2
2
  import { mapColors } from './defaults';
3
3
  import type { OpenPeepsTheme } from './types';
4
4
 
5
- export const getThemeVars = (colors: OpenPeepsTheme['colors']) =>
6
- vars(
7
- Object.fromEntries(
5
+ export const getThemeVars = (
6
+ colors: OpenPeepsTheme['colors'],
7
+ radii?: { buttonRadius?: string; radius?: string }
8
+ ) =>
9
+ vars({
10
+ ...Object.fromEntries(
8
11
  Object.entries(colors).map(([key, value]) => [`--${key}`, value])
9
- )
10
- );
12
+ ),
13
+ '--theme-rounded-base': radii?.buttonRadius || '9999px',
14
+ '--theme-rounded-container': radii?.radius || '0.5rem',
15
+ });
11
16
 
12
17
  export const buildTheme = (
13
18
  isDark: boolean,
@@ -47,6 +47,12 @@ export default {
47
47
  borderWidth: {
48
48
  hairline: hairlineWidth(),
49
49
  },
50
+ borderRadius: {
51
+ button: 'var(--theme-rounded-base)',
52
+ lg: 'var(--theme-rounded-container, 0.5rem)',
53
+ md: 'calc(var(--theme-rounded-container, 0.5rem) - 2px)',
54
+ sm: 'calc(var(--theme-rounded-container, 0.5rem) - 4px)',
55
+ },
50
56
  },
51
57
  },
52
58
  plugins: [require('tailwindcss-animate')],
@@ -1,23 +0,0 @@
1
- import React, { type ReactNode } from 'react';
2
- import { Pressable } from 'react-native';
3
-
4
- interface PlusFabProps {
5
- accessibilityLabel: string;
6
- onPress: () => void;
7
- children: ReactNode;
8
- }
9
-
10
- export const PlusFab = ({
11
- accessibilityLabel,
12
- onPress,
13
- children,
14
- }: PlusFabProps) => (
15
- <Pressable
16
- accessibilityRole="button"
17
- accessibilityLabel={accessibilityLabel}
18
- onPress={onPress}
19
- className="absolute bottom-10 right-6 z-20 size-16 items-center justify-center rounded-full bg-foreground"
20
- >
21
- {children}
22
- </Pressable>
23
- );
@@ -1,88 +0,0 @@
1
- import { View, Pressable, ActivityIndicator } from 'react-native';
2
- import React from 'react';
3
- import { Button } from '../../ui/button';
4
- import { ArrowLeftIcon } from '../../icons/index';
5
- import { ThemedText } from '../../ui/themed-text';
6
- import { useNavigation } from '@react-navigation/native';
7
-
8
- interface GenericHeaderProps {
9
- title?: string | React.ReactNode;
10
- handleGoBack?: () => void;
11
- onRightButtonPress?: () => void;
12
- rightType?: 'button' | 'icon' | 'string';
13
- rightButtonTitle?: string;
14
- rightButtonDisabled?: boolean;
15
- rightButtonLoading?: boolean;
16
- rightButtonIcon?: React.ReactNode;
17
- rightButtonVariant?: 'primary' | 'secondary' | 'outline';
18
- hideBackButton?: boolean;
19
- /** Arbitrary right-side content, e.g. a page-specific action button. */
20
- rightElement?: React.ReactNode;
21
- }
22
- export const GenericHeader = ({
23
- title,
24
- onRightButtonPress,
25
- rightButtonTitle,
26
- rightButtonDisabled,
27
- rightButtonLoading,
28
- rightType = 'button',
29
- rightButtonIcon,
30
- handleGoBack,
31
- hideBackButton = false,
32
- rightElement,
33
- }: GenericHeaderProps) => {
34
- const navigation = useNavigation();
35
- return (
36
- <View className="sticky top-0 z-20 w-full px-4 py-2 flex flex-row justify-between items-center">
37
- <View className="flex gap-4 mb-2 flex-row items-center">
38
- {!hideBackButton && (
39
- <Button
40
- size="icon"
41
- onPress={() =>
42
- handleGoBack ? handleGoBack() : navigation.goBack()
43
- }
44
- variant="outline"
45
- className="w-12 h-10"
46
- >
47
- <ArrowLeftIcon className="text-foreground" />
48
- </Button>
49
- )}
50
- {typeof title === 'string' ? (
51
- <ThemedText className="text-xl tracking-wider font-semibold">
52
- {title}
53
- </ThemedText>
54
- ) : (
55
- <>{title}</>
56
- )}
57
- </View>
58
- {rightButtonTitle && rightType === 'button' && (
59
- <Button disabled={rightButtonDisabled} onPress={onRightButtonPress}>
60
- {rightButtonLoading && <ActivityIndicator size={'small'} />}
61
-
62
- <ThemedText className="text-base font-semibold">
63
- {rightButtonTitle}
64
- </ThemedText>
65
- </Button>
66
- )}
67
- {rightButtonTitle && rightType === 'string' && (
68
- <Pressable
69
- disabled={rightButtonDisabled}
70
- className="px-4 py-2 border rounded-lg"
71
- onPress={onRightButtonPress}
72
- >
73
- {rightButtonLoading && <ActivityIndicator size={'small'} />}
74
- <ThemedText className="text-base font-semibold">
75
- {rightButtonTitle}
76
- </ThemedText>
77
- </Pressable>
78
- )}
79
-
80
- {rightButtonIcon && rightType === 'icon' && (
81
- <Pressable disabled={rightButtonDisabled} onPress={onRightButtonPress}>
82
- {rightButtonIcon}
83
- </Pressable>
84
- )}
85
- {rightElement}
86
- </View>
87
- );
88
- };
@@ -1,2 +0,0 @@
1
- export * from './generic-header';
2
- export * from './tab-screens-header';
@@ -1,199 +0,0 @@
1
- import React from 'react';
2
- import {
3
- Image,
4
- View,
5
- ImageBackground,
6
- StatusBar,
7
- Platform,
8
- StyleSheet,
9
- } from 'react-native';
10
-
11
- import { ThemedText } from '../../ui/themed-text';
12
- import { Avatar, AvatarImage, AvatarFallback } from '../../ui/avatar';
13
- import { Button } from '../../ui/button';
14
- import { BellIcon, UserIcon } from '../../icons/index';
15
- import { useDrawer } from '../../../contexts/drawer-context';
16
- import { formatBadgeCount } from '@openpeepshq/common';
17
- import { useOpenpeeps } from '@openpeepshq/react';
18
- import {
19
- useNavigation,
20
- useFocusEffect,
21
- useNavigationState,
22
- } from '@react-navigation/native';
23
- import { NativeStackNavigationProp } from '@react-navigation/native-stack';
24
- import { useAppImagesStore } from '../../../stores/useAppImagesStore';
25
- import { SafeAreaView } from 'react-native-safe-area-context';
26
- import { BASE_URL, isProduction } from '../../../lib/constants';
27
- import { useWindowSize } from '../../../hooks/index';
28
- import { ThemedSafeAreaView } from '../../ui/themed-safe-area-view';
29
- import { TabStackParamList, TAB_ROUTES } from '../../navigation/types/index';
30
- import { setAppBadgeCount } from '../../../lib/notification-helpers';
31
-
32
- interface TabScreensHeaderProps {
33
- showIcons?: boolean;
34
- showVerification?: boolean;
35
- children?: React.ReactNode;
36
- }
37
-
38
- export const TabScreensHeader = ({
39
- showIcons = true,
40
- showVerification = false,
41
- children,
42
- }: TabScreensHeaderProps) => {
43
- const { openDrawer } = useDrawer();
44
-
45
- const { isMediumScreenOrLarger } = useWindowSize();
46
-
47
- const { currentProfile, openpeepsApi } = useOpenpeeps();
48
- const {
49
- data: notificationsStats,
50
- isSuccess,
51
- refetch,
52
- } = openpeepsApi.useCurrentProfileNotificationStats();
53
- const navigation =
54
- useNavigation<NativeStackNavigationProp<TabStackParamList>>();
55
- const { background, logoSmall } = useAppImagesStore();
56
- const lastFetchRef = React.useRef<number>(0);
57
- const isOnNotificationsScreen = useNavigationState(
58
- (state) => state.routes[state.index]?.name === TAB_ROUTES.NOTIFICATIONS
59
- );
60
-
61
- const onNotificationPress = () => {
62
- navigation.navigate('Notifications');
63
- };
64
-
65
- useFocusEffect(
66
- React.useCallback(() => {
67
- if (isOnNotificationsScreen) {
68
- return undefined;
69
- }
70
- const MIN_REFRESH_INTERVAL_MS = 10_000;
71
- const now = Date.now();
72
- if (now - (lastFetchRef.current || 0) > MIN_REFRESH_INTERVAL_MS) {
73
- lastFetchRef.current = now;
74
- refetch();
75
- }
76
- return undefined;
77
- }, [refetch, isOnNotificationsScreen])
78
- );
79
-
80
- React.useEffect(() => {
81
- setAppBadgeCount(notificationsStats?.unseen ?? 0);
82
- lastFetchRef.current = Date.now();
83
- }, [notificationsStats]);
84
-
85
- if (isMediumScreenOrLarger) {
86
- return (
87
- <ThemedSafeAreaView className="p-4 pb-6 pl-1">
88
- {children}
89
- </ThemedSafeAreaView>
90
- );
91
- }
92
-
93
- return (
94
- <>
95
- <ImageBackground
96
- resizeMode="cover"
97
- source={{
98
- uri: background!,
99
- }}
100
- style={styles.header}
101
- className="pb-3 px-4"
102
- >
103
- <SafeAreaView edges={['top']} className="">
104
- {!isProduction && (
105
- <View className="mb-2 w-full rounded-lg bg-white/50 p-2">
106
- <ThemedText className="text-center text-destructive">
107
- Test Backend ({BASE_URL})
108
- </ThemedText>
109
- </View>
110
- )}
111
- <View className="flex-row items-center justify-between">
112
- <Button
113
- variant={'outline'}
114
- size={'icon'}
115
- onPress={() => {
116
- openDrawer();
117
- }}
118
- className="native:px-0 active:bg-none rounded-full bg-black"
119
- >
120
- <Avatar
121
- alt={(currentProfile?.displayName as string) || 'Profile'}
122
- >
123
- {currentProfile?.avatar ? (
124
- <AvatarImage source={{ uri: currentProfile.avatar }} />
125
- ) : (
126
- <AvatarFallback className="h-6 w-6 -bottom-2 -right-2 bg-black">
127
- <UserIcon size={20} className="text-muted-foreground" />
128
- </AvatarFallback>
129
- )}
130
- </Avatar>
131
- </Button>
132
-
133
- <Image
134
- source={{
135
- uri: logoSmall!,
136
- }}
137
- resizeMode="contain"
138
- className="w-[216px] h-[64px]"
139
- />
140
- {showIcons && (
141
- <Button
142
- variant={'outline'}
143
- size={'icon'}
144
- onPress={onNotificationPress}
145
- className="relative"
146
- >
147
- <BellIcon className="text-muted-foreground" size={18} />
148
- {isSuccess &&
149
- !isOnNotificationsScreen &&
150
- notificationsStats.unseen > 0 && (
151
- <View className="absolute -top-3 -right-2 h-6 w-6 items-center justify-center rounded-full bg-foreground">
152
- <ThemedText className="text-background text-xs">
153
- {formatBadgeCount(notificationsStats.unseen)}
154
- </ThemedText>
155
- </View>
156
- )}
157
- </Button>
158
- )}
159
- </View>
160
-
161
- {children ? children : null}
162
- {showVerification && (
163
- <>
164
- <View className="mt-4">
165
- <Image
166
- source={{
167
- uri: logoSmall!,
168
- }}
169
- className=""
170
- resizeMode="cover"
171
- />
172
- </View>
173
- <View className="mt-7 border border-input rounded-md p-4">
174
- <ThemedText className="text-xl leading-8 tracking-wider">
175
- Your email is not yet verified. Tap “Get link” below to get
176
- the verification link.
177
- </ThemedText>
178
- <View className="flex-row justify-end mt-5 gap-4">
179
- <Button variant={'ghost'} onPress={onNotificationPress}>
180
- <ThemedText> Remove</ThemedText>
181
- </Button>
182
- <Button onPress={onNotificationPress}>
183
- <ThemedText>Get link</ThemedText>
184
- </Button>
185
- </View>
186
- </View>
187
- </>
188
- )}
189
- </SafeAreaView>
190
- </ImageBackground>
191
- </>
192
- );
193
- };
194
-
195
- const styles = StyleSheet.create({
196
- header: {
197
- paddingTop: Platform.OS === 'android' ? StatusBar.currentHeight : 0,
198
- },
199
- });