diff --git a/Vernissage/Widgets/CommentsSection.swift b/Vernissage/Widgets/CommentsSection.swift index a4bbc06..68d0343 100644 --- a/Vernissage/Widgets/CommentsSection.swift +++ b/Vernissage/Widgets/CommentsSection.swift @@ -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 }