@openpeepshq/rn-components 0.3.11 → 0.3.13

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 (75) hide show
  1. package/package.json +3 -10
  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.test.tsx +147 -0
  14. package/src/components/layout/pageChrome.tsx +110 -0
  15. package/src/components/navigation/auth-navigator.tsx +2 -2
  16. package/src/components/navigation/main-navigator.tsx +17 -1
  17. package/src/components/navigation/tab-navigator.tsx +2 -0
  18. package/src/components/post/NewEventButton.tsx +23 -16
  19. package/src/components/post/NewNoteButton.tsx +15 -13
  20. package/src/pages/About.tsx +3 -5
  21. package/src/pages/CodeOfConduct.tsx +7 -7
  22. package/src/pages/Explore.tsx +87 -127
  23. package/src/pages/Members.tsx +31 -39
  24. package/src/pages/Notifications.tsx +6 -13
  25. package/src/pages/PostDetail.tsx +12 -16
  26. package/src/pages/Profile.tsx +3 -2
  27. package/src/pages/Tags.tsx +74 -16
  28. package/src/pages/Welcome.tsx +3 -8
  29. package/src/pages/articles/Edit.tsx +18 -15
  30. package/src/pages/articles/Index.tsx +11 -21
  31. package/src/pages/articles/New.tsx +18 -15
  32. package/src/pages/conversations/Index.tsx +44 -68
  33. package/src/pages/conversations/Info.tsx +6 -5
  34. package/src/pages/conversations/New.tsx +14 -13
  35. package/src/pages/conversations/NewDraft.tsx +5 -5
  36. package/src/pages/conversations/Show.tsx +16 -20
  37. package/src/pages/events/Edit.tsx +14 -13
  38. package/src/pages/events/Index.tsx +28 -32
  39. package/src/pages/events/My.tsx +7 -7
  40. package/src/pages/events/New.tsx +14 -13
  41. package/src/pages/feeds/Bookmarks.tsx +3 -9
  42. package/src/pages/feeds/Local.tsx +3 -10
  43. package/src/pages/feeds/My.tsx +3 -9
  44. package/src/pages/groups/Edit.tsx +6 -7
  45. package/src/pages/groups/EditInfo.tsx +20 -17
  46. package/src/pages/groups/EditRoles.tsx +18 -19
  47. package/src/pages/groups/Index.tsx +82 -119
  48. package/src/pages/groups/Info.tsx +22 -23
  49. package/src/pages/groups/Members.tsx +9 -8
  50. package/src/pages/groups/New.tsx +18 -15
  51. package/src/pages/groups/Show.tsx +6 -5
  52. package/src/pages/jams/Index.tsx +8 -26
  53. package/src/pages/jams/New.tsx +14 -11
  54. package/src/pages/posts/Edit.tsx +20 -17
  55. package/src/pages/posts/New.tsx +30 -29
  56. package/src/pages/posts/Reply.tsx +20 -16
  57. package/src/pages/profile/Followers.tsx +9 -10
  58. package/src/pages/profile/Following.tsx +9 -10
  59. package/src/pages/settings/AccessTokens.tsx +6 -5
  60. package/src/pages/settings/Account.tsx +13 -12
  61. package/src/pages/settings/Blocked.tsx +5 -5
  62. package/src/pages/settings/Feed.tsx +13 -12
  63. package/src/pages/settings/Index.tsx +4 -24
  64. package/src/pages/settings/Language.tsx +36 -37
  65. package/src/pages/settings/NotificationPreferences.tsx +10 -12
  66. package/src/pages/settings/Notifications.tsx +10 -9
  67. package/src/pages/settings/PublicProfile.tsx +6 -6
  68. package/src/pages/settings/PushEnabledDevices.tsx +10 -9
  69. package/src/pages/settings/Theme.tsx +13 -12
  70. package/src/pages/settings/Timezone.tsx +27 -28
  71. package/src/components/custom/common/plus-fab.tsx +0 -23
  72. package/src/components/custom/headers/generic-header.tsx +0 -103
  73. package/src/components/custom/headers/index.ts +0 -2
  74. package/src/components/custom/headers/tab-screens-header.tsx +0 -206
  75. package/src/components/navigation/auth-wrapper.tsx +0 -107
