home page

This commit is contained in:
cheykrym 2025-07-16 07:31:34 +03:00
parent a477ce2f78
commit bb8c9a2b91

View File

@ -1,16 +1,33 @@
import SwiftUI
struct HomeTab: View {
@State private var posts: [Post] = []
@State private var isLoading = true
var body: some View {
NavigationView {
VStack {
Text("Домой")
.font(.largeTitle)
.bold()
.padding()
Spacer()
}
.navigationTitle("Домой")
if isLoading {
ProgressView("Загрузка ленты...")
} else {
ScrollView {
LazyVStack(spacing: 24) {
ForEach(posts) { post in
PostDetailView(post: post)
}
}
}
}
}
.navigationTitle("Лента")
.onAppear {
if posts.isEmpty {
PostService.shared.fetchAllPosts { fetchedPosts in
self.posts = fetchedPosts
self.isLoading = false
}
}
}
}
}
}