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