@umituz/react-native-auth 3.4.30 → 3.4.32

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.
@@ -0,0 +1,230 @@
1
+ # useUserProfile
2
+
3
+ Hook for fetching user profile data for display in settings or profile screens.
4
+
5
+ ## Features
6
+
7
+ - Returns profile data based on auth state
8
+ - Generates anonymous names for anonymous users
9
+ - Memoized for performance
10
+ - Type-safe profile data
11
+
12
+ ## Usage
13
+
14
+ ```typescript
15
+ import { useUserProfile } from '@umituz/react-native-auth';
16
+
17
+ function ProfileHeader() {
18
+ const profile = useUserProfile({
19
+ accountRoute: '/account',
20
+ anonymousDisplayName: 'Guest User',
21
+ });
22
+
23
+ if (!profile) {
24
+ return <LoadingSpinner />;
25
+ }
26
+
27
+ return (
28
+ <View>
29
+ <Avatar source={{ uri: profile.avatarUrl }} />
30
+ <Text>{profile.displayName}</Text>
31
+ {profile.isAnonymous && <Text>Guest</Text>}
32
+ </View>
33
+ );
34
+ }
35
+ ```
36
+
37
+ ## API
38
+
39
+ ### Parameters
40
+
41
+ | Param | Type | Default | Description |
42
+ |-------|------|---------|-------------|
43
+ | `anonymousDisplayName` | `string` | `undefined` | Default name for anonymous users |
44
+ | `accountRoute` | `string` | `undefined` | Account settings route |
45
+ | `anonymousNameConfig` | `AnonymousNameConfig` | `undefined` | Anonymous name generation config |
46
+
47
+ ### Return Value
48
+
49
+ `UserProfileData | undefined` - `undefined` if no user, otherwise:
50
+
51
+ | Prop | Type | Description |
52
+ |------|------|-------------|
53
+ | `displayName` | `string` | User's display name |
54
+ | `userId` | `string` | User ID |
55
+ | `isAnonymous` | `boolean` | Is anonymous user |
56
+ | `avatarUrl` | `string \| undefined` | Profile photo URL |
57
+ | `accountSettingsRoute` | `string \| undefined` | Account settings route |
58
+
59
+ ## Examples
60
+
61
+ ### Simple Profile Header
62
+
63
+ ```typescript
64
+ function ProfileHeader() {
65
+ const profile = useUserProfile();
66
+
67
+ if (!profile) return null;
68
+
69
+ return (
70
+ <View style={styles.header}>
71
+ {profile.avatarUrl ? (
72
+ <Image source={{ uri: profile.avatarUrl }} style={styles.avatar} />
73
+ ) : (
74
+ <View style={styles.placeholderAvatar}>
75
+ <Text>{profile.displayName?.[0]}</Text>
76
+ </View>
77
+ )}
78
+ <View>
79
+ <Text style={styles.name}>{profile.displayName}</Text>
80
+ {profile.isAnonymous && (
81
+ <Badge style={styles.badge}>Guest</Badge>
82
+ )}
83
+ </View>
84
+ </View>
85
+ );
86
+ }
87
+ ```
88
+
89
+ ### Profile Settings Link
90
+
91
+ ```typescript
92
+ function SettingsLink() {
93
+ const profile = useUserProfile({
94
+ accountRoute: '/settings/account',
95
+ });
96
+
97
+ if (!profile || profile.isAnonymous) {
98
+ return null; // Don't show for anonymous users
99
+ }
100
+
101
+ return (
102
+ <TouchableOpacity
103
+ onPress={() => navigation.navigate(profile.accountSettingsRoute)}
104
+ >
105
+ <Text>Account Settings</Text>
106
+ </TouchableOpacity>
107
+ );
108
+ }
109
+ ```
110
+
111
+ ### Anonymous User with Custom Name
112
+
113
+ ```typescript
114
+ function UserProfileCard() {
115
+ const profile = useUserProfile({
116
+ anonymousDisplayName: 'Guest User',
117
+ anonymousNameConfig: {
118
+ prefix: 'User',
119
+ adjectiveCount: 1,
120
+ nounCount: 1,
121
+ },
122
+ });
123
+
124
+ if (!profile) return <Skeleton />;
125
+
126
+ return (
127
+ <Card>
128
+ <Card.Title>{profile.displayName}</Card.Title>
129
+ {profile.isAnonymous && (
130
+ <Card.Description>
131
+ <Link href="/register">Create an account</Link> for more features
132
+ </Card.Description>
133
+ )}
134
+ </Card>
135
+ );
136
+ }
137
+ ```
138
+
139
+ ### Navigation Integration
140
+
141
+ ```typescript
142
+ function ProfileTab() {
143
+ const profile = useUserProfile({
144
+ accountRoute: 'Account',
145
+ });
146
+
147
+ const navigation = useNavigation();
148
+
149
+ const handleProfilePress = () => {
150
+ if (profile?.isAnonymous) {
151
+ navigation.navigate('Register');
152
+ } else if (profile?.accountSettingsRoute) {
153
+ navigation.navigate(profile.accountSettingsRoute);
154
+ }
155
+ };
156
+
157
+ return (
158
+ <TouchableOpacity onPress={handleProfilePress}>
159
+ <Text>{profile?.displayName || 'Profile'}</Text>
160
+ </TouchableOpacity>
161
+ );
162
+ }
163
+ ```
164
+
165
+ ### Conditional Content Based on Auth
166
+
167
+ ```typescript
168
+ function WelcomeBanner() {
169
+ const profile = useUserProfile();
170
+
171
+ if (!profile) return <LoadingBanner />;
172
+
173
+ if (profile.isAnonymous) {
174
+ return (
175
+ <Banner>
176
+ <Text>Welcome, {profile.displayName}!</Text>
177
+ <Button onPress={() => navigation.navigate('Register')}>
178
+ Create Account
179
+ </Button>
180
+ </Banner>
181
+ );
182
+ }
183
+
184
+ return (
185
+ <Banner>
186
+ <Text>Welcome, {profile.displayName}!</Text>
187
+ <Text>Complete your profile to get the most out of the app.</Text>
188
+ </Banner>
189
+ );
190
+ }
191
+ ```
192
+
193
+ ## Anonymous Name Generation
194
+
195
+ Anonymous users automatically get random names generated:
196
+
197
+ ```typescript
198
+ import { generateAnonymousName } from '@umituz/react-native-auth';
199
+
200
+ // Default: "User_Witty_Badger_1234"
201
+ const name1 = generateAnonymousName('user-123');
202
+
203
+ // Custom config
204
+ const name2 = generateAnonymousName('user-123', {
205
+ prefix: 'Guest',
206
+ adjectiveCount: 1,
207
+ nounCount: 1,
208
+ });
209
+ // "Guest_Clever_Fox_1234"
210
+
211
+ // ID only
212
+ const name3 = generateAnonymousName('user-123', {
213
+ prefix: '',
214
+ adjectiveCount: 0,
215
+ nounCount: 0,
216
+ });
217
+ // "user-123"
218
+ ```
219
+
220
+ ## Performance Notes
221
+
222
+ - Hook uses `useMemo` for performance
223
+ - Only recalculates when dependencies change
224
+ - Automatically updates on user sign-in/sign-out
225
+
226
+ ## Related Hooks
227
+
228
+ - [`useAuth`](./useAuth.md) - Main auth state management
229
+ - [`useProfileUpdate`](./useProfileUpdate.md) - Profile updates
230
+ - [`useProfileEdit`](./useProfileEdit.md) - Profile editing form
@@ -0,0 +1,198 @@
1
+ # Auth Screens
2
+
3
+ React Native Auth paketi için hazır ekran component'leri.
4
+
5
+ ## Mevcut Screen'ler
6
+
7
+ - **[`LoginScreen`](./LoginScreen.tsx)** - Giriş ekranı
8
+ - **[`RegisterScreen`](./RegisterScreen.tsx)** - Kayıt ekranı
9
+ - **[`AccountScreen`](./AccountScreen.tsx)** - Hesap ayarları ekranı
10
+ - **[`EditProfileScreen`](./EditProfileScreen.tsx)** - Profil düzenleme ekranı
11
+
12
+ ## Kullanım
13
+
14
+ ### LoginScreen
15
+
16
+ ```typescript
17
+ import { LoginScreen } from '@umituz/react-native-auth';
18
+
19
+ function App() {
20
+ return (
21
+ <Stack.Navigator>
22
+ <Stack.Screen
23
+ name="Login"
24
+ component={LoginScreen}
25
+ options={{ headerShown: false }}
26
+ />
27
+ </Stack.Navigator>
28
+ );
29
+ }
30
+ ```
31
+
32
+ ### RegisterScreen
33
+
34
+ ```typescript
35
+ import { RegisterScreen } from '@umituz/react-native-auth';
36
+
37
+ function App() {
38
+ return (
39
+ <Stack.Navigator>
40
+ <Stack.Screen
41
+ name="Register"
42
+ component={RegisterScreen}
43
+ options={{ headerShown: false }}
44
+ />
45
+ </Stack.Navigator>
46
+ );
47
+ }
48
+ ```
49
+
50
+ ### AccountScreen
51
+
52
+ ```typescript
53
+ import { AccountScreen } from '@umituz/react-native-auth';
54
+
55
+ function App() {
56
+ return (
57
+ <Stack.Navigator>
58
+ <Stack.Screen
59
+ name="Account"
60
+ component={AccountScreen}
61
+ options={{ title: 'Hesabım' }}
62
+ />
63
+ </Stack.Navigator>
64
+ );
65
+ }
66
+ ```
67
+
68
+ ### EditProfileScreen
69
+
70
+ ```typescript
71
+ import { EditProfileScreen } from '@umituz/react-native-auth';
72
+
73
+ function App() {
74
+ return (
75
+ <Stack.Navigator>
76
+ <Stack.Screen
77
+ name="EditProfile"
78
+ component={EditProfileScreen}
79
+ options={{ title: 'Profili Düzenle' }}
80
+ />
81
+ </Stack.Navigator>
82
+ );
83
+ }
84
+ ```
85
+
86
+ ## AuthNavigator
87
+
88
+ Tüm auth ekranlarını içeren hazır navigator:
89
+
90
+ ```typescript
91
+ import { AuthNavigator } from '@umituz/react-native-auth';
92
+
93
+ function App() {
94
+ return (
95
+ <NavigationContainer>
96
+ <AuthNavigator />
97
+ </NavigationContainer>
98
+ );
99
+ }
100
+ ```
101
+
102
+ ## Konfigürasyon
103
+
104
+ ### AccountScreen Konfigürasyonu
105
+
106
+ ```typescript
107
+ import { AccountScreen } from '@umituz/react-native-auth';
108
+
109
+ function SettingsScreen() {
110
+ return (
111
+ <AccountScreen
112
+ config={{
113
+ showChangePassword: true,
114
+ benefits: ['Premium içeriklere erişim', 'Reklamsız deneyim'],
115
+ }}
116
+ />
117
+ );
118
+ }
119
+ ```
120
+
121
+ ### EditProfileScreen Konfigürasyonu
122
+
123
+ ```typescript
124
+ import { EditProfileScreen } from '@umituz/react-native-auth';
125
+
126
+ function ProfileSettings() {
127
+ return (
128
+ <EditProfileScreen
129
+ config={{
130
+ showAvatar: true,
131
+ allowEmailChange: false,
132
+ maxDisplayNameLength: 50,
133
+ }}
134
+ />
135
+ );
136
+ }
137
+ ```
138
+
139
+ ## Tam Örnek
140
+
141
+ ```typescript
142
+ import React from 'react';
143
+ import { NavigationContainer } from '@react-navigation/native';
144
+ import { createNativeStackNavigator } from '@react-navigation/native-stack';
145
+ import {
146
+ AuthNavigator,
147
+ LoginScreen,
148
+ RegisterScreen,
149
+ AccountScreen,
150
+ EditProfileScreen,
151
+ } from '@umituz/react-native-auth';
152
+
153
+ const Stack = createNativeStackNavigator();
154
+
155
+ function App() {
156
+ return (
157
+ <NavigationContainer>
158
+ <Stack.Navigator>
159
+ {/* Auth ekranları */}
160
+ <Stack.Screen
161
+ name="Login"
162
+ component={LoginScreen}
163
+ options={{ headerShown: false }}
164
+ />
165
+ <Stack.Screen
166
+ name="Register"
167
+ component={RegisterScreen}
168
+ options={{ headerShown: false }}
169
+ />
170
+
171
+ {/* Hesap ekranları */}
172
+ <Stack.Screen
173
+ name="Account"
174
+ component={AccountScreen}
175
+ options={{ title: 'Hesabım' }}
176
+ />
177
+ <Stack.Screen
178
+ name="EditProfile"
179
+ component={EditProfileScreen}
180
+ options={{ title: 'Profili Düzenle' }}
181
+ />
182
+
183
+ {/* Diğer ekranlar */}
184
+ <Stack.Screen name="Home" component={HomeScreen} />
185
+ </Stack.Navigator>
186
+ </NavigationContainer>
187
+ );
188
+ }
189
+ ```
190
+
191
+ ## İlgili Component'ler
192
+
193
+ - **[Auth Components](../components/README.md)** - Auth UI component'leri
194
+ - **[Auth Hooks](../hooks/README.md)** - Auth hook'ları
195
+
196
+ ## İlgili Navigation
197
+
198
+ - **[AuthNavigator](../navigation/AuthNavigator.tsx)** - Auth navigator
@@ -1,33 +0,0 @@
1
- /**
2
- * Auth Gradient Background Component
3
- * Gradient background for auth screens
4
- */
5
-
6
- import React from "react";
7
- import { StyleSheet } from "react-native";
8
- import { LinearGradient } from "expo-linear-gradient";
9
- import { useAppDesignTokens } from "@umituz/react-native-design-system";
10
-
11
- export const AuthGradientBackground: React.FC = () => {
12
- const tokens = useAppDesignTokens();
13
-
14
- return (
15
- <LinearGradient
16
- colors={[tokens.colors.primary, tokens.colors.surfaceSecondary]}
17
- start={{ x: 0, y: 0 }}
18
- end={{ x: 1, y: 1 }}
19
- style={StyleSheet.absoluteFill}
20
- />
21
- );
22
- };
23
-
24
-
25
-
26
-
27
-
28
-
29
-
30
-
31
-
32
-
33
-