diff options
Diffstat (limited to 'Sora/Views/Post/Grid/PostGridView.swift')
| -rw-r--r-- | Sora/Views/Post/Grid/PostGridView.swift | 96 |
1 files changed, 14 insertions, 82 deletions
diff --git a/Sora/Views/Post/Grid/PostGridView.swift b/Sora/Views/Post/Grid/PostGridView.swift index 23f7c00..330e294 100644 --- a/Sora/Views/Post/Grid/PostGridView.swift +++ b/Sora/Views/Post/Grid/PostGridView.swift @@ -6,6 +6,7 @@ struct PostGridView: View { // swiftlint:disable:this type_body_length @EnvironmentObject var settings: SettingsManager @EnvironmentObject var manager: BooruManager @State private var isSearchHistoryPresented = false + @State private var isSettingsPresented = false @Binding var selectedTab: Int @State private var isSearchablePresented = false @State private var suppressNextSearchSubmit = false @@ -296,10 +297,16 @@ struct PostGridView: View { // swiftlint:disable:this type_body_length } #endif + PlatformSpecificToolbarItem { + Button(action: { Task { isSearchHistoryPresented.toggle() } }) { + Label("Search History", systemImage: "clock.arrow.circlepath") + } + } + #if !os(macOS) - PlatformSpecificToolbarItem { - Button(action: { Task { isSearchHistoryPresented.toggle() } }) { - Label("Search History", systemImage: "clock.arrow.circlepath") + ToolbarItem(placement: .topBarTrailing) { + Button(action: { isSettingsPresented = true }) { + Label("Settings", systemImage: "gear") } } @@ -345,60 +352,6 @@ struct PostGridView: View { // swiftlint:disable:this type_body_length ToolbarItem(placement: .topBarTrailing) { ProgressView() } } #endif - - #if os(macOS) - let placement = ToolbarItemPlacement.navigation - #else - let placement = ToolbarItemPlacement.topBarLeading - #endif - - if initialTag == nil { - PlatformSpecificToolbarItem(placement: placement) { - Menu { - ForEach( - Array(manager.searchHistory.enumerated().filter { $0.offset < manager.historyIndex }), - id: \.offset - ) { offset, query in - Button(action: { - manager.historyIndex = offset - }) { - Text(query.tags.isEmpty ? "No Tags" : query.tags.joined(separator: " ")) - } - } - } label: { - Label("Previous Search", systemImage: "chevron.left") - } primaryAction: { - withAnimation { - manager.goBackInHistory() - } - } - .disabled(!manager.canGoBackInHistory) - .id("previousSearchMenu") - } - - PlatformSpecificToolbarItem(placement: placement) { - Menu { - ForEach( - Array(manager.searchHistory.enumerated().filter { $0.offset > manager.historyIndex }), - id: \.offset - ) { offset, query in - Button(action: { - manager.historyIndex = offset - }) { - Text(query.tags.isEmpty ? "No Tags" : query.tags.joined(separator: " ")) - } - } - } label: { - Label("Next Search", systemImage: "chevron.right") - } primaryAction: { - withAnimation { - manager.goForwardInHistory() - } - } - .disabled(!manager.canGoForwardInHistory) - .id("nextSearchMenu") - } - } } .navigationTitle(initialTag != nil ? initialTag! : "Posts") .refreshable { @@ -428,31 +381,10 @@ struct PostGridView: View { // swiftlint:disable:this type_body_length isPresented: $isSearchHistoryPresented ) } - #if os(iOS) - .gesture( - DragGesture() - .onEnded { value in - if initialTag == nil { - if value.startLocation.x < 50, value.translation.width > 100 { - withAnimation { - manager.goBackInHistory() - } - - debugPrint("ContentView: Swipe left, \(manager.searchHistory)") - } - - if value.startLocation.x > (UIScreen.main.bounds.width - 50), - value.translation.width < -100 - { - withAnimation { - manager.goForwardInHistory() - } - - debugPrint("ContentView: Swipe right, \(manager.searchHistory)") - } - } - } - ) + #if !os(macOS) + .sheet(isPresented: $isSettingsPresented) { + SettingsView() + } #endif } |