import SwiftUI struct HomeTab: View { @State private var posts: [Post] = [] @State private var isLoading = true @State private var isRefreshing = false var body: some View { NavigationView { VStack { if isLoading { ProgressView("Загрузка ленты...") } else { RefreshableScrollView(isRefreshing: $isRefreshing, onRefresh: { fetchData() }) { LazyVStack(spacing: 24) { ForEach(posts) { post in PostDetailView(post: post) } } } } } .navigationTitle("Лента") .onAppear { if posts.isEmpty { fetchData(isInitialLoad: true) } } } .navigationViewStyle(StackNavigationViewStyle()) } private func fetchData(isInitialLoad: Bool = false) { if isInitialLoad { isLoading = true } PostService.shared.fetchAllPosts { fetchedPosts in self.posts = fetchedPosts if isInitialLoad { print("content updated") self.isLoading = false } self.isRefreshing = false } } }