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