You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docusaurus/docs/iOS/swiftui/components/custom-avatar.md
+8-11Lines changed: 8 additions & 11 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,32 +4,29 @@ title: Message Avatar View
4
4
5
5
## Injecting Custom Avatar View
6
6
7
-
The default avatar shown for the message sender in the SDK is a rounded image with the user's photo. You can change the look and feel of this component, as well as introduce additional elements, such as the sender name.
7
+
The default avatar shown for the message sender in the SDK is a rounded image with the user's photo. You can change the look and feel of this component, as well as introduce additional elements.
8
8
9
-
To do this, you need to implement the `makeMessageAvatarView` of the `ViewFactory` and return your custom view. Here's an example on how to create a custom avatar with the author's name bellow the image.
9
+
To do this, you need to implement the `makeMessageAvatarView` of the `ViewFactory` and return your custom view. Here's an example on how to create a custom avatar with rounded rectangle clip shape.
10
10
11
11
```swift
12
12
importStreamChat
13
13
importNukeUI
14
14
importNuke
15
15
16
16
structCustomUserAvatar: View {
17
-
varauthor: ChatUser
17
+
varavatarURL: URL?
18
18
19
19
publicvar body: some View {
20
-
VStack {
21
-
iflet url =author.imageURL?.absoluteString {
20
+
ZStack {
21
+
iflet url =avatarURL {
22
22
LazyImage(source: url)
23
-
.clipShape(Circle())
23
+
.clipShape(RoundedRectangle(cornerRadius: 8))
24
24
.frame(width: 40, height: 40)
25
25
} else {
26
26
Image(systemName: "person.circle")
27
27
.resizable()
28
28
.frame(width: 40, height: 40)
29
29
}
30
-
Text(author.name??"")
31
-
.font(.system(size: 13))
32
-
.frame(maxWidth: 60)
33
30
}
34
31
}
35
32
@@ -45,8 +42,8 @@ class CustomFactory: ViewFactory {
0 commit comments