mirror of
https://github.com/omnivore-app/omnivore.git
synced 2026-03-11 08:54:26 +00:00
Merge pull request #3710 from omnivore-app/fix/ios-menus
Fix for menus on iOS17
This commit is contained in:
commit
e8ddf9ea12
12 changed files with 25 additions and 132 deletions
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
import Foundation
|
||||
import SwiftUI
|
||||
|
||||
|
|
|
|||
|
|
@ -385,7 +385,10 @@
|
|||
func playerContent(_: LinkedItemAudioProperties) -> some View {
|
||||
ZStack {
|
||||
WindowLink(level: .alert, transition: .move(edge: .bottom), isPresented: $showSnackbar) {
|
||||
OperationToast(operationMessage: $snackbarMessage, showOperationToast: $showSnackbar, operationStatus: $operationStatus)
|
||||
OperationToast(
|
||||
operationMessage: $snackbarMessage,
|
||||
showOperationToast: $showSnackbar,
|
||||
operationStatus: $operationStatus)
|
||||
.offset(y: -90)
|
||||
} label: {
|
||||
EmptyView()
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
import Foundation
|
||||
|
||||
import CoreData
|
||||
|
|
|
|||
|
|
@ -1,121 +0,0 @@
|
|||
|
||||
// import Introspect
|
||||
// import Models
|
||||
// import Services
|
||||
// import SwiftUI
|
||||
// import Views
|
||||
//
|
||||
// @MainActor final class FilterSelectorViewModel: NSObject, ObservableObject {
|
||||
// @Published var isLoading = false
|
||||
// @Published var errorMessage: String = ""
|
||||
// @Published var showErrorMessage: Bool = false
|
||||
//
|
||||
// func error(_ msg: String) {
|
||||
// errorMessage = msg
|
||||
// showErrorMessage = true
|
||||
// isLoading = false
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// struct FilterSelectorView: View {
|
||||
// @ObservedObject var viewModel: HomeFeedViewModel
|
||||
// @ObservedObject var filterViewModel = FilterByLabelsViewModel()
|
||||
// @EnvironmentObject var dataService: DataService
|
||||
// @Environment(\.dismiss) private var dismiss
|
||||
//
|
||||
// @State var showLabelsSheet = false
|
||||
//
|
||||
// init(viewModel: HomeFeedViewModel) {
|
||||
// self.viewModel = viewModel
|
||||
// }
|
||||
//
|
||||
// var body: some View {
|
||||
// Group {
|
||||
// #if os(iOS)
|
||||
// List {
|
||||
// innerBody
|
||||
// }
|
||||
// .listStyle(.grouped)
|
||||
// #elseif os(macOS)
|
||||
// List {
|
||||
// innerBody
|
||||
// }
|
||||
// .listStyle(.plain)
|
||||
// #endif
|
||||
// }
|
||||
// #if os(iOS)
|
||||
// .navigationBarTitle("Library")
|
||||
// .navigationBarTitleDisplayMode(.inline)
|
||||
// .navigationBarItems(trailing: doneButton)
|
||||
// #endif
|
||||
// }
|
||||
//
|
||||
// private var innerBody: some View {
|
||||
// Group {
|
||||
// Section {
|
||||
// ForEach(LinkedItemFilter.allCases, id: \.self) { filter in
|
||||
// HStack {
|
||||
// Text(filter.displayName)
|
||||
// .foregroundColor(filterState.appliedFilter == filter.rawValue ? Color.blue : Color.appTextDefault)
|
||||
// Spacer()
|
||||
// if filterState.appliedFilter == filter.rawValue {
|
||||
// Image(systemName: "checkmark")
|
||||
// .foregroundColor(Color.blue)
|
||||
// }
|
||||
// }
|
||||
// .contentShape(Rectangle())
|
||||
// .onTapGesture {
|
||||
// filterState.appliedFilter = filter.rawValue
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// Section("Labels") {
|
||||
// Button(
|
||||
// action: {
|
||||
// showLabelsSheet = true
|
||||
// },
|
||||
// label: {
|
||||
// HStack {
|
||||
// Text("Select Labels (\(filterState.selectedLabels.count))")
|
||||
// Spacer()
|
||||
// Image(systemName: "chevron.right")
|
||||
// }
|
||||
// }
|
||||
// )
|
||||
// }
|
||||
// }
|
||||
// .sheet(isPresented: $showLabelsSheet) {
|
||||
// FilterByLabelsView(
|
||||
// initiallySelected: filterState.selectedLabels,
|
||||
// initiallyNegated: filterState.negatedLabels
|
||||
// ) {
|
||||
// self.filterState.selectedLabels = $0
|
||||
// self.filterState.negatedLabels = $1
|
||||
// }
|
||||
// }
|
||||
// .task {
|
||||
// await filterViewModel.loadLabels(
|
||||
// dataService: dataService,
|
||||
// initiallySelectedLabels: filterState.selectedLabels,
|
||||
// initiallyNegatedLabels: filterState.negatedLabels
|
||||
// )
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// func isNegated(_ label: LinkedItemLabel) -> Bool {
|
||||
// filterViewModel.negatedLabels.contains(where: { $0.id == label.id })
|
||||
// }
|
||||
//
|
||||
// func isSelected(_ label: LinkedItemLabel) -> Bool {
|
||||
// filterViewModel.selectedLabels.contains(where: { $0.id == label.id })
|
||||
// }
|
||||
//
|
||||
// var doneButton: some View {
|
||||
// Button(
|
||||
// action: { dismiss() },
|
||||
// label: { Text("Done") }
|
||||
// )
|
||||
// .disabled(viewModel.isLoading)
|
||||
// }
|
||||
// }
|
||||
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
import Introspect
|
||||
import Models
|
||||
import Services
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
import Introspect
|
||||
import Models
|
||||
import Services
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ struct InformationalSnackbar: View {
|
|||
Text(message)
|
||||
}
|
||||
Spacer()
|
||||
|
||||
|
||||
if let undoAction = self.undoAction {
|
||||
Button(action: {
|
||||
undoAction()
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
import Models
|
||||
import Services
|
||||
import SwiftUI
|
||||
|
|
|
|||
|
|
@ -60,6 +60,10 @@ struct WebReaderContent {
|
|||
body {
|
||||
-webkit-text-size-adjust: 100%;
|
||||
}
|
||||
.is-sticky {
|
||||
right: 15px !important;
|
||||
bottom: 40px !important;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
import CoreData
|
||||
import Foundation
|
||||
import Models
|
||||
import Utils
|
||||
|
||||
public struct PDFItem {
|
||||
|
|
|
|||
|
|
@ -298,10 +298,16 @@ public final class OmnivoreWebView: WKWebView {
|
|||
case #selector(removeSelection): return true
|
||||
case #selector(copy(_:)): return true
|
||||
case #selector(setLabels(_:)): return true
|
||||
|
||||
case Selector(("_lookup:")): return (currentMenu == .defaultMenu)
|
||||
case Selector(("_define:")): return (currentMenu == .defaultMenu)
|
||||
case Selector(("_translate:")): return (currentMenu == .defaultMenu)
|
||||
// case Selector(("_findSelected:")): return (currentMenu == .defaultMenu)
|
||||
case Selector(("_findSelected:")): return (currentMenu == .defaultMenu)
|
||||
|
||||
case Selector(("lookup:")): return (currentMenu == .defaultMenu)
|
||||
case Selector(("define:")): return (currentMenu == .defaultMenu)
|
||||
case Selector(("translate:")): return (currentMenu == .defaultMenu)
|
||||
case Selector(("findSelected:")): return (currentMenu == .defaultMenu)
|
||||
default: return false
|
||||
}
|
||||
}
|
||||
|
|
@ -371,6 +377,14 @@ public final class OmnivoreWebView: WKWebView {
|
|||
|
||||
let items: [UIMenuElement]
|
||||
if currentMenu == .defaultMenu {
|
||||
let autoHighlightEnabled = UserDefaults.standard.value(forKey: UserDefaultKey.enableHighlightOnRelease.rawValue)
|
||||
if let autoHighlightEnabled = autoHighlightEnabled as? Bool, autoHighlightEnabled {
|
||||
builder.remove(menu: .standardEdit)
|
||||
builder.remove(menu: .lookup)
|
||||
builder.remove(menu: .find)
|
||||
super.buildMenu(with: builder)
|
||||
return
|
||||
}
|
||||
let highlight = UICommand(title: LocalText.genericHighlight, action: #selector(highlightSelection))
|
||||
items = [highlight, annotate]
|
||||
} else {
|
||||
|
|
@ -380,7 +394,7 @@ public final class OmnivoreWebView: WKWebView {
|
|||
}
|
||||
|
||||
let omnivore = UIMenu(title: "", options: .displayInline, children: items)
|
||||
builder.insertSibling(omnivore, beforeMenu: .lookup)
|
||||
builder.insertSibling(omnivore, afterMenu: .standardEdit)
|
||||
}
|
||||
|
||||
super.buildMenu(with: builder)
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
import Foundation
|
||||
|
||||
func cardShouldHideUrl(_ url: String?) -> Bool {
|
||||
|
|
|
|||
Loading…
Reference in a new issue