@@ -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
  };
@@ -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,103 +0,0 @@
1
- import { View, Pressable, ActivityIndicator } from 'react-native';
2
- import React from 'react';
3
- import { Button } from '../../ui/button';
4
- import { ChevronLeftIcon } from '../../icons/index';
5
- import { ThemedText } from '../../ui/themed-text';
6
- import { useNavigation, useRoute } from '@react-navigation/native';
7
- import type { NativeStackNavigationProp } from '@react-navigation/native-stack';
8
- import { useCurrentProfile } from '@openpeepshq/react';
9
- import { goToParentOrBack } from '../../navigation/parent-back';
10
- import type { MainStackParamList } from '../../navigation/types';
11
-
12
- interface GenericHeaderProps {
13
- title?: string | React.ReactNode;
14
- handleGoBack?: () => void;
15
- onRightButtonPress?: () => void;
16
- rightType?: 'button' | 'icon' | 'string';
17
- rightButtonTitle?: string;
18
- rightButtonDisabled?: boolean;
19
- rightButtonLoading?: boolean;
20
- rightButtonIcon?: React.ReactNode;
21
- rightButtonVariant?: 'primary' | 'secondary' | 'outline';
22
- hideBackButton?: boolean;
23
- /** Arbitrary right-side content, e.g. a page-specific action button. */
24
- rightElement?: React.ReactNode;
25
- }
26
- export const GenericHeader = ({
27
- title,
28
- onRightButtonPress,
29
- rightButtonTitle,
30
- rightButtonDisabled,
31
- rightButtonLoading,
32
- rightType = 'button',
33
- rightButtonIcon,
34
- handleGoBack,
35
- hideBackButton = false,
36
- rightElement,
37
- }: GenericHeaderProps) => {
38
- const navigation =
39
- useNavigation<NativeStackNavigationProp<MainStackParamList>>();
40
- const route = useRoute();
41
- const me = useCurrentProfile();
42
- return (
43
- <View className="sticky top-0 z-20 w-full px-4 py-2 flex flex-row justify-between items-center">
44
- <View className="flex gap-4 mb-2 flex-row items-center">
45
- {!hideBackButton && (
46
- <Pressable
47
- accessibilityRole="button"
48
- onPress={() => {
49
- if (handleGoBack) {
50
- handleGoBack();
51
- return;
52
- }
53
- goToParentOrBack({
54
- navigation,
55
- routeName: route.name,
56
- params: route.params as Record<string, unknown> | undefined,
57
- profileHandle: me?.handle,
58
- });
59
- }}
60
- className="items-center justify-center p-2"
61
- >
62
- <ChevronLeftIcon size={28} className="text-foreground" />
63
- </Pressable>
64
- )}
65
- {typeof title === 'string' ? (
66
- <ThemedText className="text-xl tracking-wider font-semibold">
67
- {title}
68
- </ThemedText>
69
- ) : (
70
- <>{title}</>
71
- )}
72
- </View>
73
- {rightButtonTitle && rightType === 'button' && (
74
- <Button disabled={rightButtonDisabled} onPress={onRightButtonPress}>
75
- {rightButtonLoading && <ActivityIndicator size={'small'} />}
76
-
77
- <ThemedText className="text-base font-semibold">
78
- {rightButtonTitle}
79
- </ThemedText>
80
- </Button>
81
- )}
82
- {rightButtonTitle && rightType === 'string' && (
83
- <Pressable
84
- disabled={rightButtonDisabled}
85
- className="px-4 py-2 border rounded-lg"
86
- onPress={onRightButtonPress}
87
- >
88
- {rightButtonLoading && <ActivityIndicator size={'small'} />}
89
- <ThemedText className="text-base font-semibold">
90
- {rightButtonTitle}
91
- </ThemedText>
92
- </Pressable>
93
- )}
94
-
95
- {rightButtonIcon && rightType === 'icon' && (
96
- <Pressable disabled={rightButtonDisabled} onPress={onRightButtonPress}>
97
- {rightButtonIcon}
98
- </Pressable>
99
- )}
100
- {rightElement}
101
- </View>
102
- );
103
- };
@@ -1,2 +0,0 @@
1
- export * from './generic-header';
2
- export * from './tab-screens-header';
@@ -1,206 +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
- <View className="mb-4 flex-row items-center">
89
- <Image
90
- source={{ uri: logoSmall! }}
91
- resizeMode="contain"
92
- className="h-12 w-48"
93
- />
94
- </View>
95
- {children}
96
- </ThemedSafeAreaView>
97
- );
98
- }
99
-
100
- return (
101
- <>
102
- <ImageBackground
103
- resizeMode="cover"
104
- source={{
105
- uri: background!,
106
- }}
107
- style={styles.header}
108
- className="pb-3 px-4"
109
- >
110
- <SafeAreaView edges={['top']} className="">
111
- {!isProduction && (
112
- <View className="mb-2 w-full rounded-lg bg-white/50 p-2">
113
- <ThemedText className="text-center text-destructive">
114
- Test Backend ({BASE_URL})
115
- </ThemedText>
116
- </View>
117
- )}
118
- <View className="flex-row items-center justify-between">
119
- <Button
120
- variant={'outline'}
121
- size={'icon'}
122
- onPress={() => {
123
- openDrawer();
124
- }}
125
- className="native:px-0 active:bg-none rounded-full bg-black"
126
- >
127
- <Avatar
128
- alt={(currentProfile?.displayName as string) || 'Profile'}
129
- >
130
- {currentProfile?.avatar ? (
131
- <AvatarImage source={{ uri: currentProfile.avatar }} />
132
- ) : (
133
- <AvatarFallback className="h-6 w-6 -bottom-2 -right-2 bg-black">
134
- <UserIcon size={20} className="text-muted-foreground" />
135
- </AvatarFallback>
136
- )}
137
- </Avatar>
138
- </Button>
139
-
140
- <Image
141
- source={{
142
- uri: logoSmall!,
143
- }}
144
- resizeMode="contain"
145
- className="w-[216px] h-[64px]"
146
- />
147
- {showIcons && (
148
- <Button
149
- variant={'outline'}
150
- size={'icon'}
151
- onPress={onNotificationPress}
152
- className="relative"
153
- >
154
- <BellIcon className="text-muted-foreground" size={18} />
155
- {isSuccess &&
156
- !isOnNotificationsScreen &&
157
- notificationsStats.unseen > 0 && (
158
- <View className="absolute -top-3 -right-2 h-6 w-6 items-center justify-center rounded-full bg-foreground">
159
- <ThemedText className="text-background text-xs">
160
- {formatBadgeCount(notificationsStats.unseen)}
161
- </ThemedText>
162
- </View>
163
- )}
164
- </Button>
165
- )}
166
- </View>
167
-
168
- {children ? children : null}
169
- {showVerification && (
170
- <>
171
- <View className="mt-4">
172
- <Image
173
- source={{
174
- uri: logoSmall!,
175
- }}
176
- className=""
177
- resizeMode="cover"
178
- />
179
- </View>
180
- <View className="mt-7 border border-input rounded-md p-4">
181
- <ThemedText className="text-xl leading-8 tracking-wider">
182
- Your email is not yet verified. Tap “Get link” below to get
183
- the verification link.
184
- </ThemedText>
185
- <View className="flex-row justify-end mt-5 gap-4">
186
- <Button variant={'ghost'} onPress={onNotificationPress}>
187
- <ThemedText> Remove</ThemedText>
188
- </Button>
189
- <Button onPress={onNotificationPress}>
190
- <ThemedText>Get link</ThemedText>
191
- </Button>
192
- </View>
193
- </View>
194
- </>
195
- )}
196
- </SafeAreaView>
197
- </ImageBackground>
198
- </>
199
- );
200
- };
201
-
202
- const styles = StyleSheet.create({
203
- header: {
204
- paddingTop: Platform.OS === 'android' ? StatusBar.currentHeight : 0,
205
- },
206
- });
@@ -1,107 +0,0 @@
1
- import { useOpenpeeps } from '@openpeepshq/react';
2
- import React from 'react';
3
-
4
- import { Image, ImageBackground, View } from 'react-native';
5
- import { KeyboardAwareScrollView } from 'react-native-keyboard-aware-scroll-view';
6
- import { ThemedText } from '../ui/themed-text';
7
- import { isProduction } from '../../lib/constants';
8
- import { BASE_URL } from '../../lib/constants';
9
- import { useWindowSize } from '../../hooks/index';
10
- import { getTheme } from '@openpeepshq/common';
11
- import { toAbsoluteMediaUrl } from '../../lib/media-url';
12
-
13
- const DevBanner = () =>
14
- (!isProduction && (
15
- <View className="absolute bg-white/80 z-10 ml-8 mr-8 w-auto top-64 p-4 rounded-lg">
16
- <ThemedText className="text-center text-destructive">
17
- Test Backend ({BASE_URL})
18
- </ThemedText>
19
- </View>
20
- )) ||
21
- null;
22
-
23
- const Logo = ({ uri }: { uri?: string }) => {
24
- if (!uri) {
25
- return null;
26
- }
27
-
28
- return (
29
- <Image
30
- source={{ uri }}
31
- className="absolute z-10 top-16 left-2 max-w-fit w-[206px] h-[26px]"
32
- resizeMode="contain"
33
- />
34
- );
35
- };
36
-
37
- const AuthImage = ({ children }: { children?: React.ReactNode }) => {
38
- const { openpeepsApi } = useOpenpeeps();
39
- const { data: serverInfo, isLoading } = openpeepsApi.useServerInfo();
40
- const resolvedTheme = serverInfo
41
- ? getTheme(serverInfo.communityConfig)
42
- : undefined;
43
- const authBackgroundUri = resolvedTheme?.backgroundAuth;
44
- const resolvedAuthBackgroundUri = toAbsoluteMediaUrl(authBackgroundUri);
45
- const resolvedLogoUri = toAbsoluteMediaUrl(resolvedTheme?.logoSmall);
46
-
47
- const content = (
48
- <>
49
- <Logo uri={resolvedLogoUri} />
50
- <DevBanner />
51
- {children}
52
- </>
53
- );
54
-
55
- if (resolvedAuthBackgroundUri && !isLoading) {
56
- return (
57
- <ImageBackground
58
- source={{ uri: resolvedAuthBackgroundUri }}
59
- className="w-full justify-end flex-1"
60
- >
61
- {content}
62
- </ImageBackground>
63
- );
64
- }
65
-
66
- return (
67
- <View className="w-full justify-end flex-1 bg-background">{content}</View>
68
- );
69
- };
70
-
71
- const NarrowAuthWrapper = ({ children }: { children: React.ReactNode }) => {
72
- return (
73
- <AuthImage>
74
- <View className="px-2 pt-4 w-full bg-background min-h-[400px] pb-10">
75
- {children}
76
- </View>
77
- </AuthImage>
78
- );
79
- };
80
-
81
- const WideAuthWrapper = ({ children }: { children: React.ReactNode }) => {
82
- return (
83
- <View className="flex flex-1 flex-row">
84
- <View className="flex-1">
85
- <AuthImage />
86
- </View>
87
- <View className="flex flex-1 justify-center p-6">{children}</View>
88
- </View>
89
- );
90
- };
91
-
92
- export const AuthWrapper = ({ children }: { children: React.ReactNode }) => {
93
- const { isMediumScreenOrLarger } = useWindowSize();
94
-
95
- return (
96
- <KeyboardAwareScrollView
97
- contentContainerClassName="grow"
98
- className="w-full flex bg-background"
99
- >
100
- {isMediumScreenOrLarger ? (
101
- <WideAuthWrapper>{children}</WideAuthWrapper>
102
- ) : (
103
- <NarrowAuthWrapper>{children}</NarrowAuthWrapper>
104
- )}
105
- </KeyboardAwareScrollView>
106
- );
107
- };