profile fix

This commit is contained in:
cheykrym 2025-07-16 06:52:35 +03:00
parent 2e821a0075
commit ff155b23e5
2 changed files with 16 additions and 15 deletions

View File

@ -6,9 +6,9 @@ struct ProfileContentGrid: View {
let selectedTabIndex: Int let selectedTabIndex: Int
let searchQuery: String let searchQuery: String
let selectedCategory: String let selectedCategory: String
@State private var allPosts: [Post] = [] let allPosts: [Post]
let isLoading: Bool
@State private var selectedPostID: PostIDWrapper? = nil @State private var selectedPostID: PostIDWrapper? = nil
@State private var isLoading = true
var body: some View { var body: some View {
VStack(alignment: .leading, spacing: 0) { VStack(alignment: .leading, spacing: 0) {
@ -87,17 +87,6 @@ struct ProfileContentGrid: View {
} }
} }
.frame(maxWidth: .infinity, alignment: .topLeading) .frame(maxWidth: .infinity, alignment: .topLeading)
.onAppear {
// guard isContentLoaded else { return }
if allPosts.isEmpty {
isLoading = true
PostService.shared.fetchAllPosts { result in
self.allPosts = result
self.isLoading = false
}
}
}
.fullScreenCover(item: $selectedPostID) { wrapper in .fullScreenCover(item: $selectedPostID) { wrapper in
PostDetailView(postID: wrapper.id) PostDetailView(postID: wrapper.id)
} }

View File

@ -6,6 +6,8 @@ struct ProfileContentTabbedGrid: View {
@State private var selectedCategory = "#все" @State private var selectedCategory = "#все"
@State private var searchQuery = "" @State private var searchQuery = ""
@State private var selectedSort = "По дате" @State private var selectedSort = "По дате"
@State private var allPosts: [Post] = []
@State private var isLoading = true
var body: some View { var body: some View {
VStack(spacing: 0) { VStack(spacing: 0) {
@ -68,14 +70,24 @@ struct ProfileContentTabbedGrid: View {
isContentLoaded: isContentLoaded, isContentLoaded: isContentLoaded,
selectedTabIndex: index, selectedTabIndex: index,
searchQuery: searchQuery, searchQuery: searchQuery,
selectedCategory: selectedCategory selectedCategory: selectedCategory,
allPosts: allPosts,
isLoading: isLoading
) )
// .frame(maxWidth: .infinity, minHeight: 10)
.tag(index) .tag(index)
} }
} }
.tabViewStyle(PageTabViewStyle(indexDisplayMode: .never)) .tabViewStyle(PageTabViewStyle(indexDisplayMode: .never))
} }
.onAppear {
if allPosts.isEmpty {
isLoading = true
PostService.shared.fetchAllPosts { result in
self.allPosts = result
self.isLoading = false
}
}
}
} }
// MARK: - Вкладка с меню // MARK: - Вкладка с меню