Skip to content

Commit

Permalink
#34 Use placeholder avatar image on room list
Browse files Browse the repository at this point in the history
  • Loading branch information
ismailgulek committed Jun 22, 2022
1 parent d959b9b commit 0050766
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
3 changes: 2 additions & 1 deletion ElementX/Sources/Screens/HomeScreen/View/HomeScreen.swift
Expand Up @@ -127,7 +127,8 @@ struct RoomCell: View {
.frame(width: 40, height: 40)
.mask(Circle())
} else {
Image(systemName: "person.3")
PlaceholderAvatarImage(text: room.displayName ?? "")
.clipShape(Circle())
.frame(width: 40, height: 40)
}

Expand Down
Expand Up @@ -32,6 +32,18 @@ struct PlaceholderAvatarImage: View {
}
.aspectRatio(1, contentMode: .fill)
}

init(firstCharacter: String) {
self.firstCharacter = firstCharacter
}

init(text: String) {
if let first = text.first {
firstCharacter = String(first)
} else {
firstCharacter = ""
}
}
}

struct PlaceholderAvatarImage_Previews: PreviewProvider {
Expand Down

0 comments on commit 0050766

Please sign in to comment.