[Android] 1.9.2
All checks were successful
OpenClimb Docker Deploy / build-and-push (push) Successful in 2m29s
All checks were successful
OpenClimb Docker Deploy / build-and-push (push) Successful in 2m29s
This commit is contained in:
39
ios/OpenClimb/Components/AsyncImageView.swift
Normal file
39
ios/OpenClimb/Components/AsyncImageView.swift
Normal file
@@ -0,0 +1,39 @@
|
||||
import SwiftUI
|
||||
|
||||
struct AsyncImageView: View {
|
||||
let imagePath: String
|
||||
let targetSize: CGSize
|
||||
|
||||
@State private var image: UIImage?
|
||||
|
||||
var body: some View {
|
||||
ZStack {
|
||||
Rectangle()
|
||||
.fill(Color(.systemGray6))
|
||||
|
||||
if let image = image {
|
||||
Image(uiImage: image)
|
||||
.resizable()
|
||||
.scaledToFill()
|
||||
.transition(.opacity.animation(.easeInOut(duration: 0.3)))
|
||||
} else {
|
||||
Image(systemName: "photo")
|
||||
.font(.system(size: 24))
|
||||
.foregroundColor(Color(.systemGray3))
|
||||
}
|
||||
}
|
||||
.frame(width: targetSize.width, height: targetSize.height)
|
||||
.clipped()
|
||||
.cornerRadius(8)
|
||||
.task(id: imagePath) {
|
||||
if self.image != nil {
|
||||
self.image = nil
|
||||
}
|
||||
|
||||
self.image = await ImageManager.shared.loadThumbnail(
|
||||
fromPath: imagePath,
|
||||
targetSize: targetSize
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user