diff options
| author | Fuwn <[email protected]> | 2025-03-01 05:44:27 -0800 |
|---|---|---|
| committer | Fuwn <[email protected]> | 2025-03-01 05:44:27 -0800 |
| commit | 7b1bbee91606e643b22d4c5b05f74ca9bafd4059 (patch) | |
| tree | 855203c4e7192ec7e7ef5dc4998adc01c4c850cd | |
| parent | feat: Development commit (diff) | |
| download | sora-testing-7b1bbee91606e643b22d4c5b05f74ca9bafd4059.tar.xz sora-testing-7b1bbee91606e643b22d4c5b05f74ca9bafd4059.zip | |
feat: Development commit
| -rw-r--r-- | Localizable.xcstrings | 3 | ||||
| -rw-r--r-- | Sora/Data/Booru/BooruManager.swift | 1 | ||||
| -rw-r--r-- | Sora/Views/Post/Details/PostDetailsImageView.swift | 23 | ||||
| -rw-r--r-- | Sora/Views/Post/Details/PostDetailsView.swift | 1 | ||||
| -rw-r--r-- | Sora/Views/Post/Grid/PostGridView.swift | 1 |
5 files changed, 24 insertions, 5 deletions
diff --git a/Localizable.xcstrings b/Localizable.xcstrings index 5d6c4f1..3e6a136 100644 --- a/Localizable.xcstrings +++ b/Localizable.xcstrings @@ -153,6 +153,9 @@ } } }, + "Preloaded Images" : { + + }, "Provider" : { "localizations" : { "ja" : { diff --git a/Sora/Data/Booru/BooruManager.swift b/Sora/Data/Booru/BooruManager.swift index d229049..e8c684f 100644 --- a/Sora/Data/Booru/BooruManager.swift +++ b/Sora/Data/Booru/BooruManager.swift @@ -114,6 +114,7 @@ class BooruManager: ObservableObject { } else { self.posts += Array(Set(newPosts)) + self.posts = self.posts.sorted { $0.id > $1.id } self.postIndexMap.merge( zip(newPosts.indices, newPosts.map(\.id)).reduce(into: [:]) { result, element in result[element.1] = element.0 diff --git a/Sora/Views/Post/Details/PostDetailsImageView.swift b/Sora/Views/Post/Details/PostDetailsImageView.swift index cdf299a..9c6d6eb 100644 --- a/Sora/Views/Post/Details/PostDetailsImageView.swift +++ b/Sora/Views/Post/Details/PostDetailsImageView.swift @@ -98,10 +98,18 @@ struct PostDetailsImageView<Placeholder: View>: View { #if os(macOS) return content.overlay( - Button(action: saveImageToPicturesFolder) { - EmptyView() + Group { + Button(action: saveImageToPicturesFolder) { + EmptyView() + } + .keyboardShortcut("s", modifiers: [.command]) + + Button(action: { movePostCursor(by: 1) }) { EmptyView() } + .keyboardShortcut(.rightArrow, modifiers: []) + + Button(action: { movePostCursor(by: -1) }) { EmptyView() } + .keyboardShortcut(.leftArrow, modifiers: []) } - .keyboardShortcut("s", modifiers: [.command]) .frame(width: 0, height: 0) .opacity(0) ) @@ -110,6 +118,15 @@ struct PostDetailsImageView<Placeholder: View>: View { #endif } + func movePostCursor(by direction: Int) { + guard let selectedPost = manager.selectedPost, + let index = manager.postIndexMap[selectedPost.id], + (0..<manager.posts.count).contains(index + direction) + else { return } + + manager.selectedPost = manager.posts[index + direction] + } + init( url: URL?, loadingStage: Binding<BooruPostLoadingState>, diff --git a/Sora/Views/Post/Details/PostDetailsView.swift b/Sora/Views/Post/Details/PostDetailsView.swift index 4662f4a..e040bc3 100644 --- a/Sora/Views/Post/Details/PostDetailsView.swift +++ b/Sora/Views/Post/Details/PostDetailsView.swift @@ -22,7 +22,6 @@ struct PostDetailsView: View { var filteredPosts: [BooruPost] { manager.posts .filter { settings.displayRatings.contains($0.rating) } - .sorted { $0.id > $1.id } } var body: some View { diff --git a/Sora/Views/Post/Grid/PostGridView.swift b/Sora/Views/Post/Grid/PostGridView.swift index 20d6b3a..187acc9 100644 --- a/Sora/Views/Post/Grid/PostGridView.swift +++ b/Sora/Views/Post/Grid/PostGridView.swift @@ -13,7 +13,6 @@ struct PostGridView: View { var filteredPosts: [BooruPost] { manager.posts .filter { settings.displayRatings.contains($0.rating) } - .sorted { $0.id > $1.id } } var body: some View { |