chore: refactor

This commit is contained in:
dscyrescotti
2024-07-14 16:44:21 +07:00
parent ca93472cd4
commit 9b9ccf2a86
55 changed files with 341 additions and 244 deletions
+14 -1
View File
@@ -8,8 +8,21 @@
import Combine
import SwiftUI
class Application: NSObject, ObservableObject {
final class Application: NSObject, ObservableObject {
}
extension Application {
func activateSearchBar() {
#if os(macOS)
guard let toolbar = NSApp.keyWindow?.toolbar else { return }
if let search = toolbar.items.first(where: { $0.itemIdentifier.rawValue == "com.apple.SwiftUI.search" }) as? NSSearchToolbarItem {
search.beginSearchInteraction()
}
#else
#warning("TODO: implement for ipad")
#endif
}
}
#if os(macOS)
+4 -3
View File
@@ -10,9 +10,9 @@ import SwiftUI
@main
struct MemolaApp: App {
#if os(macOS)
@NSApplicationDelegateAdaptor(Application.self) var application
@NSApplicationDelegateAdaptor(Application.self) private var application
#else
@UIApplicationDelegateAdaptor(Application.self) var application
@UIApplicationDelegateAdaptor(Application.self) private var application
#endif
var body: some Scene {
@@ -30,6 +30,7 @@ struct MemolaApp: App {
#if os(macOS)
.frame(minWidth: 1000, minHeight: 600)
#endif
.environmentObject(application)
}
#if os(macOS)
.defaultPosition(.center)
@@ -41,7 +42,7 @@ struct MemolaApp: App {
AppCommands()
FileCommands()
EditCommands()
ViewCommands()
ViewCommands(application: application)
}
}
}