diff options
| author | Fuwn <[email protected]> | 2025-06-16 03:34:03 -0700 |
|---|---|---|
| committer | Fuwn <[email protected]> | 2025-06-16 03:34:03 -0700 |
| commit | 9e6b289969abe2329f62fd3869f48ef57a4b640d (patch) | |
| tree | 8716bd46b7553017963982ff9458dd2a9689de55 | |
| parent | feat: Development commit (diff) | |
| download | sora-testing-9e6b289969abe2329f62fd3869f48ef57a4b640d.tar.xz sora-testing-9e6b289969abe2329f62fd3869f48ef57a4b640d.zip | |
feat: Development commit
| -rw-r--r-- | Localizable.xcstrings | 2 | ||||
| -rw-r--r-- | Sora/Views/Post/Grid/PostGridView.swift | 74 |
2 files changed, 48 insertions, 28 deletions
diff --git a/Localizable.xcstrings b/Localizable.xcstrings index c508554..015859a 100644 --- a/Localizable.xcstrings +++ b/Localizable.xcstrings @@ -130,7 +130,7 @@ "Domain" : { }, - "Eager Thumbnail Grid Loading" : { + "Eager Thumbnail Loading" : { }, "Enable \"Share Image\" Shortcut" : { diff --git a/Sora/Views/Post/Grid/PostGridView.swift b/Sora/Views/Post/Grid/PostGridView.swift index 086d387..be15140 100644 --- a/Sora/Views/Post/Grid/PostGridView.swift +++ b/Sora/Views/Post/Grid/PostGridView.swift @@ -1,7 +1,7 @@ import SwiftUI import WaterfallGrid -struct PostGridView: View { +struct PostGridView: View { // swiftlint:disable:this type_body_length @EnvironmentObject var settings: SettingsManager @EnvironmentObject var manager: BooruManager @State private var isSearchHistoryPresented = false @@ -29,44 +29,64 @@ struct PostGridView: View { .filter { settings.displayRatings.contains($0.rating) } ?? [] ScrollView { - if filteredPosts.isEmpty && isActive { - ProgressView() - .padding() - } - - let columnCount = settings.thumbnailGridColumns - - if settings.alternativeThumbnailGrid { - WaterfallGrid(filteredPosts, id: \.id) { post in - waterfallGridContent(post: post) - .id(post.id) - } - .gridStyle(columns: columnCount) - .padding(.horizontal) - } else { - let columnsData = (0..<columnCount).map { columnIndex in - filteredPosts.enumerated().compactMap { index, post in - index % columnCount == columnIndex ? post : nil + Group { + if filteredPosts.isEmpty, isActive, manager.isLoading { + let gridItems = Array( + repeating: GridItem(.flexible()), + count: settings.thumbnailGridColumns + ) + + LazyVGrid(columns: gridItems) { + ForEach(0..<(50 / settings.thumbnailGridColumns), id: \.self) { _ in + RoundedRectangle(cornerRadius: 8) + .fill(Color(.systemGray5)) + .aspectRatio(1, contentMode: .fit) + .redacted(reason: .placeholder) + } } - } + .padding(.horizontal) + .transition(.opacity) + } else { + let columnCount = settings.thumbnailGridColumns + + if settings.alternativeThumbnailGrid { + WaterfallGrid(filteredPosts, id: \.id) { post in + waterfallGridContent(post: post) + .id(post.id) + } + .gridStyle(columns: columnCount) + .padding(.horizontal) + .transition(.opacity) + } else { + let columnsData = (0..<columnCount).map { columnIndex in + filteredPosts.enumerated().compactMap { index, post in + index % columnCount == columnIndex ? post : nil + } + } - HStack(alignment: .top) { - ForEach(0..<columnCount, id: \.self) { columnIndex in - LazyVStack { - ForEach(columnsData[columnIndex], id: \.id) { post in - waterfallGridContent(post: post) - .id(post.id) + HStack(alignment: .top) { + ForEach(0..<columnCount, id: \.self) { columnIndex in + LazyVStack { + ForEach(columnsData[columnIndex], id: \.id) { post in + waterfallGridContent(post: post) + .id(post.id) + } + } } } + .padding(.horizontal) + .transition(.opacity) } } - .padding(.horizontal) } + .animation(.easeInOut, value: manager.isLoading) } .opacity(isActive ? 1 : 0) .frame(height: isActive ? nil : 0) + .animation(.easeInOut, value: isActive) } } + .animation(.easeInOut, value: manager.historyIndex) .searchable(text: $manager.searchText, isPresented: $isSearchablePresented, prompt: "Tags") .searchSuggestions { if settings.searchSuggestionsMode != .disabled { |