ios_app/Shared/Views/Tab/Profile/PostDetailView.swift
2025-07-16 07:14:30 +03:00

98 lines
3.4 KiB
Swift
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import SwiftUI
struct PostDetailView: View {
let postID: UUID
@State private var post: Post?
var body: some View {
VStack(alignment: .leading, spacing: 0) {
if let post = post {
// Шапка поста
HStack {
Image(systemName: "person.crop.circle.fill")
.resizable()
.frame(width: 36, height: 36)
.foregroundColor(.gray)
Text(post.authorUsername)
.font(.headline)
Spacer()
Button(action: {}) {
Image(systemName: "ellipsis")
.foregroundColor(.primary)
}
}
.padding(.horizontal)
.padding(.vertical, 8)
// Изображение поста
Rectangle()
.fill(Color.gray.opacity(0.3))
.aspectRatio(1, contentMode: .fit)
.frame(maxWidth: .infinity)
// Панель действий
HStack(spacing: 16) {
Button(action: {}) {
Image(systemName: "heart")
.font(.system(size: 24))
}
Button(action: {}) {
Image(systemName: "message")
.font(.system(size: 24))
}
Button(action: {}) {
Image(systemName: "paperplane")
.font(.system(size: 24))
}
Spacer()
Button(action: {}) {
Image(systemName: "bookmark")
.font(.system(size: 24))
}
}
.foregroundColor(.primary)
.padding(.horizontal)
.padding(.top, 8)
// Лайки и описание
VStack(alignment: .leading, spacing: 4) {
Text("\(post.likes) likes")
.font(.headline)
Text(post.description ?? "")
.font(.subheadline)
}
.padding(.horizontal)
.padding(.top, 8)
// Комментарии
VStack(alignment: .leading, spacing: 4) {
Text("View all \(post.commentsCount) comments")
.font(.caption)
.foregroundColor(.secondary)
.padding(.top, 4)
Text("2 hours ago")
.font(.caption2)
.foregroundColor(.secondary)
.padding(.top, 4)
}
.padding(.horizontal)
Spacer()
} else {
ProgressView("Загрузка...")
.onAppear {
// Симуляция загрузки поста
PostService.shared.fetchPost(by: postID) { fetchedPost in
self.post = fetchedPost
}
}
}
}
.navigationBarTitleDisplayMode(.inline)
.navigationTitle("Post")
}
}