summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFuwn <[email protected]>2025-06-16 03:02:23 -0700
committerFuwn <[email protected]>2025-06-16 03:02:23 -0700
commit2b4125f5e2adef495f8d413d4ba401f62f4b6d8e (patch)
tree6636ea8e153266411ce0de312e3d7a5d476e1039
parentfeat: Development commit (diff)
downloadsora-testing-2b4125f5e2adef495f8d413d4ba401f62f4b6d8e.tar.xz
sora-testing-2b4125f5e2adef495f8d413d4ba401f62f4b6d8e.zip
feat: Development commit
-rw-r--r--Localizable.xcstrings3
-rw-r--r--Sora/Data/Settings/SettingsManager.swift3
-rw-r--r--Sora/Views/Post/Grid/PostGridView.swift33
-rw-r--r--Sora/Views/Settings/Section/SettingsThumbnailsView.swift2
-rw-r--r--project.yml4
5 files changed, 34 insertions, 11 deletions
diff --git a/Localizable.xcstrings b/Localizable.xcstrings
index fb779e3..c508554 100644
--- a/Localizable.xcstrings
+++ b/Localizable.xcstrings
@@ -130,6 +130,9 @@
"Domain" : {
},
+ "Eager Thumbnail Grid Loading" : {
+
+ },
"Enable \"Share Image\" Shortcut" : {
},
diff --git a/Sora/Data/Settings/SettingsManager.swift b/Sora/Data/Settings/SettingsManager.swift
index ba0dcdf..98ea00c 100644
--- a/Sora/Data/Settings/SettingsManager.swift
+++ b/Sora/Data/Settings/SettingsManager.swift
@@ -28,6 +28,9 @@ class SettingsManager: ObservableObject { // swiftlint:disable:this type_body_l
@AppStorage("enableSync")
var enableSync: Bool = false
+ @AppStorage("alternativeThumbnailGrid")
+ var alternativeThumbnailGrid = false
+
private var syncObservation: NSObjectProtocol?
#if os(macOS)
diff --git a/Sora/Views/Post/Grid/PostGridView.swift b/Sora/Views/Post/Grid/PostGridView.swift
index 2b4b8c5..086d387 100644
--- a/Sora/Views/Post/Grid/PostGridView.swift
+++ b/Sora/Views/Post/Grid/PostGridView.swift
@@ -1,4 +1,5 @@
import SwiftUI
+import WaterfallGrid
struct PostGridView: View {
@EnvironmentObject var settings: SettingsManager
@@ -34,23 +35,33 @@ struct PostGridView: View {
}
let columnCount = settings.thumbnailGridColumns
- let columnsData = (0..<columnCount).map { columnIndex in
- filteredPosts.enumerated().compactMap { index, post in
- index % columnCount == columnIndex ? post : nil
+
+ 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
+ }
}
- }
- 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)
}
- .padding(.horizontal)
}
.opacity(isActive ? 1 : 0)
.frame(height: isActive ? nil : 0)
diff --git a/Sora/Views/Settings/Section/SettingsThumbnailsView.swift b/Sora/Views/Settings/Section/SettingsThumbnailsView.swift
index ddd8b29..29fe1ff 100644
--- a/Sora/Views/Settings/Section/SettingsThumbnailsView.swift
+++ b/Sora/Views/Settings/Section/SettingsThumbnailsView.swift
@@ -23,6 +23,8 @@ struct SettingsThumbnailsView: View {
)
#endif
+ Toggle("Eager Thumbnail Loading", isOn: $settings.alternativeThumbnailGrid)
+
#if os(macOS)
Button("Content Filtering") {
isShowingContentFiltering.toggle()
diff --git a/project.yml b/project.yml
index d52e6fa..c7ab66d 100644
--- a/project.yml
+++ b/project.yml
@@ -24,6 +24,9 @@ packages:
NetworkImage:
url: https://github.com/gonzalezreal/NetworkImage
majorVersion: 6.0.1
+ WaterfallGrid:
+ url: https://github.com/paololeonardi/WaterfallGrid
+ majorVersion: 1.1.0
targets:
Sora:
type: application
@@ -71,6 +74,7 @@ targets:
dependencies:
- package: Alamofire
- package: NetworkImage
+ - package: WaterfallGrid
info:
path: Sora/Resources/Info.generated.plist
properties: