// // AppDelegate.swift // Gemini // // Created by Shadowfacts on 7/12/20. // import Cocoa import SwiftUI import GeminiProtocol import Combine @NSApplicationMain class AppDelegate: NSObject, NSApplicationDelegate { // var window: NSWindow! var windowControllers = [BrowserWindowController]() let homePage = URL(string: "gemini://gemini.circumlunar.space/")! // private(set) lazy var navigationManager = NavigationManager(url: homePage) // private var toolbarTextField: NSTextField! // private var toolbarUpdater: Cancellable? func applicationDidFinishLaunching(_ aNotification: Notification) { // // Create the SwiftUI view that provides the window contents. // let contentView = ContentView(navigator: navigationManager) // // // Create the window and set the content view. // window = NSWindow( // contentRect: NSRect(x: 0, y: 0, width: 480, height: 300), // styleMask: [.titled, .closable, .miniaturizable, .resizable, .fullSizeContentView], // backing: .buffered, defer: false) // window.isReleasedWhenClosed = false // window.center() // window.setFrameAutosaveName("Main Window") // window.contentView = NSHostingView(rootView: contentView) //// window.title = "Gemini" //// let toolbar = NSToolbar() //// toolbar.delegate = self //// toolbar.displayMode = .iconAndLabel //// window.toolbar = toolbar // window.makeKeyAndOrderFront(nil) // // toolbarTextField = NSTextField(string: navigationManager.currentURL.absoluteString) // toolbarTextField.delegate = self // // toolbarTextField.widthAnchor.constraint(equalToConstant: 250).isActive = true // // toolbarUpdater = navigationManager.$currentURL.sink(receiveValue: { (newValue) in // self.toolbarTextField.stringValue = newValue.absoluteString // }) let wc = BrowserWindowController() windowControllers.append(wc) wc.showWindow(nil) } func applicationWillTerminate(_ aNotification: Notification) { // Insert code here to tear down your application } } //extension AppDelegate: NSToolbarDelegate { // func toolbarAllowedItemIdentifiers(_ toolbar: NSToolbar) -> [NSToolbarItem.Identifier] { // return [ // .flexibleSpace, // .urlField, // ] // } // // func toolbarDefaultItemIdentifiers(_ toolbar: NSToolbar) -> [NSToolbarItem.Identifier] { // return [ // .flexibleSpace, // .urlField, // .flexibleSpace, // ] // } // // func toolbar(_ toolbar: NSToolbar, itemForItemIdentifier itemIdentifier: NSToolbarItem.Identifier, willBeInsertedIntoToolbar flag: Bool) -> NSToolbarItem? { // if itemIdentifier == .urlField { // let item = NSToolbarItem(itemIdentifier: .urlField) // item.label = "URL" // item.view = toolbarTextField // return item // } else { // return NSToolbarItem(itemIdentifier: .urlField) // } // } //} // //extension AppDelegate: NSTextFieldDelegate { // func controlTextDidEndEditing(_ obj: Notification) { // print("did end edting, new text: '\(toolbarTextField.stringValue)'") // } //} // //extension NSToolbarItem.Identifier { // static let urlField = NSToolbarItem.Identifier("GeminiUrlField") //}