@umituz/react-native-design-system 2.6.87 → 2.6.88

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,431 @@
1
+ # Avatar (Molecule)
2
+
3
+ Avatar molecule bileşeni, kullanıcı profil resimlerini göstermek için gelişmiş bir bileşendir. Resim, isim baş harfleri veya ikon fallback'ları destekler. Ayrıca online durumu gösterebilir.
4
+
5
+ ## Özellikler
6
+
7
+ - 🖼️ **Resim Desteği**: URI ile resim yükleme
8
+ - 🔤 **Initials**: İsimden baş harfleri oluşturma
9
+ - 🎭 **İkon Fallback**: Fallback ikon desteği
10
+ - 🟢 **Status Indicator**: Online/offline durumu
11
+ - 📏 **5 Size**: xs, sm, md, lg, xl
12
+ - 🔲 **2 Shape**: Circle, Square
13
+ - 🎨 **Özelleştirilebilir**: Renk ve stil
14
+ - 👆 **Pressable**: Tıklanabilir avatar
15
+
16
+ ## Kurulum
17
+
18
+ ```tsx
19
+ import { Avatar } from 'react-native-design-system';
20
+ ```
21
+
22
+ ## Temel Kullanım
23
+
24
+ ```tsx
25
+ import React from 'react';
26
+ import { View } from 'react-native';
27
+ import { Avatar } from 'react-native-design-system';
28
+
29
+ export const BasicExample = () => {
30
+ return (
31
+ <View style={{ padding: 16 }}>
32
+ <Avatar
33
+ uri="https://example.com/avatar.jpg"
34
+ size="md"
35
+ />
36
+ </View>
37
+ );
38
+ };
39
+ ```
40
+
41
+ ## Basic Avatar
42
+
43
+ ```tsx
44
+ {/* Resim ile */}
45
+ <Avatar
46
+ uri="https://example.com/avatar.jpg"
47
+ size="md"
48
+ />
49
+
50
+ {/* İsim ile (initials) */}
51
+ <Avatar
52
+ name="Ahmet Yılmaz"
53
+ size="md"
54
+ />
55
+
56
+ {/* İkon ile */}
57
+ <Avatar
58
+ icon="person-outline"
59
+ size="md"
60
+ />
61
+ ```
62
+
63
+ ## Boyutlar
64
+
65
+ ```tsx
66
+ <View style={{ flexDirection: 'row', gap: 8, alignItems: 'center' }}>
67
+ <Avatar name="A" size="xs" />
68
+ <Avatar name="A" size="sm" />
69
+ <Avatar name="A" size="md" />
70
+ <Avatar name="A" size="lg" />
71
+ <Avatar name="A" size="xl" />
72
+ </View>
73
+ ```
74
+
75
+ ## Shape
76
+
77
+ ```tsx
78
+ <View style={{ flexDirection: 'row', gap: 8 }}>
79
+ {/* Circle (varsayılan) */}
80
+ <Avatar
81
+ uri="https://example.com/avatar.jpg"
82
+ shape="circle"
83
+ size="lg"
84
+ />
85
+
86
+ {/* Square */}
87
+ <Avatar
88
+ uri="https://example.com/avatar.jpg"
89
+ shape="square"
90
+ size="lg"
91
+ />
92
+ </View>
93
+ ```
94
+
95
+ ## Status Indicator
96
+
97
+ ```tsx
98
+ <View style={{ flexDirection: 'row', gap: 8 }}>
99
+ <Avatar
100
+ uri="https://example.com/avatar.jpg"
101
+ showStatus
102
+ status="online"
103
+ size="lg"
104
+ />
105
+
106
+ <Avatar
107
+ uri="https://example.com/avatar.jpg"
108
+ showStatus
109
+ status="offline"
110
+ size="lg"
111
+ />
112
+
113
+ <Avatar
114
+ uri="https://example.com/avatar.jpg"
115
+ showStatus
116
+ status="away"
117
+ size="lg"
118
+ />
119
+
120
+ <Avatar
121
+ uri="https://example.com/avatar.jpg"
122
+ showStatus
123
+ status="busy"
124
+ size="lg"
125
+ />
126
+ </View>
127
+ ```
128
+
129
+ ## Custom Background
130
+
131
+ ```tsx
132
+ <Avatar
133
+ name="Ahmet"
134
+ backgroundColor="#6366f1"
135
+ size="lg"
136
+ />
137
+ ```
138
+
139
+ ## Pressable
140
+
141
+ ```tsx
142
+ <Avatar
143
+ uri="https://example.com/avatar.jpg"
144
+ size="lg"
145
+ onPress={() => navigation.navigate('Profile')}
146
+ />
147
+ ```
148
+
149
+ ## Örnek Kullanımlar
150
+
151
+ ### Kullanıcı Listesi
152
+
153
+ ```tsx
154
+ export const UserList = ({ users }) => {
155
+ return (
156
+ <View style={{ padding: 16 }}>
157
+ {users.map((user) => (
158
+ <View key={user.id} style={{ flexDirection: 'row', alignItems: 'center', marginBottom: 16 }}>
159
+ <Avatar
160
+ uri={user.avatar}
161
+ name={user.name}
162
+ showStatus
163
+ status={user.status}
164
+ size="md"
165
+ style={{ marginRight: 12 }}
166
+ />
167
+
168
+ <View style={{ flex: 1 }}>
169
+ <AtomicText type="bodyLarge" fontWeight="600">
170
+ {user.name}
171
+ </AtomicText>
172
+ <AtomicText type="bodySmall" color="textSecondary">
173
+ @{user.username}
174
+ </AtomicText>
175
+ </View>
176
+ </View>
177
+ ))}
178
+ </View>
179
+ );
180
+ };
181
+ ```
182
+
183
+ ### Avatar Group
184
+
185
+ ```tsx
186
+ export const AvatarGroup = ({ users, max = 3 }) => {
187
+ const visibleUsers = users.slice(0, max);
188
+ const remainingCount = users.length - max;
189
+
190
+ return (
191
+ <View style={{ flexDirection: 'row' }}>
192
+ {visibleUsers.map((user, index) => (
193
+ <Avatar
194
+ key={user.id}
195
+ uri={user.avatar}
196
+ name={user.name}
197
+ size="sm"
198
+ style={{
199
+ marginLeft: index > 0 ? -8 : 0,
200
+ borderWidth: 2,
201
+ borderColor: '#fff',
202
+ }}
203
+ />
204
+ ))}
205
+
206
+ {remainingCount > 0 && (
207
+ <View
208
+ style={{
209
+ width: 40,
210
+ height: 40,
211
+ borderRadius: 20,
212
+ backgroundColor: '#e0e0e0',
213
+ justifyContent: 'center',
214
+ alignItems: 'center',
215
+ marginLeft: -8,
216
+ borderWidth: 2,
217
+ borderColor: '#fff',
218
+ }}
219
+ >
220
+ <AtomicText type="labelSmall">
221
+ +{remainingCount}
222
+ </AtomicText>
223
+ </View>
224
+ )}
225
+ </View>
226
+ );
227
+ };
228
+ ```
229
+
230
+ ### Profil Header
231
+
232
+ ```tsx
233
+ export const ProfileHeader = ({ user }) => {
234
+ return (
235
+ <View style={{ alignItems: 'center', padding: 24 }}>
236
+ <Avatar
237
+ uri={user.avatar}
238
+ name={user.name}
239
+ size="xl"
240
+ showStatus
241
+ status={user.status}
242
+ style={{ marginBottom: 16 }}
243
+ />
244
+
245
+ <AtomicText type="headlineSmall">
246
+ {user.name}
247
+ </AtomicText>
248
+
249
+ <AtomicText type="bodyMedium" color="textSecondary">
250
+ @{user.username}
251
+ </AtomicText>
252
+ </View>
253
+ );
254
+ };
255
+ ```
256
+
257
+ ### Sohbet Listesi
258
+
259
+ ```tsx
260
+ export const ChatList = ({ chats }) => {
261
+ return (
262
+ <FlatList
263
+ data={chats}
264
+ keyExtractor={(item) => item.id}
265
+ renderItem={({ item }) => (
266
+ <Pressable
267
+ style={{ flexDirection: 'row', alignItems: 'center', padding: 16 }}
268
+ onPress={() => navigation.navigate('Chat', { chatId: item.id })}
269
+ >
270
+ <Avatar
271
+ uri={item.avatar}
272
+ name={item.name}
273
+ showStatus
274
+ status={item.online ? 'online' : 'offline'}
275
+ size="md"
276
+ style={{ marginRight: 12 }}
277
+ />
278
+
279
+ <View style={{ flex: 1 }}>
280
+ <AtomicText type="bodyLarge" fontWeight="600">
281
+ {item.name}
282
+ </AtomicText>
283
+ <AtomicText type="bodySmall" color="textSecondary" numberOfLines={1}>
284
+ {item.lastMessage}
285
+ </AtomicText>
286
+ </View>
287
+
288
+ <AtomicText type="bodySmall" color="textTertiary">
289
+ {item.time}
290
+ </AtomicText>
291
+ </Pressable>
292
+ )}
293
+ />
294
+ );
295
+ };
296
+ ```
297
+
298
+ ### Takım Üyeleri
299
+
300
+ ```tsx
301
+ export const TeamMembers = ({ members }) => {
302
+ return (
303
+ <View style={{ flexDirection: 'row', flexWrap: 'wrap', gap: 8 }}>
304
+ {members.map((member) => (
305
+ <View key={member.id} style={{ alignItems: 'center' }}>
306
+ <Avatar
307
+ uri={member.avatar}
308
+ name={member.name}
309
+ showStatus
310
+ status={member.status}
311
+ size="sm"
312
+ />
313
+
314
+ <AtomicText type="bodySmall" style={{ marginTop: 4 }}>
315
+ {member.firstName}
316
+ </AtomicText>
317
+ </View>
318
+ ))}
319
+ </View>
320
+ );
321
+ };
322
+ ```
323
+
324
+ ## Props
325
+
326
+ ### AvatarProps
327
+
328
+ | Prop | Tip | Varsayılan | Açıklama |
329
+ |------|-----|------------|----------|
330
+ | `uri` | `string` | - | Resim URI'si |
331
+ | `name` | `string` | - | Kullanıcı ismi |
332
+ | `icon` | `string` | - | Fallback ikon |
333
+ | `size` | `AvatarSize` | `'md'` | Avatar boyutu |
334
+ | `shape` | `AvatarShape` | `'circle'` | Avatar şekli |
335
+ | `backgroundColor` | `string` | - | Arka plan rengi |
336
+ | `showStatus` | `boolean` | `false` | Status göster |
337
+ | `status` | `StatusType` | `'offline'` | Durum |
338
+ | `style` | `ViewStyle` | - | Özel stil |
339
+ | `imageStyle` | `ImageStyle` | - | Resim stili |
340
+ | `onPress` | `() => void` | - | Tıklama olayı |
341
+
342
+ ### AvatarSize
343
+
344
+ ```typescript
345
+ type AvatarSize =
346
+ | 'xs' // Extra small
347
+ | 'sm' // Small
348
+ | 'md' // Medium (varsayılan)
349
+ | 'lg' // Large
350
+ | 'xl'; // Extra large
351
+ ```
352
+
353
+ ### AvatarShape
354
+
355
+ ```typescript
356
+ type AvatarShape = 'circle' | 'square';
357
+ ```
358
+
359
+ ### StatusType
360
+
361
+ ```typescript
362
+ type StatusType =
363
+ | 'online' // Yeşil
364
+ | 'offline' // Gri
365
+ | 'away' // Sarı
366
+ | 'busy'; // Kırmızı
367
+ ```
368
+
369
+ ## Best Practices
370
+
371
+ ### 1. Boyut Seçimi
372
+
373
+ ```tsx
374
+ // Liste içinde
375
+ <Avatar size="sm" />
376
+
377
+ // Profil sayfası
378
+ <Avatar size="xl" />
379
+
380
+ // Navigasyon
381
+ <Avatar size="md" />
382
+ ```
383
+
384
+ ### 2. Status Kullanımı
385
+
386
+ ```tsx
387
+ // Kullanıcı durumu
388
+ <Avatar showStatus status="online" />
389
+
390
+ // Sohbet uygulaması
391
+ <Avatar showStatus status={user.isOnline ? 'online' : 'offline'} />
392
+ ```
393
+
394
+ ### 3. Fallback Hierarchy
395
+
396
+ ```tsx
397
+ // 1. Resim varsa
398
+ <Avatar uri={avatarUri} />
399
+
400
+ // 2. İsim varsa
401
+ <Avatar name="Ahmet Yılmaz" /> {/* AY */}
402
+
403
+ // 3. Hiçbiri yoksa
404
+ <Avatar /> {/* İkon */}
405
+ ```
406
+
407
+ ## Erişilebilirlik
408
+
409
+ Avatar, tam erişilebilirlik desteği sunar:
410
+
411
+ - ✅ Screen reader desteği
412
+ - ✅ Accessibility label
413
+ - ✅ FaceID for status
414
+ - ✅ Touch uygun boyut
415
+ - ✅ Test ID desteği
416
+
417
+ ## Performans İpuçları
418
+
419
+ 1. **Image Caching**: Resimleri cache'leyin
420
+ 2. **Lazy Loading**: Uzun listelerde lazy load kullanın
421
+ 3. **Resize**: Resimleri doğru boyutta yükleyin
422
+
423
+ ## İlgili Bileşenler
424
+
425
+ - [`AvatarGroup`](./AvatarGroup/README.md) - Avatar grubu
426
+ - [`AtomicAvatar`](../../atoms/AtomicAvatar/README.md) - Atom avatar
427
+ - [`AtomicIcon`](../../atoms/AtomicIcon/README.md) - İkon bileşeni
428
+
429
+ ## Lisans
430
+
431
+ MIT