update home and profile
This commit is contained in:
		
							parent
							
								
									a716b296d5
								
							
						
					
					
						commit
						ebb34b672a
					
				@ -29,6 +29,7 @@ struct HomeTab: View {
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        .navigationViewStyle(StackNavigationViewStyle())
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private func fetchData(isInitialLoad: Bool = false) {
 | 
			
		||||
 | 
			
		||||
@ -8,6 +8,7 @@ struct ProfileContentGrid: View {
 | 
			
		||||
    let selectedCategory: String
 | 
			
		||||
    let allPosts: [Post]
 | 
			
		||||
    let isLoading: Bool
 | 
			
		||||
    let onPostTapped: (Post, [Post]) -> Void
 | 
			
		||||
    
 | 
			
		||||
    var body: some View {
 | 
			
		||||
        VStack(alignment: .leading, spacing: 0) {
 | 
			
		||||
@ -28,7 +29,7 @@ struct ProfileContentGrid: View {
 | 
			
		||||
            } else {
 | 
			
		||||
                LazyVGrid(columns: Array(repeating: .init(.flexible()), count: 3), spacing: 2) {
 | 
			
		||||
                    ForEach(filteredPosts) { post in
 | 
			
		||||
                        NavigationLink(destination: PostFeedView(posts: filteredPosts, selectedPostID: post.id)) {
 | 
			
		||||
                        Button(action: { onPostTapped(post, filteredPosts) }) {
 | 
			
		||||
                            Rectangle()
 | 
			
		||||
                                .fill(Color.gray.opacity(0.2))
 | 
			
		||||
                                .aspectRatio(1, contentMode: .fit)
 | 
			
		||||
 | 
			
		||||
@ -4,6 +4,7 @@ struct ProfileContentTabbedGrid: View {
 | 
			
		||||
    let isContentLoaded: Bool
 | 
			
		||||
    @Binding var allPosts: [Post]
 | 
			
		||||
    @Binding var isLoading: Bool
 | 
			
		||||
    let onPostTapped: (Post, [Post]) -> Void
 | 
			
		||||
    @State private var selectedTabIndex = 0
 | 
			
		||||
    @State private var selectedCategory = "#все"
 | 
			
		||||
    @State private var searchQuery = ""
 | 
			
		||||
@ -70,7 +71,8 @@ struct ProfileContentTabbedGrid: View {
 | 
			
		||||
                searchQuery: searchQuery,
 | 
			
		||||
                selectedCategory: selectedCategory,
 | 
			
		||||
                allPosts: allPosts,
 | 
			
		||||
                isLoading: isLoading
 | 
			
		||||
                isLoading: isLoading,
 | 
			
		||||
                onPostTapped: onPostTapped
 | 
			
		||||
            )
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@ -20,26 +20,45 @@ struct ProfileTab: View {
 | 
			
		||||
    @State private var isLoading = true
 | 
			
		||||
    @State private var isRefreshing = false
 | 
			
		||||
 | 
			
		||||
    @State private var selectedPostData: (Post, [Post])?
 | 
			
		||||
 | 
			
		||||
    var body: some View {
 | 
			
		||||
        NavigationView {
 | 
			
		||||
            if !isContentLoaded {
 | 
			
		||||
                SplashScreenView()
 | 
			
		||||
            } else {
 | 
			
		||||
                RefreshableScrollView(isRefreshing: $isRefreshing, onRefresh: {
 | 
			
		||||
                    fetchData()
 | 
			
		||||
                }) {
 | 
			
		||||
                    VStack(spacing: 0) {
 | 
			
		||||
                        header
 | 
			
		||||
                            .frame(minHeight: 300)
 | 
			
		||||
                            .frame(maxWidth: .infinity)
 | 
			
		||||
                            .background(Color(.systemBackground))
 | 
			
		||||
                        
 | 
			
		||||
                        ProfileContentTabbedGrid(
 | 
			
		||||
                            isContentLoaded: isContentLoaded,
 | 
			
		||||
                            allPosts: $allPosts,
 | 
			
		||||
                            isLoading: $isLoading
 | 
			
		||||
                VStack(spacing: 0) {
 | 
			
		||||
                    // Скрытый NavigationLink для программного перехода
 | 
			
		||||
                    if let (post, posts) = selectedPostData {
 | 
			
		||||
                        NavigationLink(
 | 
			
		||||
                            destination: PostFeedView(posts: posts, selectedPostID: post.id),
 | 
			
		||||
                            isActive: Binding(
 | 
			
		||||
                                get: { selectedPostData != nil },
 | 
			
		||||
                                set: { if !$0 { selectedPostData = nil } }
 | 
			
		||||
                            ),
 | 
			
		||||
                            label: { EmptyView() }
 | 
			
		||||
                        )
 | 
			
		||||
                    }
 | 
			
		||||
 | 
			
		||||
                    RefreshableScrollView(isRefreshing: $isRefreshing, onRefresh: {
 | 
			
		||||
                        fetchData()
 | 
			
		||||
                    }) {
 | 
			
		||||
                        VStack(spacing: 0) {
 | 
			
		||||
                            header
 | 
			
		||||
                                .frame(minHeight: 300)
 | 
			
		||||
                                .frame(maxWidth: .infinity)
 | 
			
		||||
                                .background(Color(.systemBackground))
 | 
			
		||||
                            
 | 
			
		||||
                            ProfileContentTabbedGrid(
 | 
			
		||||
                                isContentLoaded: isContentLoaded,
 | 
			
		||||
                                allPosts: $allPosts,
 | 
			
		||||
                                isLoading: $isLoading,
 | 
			
		||||
                                onPostTapped: { post, posts in
 | 
			
		||||
                                    self.selectedPostData = (post, posts)
 | 
			
		||||
                                }
 | 
			
		||||
                            )
 | 
			
		||||
                        }
 | 
			
		||||
                    }
 | 
			
		||||
                }
 | 
			
		||||
                .navigationBarTitleDisplayMode(.inline)
 | 
			
		||||
                .toolbar {
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user