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,11 +20,26 @@ 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 {
|
||||
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()
|
||||
}) {
|
||||
@ -37,10 +52,14 @@ struct ProfileTab: View {
|
||||
ProfileContentTabbedGrid(
|
||||
isContentLoaded: isContentLoaded,
|
||||
allPosts: $allPosts,
|
||||
isLoading: $isLoading
|
||||
isLoading: $isLoading,
|
||||
onPostTapped: { post, posts in
|
||||
self.selectedPostData = (post, posts)
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
.navigationBarTitleDisplayMode(.inline)
|
||||
.toolbar {
|
||||
ToolbarItem(placement: .principal) {
|
||||
|
||||
Reference in New Issue
Block a user