@openpeepshq/rn-components 0.3.11 → 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 (74) hide show
  1. package/package.json +3 -3
  2. package/src/components/custom/common/index.ts +0 -1
  3. package/src/components/custom/index.ts +0 -1
  4. package/src/components/index.ts +1 -0
  5. package/src/components/jams/CreateNewJam.tsx +11 -10
  6. package/src/components/layout/AuthLayout.tsx +120 -0
  7. package/src/components/layout/ContentHeader.tsx +62 -0
  8. package/src/components/layout/HeaderActionButton.tsx +23 -0
  9. package/src/components/layout/HeaderMobile.tsx +96 -0
  10. package/src/components/layout/PlusButton.tsx +26 -0
  11. package/src/components/layout/RootLayout.tsx +30 -0
  12. package/src/components/layout/index.ts +13 -0
  13. package/src/components/layout/pageChrome.tsx +75 -0
  14. package/src/components/navigation/auth-navigator.tsx +2 -2
  15. package/src/components/navigation/main-navigator.tsx +17 -1
  16. package/src/components/navigation/tab-navigator.tsx +2 -0
  17. package/src/components/post/NewEventButton.tsx +23 -16
  18. package/src/components/post/NewNoteButton.tsx +15 -13
  19. package/src/pages/About.tsx +3 -5
  20. package/src/pages/CodeOfConduct.tsx +7 -7
  21. package/src/pages/Explore.tsx +87 -127
  22. package/src/pages/Members.tsx +31 -39
  23. package/src/pages/Notifications.tsx +6 -13
  24. package/src/pages/PostDetail.tsx +12 -16
  25. package/src/pages/Profile.tsx +3 -2
  26. package/src/pages/Tags.tsx +74 -16
  27. package/src/pages/Welcome.tsx +3 -8
  28. package/src/pages/articles/Edit.tsx +18 -15
  29. package/src/pages/articles/Index.tsx +11 -21
  30. package/src/pages/articles/New.tsx +18 -15
  31. package/src/pages/conversations/Index.tsx +44 -68
  32. package/src/pages/conversations/Info.tsx +6 -5
  33. package/src/pages/conversations/New.tsx +14 -13
  34. package/src/pages/conversations/NewDraft.tsx +5 -5
  35. package/src/pages/conversations/Show.tsx +16 -20
  36. package/src/pages/events/Edit.tsx +14 -13
  37. package/src/pages/events/Index.tsx +28 -32
  38. package/src/pages/events/My.tsx +7 -7
  39. package/src/pages/events/New.tsx +14 -13
  40. package/src/pages/feeds/Bookmarks.tsx +3 -9
  41. package/src/pages/feeds/Local.tsx +3 -10
  42. package/src/pages/feeds/My.tsx +3 -9
  43. package/src/pages/groups/Edit.tsx +6 -7
  44. package/src/pages/groups/EditInfo.tsx +20 -17
  45. package/src/pages/groups/EditRoles.tsx +18 -19
  46. package/src/pages/groups/Index.tsx +82 -119
  47. package/src/pages/groups/Info.tsx +22 -23
  48. package/src/pages/groups/Members.tsx +9 -8
  49. package/src/pages/groups/New.tsx +18 -15
  50. package/src/pages/groups/Show.tsx +6 -5
  51. package/src/pages/jams/Index.tsx +8 -26
  52. package/src/pages/jams/New.tsx +14 -11
  53. package/src/pages/posts/Edit.tsx +20 -17
  54. package/src/pages/posts/New.tsx +30 -29
  55. package/src/pages/posts/Reply.tsx +20 -16
  56. package/src/pages/profile/Followers.tsx +9 -10
  57. package/src/pages/profile/Following.tsx +9 -10
  58. package/src/pages/settings/AccessTokens.tsx +6 -5
  59. package/src/pages/settings/Account.tsx +13 -12
  60. package/src/pages/settings/Blocked.tsx +5 -5
  61. package/src/pages/settings/Feed.tsx +13 -12
  62. package/src/pages/settings/Index.tsx +4 -24
  63. package/src/pages/settings/Language.tsx +36 -37
  64. package/src/pages/settings/NotificationPreferences.tsx +10 -12
  65. package/src/pages/settings/Notifications.tsx +10 -9
  66. package/src/pages/settings/PublicProfile.tsx +6 -6
  67. package/src/pages/settings/PushEnabledDevices.tsx +10 -9
  68. package/src/pages/settings/Theme.tsx +13 -12
  69. package/src/pages/settings/Timezone.tsx +27 -28
  70. package/src/components/custom/common/plus-fab.tsx +0 -23
  71. package/src/components/custom/headers/generic-header.tsx +0 -103
  72. package/src/components/custom/headers/index.ts +0 -2
  73. package/src/components/custom/headers/tab-screens-header.tsx +0 -206
  74. package/src/components/navigation/auth-wrapper.tsx +0 -107
