WelcomeWindow

1.4.1

SwiftUI Welcome screen modeled after the 'Welcome to Xcode' window
JUSTINMKAUFMAN/WelcomeWindow

What's New

1.4.1

2021-05-27T16:12:58Z

This is a breaking API change from versions 1.3.X and below. Instead of passing an Image into the WelcomeWindow initializer, you now pass an instance of AnyView, enabling greater flexibility around what appears in this part of the window.

WelcomeWindow

Version License Platform Platform

A welcome screen for a SwiftUI application modeled after the 'Welcome to Xcode' window.


Compatibility

WelcomeWindow is compatible with applications targeting macOS 11+ and iOS 14+.

Installation

Swift Package Manager

WelcomeWindow is available as a Swift Package. To use it in your project, add it to your project's Swift Packages:

https://github.com/JUSTINMKAUFMAN/WelcomeWindow.git

Usage

Refer to the Demo application (included in this repository) for sample usage.

Alternatively, WelcomeWindow can be used as follows:

import SwiftUI
import WelcomeWindow

@main
struct WelcomeWindowDemoApp: App {
    // Optionally track the hover state of the logo (macOS only)
    @State var isHoveringLogo: Bool = false
    
    private var logoView: AnyView {
        AnyView(
            Image(systemName: "qrcode.viewfinder")
                .resizable()
                .scaleEffect(isHoveringLogo ? 0.8 : 1.0)
                .rotationEffect(Angle(degrees: isHoveringLogo ? 180.0 : 0.0))
                .animation(.easeInOut, value: isHoveringLogo)
                .onHover { isHoveringLogo = $0 }
        )
    }
    
    @SceneBuilder var body: some Scene {
        WindowGroup {
            WelcomeWindow(
                logoView: logoView,
                titleText: "Welcome to App",
                actions: [
                    WelcomeAction(
                        title: "Create a new project",
                        detail: "Create a new project",
                        systemImage: "plus.square",
                        imageColor: Color.red,
                        isEnabled: false,
                        onSelect: { print("Action triggered") }
                    ),
                    WelcomeAction(
                        title: "Create a new project",
                        detail: "Create a new project",
                        systemImage: "plus.square",
                        imageColor: Color.green,
                        onSelect: { print("Action triggered") }
                    ),
                    WelcomeAction(
                        title: "Create a new project",
                        detail: "Create a new project",
                        systemImage: "plus.square",
                        onSelect: { print("Action triggered") }
                    )
                ],
                documentListTitle: "Recently Opened",
                recentDocuments: [
                    RecentDocument(
                        name: "MyDocA",
                        detail: "/path/to/MyDocA",
                        contextMenu: {
                            AnyView(
                                VStack {
                                    Button(
                                        action: { print("Context Action A triggered") },
                                        label: { Text("Context Action A") }
                                    )
                                    Button(
                                        action: { print("Context Action B triggered") },
                                        label: { Text("Context Action B") }
                                    )
                                }
                            )
                        }
                    ),
                    RecentDocument(
                        name: "MyDocB",
                        detail: "/path/to/MyDocB",
                        contextMenu: {
                            AnyView(
                                VStack {
                                    Button(
                                        action: { print("Context Action A triggered") },
                                        label: { Text("Context Action A") }
                                    )
                                    Button(
                                        action: { print("Context Action B triggered") },
                                        label: { Text("Context Action B") }
                                    )
                                }
                            )
                        }
                    ),
                    RecentDocument(
                        name: "MyDocB",
                        detail: "/path/to/MyDocB",
                        systemImage: "plus.square",
                        contextMenu: {
                            AnyView(
                                VStack {
                                    Button(
                                        action: { print("Context Action A triggered") },
                                        label: { Text("Context Action A") }
                                    )
                                    Button(
                                        action: { print("Context Action B triggered") },
                                        label: { Text("Context Action B") }
                                    )
                                }
                            )
                        }
                    )
                ],
                handleOpenDocument: { doc in print("Document opened: \(doc.name)") },
                isHoveringLogo: $isHoveringLogo
            )
        }
    }
}

Author

Justin Kaufman, jmkauf@gmail.com

License

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

Description

  • Swift Tools 5.3.0
View More Packages from this Author

Dependencies

  • None
Last updated: Thu Oct 31 2024 05:36:18 GMT-0900 (Hawaii-Aleutian Daylight Time)