Skip to content

SwiftUISpotlight: Easily add highlighting functionality to SwiftUI views.

License

Notifications You must be signed in to change notification settings

nicodioso/SwiftUISpotlight

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SwiftUISpotlight

SwiftUISpotlight: Easily add highlighting functionality to SwiftUI views.

Welcome to SwiftUISpotlight! 🌟

SwiftUISpotlight Loop

SwiftUISpotlight is your go-to repository for adding highlighting functionality to SwiftUI views with ease. Whether you need to emphasize specific areas within your app or guide users' attention, our highlight function simplifies the process. Define custom shapes for different items and handle taps effortlessly.

Basic Highlighting

Here's a basic example of how to use SwiftUISpotlight to highlight a specific area within a view:

struct MyPage: View {
  @State var highlightedId: String? = nil

  var body: some View {
    GeometryReader { geometry in
      MyComponent()
        .highlightable(id: "myComponent", inside: geometry)
    }
    .highlight(
      highlightedId,
      onTap: {
        highlightedId = nil
      }
    )
    .task {
      highlightedId = "myComponent"
    }
  }
}

See Examples/Example1.swift for the demo video's code.

Custom Highlight Shapes

You can define custom highlight shapes for each identifier using the .highlight(id) modifier:

.highlight(id: "myComponent1") {
    if id == "myComponent1" {
       Circle()
    } else {
       Rectangle()
    }
}

Adding Padding

You can add padding to your highlightable areas using the .highlightable(id:inside:padding:) modifier:

.highlightable(id: "myComponent1", inside: geometry, padding: 10)

or

.highlightable(id: "myComponent1", inside: geometry, padding: .top, 10)

This allows you to customize the padding around the highlighted area.

License

SwiftUISpotlight is available under the MIT license. See the LICENSE file for more information.

This README.md includes the additional features of defining custom highlight shapes for each identifier and adding padding to highlightable areas. It provides usage examples for each feature to help users understand how to incorporate them into their projects.

About

SwiftUISpotlight: Easily add highlighting functionality to SwiftUI views.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages