mirror of
https://github.com/Dimillian/IceCubesApp.git
synced 2024-06-09 16:59:35 +00:00
33 lines
713 B
Swift
33 lines
713 B
Swift
|
import SwiftUI
|
||
|
|
||
|
public struct AvatarView: View {
|
||
|
@Environment(\.redactionReasons) private var reasons
|
||
|
public let url: URL
|
||
|
|
||
|
public init(url: URL) {
|
||
|
self.url = url
|
||
|
}
|
||
|
|
||
|
public var body: some View {
|
||
|
if reasons == .placeholder {
|
||
|
RoundedRectangle(cornerRadius: 4)
|
||
|
.fill(.gray)
|
||
|
.frame(maxWidth: 40, maxHeight: 40)
|
||
|
} else {
|
||
|
AsyncImage(
|
||
|
url: url,
|
||
|
content: { image in
|
||
|
image.resizable()
|
||
|
.aspectRatio(contentMode: .fit)
|
||
|
.cornerRadius(4)
|
||
|
.frame(maxWidth: 40, maxHeight: 40)
|
||
|
},
|
||
|
placeholder: {
|
||
|
ProgressView()
|
||
|
.frame(maxWidth: 40, maxHeight: 40)
|
||
|
}
|
||
|
)
|
||
|
}
|
||
|
}
|
||
|
}
|