home page
This commit is contained in:
		
							parent
							
								
									a477ce2f78
								
							
						
					
					
						commit
						bb8c9a2b91
					
				@ -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()
 | 
			
		||||
                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
 | 
			
		||||
                    }
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
            .navigationTitle("Домой")
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user