Fix images into comments

This commit is contained in:
Marcin Czachursk 2023-01-08 15:27:16 +01:00
parent 2ebfe762f0
commit f10a32537c

View File

@ -71,30 +71,34 @@ struct CommentsSection: View {
.padding(.top, -4)
.padding(.leading, -4)
// if status.mediaAttachments.count > 0 {
// LazyVGrid(columns: self.getColumns(status: status), alignment: .center, spacing: 4) {
// ForEach(status.mediaAttachments, id: \.id) { attachment in
// AsyncImage(url: status.mediaAttachments[0].url) { image in
// image
// .resizable()
// .scaledToFill()
// .frame(minWidth: 0, maxWidth: .infinity)
// .frame(height: status.mediaAttachments.count == 1 ? 200 : 100)
// .cornerRadius(10)
// .shadow(color: .mainTextColor.opacity(0.3), radius: 2)
// } placeholder: {
// Image(systemName: "photo")
// .resizable()
// .scaledToFit()
// .frame(minWidth: 0, maxWidth: .infinity)
// .frame(height: status.mediaAttachments.count == 1 ? 200 : 100)
// .foregroundColor(.mainTextColor)
// .opacity(0.05)
// }
// }
// }
// .padding(.bottom, 8)
// }
if status.mediaAttachments.count > 0 {
LazyVGrid(
columns: status.mediaAttachments.count == 1 ? [GridItem(.flexible())]: [GridItem(.flexible()), GridItem(.flexible())],
alignment: .center,
spacing: 4
) {
ForEach(status.mediaAttachments, id: \.id) { attachment in
AsyncImage(url: attachment.url) { image in
image
.resizable()
.scaledToFill()
.frame(minWidth: 0, maxWidth: .infinity)
.frame(height: status.mediaAttachments.count == 1 ? 200 : 100)
.cornerRadius(10)
.shadow(color: .mainTextColor.opacity(0.3), radius: 2)
} placeholder: {
Image(systemName: "photo")
.resizable()
.scaledToFit()
.frame(minWidth: 0, maxWidth: .infinity)
.frame(height: status.mediaAttachments.count == 1 ? 200 : 100)
.foregroundColor(.mainTextColor)
.opacity(0.05)
}
}
}
.padding(.bottom, 8)
}
}
.onTapGesture {
withAnimation(.linear(duration: 0.3)) {
@ -152,10 +156,6 @@ struct CommentsSection: View {
return status.account?.displayName ?? status.account?.acct ?? status.account?.username ?? ""
}
private func getColumns(status: Status) -> [GridItem.Size] {
return Array(repeating: .flexible(), count: status.mediaAttachments.count == 1 ? 1 : 2)
}
private func getInteractionRowTextColor() -> Color {
return self.colorScheme == .dark ? Color.black : Color.white
}