Bubble/Threaded/Components/ProfilePicture.swift

33 lines
732 B
Swift
Raw Normal View History

//Made by Lumaa
import SwiftUI
struct ProfilePicture: View {
@EnvironmentObject private var pref: UserPreferences
var url: URL
var size: CGFloat = 50.0
init(url: URL, size: CGFloat = 50.0) {
self.url = url
self.size = size
}
var cornerRadius: CGFloat {
2024-02-12 12:28:51 +01:00
return pref.profilePictureShape == .circle ? (size / 2) : 10.0
}
init(url: URL) {
self.url = url
}
init(url: String) {
self.url = .init(string: url)!
}
var body: some View {
OnlineImage(url: url, size: size, useNuke: true)
.frame(width: size - 10, height: size - 10)
.clipShape(RoundedRectangle(cornerRadius: cornerRadius))
}
}