@umituz/react-native-auth 3.4.30 → 3.4.31

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,303 @@
1
+ # SocialLoginButtons
2
+
3
+ Google ve Apple ile social login button'larını gösteren component.
4
+
5
+ ## Özellikler
6
+
7
+ - ✅ Google ve Apple login button'ları
8
+ - ✅ Loading states
9
+ - ✅ Disabled states
10
+ - ✅ Platform check (Apple sadece iOS)
11
+ - ✅ Localisation desteği
12
+ - ✅ Design system uyumlu
13
+
14
+ ## Kullanım
15
+
16
+ ```typescript
17
+ import { SocialLoginButtons } from '@umituz/react-native-auth';
18
+
19
+ function LoginScreen() {
20
+ const { signInWithGoogle, googleLoading } = useGoogleAuth({
21
+ webClientId: 'your-client-id',
22
+ });
23
+
24
+ const { signInWithApple, appleLoading } = useAppleAuth();
25
+
26
+ return (
27
+ <View>
28
+ <LoginForm />
29
+
30
+ <SocialLoginButtons
31
+ enabledProviders={['google', 'apple']}
32
+ onGooglePress={signInWithGoogle}
33
+ onApplePress={signInWithApple}
34
+ googleLoading={googleLoading}
35
+ appleLoading={appleLoading}
36
+ />
37
+ </View>
38
+ );
39
+ }
40
+ ```
41
+
42
+ ## Props
43
+
44
+ | Prop | Tip | Required | Default | Açıklama |
45
+ |------|-----|----------|---------|----------|
46
+ | `enabledProviders` | `SocialAuthProvider[]` | Yes | - | Aktif provider'lar |
47
+ | `onGooglePress` | `() => void` | No | - | Google butonu handler |
48
+ | `onApplePress` | `() => void` | No | - | Apple butonu handler |
49
+ | `googleLoading` | `boolean` | No | `false` | Google loading durumu |
50
+ | `appleLoading` | `boolean` | No | `false` | Apple loading durumu |
51
+ | `disabled` | `boolean` | No | `false` | Tüm butonları disable et |
52
+
53
+ ### SocialAuthProvider
54
+
55
+ ```typescript
56
+ type SocialAuthProvider = 'google' | 'apple';
57
+ ```
58
+
59
+ ## Örnekler
60
+
61
+ ### Sadece Google
62
+
63
+ ```typescript
64
+ function LoginScreen() {
65
+ const { signInWithGoogle, googleLoading } = useGoogleAuth({
66
+ webClientId: Config.GOOGLE_WEB_CLIENT_ID,
67
+ });
68
+
69
+ return (
70
+ <View>
71
+ <LoginForm />
72
+
73
+ <SocialLoginButtons
74
+ enabledProviders={['google']}
75
+ onGooglePress={signInWithGoogle}
76
+ googleLoading={googleLoading}
77
+ />
78
+ </View>
79
+ );
80
+ }
81
+ ```
82
+
83
+ ### Google ve Apple (iOS)
84
+
85
+ ```typescript
86
+ function LoginScreen() {
87
+ const { signInWithGoogle, googleLoading } = useGoogleAuth({
88
+ iosClientId: Config.GOOGLE_IOS_CLIENT_ID,
89
+ });
90
+
91
+ const { signInWithApple, appleLoading } = useAppleAuth();
92
+
93
+ return (
94
+ <View>
95
+ <LoginForm />
96
+
97
+ <SocialLoginButtons
98
+ enabledProviders={['google', 'apple']}
99
+ onGooglePress={signInWithGoogle}
100
+ onApplePress={signInWithApple}
101
+ googleLoading={googleLoading}
102
+ appleLoading={appleLoading}
103
+ />
104
+ </View>
105
+ );
106
+ }
107
+ ```
108
+
109
+ ### Platform-Specific Providers
110
+
111
+ ```typescript
112
+ function LoginScreen() {
113
+ const { signInWithGoogle, googleLoading } = useGoogleAuth({
114
+ webClientId: Config.GOOGLE_WEB_CLIENT_ID,
115
+ });
116
+
117
+ const { signInWithApple, appleLoading, appleAvailable } = useAppleAuth();
118
+
119
+ // Sadece mevcut provider'ları göster
120
+ const enabledProviders = ['google'];
121
+ if (appleAvailable) {
122
+ enabledProviders.push('apple');
123
+ }
124
+
125
+ return (
126
+ <View>
127
+ <SocialLoginButtons
128
+ enabledProviders={enabledProviders}
129
+ onGooglePress={signInWithGoogle}
130
+ onApplePress={signInWithApple}
131
+ googleLoading={googleLoading}
132
+ appleLoading={appleLoading}
133
+ />
134
+ </View>
135
+ );
136
+ }
137
+ ```
138
+
139
+ ### Custom Handlers
140
+
141
+ ```typescript
142
+ function LoginScreen() {
143
+ const navigation = useNavigation();
144
+
145
+ const handleGoogleSignIn = async () => {
146
+ try {
147
+ const result = await customGoogleSignIn();
148
+
149
+ if (result.success) {
150
+ navigation.navigate('Home');
151
+ } else {
152
+ Alert.alert('Hata', result.error);
153
+ }
154
+ } catch (error) {
155
+ Alert.alert('Hata', 'Bir sorun oluştu');
156
+ }
157
+ };
158
+
159
+ const handleAppleSignIn = async () => {
160
+ try {
161
+ const result = await customAppleSignIn();
162
+
163
+ if (result.success) {
164
+ navigation.navigate('Home');
165
+ } else {
166
+ Alert.alert('Hata', result.error);
167
+ }
168
+ } catch (error) {
169
+ Alert.alert('Hata', 'Bir sorun oluştu');
170
+ }
171
+ };
172
+
173
+ return (
174
+ <View>
175
+ <SocialLoginButtons
176
+ enabledProviders={['google', 'apple']}
177
+ onGooglePress={handleGoogleSignIn}
178
+ onApplePress={handleAppleSignIn}
179
+ />
180
+ </View>
181
+ );
182
+ }
183
+ ```
184
+
185
+ ### Disabled State
186
+
187
+ ```typescript
188
+ function LoginScreen() {
189
+ const [isSubmitting, setIsSubmitting] = useState(false);
190
+ const { signInWithGoogle, googleLoading } = useGoogleAuth();
191
+
192
+ return (
193
+ <View>
194
+ <Button onPress={handleSubmit} loading={isSubmitting}>
195
+ Giriş Yap
196
+ </Button>
197
+
198
+ <SocialLoginButtons
199
+ enabledProviders={['google']}
200
+ onGooglePress={signInWithGoogle}
201
+ googleLoading={googleLoading}
202
+ disabled={isSubmitting} // Form submit sırasında disable et
203
+ />
204
+ </View>
205
+ );
206
+ }
207
+ ```
208
+
209
+ ### Error Handling
210
+
211
+ ```typescript
212
+ function LoginScreen() {
213
+ const { signInWithGoogle, googleLoading } = useGoogleAuth();
214
+ const [error, setError] = useState<string | null>(null);
215
+
216
+ const handleGoogleSignIn = async () => {
217
+ setError(null);
218
+ try {
219
+ const result = await signInWithGoogle();
220
+
221
+ if (!result.success) {
222
+ setError(result.error || 'Google ile giriş başarısız');
223
+ }
224
+ } catch (err) {
225
+ setError(err instanceof Error ? err.message : 'Bir hata oluştu');
226
+ }
227
+ };
228
+
229
+ return (
230
+ <View>
231
+ {error && <Text style={styles.error}>{error}</Text>}
232
+
233
+ <SocialLoginButtons
234
+ enabledProviders={['google']}
235
+ onGooglePress={handleGoogleSignIn}
236
+ googleLoading={googleLoading}
237
+ />
238
+ </View>
239
+ );
240
+ }
241
+ ```
242
+
243
+ ## Görünüm
244
+
245
+ ### Divider
246
+ ```
247
+ ─────────────────── veya şununla devam et ───────────────────
248
+ ```
249
+
250
+ ### Buttons
251
+ ```
252
+ ┌─────────────────┐ ┌─────────────────┐
253
+ │ G Google │ │ A Apple │
254
+ └─────────────────┘ └─────────────────┘
255
+ ```
256
+
257
+ ### Loading
258
+ ```
259
+ ┌─────────────────┐
260
+ │ ⏳ Yükleniyor... │
261
+ └─────────────────┘
262
+ ```
263
+
264
+ ## Platform Davranışı
265
+
266
+ | Platform | Google | Apple |
267
+ |----------|--------|-------|
268
+ | iOS | ✅ | ✅ |
269
+ | Android | ✅ | ❌ |
270
+ | Web | ✅ | ❌ |
271
+
272
+ Apple butonu otomatik olarak sadece iOS'ta gösterilir.
273
+
274
+ ## Localisation
275
+
276
+ Component localisation kullanır:
277
+
278
+ ```typescript
279
+ // Türkçe
280
+ "auth.orContinueWith": "veya şununla devam et"
281
+ "auth.google": "Google"
282
+ "auth.apple": "Apple"
283
+ ```
284
+
285
+ ## Design System
286
+
287
+ Component design system tokens kullanır:
288
+
289
+ - `tokens.colors.border` - Border rengi
290
+ - `tokens.colors.textPrimary` - Metin rengi
291
+ - `tokens.spacing` - Spacing değerleri
292
+
293
+ ## İlgili Component'ler
294
+
295
+ - [`LoginForm`](./LoginForm.md) - Login formu
296
+ - [`RegisterForm`](./LoginForm.md#registerform) - Kayıt formu
297
+ - [`AuthDivider`](./AuthDivider.md) - Divider component'i
298
+
299
+ ## İlgili Hook'lar
300
+
301
+ - [`useGoogleAuth`](../hooks/useSocialLogin.md#usegoogleauth) - Google auth hook'u
302
+ - [`useAppleAuth`](../hooks/useSocialLogin.md#useappleauth) - Apple auth hook'u
303
+ - [`useSocialLogin`](../hooks/useSocialLogin.md#usesociallogin) - Genel social login hook'u
@@ -0,0 +1,122 @@
1
+ # Auth Hooks
2
+
3
+ Collection of custom React hooks for the React Native Auth package. These hooks manage authentication operations and state.
4
+
5
+ ## Available Hooks
6
+
7
+ ### Core Hooks
8
+ - **[`useAuth`](./useAuth.md)** - Main authentication state and operations
9
+ - **[`useAuthRequired`](./useAuthRequired.md)** - For components requiring auth
10
+ - **[`useRequireAuth`](./useRequireAuth.md)** - Alternative hook for route protection
11
+
12
+ ### User Profile Hooks
13
+ - **[`useUserProfile`](./useUserProfile.md)** - Fetch user profile data
14
+ - **[`useProfileUpdate`](./useProfileUpdate.md)** - Profile update operations
15
+ - **[`useProfileEdit`](./useProfileEdit.md)** - Profile editing form state
16
+
17
+ ### Account Management Hooks
18
+ - **[`useAccountManagement`](./useAccountManagement.md)** - Account deletion, logout, etc.
19
+
20
+ ### Social Login Hooks
21
+ - **[`useSocialLogin`](./useSocialLogin.md)** - General social login management
22
+ - **[`useGoogleAuth`](./useSocialLogin.md#usegoogleauth)** - Google sign-in
23
+ - **[`useAppleAuth`](./useSocialLogin.md#useappleauth)** - Apple sign-in
24
+
25
+ ### Form Hooks
26
+ - **[`useLoginForm`](./useLoginForm.md)** - Login form state management
27
+ - **[`useRegisterForm`](./useRegisterForm.md)** - Registration form state management
28
+
29
+ ### UI Hooks
30
+ - **[`useAuthBottomSheet`](./useAuthBottomSheet.md)** - Auth bottom sheet management
31
+
32
+ ### Mutation Hooks
33
+ - **[`useAuthMutations`](./mutations/useAuthMutations.md)** - Auth mutation operations
34
+
35
+ ## Usage
36
+
37
+ ```typescript
38
+ import {
39
+ useAuth,
40
+ useUserProfile,
41
+ useSocialLogin
42
+ } from '@umituz/react-native-auth';
43
+
44
+ function MyComponent() {
45
+ const { user, signIn, signOut } = useAuth();
46
+ const { profile, isLoading } = useUserProfile();
47
+ const { signInWithGoogle } = useSocialLogin();
48
+
49
+ // ...
50
+ }
51
+ ```
52
+
53
+ ## Hooks Documentation
54
+
55
+ See each hook's documentation for detailed usage information and examples.
56
+
57
+ ## Quick Reference
58
+
59
+ | Hook | Purpose | Returns |
60
+ |------|---------|---------|
61
+ | `useAuth` | Main auth state | `UseAuthResult` |
62
+ | `useAuthRequired` | Check auth + show modal | `UseAuthRequiredResult` |
63
+ | `useRequireAuth` | Get userId or throw | `string` |
64
+ | `useUserProfile` | Fetch profile data | `UserProfileData \| undefined` |
65
+ | `useProfileUpdate` | Update profile | `UseProfileUpdateReturn` |
66
+ | `useProfileEdit` | Edit profile form | `UseProfileEditReturn` |
67
+ | `useAccountManagement` | Account operations | `UseAccountManagementReturn` |
68
+ | `useSocialLogin` | Social login | `UseSocialLoginResult` |
69
+ | `useGoogleAuth` | Google auth | `UseGoogleAuthResult` |
70
+ | `useAppleAuth` | Apple auth | `UseAppleAuthResult` |
71
+ | `useAuthBottomSheet` | Bottom sheet | Modal ref + handlers |
72
+
73
+ ## Best Practices
74
+
75
+ ### 1. Use Appropriate Hooks
76
+
77
+ ```typescript
78
+ // ✅ Good - Use useAuth for general auth
79
+ function Component() {
80
+ const { user, signIn } = useAuth();
81
+ }
82
+
83
+ // ❌ Bad - Using useRequireAuth when you don't need userId
84
+ function Component() {
85
+ const userId = useRequireAuth(); // Throws if not auth
86
+ }
87
+ ```
88
+
89
+ ### 2. Handle Loading States
90
+
91
+ ```typescript
92
+ // ✅ Good
93
+ function Component() {
94
+ const { loading, isAuthReady, user } = useAuth();
95
+
96
+ if (loading) return <LoadingSpinner />;
97
+ if (!isAuthReady) return <InitializingScreen />;
98
+ if (!user) return <LoginScreen />;
99
+
100
+ return <HomeScreen />;
101
+ }
102
+ ```
103
+
104
+ ### 3. Use Selectors for Performance
105
+
106
+ ```typescript
107
+ // ✅ Good - Selectors prevent unnecessary re-renders
108
+ function Component() {
109
+ const isAuthenticated = useAuthStore(selectIsAuthenticated);
110
+ }
111
+
112
+ // ❌ Bad - Re-renders on any state change
113
+ function Component() {
114
+ const { isAuthenticated } = useAuth();
115
+ }
116
+ ```
117
+
118
+ ## Related Documentation
119
+
120
+ - **[Components](../components/README.md)** - UI components
121
+ - **[Services](../../infrastructure/services/README.md)** - Core services
122
+ - **[Domain](../../domain/README.md)** - Domain entities