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