use async image for profile card and linked item cards

This commit is contained in:
Satindar Dhillon 2022-08-25 21:36:58 -07:00
parent d795885785
commit 357ed7a8ec
3 changed files with 15 additions and 22 deletions

View file

@ -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()
}
}
}

View file

@ -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)
}
}
}

View file

@ -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)