diff --git a/Shared/Views/Tab/HomeTab.swift b/Shared/Views/Tab/HomeTab.swift index 5a1e661..788ac3c 100644 --- a/Shared/Views/Tab/HomeTab.swift +++ b/Shared/Views/Tab/HomeTab.swift @@ -29,6 +29,7 @@ struct HomeTab: View { } } } + .navigationViewStyle(StackNavigationViewStyle()) } private func fetchData(isInitialLoad: Bool = false) { diff --git a/Shared/Views/Tab/Profile/ProfileContentGrid.swift b/Shared/Views/Tab/Profile/ProfileContentGrid.swift index f3add88..0d1b828 100644 --- a/Shared/Views/Tab/Profile/ProfileContentGrid.swift +++ b/Shared/Views/Tab/Profile/ProfileContentGrid.swift @@ -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) diff --git a/Shared/Views/Tab/Profile/ProfileContentTabbedGrid.swift b/Shared/Views/Tab/Profile/ProfileContentTabbedGrid.swift index b5f38ea..00c8743 100644 --- a/Shared/Views/Tab/Profile/ProfileContentTabbedGrid.swift +++ b/Shared/Views/Tab/Profile/ProfileContentTabbedGrid.swift @@ -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 ) } } diff --git a/Shared/Views/Tab/Profile/ProfileTab.swift b/Shared/Views/Tab/Profile/ProfileTab.swift index c598eb2..0a132ac 100644 --- a/Shared/Views/Tab/Profile/ProfileTab.swift +++ b/Shared/Views/Tab/Profile/ProfileTab.swift @@ -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 {