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