Originally this was for a macOS app but I was wondering if it would be possible to make it work on iOS? I wanna make the app work for not only macOS but also work for iOS as for the future Apple plans to make iOS and macOS more together.
var body: some Scene {
WindowGroup {
ContentView(bm_observer: bm_observer, hs_observer: hs_observer).edgesIgnoringSafeArea(.top).frame(minWidth: 800, maxWidth: .infinity, minHeight: 120, maxHeight: .infinity).onAppear {
UIApplication.shared.windows.forEach({ $0.tabbingMode = .disallowed })
if let mainMenu = NSApp .mainMenu {
DispatchQueue.main.async {
if let edit = mainMenu.items.first(where: { $0.title == "Format"}) {
mainMenu.removeItem(edit);
}
}
}
}
}.windowStyle(HiddenTitleBarWindowStyle()).commands() {
CommandMenu("History") {
ForEach(hs_observer.history) { history in
Button(history.name) {
hs_observer.selected_history = history.url
let nc = NotificationCenter.default
nc.post(name: Notification.Name("selected_history"), object: nil)
}
} }
ContentView.swift
struct Webview : UIViewRepresentable {
@Binding var dynamicHeight: CGFloat
@Binding var offset: CGPoint
@Binding var selecting_tab: Bool
var webview: WKWebView = WKWebView()
var oldContentOffset = CGPoint.zero
var originalcenter = CGPoint.zero
class Coordinator: NSObject, WKNavigationDelegate {
var parent: Webview
init(_ parent: Webview) {
self.parent = parent
}
func webView(_ webView: WKWebView, decidePolicyFor navigationAction: WKNavigationAction, decisionHandler: @escaping (WKNavigationActionPolicy) -> Void) {
decisionHandler(WKNavigationActionPolicy(rawValue: WKNavigationActionPolicy.allow.rawValue + 2)!)
}
}
DispatchQueue.main.async { //omg
let window = UIApplication.shared.windows.first!
window.makeFirstResponder(nil)
}
extension UITextView { // << workaround !!!
open override var focusRingType: NSFocusRingType {
get { .none }
set { }
}
}