A sheet to introduce the user to your app and to welcome them or to inform them about new features after an update.
Apple uses it in all of their apps, but unfortunately they don't make it available to us in their SDK. That's why I have my own implementation and make it available, as I have hardly found another good one on github.
- iOS 13
- Swift 5.1
- Xcode 12
The preferred way of installing FirstOpenViews is via the Swift Package Manager.
Xcode 11 integrates with libSwiftPM to provide support for iOS, watchOS, and tvOS platforms.
- In Xcode, open your project and navigate to File → Swift Packages → Add Package Dependency...
- Paste the repository URL (
https://github.com/lucaszischka/FirstOpenViews
) and click Next. - For Rules, select Branch (with branch set to
main
). - Click Finish.
WARNING: This is Sample Code for visualisation where and how to use, without a working initializer. Please see Examples for working code
Same way you use Sheet in SwiftUI
//SceneDelegate.swift
func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {
let contentView = ContentView() //1
.welcomeView() //2
.whatsNewView() //3
if let windowScene = scene as? UIWindowScene {
let window = UIWindow(windowScene: windowScene)
window.rootViewController = UIHostingController(rootView: contentView)
self.window = window
window.makeKeyAndVisible()
}
}
@main
struct TestApp: App {
var body: some Scene {
WindowGroup {
ContentView() //1
.welcomeView() //2
.whatsNewView() //3
}
}
}
//1
You add it to the highest Navigation Level
//2
This is how you add the WelcomeView (first launch)
//3
This is how you add the WhatsNewView (after update)
WARNING: This is Sample Code for visualisation of the parameters and their default values and value types, without a working initializer. Please see Examples for working code
.welcomeView(
imageName: String? = nil,
mainColor: Color = Color.blue,
informationDetailViews: [InformationDetailView]
)
-
imageName
Here you can add a image to the sheet if you wish. -
mainColor
Here you can change the color used for the App Name and the Continue Button. -
informationDetailViews
Here you add the InformationDetailView's. Three are recommend. Please see InformationDetailView for parameters.
WARNING: This is Sample Code for visualisation of the parameters and their default values and value types, without a working initializer. Please see Examples for working code
.whatsNewView(
imageName: String? = nil,
mainColor: Color = Color.blue,
informationDetailViews: [InformationDetailView]
)
-
imageName
Here you can add a image to the sheet if you wish. -
mainColor
Here you can change the color used for the App Name and the Continue Button. -
informationDetailViews
Here you add the InformationDetailView's. Three are recommend. Please see InformationDetailView for parameters.
WARNING: This is Sample Code for visualisation of the parameters and their default values and value types, without a working initializer. Please see Examples for working code
InformationDetailView(
title: String,
subTitle: Sring,
image: Image,
mainColor: Color = Color.blue
)
-
title
The title for the view -
subTitle
The text for the view -
image
Here you add the picture for the View. SFSymbols are preferred. -
mainColor
Here you can change the color of the picture if it is an SFSymbol.
import UIKit
import SwiftUI
import FirstOpenViews
class SceneDelegate: UIResponder, UIWindowSceneDelegate {
var window: UIWindow?
func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {
let contentView = ContentView()
.welcomeView(informationDetailViews: [
InformationDetailView(title: "Car", subTitle: "A car (or automobile) is a wheeled motor vehicle used for transportation.", image: Image(systemName: "car.fill")),
InformationDetailView(title: "Airplane", subTitle: "An airplane or aeroplane (informally plane) is a powered, fixed-wing aircraft that is propelled forward by thrust from a jet engine, propeller or rocket engine.", image: Image(systemName: "airplane")),
InformationDetailView(title: "Tram", subTitle: "A tram (in North America streetcar or trolley) is a rail vehicle that runs on tramway tracks along public urban streets.", image: Image(systemName: "tram.fill"))
])
.whatsNewView(informationDetailViews: [
InformationDetailView(title: "Car", subTitle: "A car (or automobile) is a wheeled motor vehicle used for transportation.", image: Image(systemName: "car.fill")),
InformationDetailView(title: "Airplane", subTitle: "An airplane or aeroplane (informally plane) is a powered, fixed-wing aircraft that is propelled forward by thrust from a jet engine, propeller or rocket engine.", image: Image(systemName: "airplane")),
InformationDetailView(title: "Tram", subTitle: "A tram (in North America streetcar or trolley) is a rail vehicle that runs on tramway tracks along public urban streets.", image: Image(systemName: "tram.fill"))
])
if let windowScene = scene as? UIWindowScene {
let window = UIWindow(windowScene: windowScene)
window.rootViewController = UIHostingController(rootView: contentView)
self.window = window
window.makeKeyAndVisible()
}
}
func sceneDidDisconnect(_ scene: UIScene) {}
func sceneDidBecomeActive(_ scene: UIScene) {}
func sceneWillResignActive(_ scene: UIScene) {}
func sceneWillEnterForeground(_ scene: UIScene) {}
func sceneDidEnterBackground(_ scene: UIScene) {}
}
import SwiftUI
import FirstOpenViews
@main
struct TestApp: App {
var body: some Scene {
WindowGroup {
ContentView()
.welcomeView(informationDetailViews: [
InformationDetailView(title: "Car", subTitle: "A car (or automobile) is a wheeled motor vehicle used for transportation.", image: Image(systemName: "car.fill")),
InformationDetailView(title: "Airplane", subTitle: "An airplane or aeroplane (informally plane) is a powered, fixed-wing aircraft that is propelled forward by thrust from a jet engine, propeller or rocket engine.", image: Image(systemName: "airplane")),
InformationDetailView(title: "Tram", subTitle: "A tram (in North America streetcar or trolley) is a rail vehicle that runs on tramway tracks along public urban streets.", image: Image(systemName: "tram.fill"))
])
.whatsNewView(informationDetailViews: [
InformationDetailView(title: "Car", subTitle: "A car (or automobile) is a wheeled motor vehicle used for transportation.", image: Image(systemName: "car.fill")),
InformationDetailView(title: "Airplane", subTitle: "An airplane or aeroplane (informally plane) is a powered, fixed-wing aircraft that is propelled forward by thrust from a jet engine, propeller or rocket engine.", image: Image(systemName: "airplane")),
InformationDetailView(title: "Tram", subTitle: "A tram (in North America streetcar or trolley) is a rail vehicle that runs on tramway tracks along public urban streets.", image: Image(systemName: "tram.fill"))
])
}
}
}
FirstOpenViews welcomes contributions in the form of GitHub issues and pull-requests.
FirstOpenViews is available under the MIT license. See the LICENSE file for more information.
FirstOpenViews is a project of @lucaszischka.