Swiftpack.co -  muhammedtanriverdi/SwiftUIProgressiveOnboard as Swift Package
Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
muhammedtanriverdi/SwiftUIProgressiveOnboard
SwiftUI Progressive Onboard
.package(url: "https://github.com/muhammedtanriverdi/SwiftUIProgressiveOnboard.git", from: "v0.0.1")

SwiftUIProgressiveOnboard

SwiftUIProgressiveOnboard is designed for progressive onboards in SwiftUI.

Installation

Swift Package Manager

Open your project in Xcode, click File -> Swift Packages -> Add Package Dependency, enter the repo's URL.

https://github.com/muhammedtanriverdi/SwiftUIProgressiveOnboard.git

Usage

Import the library

import SwiftUIProgressiveOnboard   

STEP 1: Set your data as a json format string

let progressiveOnboardsJson = """
[
    {
        "description": "You can use onboard screens. This is the first onboard text. Let's make it longer with the same text. You can use onboard screens. This is the first onboard text.",
        "previousButtonTitle": "",
        "nextButtonTitle": "Next"
    },
    {
        "description": "This is the second one, go down for a button",
        "previousButtonTitle": "Previous",
        "nextButtonTitle": "Go"
    }
]	
"""

STEP 2: Create an observable ProgressiveOnboard object with your data

@ObservedObject var onboard = ProgressiveOnboard.init(withJson: progressiveOnboardsJson)

STEP 3: Create a ZStack for overlay

var body: some View {
    ZStack {

    }
    .frame(maxWidth: .infinity, maxHeight: .infinity)
    .edgesIgnoringSafeArea(.all)
}

STEP 4: Add progressive board views to the buttons, texts, views... (filterViews are automatically created by the given data count)

var body: some View {
    ZStack {
    	VStack {
        	Text("Lorem Ipsum 1")
        		.background(ProgressiveOnboardGeometry(withRect: $onboard.filterViews[0]))


        	Button("Simple Button") {}
            	.background(ProgressiveOnboardGeometry(withRect: $onboard.filterViews[1]))
    	}
    }
}

STEP 5: Show your onboard view at the top of ZStack

var body: some View {
    ZStack {
    	VStack {
        	Text("Lorem Ipsum 1")
        		.background(ProgressiveOnboardGeometry(withRect: $onboard.filterViews[0]))


        	Button("Simple Button") {}
            	.background(ProgressiveOnboardGeometry(withRect: $onboard.filterViews[1]))
    	}

    	if(onboard.showOnboardScreen) {
            ProgressiveOnboardView.init(withProgressiveOnboard: self.onboard)
        }
    }
}

USING ON DETAIL VIEW If you want to use it in another view, you can follow the same steps from the beginning. You also need to define the coordinate system as "OnboardSpace" for the GeometryReader for the ZStack.

STEP 6:

ZStack {
    ...
}
.frame(maxWidth: .infinity, maxHeight: .infinity)
.coordinateSpace(name: "OnboardSpace")

Licence

SwiftUIProgressiveOnboard is available under the MIT license. See the LICENSE file for more info.

GitHub

link
Stars: 7
Last commit: 5 weeks ago

Ad: Job Offers

iOS Software Engineer @ Perry Street Software
Perry Street Software is Jack’d and SCRUFF. We are two of the world’s largest gay, bi, trans and queer social dating apps on iOS and Android. Our brands reach more than 20 million members worldwide so members can connect, meet and express themselves on a platform that prioritizes privacy and security. We invest heavily into SwiftUI and using Swift Packages to modularize the codebase.

Release Notes

First Release
37 weeks ago

Specify the coordinate system for the GeometryReader for Detail Views

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API