-
-
Notifications
You must be signed in to change notification settings - Fork 67
Setup
Tomasz K. edited this page Oct 30, 2024
·
50 revisions
Człowiek wyruszył na spotkanie innych światów, innych cywilizacji, nie poznawszy do końca własnych zakamarków, ślepych dróg, studni, zabarykadowanych, ciemnych drzwi.
This page outlines possible ways to integrate MijickPopups
into your application.
Warning
The method below does not work with Apple Sheets
Within the @main
structure of your app, call the registerPopups()
method.
It takes an optional argument, configBuilder, which can be used to configure some modifiers for all popups in the application.
@main struct App_Main: App {
var body: some Scene { WindowGroup {
ContentView()
.registerPopups(id: .shared) { config in config
.vertical { $0
.enableDragGesture(true)
.tapOutsideToDismissPopup(true)
.cornerRadius(32)
}
.centre { $0
.tapOutsideToDismissPopup(false)
.backgroundColor(.white)
}
}
}}
}
Important
The method does work only with iOS
@main struct App_Main: App {
@UIApplicationDelegateAdaptor(AppDelegate.self) var appDelegate
var body: some Scene { WindowGroup(content: ContentView.init) }
}
class AppDelegate: NSObject, UIApplicationDelegate {
func application(_ application: UIApplication, configurationForConnecting connectingSceneSession: UISceneSession, options: UIScene.ConnectionOptions) -> UISceneConfiguration {
let sceneConfig = UISceneConfiguration(name: nil, sessionRole: connectingSceneSession.role)
sceneConfig.delegateClass = CustomPopupSceneDelegate.self
return sceneConfig
}
}
class CustomPopupSceneDelegate: PopupSceneDelegate {
override init() { super.init()
configBuilder = { $0
.vertical { $0
.enableDragGesture(true)
.tapOutsideToDismissPopup(true)
.cornerRadius(32)
}
.centre { $0
.tapOutsideToDismissPopup(false)
.backgroundColor(.white)
}
}
}
}