Swiftpack.co - Package - demianturner/DTOnboarding

DTOnboarding

Swift5 Swift Package Manager GitHub release (latest SemVer) GitHub macOS

A macOS onboarding component.

  • creates a window containing a configurable number of screens
  • use buttons or gestures to navigate
  • component size, layout and content easily are configurable

Installation

Install using Swift Package Manager. Use master branch.

Dependencies

Requirements

  • OS X 10.12+
  • Xcode 11.0 or above

Demo/Example

Either compile and run the demo from the example repo or see it used in Crypto Tools.

Usage

For this example, ensure 3 pngs exist (provided in the example repo) in the project's asset catalog, in this case 1.png, 2.png, 3.png

Use the following code in your AppDelegate.swift or similar.

class AppDelegate: NSObject, NSApplicationDelegate {
    private var onboardingWindowController: NSWindowController?

    func applicationDidFinishLaunching(_ aNotification: Notification) {
        let config = OnboardingConfig(
            windowWidth: 350,
            windowHeight: 430,
            windowTitle: "my sample title",
            pageCount: 3,
            pageControlWidth: 200,
            pageControlHeight: 20,
            pageControlVerticalDistanceFromBottom: 20, 
            pageTransitionStyle: .stackBook
        )

        let pages = [
            DTOnboardingViewController(controllerId: "1"),
            DTOnboardingViewController(controllerId: "2"),
            DTOnboardingViewController(controllerId: "3")
        ]

        let pageController = DTPageController(config: config, pages: pages)
        let frame = pageController.view.bounds
        let myWindow = NSWindow(
            contentRect: .init(origin: .zero, size: frame.size),
            styleMask: [.closable, .miniaturizable, .resizable, .titled],
            backing: .buffered,
            defer: false
        )
        myWindow.title = config.windowTitle
        myWindow.center()

        onboardingWindowController = NSWindowController(window: myWindow)
        onboardingWindowController?.contentViewController = pageController
        onboardingWindowController?.showWindow(self)
    }
}

License

This software is Open Source under the MIT license, see LICENSE for details.

Github

link
Stars: 6

Dependencies

Used By

Total: 0

Releases

- 2020-05-18 13:36:58

- 2020-05-13 10:21:28