@@ -1,4 +1,4 @@
1
- import React from 'react';
1
+ import { useMemo } from 'react';
2
2
  import { useTranslation } from 'react-i18next';
3
3
  import {
4
4
  canCreatePost,
@@ -7,8 +7,7 @@ import {
7
7
  type VisibilityType,
8
8
  } from '@openpeepshq/common';
9
9
  import { useAuthData } from '@openpeepshq/react';
10
- import { PlusFab } from '../custom/common/plus-fab';
11
- import { PencilLineIcon } from '../icons/index';
10
+ import { useSetPlusButtonActions } from '../layout';
12
11
  import { useNewPostModal } from './post-form/NewPostModalContext';
13
12
 
14
13
  export interface NewNoteButtonProps {
@@ -17,7 +16,7 @@ export interface NewNoteButtonProps {
17
16
  group?: GroupWithMeta;
18
17
  }
19
18
 
20
- /** Floating action button — the native stand-in for the web layout plus button. */
19
+ /** Registers the RootLayout plus button for creating a note. */
21
20
  export const NewNoteButton = ({
22
21
  visibility,
23
22
  currentProfile,
@@ -31,14 +30,17 @@ export const NewNoteButton = ({
31
30
  const canPost =
32
31
  !!profile && canCreatePost(authData, 'note', visibility, group);
33
32
 
34
- if (!canPost) return null;
35
-
36
- return (
37
- <PlusFab
38
- accessibilityLabel={t('posts.form.title')}
39
- onPress={() => openNewPost({ visibility, group })}
40
- >
41
- <PencilLineIcon size={24} className="text-background" />
42
- </PlusFab>
33
+ const plusActions = useMemo(
34
+ () =>
35
+ canPost
36
+ ? {
37
+ title: t('posts.form.title'),
38
+ action: () => openNewPost({ visibility, group }),
39
+ }
40
+ : undefined,
41
+ [canPost, group, openNewPost, t, visibility]
43
42
  );
43
+
44
+ useSetPlusButtonActions(plusActions);
45
+ return null;
44
46
  };
@@ -2,10 +2,9 @@ import React from 'react';
2
2
  import { ScrollView } from 'react-native';
3
3
  import { useTranslation } from 'react-i18next';
4
4
  import { useCommunityInfoPages } from '@openpeepshq/react';
5
- import { GenericHeader } from '../components/custom/index';
5
+ import { AuthLayout } from '../components/layout';
6
6
  import { OpenpeepsMarkdown } from '../components/markdown/index';
7
7
  import { MainScreenProps } from '../components/navigation/types/index';
8
- import { ThemedSafeAreaView } from '../components/ui/themed-safe-area-view';
9
8
  import { ThemedText } from '../components/ui/themed-text';
10
9
 
11
10
  export const About: React.FC<MainScreenProps<'About'>> = () => {
@@ -13,8 +12,7 @@ export const About: React.FC<MainScreenProps<'About'>> = () => {
13
12
  const { communityName, aboutPage } = useCommunityInfoPages();
14
13
 
15
14
  return (
16
- <ThemedSafeAreaView className="flex-1">
17
- <GenericHeader title={t('navigation.about', { defaultValue: 'About' })} />
15
+ <AuthLayout noRedirect>
18
16
  <ScrollView contentContainerClassName="p-4 pb-12">
19
17
  <ThemedText className="text-2xl font-bold pb-4">
20
18
  {t('about.welcomeTo', {
@@ -24,6 +22,6 @@ export const About: React.FC<MainScreenProps<'About'>> = () => {
24
22
  </ThemedText>
25
23
  <OpenpeepsMarkdown source={aboutPage} />
26
24
  </ScrollView>
27
- </ThemedSafeAreaView>
25
+ </AuthLayout>
28
26
  );
29
27
  };
@@ -2,23 +2,23 @@ import React from 'react';
2
2
  import { ScrollView } from 'react-native';
3
3
  import { useTranslation } from 'react-i18next';
4
4
  import { useCommunityInfoPages } from '@openpeepshq/react';
5
- import { GenericHeader } from '../components/custom/index';
5
+ import { AuthLayout } from '../components/layout';
6
6
  import { OpenpeepsMarkdown } from '../components/markdown/index';
7
7
  import { MainScreenProps } from '../components/navigation/types/index';
8
- import { ThemedSafeAreaView } from '../components/ui/themed-safe-area-view';
8
+ import { ThemedText } from '../components/ui/themed-text';
9
9
 
10
10
  export const CodeOfConduct: React.FC<MainScreenProps<'CodeOfConduct'>> = () => {
11
11
  const { t } = useTranslation();
12
12
  const { codeOfConduct } = useCommunityInfoPages();
13
13
 
14
14
  return (
15
- <ThemedSafeAreaView className="flex-1">
16
- <GenericHeader
17
- title={t('codeOfConduct.title', { defaultValue: 'Code of conduct' })}
18
- />
15
+ <AuthLayout noRedirect>
19
16
  <ScrollView contentContainerClassName="p-4 pb-12">
17
+ <ThemedText className="text-2xl font-bold pb-4">
18
+ {t('codeOfConduct.title', { defaultValue: 'Code of conduct' })}
19
+ </ThemedText>
20
20
  <OpenpeepsMarkdown source={codeOfConduct} />
21
21
  </ScrollView>
22
- </ThemedSafeAreaView>
22
+ </AuthLayout>
23
23
  );
24
24
  };
@@ -14,8 +14,8 @@ import { CompositeScreenProps } from '@react-navigation/native';
14
14
  import {
15
15
  EmptyStateContainer,
16
16
  InfiniteScrollContainer,
17
- TabScreensHeader,
18
17
  } from '../components/custom/index';
18
+ import { useSetPageHeader } from '../components/layout';
19
19
  import { ThemedText } from '../components/ui/themed-text';
20
20
  import { useTranslation } from 'react-i18next';
21
21
  import { Pressable, TouchableOpacity, View, ScrollView } from 'react-native';
@@ -58,139 +58,99 @@ export const Explore: React.FC<ExploreScreenProps> = ({ navigation }) => {
58
58
  [currentProfile]
59
59
  );
60
60
 
61
+ useSetPageHeader(
62
+ t('navigation.explore'),
63
+ isSearchToggled ? (
64
+ <View className="max-w-[200px] flex-row items-center">
65
+ <Input
66
+ className="flex-1"
67
+ placeholder={t('explore.searchPlaceholder', {
68
+ defaultValue: 'Search',
69
+ })}
70
+ value={searchQuery}
71
+ onChangeText={setSearchQuery}
72
+ />
73
+ <TouchableOpacity
74
+ className="items-center justify-center px-2"
75
+ onPress={() => {
76
+ setSearchQuery('');
77
+ setIsSearchToggled(false);
78
+ setTabValue('landing');
79
+ }}
80
+ >
81
+ <XIcon size={20} className="text-foreground" />
82
+ </TouchableOpacity>
83
+ </View>
84
+ ) : (
85
+ <TouchableOpacity onPress={() => setIsSearchToggled(true)}>
86
+ <SearchIcon size={20} className="text-foreground" />
87
+ </TouchableOpacity>
88
+ )
89
+ );
90
+
61
91
  return (
62
92
  <ThemedView className="grow">
63
93
  <Tabs
64
94
  value={tabValue}
65
95
  onValueChange={setTabValue}
66
- className="w-full mx-auto flex-col gap-1.5"
96
+ className="mx-auto w-full flex-col gap-1.5"
67
97
  >
68
- <TabScreensHeader
69
- children={
70
- <View className="flex-row items-center justify-between p-2">
71
- {!isSearchToggled && (
72
- <ThemedText className="text-2xl font-semibold">
73
- {t('navigation.explore')}
74
- </ThemedText>
75
- )}
76
- <View
77
- className={`${
78
- isSearchToggled
79
- ? 'flex justify-end '
80
- : 'flex-row items-center gap-x-6'
81
- }`}
98
+ {isSearchToggled ? (
99
+ <ScrollView horizontal showsHorizontalScrollIndicator={false}>
100
+ <TabsList className="flex-row w-full bg-transparent border-muted rounded-none border-b p-0">
101
+ <TabsTrigger
102
+ value="landing"
103
+ className="hidden"
104
+ onPress={() => setTabValue('hidden')}
105
+ />
106
+ <TabsTrigger
107
+ value="members"
108
+ className={
109
+ tabValue === 'members' ? 'border-b-2 border-foreground' : ''
110
+ }
111
+ onPress={() => setTabValue('members')}
82
112
  >
83
- {isSearchToggled ? (
84
- <>
85
- <View className=" w-full flex-row flex justify-end">
86
- <Input
87
- className="flex-1"
88
- placeholder="Search for members, posts, groups, jams, events"
89
- value={searchQuery}
90
- onChangeText={setSearchQuery}
91
- />
92
- <TouchableOpacity
93
- className="items-center justify-center px-4"
94
- onPress={() => {
95
- setSearchQuery('');
96
- setIsSearchToggled(false);
97
- setTabValue('landing');
98
- }}
99
- >
100
- <XIcon size={24} className="text-foreground" />
101
- </TouchableOpacity>
102
- </View>
103
- <ScrollView
104
- horizontal
105
- showsHorizontalScrollIndicator={false}
106
- >
107
- <TabsList className="flex-row w-full bg-transparent border-muted rounded-none border-b p-0">
108
- <TabsTrigger
109
- value="landing"
110
- className={'hidden'}
111
- onPress={() => {
112
- setTabValue('hidden');
113
- }}
114
- />
115
- <TabsTrigger
116
- value="members"
117
- className={`${
118
- tabValue === 'members'
119
- ? 'border-b-2 border-foreground'
120
- : ''
121
- }`}
122
- onPress={() => {
123
- setTabValue('members');
124
- }}
125
- >
126
- <ThemedText>Members</ThemedText>
127
- </TabsTrigger>
128
- <TabsTrigger
129
- value="posts"
130
- className={`${
131
- tabValue === 'posts'
132
- ? 'border-b-2 border-foreground'
133
- : ''
134
- }`}
135
- onPress={() => {
136
- setTabValue('posts');
137
- }}
138
- >
139
- <ThemedText>Posts</ThemedText>
140
- </TabsTrigger>
141
- <TabsTrigger
142
- value="jams"
143
- className={`${
144
- tabValue === 'jams'
145
- ? 'border-b-2 border-foreground'
146
- : ''
147
- }`}
148
- onPress={() => {
149
- setTabValue('jams');
150
- }}
151
- >
152
- <ThemedText>Jams</ThemedText>
153
- </TabsTrigger>
154
- <TabsTrigger
155
- value="events"
156
- className={`${
157
- tabValue === 'events'
158
- ? 'border-b-2 border-foreground'
159
- : ''
160
- }`}
161
- onPress={() => {
162
- setTabValue('events');
163
- }}
164
- >
165
- <ThemedText>Events</ThemedText>
166
- </TabsTrigger>
167
- <TabsTrigger
168
- value="groups"
169
- className={`${
170
- tabValue === 'groups'
171
- ? 'border-b-2 border-foreground'
172
- : ''
173
- }`}
174
- onPress={() => {
175
- setTabValue('groups');
176
- }}
177
- >
178
- <ThemedText>Groups</ThemedText>
179
- </TabsTrigger>
180
- </TabsList>
181
- </ScrollView>
182
- </>
183
- ) : (
184
- <>
185
- <TouchableOpacity onPress={() => setIsSearchToggled(true)}>
186
- <SearchIcon size={20} className="text-foreground" />
187
- </TouchableOpacity>
188
- </>
189
- )}
190
- </View>
191
- </View>
192
- }
193
- />
113
+ <ThemedText>Members</ThemedText>
114
+ </TabsTrigger>
115
+ <TabsTrigger
116
+ value="posts"
117
+ className={
118
+ tabValue === 'posts' ? 'border-b-2 border-foreground' : ''
119
+ }
120
+ onPress={() => setTabValue('posts')}
121
+ >
122
+ <ThemedText>Posts</ThemedText>
123
+ </TabsTrigger>
124
+ <TabsTrigger
125
+ value="jams"
126
+ className={
127
+ tabValue === 'jams' ? 'border-b-2 border-foreground' : ''
128
+ }
129
+ onPress={() => setTabValue('jams')}
130
+ >
131
+ <ThemedText>Jams</ThemedText>
132
+ </TabsTrigger>
133
+ <TabsTrigger
134
+ value="events"
135
+ className={
136
+ tabValue === 'events' ? 'border-b-2 border-foreground' : ''
137
+ }
138
+ onPress={() => setTabValue('events')}
139
+ >
140
+ <ThemedText>Events</ThemedText>
141
+ </TabsTrigger>
142
+ <TabsTrigger
143
+ value="groups"
144
+ className={
145
+ tabValue === 'groups' ? 'border-b-2 border-foreground' : ''
146
+ }
147
+ onPress={() => setTabValue('groups')}
148
+ >
149
+ <ThemedText>Groups</ThemedText>
150
+ </TabsTrigger>
151
+ </TabsList>
152
+ </ScrollView>
153
+ ) : null}
194
154
  <TabsContent
195
155
  value="landing"
196
156
  className="w-full flex h-64 items-center justify-center"
@@ -2,11 +2,8 @@ import { useTranslation } from 'react-i18next';
2
2
  import { View, Pressable, ActivityIndicator } from 'react-native';
3
3
  import React, { useEffect } from 'react';
4
4
  import { ThemedView } from '../components/ui/themed-view';
5
- import {
6
- EmptyStateContainer,
7
- TabScreensHeader,
8
- } from '../components/custom/index';
9
- import { ThemedText } from '../components/ui/themed-text';
5
+ import { EmptyStateContainer } from '../components/custom/index';
6
+ import { useSetPageHeader } from '../components/layout';
10
7
  import {
11
8
  XIcon,
12
9
  SearchIcon,
@@ -52,42 +49,37 @@ export const Members: React.FC<DirectoryProps> = ({ navigation }) => {
52
49
  }
53
50
  }, [searchQuery, profiles, currentProfile]);
54
51
 
52
+ useSetPageHeader(
53
+ t('navigation.members'),
54
+ isSearchButtonClicked ? (
55
+ <View className="max-w-[200px] flex-row items-center">
56
+ <Input
57
+ className="flex-1"
58
+ placeholder={t('members.searchPlaceholder', {
59
+ defaultValue: 'Enter name or handle',
60
+ })}
61
+ value={searchQuery}
62
+ onChangeText={setSearchQuery}
63
+ />
64
+ <Pressable
65
+ className="items-center justify-center px-2"
66
+ onPress={() => {
67
+ setIsSearchButtonClicked(false);
68
+ setSearchQuery('');
69
+ }}
70
+ >
71
+ <XIcon className="text-foreground" />
72
+ </Pressable>
73
+ </View>
74
+ ) : (
75
+ <Pressable onPress={() => setIsSearchButtonClicked(true)}>
76
+ <SearchIcon className="text-foreground" />
77
+ </Pressable>
78
+ )
79
+ );
80
+
55
81
  return (
56
82
  <ThemedView className="grow">
57
- <TabScreensHeader
58
- children={
59
- <>
60
- {!isSearchButtonClicked ? (
61
- <View className="w-full flex flex-row justify-between items-center p-4">
62
- <ThemedText className="text-xl">
63
- {t('navigation.members')}
64
- </ThemedText>
65
- <Pressable onPress={() => setIsSearchButtonClicked(true)}>
66
- <SearchIcon className="text-foreground" />
67
- </Pressable>
68
- </View>
69
- ) : (
70
- <View className="w-full flex flex-row justify-between items-center p-4">
71
- <Input
72
- className="flex-1"
73
- placeholder="Enter name or handle"
74
- value={searchQuery}
75
- onChangeText={setSearchQuery}
76
- />
77
- <Pressable
78
- className=" w-[10%] flex justify-center items-center"
79
- onPress={() => {
80
- setIsSearchButtonClicked(false);
81
- setSearchQuery('');
82
- }}
83
- >
84
- <XIcon className="text-foreground" />
85
- </Pressable>
86
- </View>
87
- )}
88
- </>
89
- }
90
- />
91
83
  <KeyboardAwareScrollView className="relative w-full grow flex bg-background gap-y-4 border-t border-border p-2">
92
84
  {isLoading && <ActivityIndicator size={'small'} />}
93
85
  {filteredProfiles?.map((profile, index) => {
@@ -1,9 +1,7 @@
1
1
  import React from 'react';
2
- import { TabScreensHeader } from '../components/custom/index';
3
2
  import { ThemedView } from '../components/ui/themed-view';
4
- import { ThemedText } from '../components/ui/themed-text';
5
- import { View } from 'react-native';
6
3
  import { useOpenpeeps } from '@openpeepshq/react';
4
+ import { useSetPageHeader } from '../components/layout';
7
5
  import { useTranslation } from 'react-i18next';
8
6
  import {
9
7
  NotificationHeaderActions,
@@ -23,18 +21,13 @@ export const Notifications = () => {
23
21
  refetchFeed: () => query.refetch(),
24
22
  });
25
23
 
24
+ useSetPageHeader(
25
+ t('navigation.notifications'),
26
+ <NotificationHeaderActions />
27
+ );
28
+
26
29
  return (
27
30
  <ThemedView className="grow">
28
- <TabScreensHeader
29
- children={
30
- <View className="flex-row items-center justify-between">
31
- <ThemedText className="text-xl font-bold">
32
- {t('navigation.notifications')}
33
- </ThemedText>
34
- <NotificationHeaderActions />
35
- </View>
36
- }
37
- />
38
31
  <NotificationsList
39
32
  query={query}
40
33
  onRefresh={async () => {
@@ -3,8 +3,8 @@ import { RefreshControl } from 'react-native-gesture-handler';
3
3
  import { KeyboardAwareScrollView } from 'react-native-keyboard-aware-scroll-view';
4
4
  import { useTranslation } from 'react-i18next';
5
5
  import { useOpenpeeps, usePostDetailTitle } from '@openpeepshq/react';
6
- import { GenericHeader } from '../components/custom/index';
7
- import { ThemedSafeAreaView } from '../components/ui/themed-safe-area-view';
6
+ import { useSetPageHeader } from '../components/layout';
7
+ import { ThemedView } from '../components/ui/themed-view';
8
8
  import { MainScreenProps } from '../components/navigation/types/index';
9
9
  import { goToParentOrBack } from '../components/navigation/parent-back';
10
10
  import { PostDetail as PostDetailComponent } from '../components/post/index';
@@ -38,20 +38,16 @@ export const PostDetail = ({ route, navigation }: PostProps) => {
38
38
  post,
39
39
  });
40
40
 
41
+ useSetPageHeader(
42
+ title,
43
+ post?.type === 'event' ? (
44
+ <FullEventActions post={post} occurrence={occurrence} />
45
+ ) : undefined,
46
+ handleGoBack
47
+ );
48
+
41
49
  return (
42
- <ThemedSafeAreaView className="flex-1">
43
- {post?.type === 'event' ? (
44
- <GenericHeader
45
- title={title}
46
- handleGoBack={handleGoBack}
47
- rightType="icon"
48
- rightButtonIcon={
49
- <FullEventActions post={post} occurrence={occurrence} />
50
- }
51
- />
52
- ) : (
53
- <GenericHeader title={title} handleGoBack={handleGoBack} />
54
- )}
50
+ <ThemedView className="flex-1">
55
51
  <KeyboardAwareScrollView
56
52
  className="w-full flex bg-background relative"
57
53
  refreshControl={
@@ -60,6 +56,6 @@ export const PostDetail = ({ route, navigation }: PostProps) => {
60
56
  >
61
57
  <PostDetailComponent postId={id} occurrence={occurrence} />
62
58
  </KeyboardAwareScrollView>
63
- </ThemedSafeAreaView>
59
+ </ThemedView>
64
60
  );
65
61
  };
@@ -2,7 +2,7 @@ import React from 'react';
2
2
  import { ActivityIndicator, View } from 'react-native';
3
3
  import { useTranslation } from 'react-i18next';
4
4
  import { useCurrentProfile, useOpenpeeps } from '@openpeepshq/react';
5
- import { GenericHeader } from '../components/custom/index';
5
+ import { useSetPageHeader } from '../components/layout';
6
6
  import { RssIcon } from '../components/icons/index';
7
7
  import { MainScreenProps } from '../components/navigation/types/index';
8
8
  import {
@@ -36,9 +36,10 @@ export const Profile = ({ route }: ProfileProps) => {
36
36
  </View>
37
37
  );
38
38
 
39
+ useSetPageHeader(profile?.displayName || `@${handle}`);
40
+
39
41
  return (
40
42
  <ThemedSafeAreaView className="flex-1">
41
- <GenericHeader title={profile?.displayName || `@${handle}`} />
42
43
  {profileQuery.isLoading && !profile ? (
43
44
  <ActivityIndicator size="small" />
44
45
  ) : profile ? (
@@ -1,28 +1,36 @@
1
- import React from 'react';
2
- import {
3
- MainStackParamList,
4
- TabStackParamList,
5
- } from '../components/navigation/types/index';
1
+ import React, { useMemo, useRef, useState } from 'react';
2
+ import { RefreshControl, ScrollView } from 'react-native';
3
+ import { CompositeScreenProps } from '@react-navigation/native';
4
+ import { NativeStackScreenProps } from '@react-navigation/native-stack';
5
+ import { normalizeHashtagTag } from '@openpeepshq/common/types';
6
6
  import {
7
+ useCurrentProfile,
7
8
  useDefaultVisibility,
8
9
  useFeedListParams,
9
10
  useOpenpeeps,
10
11
  } from '@openpeepshq/react';
11
- import { GenericHeader } from '../components/custom/index';
12
- import { CompositeScreenProps } from '@react-navigation/native';
13
- import { NativeStackScreenProps } from '@react-navigation/native-stack';
14
- import { RefreshControl, ScrollView } from 'react-native';
15
-
12
+ import { useTranslation } from 'react-i18next';
13
+ import { useSetPageHeader } from '../components/layout';
16
14
  import { Feed, NewNoteButton } from '../components/post/index';
17
- import { TAB_ROUTES } from '../components/navigation/types/index';
15
+ import {
16
+ MainStackParamList,
17
+ TabStackParamList,
18
+ } from '../components/navigation/types/index';
19
+ import { Button } from '../components/ui/button';
20
+ import { ThemedText } from '../components/ui/themed-text';
21
+
18
22
  type HomeScreenProps = CompositeScreenProps<
19
23
  NativeStackScreenProps<TabStackParamList, 'HashtagPosts'>,
20
24
  NativeStackScreenProps<MainStackParamList>
21
25
  >;
22
- export const Tags: React.FC<HomeScreenProps> = ({ route, navigation }) => {
26
+
27
+ export const Tags: React.FC<HomeScreenProps> = ({ route }) => {
28
+ const { t } = useTranslation();
23
29
  const { openpeepsApi } = useOpenpeeps();
30
+ const me = useCurrentProfile();
24
31
  const { tag } = route.params;
25
32
  const visibility = useDefaultVisibility();
33
+ const [toggling, setToggling] = useState(false);
26
34
 
27
35
  const query = openpeepsApi.usePostsByHashtag(
28
36
  tag,
@@ -36,12 +44,62 @@ export const Tags: React.FC<HomeScreenProps> = ({ route, navigation }) => {
36
44
  setRefreshing(false);
37
45
  }, [query]);
38
46
 
47
+ const followHashtag = openpeepsApi.followHashtagAction({
48
+ tag,
49
+ } as never);
50
+ const unfollowHashtag = openpeepsApi.unfollowHashtagAction({
51
+ tag,
52
+ } as never);
53
+ const followHashtagRef = useRef(followHashtag);
54
+ const unfollowHashtagRef = useRef(unfollowHashtag);
55
+ followHashtagRef.current = followHashtag;
56
+ unfollowHashtagRef.current = unfollowHashtag;
57
+
58
+ const normalizedTag = normalizeHashtagTag(tag);
59
+ const isFollowing = !!me?.followedHashtags?.some(
60
+ (h) => h.tag === normalizedTag
61
+ );
62
+
63
+ const headerActions = useMemo(() => {
64
+ if (!me) return undefined;
65
+ const toggleFollow = async () => {
66
+ setToggling(true);
67
+ try {
68
+ if (isFollowing) {
69
+ await unfollowHashtagRef.current();
70
+ } else {
71
+ await followHashtagRef.current();
72
+ }
73
+ } finally {
74
+ setToggling(false);
75
+ }
76
+ };
77
+ return (
78
+ <Button
79
+ variant={isFollowing ? 'outline' : 'default'}
80
+ disabled={toggling}
81
+ onPress={() => void toggleFollow()}
82
+ >
83
+ <ThemedText
84
+ className={
85
+ isFollowing ? 'text-foreground' : 'text-primary-foreground'
86
+ }
87
+ >
88
+ {isFollowing
89
+ ? t('tags.following', { defaultValue: 'Following' })
90
+ : t('tags.follow', { defaultValue: 'Follow hashtag' })}
91
+ </ThemedText>
92
+ </Button>
93
+ );
94
+ }, [isFollowing, me, t, toggling]);
95
+
96
+ useSetPageHeader(
97
+ t('tags.title', { defaultValue: '#{{hashtag}}', hashtag: tag }),
98
+ headerActions
99
+ );
100
+
39
101
  return (
40
102
  <>
41
- <GenericHeader
42
- title={`#${tag}`}
43
- handleGoBack={() => navigation.navigate(TAB_ROUTES.HOME)}
44
- />
45
103
  <ScrollView
46
104
  className="bg-background"
47
105
  refreshControl={