From 4ec99934e4ba886713eb16f71b6ac49edc4039b9 Mon Sep 17 00:00:00 2001 From: cheykrym Date: Wed, 13 Aug 2025 02:32:18 +0300 Subject: [PATCH] =?UTF-8?q?=D0=BE=D1=82=D1=81=D1=82=D1=83=D0=BF=D1=8B=20?= =?UTF-8?q?=D0=BC=D0=B5=D0=B6=D0=B4=D1=83=20=D0=BA=D0=B0=D1=80=D1=82=D0=BE?= =?UTF-8?q?=D1=87=D0=B5=D0=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Shared/Views/Tab/NewHomeTab.swift | 75 +++++++++++++++---------------- 1 file changed, 37 insertions(+), 38 deletions(-) diff --git a/Shared/Views/Tab/NewHomeTab.swift b/Shared/Views/Tab/NewHomeTab.swift index 62cc25a..8ffdc0b 100644 --- a/Shared/Views/Tab/NewHomeTab.swift +++ b/Shared/Views/Tab/NewHomeTab.swift @@ -17,25 +17,26 @@ struct NewHomeTab: View { ProgressView("Загрузка ленты...") } else { ScrollView { - HStack(alignment: .top, spacing: 2) { - LazyVStack(spacing: 8) { + HStack(alignment: .top, spacing: 6) { + LazyVStack(spacing: 6) { ForEach(column1Posts) { post in PostGridItem(post: post) } } - LazyVStack(spacing: 8) { + LazyVStack(spacing: 6) { ForEach(column2Posts) { post in PostGridItem(post: post) } } } - .padding(.horizontal, 2) + .padding(.horizontal, 4) } } } .onAppear { viewModel.fetchDataIfNeeded() } + .background(Color(.secondarySystemBackground)) // Фон для всей вкладки } } @@ -43,57 +44,55 @@ struct PostGridItem: View { let post: Post private var randomHeight: CGFloat { - // Мы можем сделать высоту зависимой от типа контента, если нужно - // пока оставим случайной для визуального разнообразия CGFloat.random(in: 150...300) } var body: some View { - VStack(alignment: .leading, spacing: 8) { + VStack(alignment: .leading, spacing: 0) { // Убираем отступ между картинкой и текстом // 1. Медиа контент if let _ = post.media.first { - Image("placeholderPhoto") // Используем локальный плейсхолдер + Image("placeholderPhoto") .resizable() .aspectRatio(contentMode: .fill) .frame(height: randomHeight) - .clipped() - .cornerRadius(10) } - // 2. Название поста - if let title = post.title, !title.isEmpty { - Text(title) - .font(.headline) - .lineLimit(2) - } - - // 3. Информация об авторе и лайки - HStack { - // Аватар и имя пользователя - HStack(spacing: 4) { - Image(systemName: "person.circle.fill") - .resizable() - .frame(width: 24, height: 24) - .foregroundColor(.gray) - Text(post.authorUsername) + // Контейнер для текста, который создает эффект "расширения" + VStack(alignment: .leading, spacing: 8) { + // 2. Название поста + if let title = post.title, !title.isEmpty { + Text(title) .font(.subheadline) - .lineLimit(1) + .lineLimit(2) } - Spacer() - - // Лайки - HStack(spacing: 4) { - Image(systemName: post.isLikedByCurrentUser ? "heart.fill" : "heart") - .foregroundColor(post.isLikedByCurrentUser ? .red : .primary) - Text("\(post.likes)") - .font(.subheadline) + // 3. Информация об авторе и лайки + HStack { + HStack(spacing: 4) { + Image(systemName: "person.circle.fill") + .resizable() + .frame(width: 20, height: 20) + .foregroundColor(.gray) + Text(post.authorUsername) + .font(.footnote) + .lineLimit(1) + } + + Spacer() + + HStack(spacing: 4) { + Image(systemName: post.isLikedByCurrentUser ? "heart.fill" : "heart") + .foregroundColor(post.isLikedByCurrentUser ? .red : .primary) + Text("\(post.likes)") + .font(.subheadline) + } } } + .padding(8) + .background(Color(UIColor.systemBackground)) // Фон только для текстовой части } - .padding(8) - .background(Color(UIColor.systemBackground)) // Для поддержки темной/светлой темы - .cornerRadius(12) + .cornerRadius(6) // Закругляем всю карточку + .clipped() // Обрезаем дочерние вью по закругленной форме родителя .shadow(color: Color.black.opacity(0.1), radius: 5, x: 0, y: 2) } }