Last active
January 10, 2021 02:07
-
-
Save mfcollins3/76dd8cd29b1444f959699e422790eda1 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import UIKit | |
final class AppDelegate: UIResponder, UIApplicationDelegate { | |
func application( | |
_ application: UIApplication, | |
configurationForConnecting connectingSceneSession: UISceneSession, | |
options: UIScene.ConnectionOptions | |
) -> UISceneConfiguration { | |
let configuration = UISceneConfiguration( | |
name: "Main Scene", | |
sessionRole: connectingSceneSession.role | |
) | |
configuration.delegateClass = MainSceneDelegate.self | |
return configuration | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import SwiftUI | |
struct ContentView: View { | |
@State private var showComposeView = false | |
var body: some View { | |
Text("Hello, world!") | |
.padding | |
.alert(isPresented: $showComposeView) { | |
Alert( | |
title: Text("Compose Note"), | |
message: Text("TODO: Compose a note"), | |
primaryButton: .default(Text("Create")), | |
secondaryButton: .cancel() | |
) | |
} | |
.onOpenURL { url in | |
guard url.path == "/createNote" else { | |
return | |
} | |
showComposeView = true | |
} | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import SwiftUI | |
import UIKit | |
final class MainSceneDelegate: UIResponder, UIWindowSceneDelegate { | |
@Environment(\.openURL) private var openURL: OpenURLAction | |
func scene( | |
_ scene: UIScene, | |
willConnectTo session: UISceneSession, | |
options connectionptions: UIScene.ConnectionOptions | |
) { | |
guard let shortcutItem = connectionOptions.shortcutItem else { | |
return | |
} | |
handleShortcutItem(shortcutItem) | |
} | |
func windowScene( | |
_ windowScene: UIWindowScene, | |
performActionFor shortcutItem: UIApplicationShortcutItem, | |
completionHandler: @escaping (Bool) -> Void | |
) { | |
handleShortcutItem(shortcutItem, completionHandler: completionHandler) | |
} | |
private func handleShortcutItem( | |
_ shortcutItem: UIApplicationShortcutItem, | |
completionHandler: ((Bool) -> Void)? = nil | |
) { | |
guard shortcutItem.type == "me.michaelfcollins3.QuickActionDemo.CreateNoteAction" else { | |
completionHandler(false) | |
return | |
} | |
openURL(URL(string: "quickactiondemo://actions/createNote")!) { completed in | |
completionHandler(completed | |
} | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import SwiftUI | |
@main | |
struct QuickActionDemoApp: App { | |
var body: some Scene { | |
WindowGroup { | |
ContentView() | |
} | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import SwiftUI | |
@main | |
struct QuickActionDemoApp: App { | |
@UIApplicationDelegateAdaptor private var appDelegate: AppDelegate | |
var body: some Scene { | |
WindowGroup { | |
ContentView() | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment