iOS build fixes
This commit is contained in:
@ -60,7 +60,7 @@ struct LibraryAddLinkView: View {
|
||||
|
||||
var pasteboardString: String? {
|
||||
#if os(iOS)
|
||||
UIPasteboard.general.url.absoluteString
|
||||
UIPasteboard.general.url?.absoluteString
|
||||
#else
|
||||
NSPasteboard.general.string(forType: NSPasteboard.PasteboardType.URL)
|
||||
#endif
|
||||
|
||||
@ -1,55 +1,57 @@
|
||||
import SwiftUI
|
||||
|
||||
public struct MacSearchBar: NSViewRepresentable {
|
||||
@Binding var searchTerm: String
|
||||
#if os(macOS)
|
||||
public struct MacSearchBar: NSViewRepresentable {
|
||||
@Binding var searchTerm: String
|
||||
|
||||
public init(
|
||||
searchTerm: Binding<String>
|
||||
) {
|
||||
self._searchTerm = searchTerm
|
||||
}
|
||||
|
||||
public func makeNSView(context _: Context) -> NSSearchField {
|
||||
let searchField = NSSearchField(frame: .zero)
|
||||
searchField.translatesAutoresizingMaskIntoConstraints = false
|
||||
searchField.heightAnchor.constraint(greaterThanOrEqualToConstant: 28).isActive = true
|
||||
searchField.resignFirstResponder()
|
||||
|
||||
return searchField
|
||||
}
|
||||
|
||||
func changeSearchFieldItem(searchField: NSSearchField, sender: AnyObject) -> NSSearchField {
|
||||
// Based on the Menu item selection in the search field the placeholder string is set
|
||||
(searchField.cell as? NSSearchFieldCell)?.placeholderString = sender.title
|
||||
return searchField
|
||||
}
|
||||
|
||||
public func updateNSView(_ searchField: NSSearchField, context: Context) {
|
||||
searchField.font = searchField.font?.withSize(14)
|
||||
searchField.stringValue = searchTerm
|
||||
searchField.delegate = context.coordinator
|
||||
searchField.resignFirstResponder()
|
||||
}
|
||||
|
||||
public func makeCoordinator() -> Coordinator {
|
||||
let coordinator = Coordinator(searchTerm: $searchTerm)
|
||||
return coordinator
|
||||
}
|
||||
|
||||
public class Coordinator: NSObject, NSSearchFieldDelegate {
|
||||
var searchTerm: Binding<String>
|
||||
|
||||
init(searchTerm: Binding<String>) {
|
||||
self.searchTerm = searchTerm
|
||||
super.init()
|
||||
public init(
|
||||
searchTerm: Binding<String>
|
||||
) {
|
||||
self._searchTerm = searchTerm
|
||||
}
|
||||
|
||||
public func controlTextDidChange(_ notification: Notification) {
|
||||
guard let searchField = notification.object as? NSSearchField else {
|
||||
// log.error("Unexpected control in update notification", source: .ui)
|
||||
return
|
||||
public func makeNSView(context _: Context) -> NSSearchField {
|
||||
let searchField = NSSearchField(frame: .zero)
|
||||
searchField.translatesAutoresizingMaskIntoConstraints = false
|
||||
searchField.heightAnchor.constraint(greaterThanOrEqualToConstant: 28).isActive = true
|
||||
searchField.resignFirstResponder()
|
||||
|
||||
return searchField
|
||||
}
|
||||
|
||||
func changeSearchFieldItem(searchField: NSSearchField, sender: AnyObject) -> NSSearchField {
|
||||
// Based on the Menu item selection in the search field the placeholder string is set
|
||||
(searchField.cell as? NSSearchFieldCell)?.placeholderString = sender.title
|
||||
return searchField
|
||||
}
|
||||
|
||||
public func updateNSView(_ searchField: NSSearchField, context: Context) {
|
||||
searchField.font = searchField.font?.withSize(14)
|
||||
searchField.stringValue = searchTerm
|
||||
searchField.delegate = context.coordinator
|
||||
searchField.resignFirstResponder()
|
||||
}
|
||||
|
||||
public func makeCoordinator() -> Coordinator {
|
||||
let coordinator = Coordinator(searchTerm: $searchTerm)
|
||||
return coordinator
|
||||
}
|
||||
|
||||
public class Coordinator: NSObject, NSSearchFieldDelegate {
|
||||
var searchTerm: Binding<String>
|
||||
|
||||
init(searchTerm: Binding<String>) {
|
||||
self.searchTerm = searchTerm
|
||||
super.init()
|
||||
}
|
||||
|
||||
public func controlTextDidChange(_ notification: Notification) {
|
||||
guard let searchField = notification.object as? NSSearchField else {
|
||||
// log.error("Unexpected control in update notification", source: .ui)
|
||||
return
|
||||
}
|
||||
searchTerm.wrappedValue = searchField.stringValue
|
||||
}
|
||||
searchTerm.wrappedValue = searchField.stringValue
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user