Skip to content

Simple spotlight instruction framework for UIKit iOS

License

Notifications You must be signed in to change notification settings

toshi0383/Yokoso

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

48 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🌸Yokoso🗻

Yet another super simple spotlight instruction framework for UIKit iOS.

Why Yokoso?

  • Checks if interested view is inside window's bounds
  • Supports device rotation / iPad SplitView
  • Swift Concurrency
  • Swift 6 Concurrency Check Mode ( work in progress )

Unique Error Feature

You don't want to show spotlight on an invisible view, right? One good thing about Yokoso, is that it checks if the interested view is fully visible to your user. Otherwise InstructionError.interestedViewOutOfBounds is thrown. With Yokoso, your tutorial UI/UX is better than ever.

Screenshot

yokoso.mp4

How to use

It's super simple. Import the module,

import Yokoso

initialize InstructionManager,

let manager = InstructionManager(overlayBackgroundColor: .overlayBackground)

then use InstructionManager's interface to show or close your Instruction.

Showing single Instruction

do {

    try instructionManager.show(
        .init(
            message: .init(
                attributedString: attributedString,
                backgroundColor: uicolor
            ),
            nextButton: .simple("Next"),
            sourceView: label
        ),
        in: view
    )

} catch {
    if let error = error as? InstructionError {
        assertionFailure(error.localizedDescription)
    }
}

Please refer to the Example app for further customization.

SwiftUI

You can use Yokoso for SwiftUI view, at least if you're embedding with UIHostingController.

First you need to retrieve interested view's frame via ObservableObject + GeometryReader.

class ViewModel: ObservableObject {
    @Published var interestedViewRect: CGRect?
}

struct YourView: View {
    @ObservedObject var viewModel: ViewModel
    var body: some View {
        GeometryReader { p in
            yourLayout
                .onAppear {
                    viewModel.interestedViewRect = p.frame(in: .global)
                }
        }
    }

}

Then pass that frame to sourceRect parameter of InstructionManager.show.

    try await instructionManager?.show(
        .init(
            message: .init(attributedString: message, backgroundColor: .v4.monotone8),
            nextButton: .custom(...),
            sourceView: view,
            sourceRect: sourceRect,
            blocksTapOutsideCutoutPath: true,
            ignoresTapInsideCutoutPath: true
        ),
        in: view
    )

Requirements

  • iOS 14+

Install

  • Swift Package Manager

Contributing

Any contributions are warmly welcomed.😊

  • Feature Request / Pull Request
  • Bug Report
  • Question!

LICENSE

MIT

About

Simple spotlight instruction framework for UIKit iOS

Topics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Languages