mirror of
https://github.com/omnivore-app/omnivore.git
synced 2026-03-11 08:54:26 +00:00
use async image for profile card and linked item cards
This commit is contained in:
parent
d795885785
commit
357ed7a8ec
3 changed files with 15 additions and 22 deletions
|
|
@ -133,19 +133,19 @@ public struct GridCard: View {
|
|||
Spacer()
|
||||
|
||||
if let imageURL = item.imageURL {
|
||||
AsyncLoadingImage(url: imageURL) { imageStatus in
|
||||
if case let AsyncImageStatus.loaded(image) = imageStatus {
|
||||
AsyncImage(url: imageURL) { phase in
|
||||
if let image = phase.image {
|
||||
image
|
||||
.resizable()
|
||||
.aspectRatio(contentMode: .fill)
|
||||
.frame(width: geo.size.width / 3, height: (geo.size.width * 2) / 9)
|
||||
.cornerRadius(3)
|
||||
} else if case AsyncImageStatus.loading = imageStatus {
|
||||
} else if phase.error != nil {
|
||||
EmptyView()
|
||||
} else {
|
||||
Color.appButtonBackground
|
||||
.frame(width: geo.size.width / 3, height: (geo.size.width * 2) / 9)
|
||||
.cornerRadius(3)
|
||||
} else {
|
||||
EmptyView()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -47,19 +47,19 @@ public struct FeedCard: View {
|
|||
|
||||
Group {
|
||||
if let imageURL = item.imageURL {
|
||||
AsyncLoadingImage(url: imageURL) { imageStatus in
|
||||
if case let AsyncImageStatus.loaded(image) = imageStatus {
|
||||
AsyncImage(url: imageURL) { phase in
|
||||
if let image = phase.image {
|
||||
image
|
||||
.resizable()
|
||||
.aspectRatio(contentMode: .fill)
|
||||
.frame(width: 80, height: 80)
|
||||
.cornerRadius(6)
|
||||
} else if case AsyncImageStatus.loading = imageStatus {
|
||||
} else if phase.error != nil {
|
||||
EmptyView().frame(width: 80, height: 80, alignment: .top)
|
||||
} else {
|
||||
Color.appButtonBackground
|
||||
.frame(width: 80, height: 80)
|
||||
.cornerRadius(6)
|
||||
} else {
|
||||
EmptyView().frame(width: 80, height: 80, alignment: .top)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,18 +22,11 @@ public struct ProfileCard: View {
|
|||
public var body: some View {
|
||||
HStack(alignment: .center) {
|
||||
Group {
|
||||
if let url = data.imageURL {
|
||||
AsyncLoadingImage(url: url) { imageStatus in
|
||||
if case let AsyncImageStatus.loaded(image) = imageStatus {
|
||||
image.resizable()
|
||||
} else {
|
||||
Image(systemName: "person.crop.circle").resizable()
|
||||
}
|
||||
}
|
||||
} else {
|
||||
Image(systemName: "person.crop.circle")
|
||||
.resizable()
|
||||
}
|
||||
AsyncImage(
|
||||
url: data.imageURL,
|
||||
content: { $0.resizable() },
|
||||
placeholder: { Image(systemName: "person.crop.circle").resizable() }
|
||||
)
|
||||
}
|
||||
.aspectRatio(contentMode: .fill)
|
||||
.frame(width: 70, height: 70, alignment: .center)
|
||||
|
|
|
|||
Loading…
Reference in a new issue