post debug

This commit is contained in:
cheykrym 2025-08-14 20:21:26 +03:00
parent 874e920f6f
commit 9a9d8038e2

View File

@ -65,70 +65,75 @@ struct PostGridItem: View {
} }
var body: some View { var body: some View {
VStack(alignment: .leading, spacing: 0) { // Убираем отступ между картинкой и текстом NavigationLink(destination: PostDetailView(post: post)) {
VStack(alignment: .leading, spacing: 0) { // Убираем отступ между картинкой и текстом
// 1. Медиа контент // 1. Медиа контент
if let url = imageURL { if let url = imageURL {
// Создаем контейнер с четкими границами, чтобы избежать перекрытия // Создаем контейнер с четкими границами, чтобы избежать перекрытия
Color.clear Color.clear
.frame(width: width, height: imageHeight) // Используем вычисленную высоту .frame(width: width, height: imageHeight) // Используем вычисленную высоту
.background( .background(
RemoteImageView(url: url) RemoteImageView(url: url)
.scaledToFill() .scaledToFill()
) )
.clipped() .clipped()
}
// Контейнер для текста, который создает эффект "расширения"
VStack(alignment: .leading, spacing: 8) {
// 2. Название поста
if let title = post.title, !title.isEmpty {
Text(title)
.font(.subheadline)
.lineLimit(2)
} }
// 3. Информация об авторе и лайки // Контейнер для текста, который создает эффект "расширения"
HStack { VStack(alignment: .leading, spacing: 8) {
// 2. Название поста
Button(action: { if let title = post.title, !title.isEmpty {
// пока ничего не делаем Text(title)
}) {
HStack(spacing: 4) {
Image(systemName: "person.circle.fill")
.resizable()
.frame(width: 20, height: 20)
.foregroundColor(.gray)
Text(post.authorUsername)
.font(.footnote)
.lineLimit(1)
.foregroundColor(.primary)
}
}
.contentShape(Rectangle())
Spacer()
Button(action: {
// пока ничего не делаем
}) {
HStack(spacing: 4) {
Image(systemName: post.isLikedByCurrentUser ? "heart.fill" : "heart")
.foregroundColor(post.isLikedByCurrentUser ? .red : .primary)
Text("\(post.likes)")
.font(.subheadline) .font(.subheadline)
.foregroundColor(.primary) .lineLimit(2)
} }
}
.contentShape(Rectangle())
// 3. Информация об авторе и лайки
HStack {
Button(action: {
print("account \(post.id)")
// пока ничего не делаем
}) {
HStack(spacing: 4) {
Image(systemName: "person.circle.fill")
.resizable()
.frame(width: 20, height: 20)
.foregroundColor(.gray)
Text(post.authorUsername)
.font(.footnote)
.lineLimit(1)
.foregroundColor(.primary)
}
}
.contentShape(Rectangle())
Spacer()
Button(action: {
print("like \(post.id)")
// пока ничего не делаем
}) {
HStack(spacing: 4) {
Image(systemName: post.isLikedByCurrentUser ? "heart.fill" : "heart")
.foregroundColor(post.isLikedByCurrentUser ? .red : .primary)
Text("\(post.likes)")
.font(.subheadline)
.foregroundColor(.primary)
}
}
.contentShape(Rectangle())
}
} }
.padding(8)
.background(Color(UIColor.systemBackground)) // Фон только для текстовой части
} }
.padding(8) .cornerRadius(6) // Закругляем всю карточку
.background(Color(UIColor.systemBackground)) // Фон только для текстовой части .clipped() // Обрезаем дочерние вью по закругленной форме родителя
.shadow(color: Color.black.opacity(0.1), radius: 5, x: 0, y: 2)
} }
.cornerRadius(6) // Закругляем всю карточку .buttonStyle(PlainButtonStyle()) // Убираем стандартный стиль кнопки, чтобы не влиять на UI
.clipped() // Обрезаем дочерние вью по закругленной форме родителя
.shadow(color: Color.black.opacity(0.1), radius: 5, x: 0, y: 2)
} }
} }