https://github.com/boraseoksoon/spotlight
SpotlightUI for SwiftUI
https://github.com/boraseoksoon/spotlight
Last synced: 3 months ago
JSON representation
SpotlightUI for SwiftUI
- Host: GitHub
- URL: https://github.com/boraseoksoon/spotlight
- Owner: boraseoksoon
- License: mit
- Created: 2019-12-04T05:38:34.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2019-12-05T11:15:40.000Z (over 5 years ago)
- Last Synced: 2025-02-05T08:51:26.679Z (4 months ago)
- Language: Swift
- Size: 144 KB
- Stars: 3
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Spotlight
[](https://travis-ci.org/boraseoksoon/Spotlight)
[](https://cocoapods.org/pods/Spotlight)
[](https://cocoapods.org/pods/Spotlight)
[](https://cocoapods.org/pods/Spotlight)Spotlight Search in SwiftUI
Screenshots
-----------

Youtube video URL Link for how it works:
[link0](https://youtu.be/QTB7GqZL-L8)At a Glance
-----------```swift
// MARK: - Body
var body: some View {
Spotlight(searchKeywords:viewModel.searchableItems,
isSearching:$isSearching,
didChangeSearchText: { self.viewModel.searchText = $0 },
didTapSearchItem: { self.viewModel.searchText = $0 }) {
Text("Your View Goes here")
}
}
```## Features
- [x] Written in SwiftUI and Combine 100%.
- [x] It aims to provide quick and beautiful search UI/UX out of box like macOS Spotlight Search in iOS.
- [x] MVVM
## Example
To run the example project, clone the repo, and run `pod install` from the Example directory first.
It includes examples for UIKit as well as SwiftUI.## Requirements
- iOS 13.0 or later
- Swift 5.0 or later
- Xcode 11.0 or laterGetting Started
---------------* SwiftUI
```Swift
import SwiftUI/// Step1: 😙 import `Spotlight`
import Spotlightstruct ItemListView: View {
@ObservedObject var viewModel: YOUR_VIEW_MODEL = YOUR_VIEW_MODEL()
@State private var isSearching = false// MARK: - Body
var body: some View {
/// Step2: 😆 Declare `Spotlight` externally.
Spotlight(searchKeywords:viewModel.searchableItems, // search keyword list as string array
isSearching:$isSearching, // Spotlight appears when true.
/// Step3: 😎 Whenever typing searching any keywords, and tap the suggested keywords,
/// those goes below. do your implementation as you need.
didChangeSearchText: { self.viewModel.searchText = $0 },
didTapSearchItem: { self.viewModel.searchText = $0 }) {
/// Step4: 😎 Let's wrap SwiftUI Views in it, using trailing closure.
Text("Your View")
}
}
}
``````
## Installation
There are three ways to use Spotlight in your project:
- using CocoaPods
- using Swift Package Manager
- manual install (build frameworks or embed Xcode Project)### Installation with CocoaPods
[CocoaPods](http://cocoapods.org/) is a dependency manager for Objective-C, which automates and simplifies the process of using 3rd-party libraries in your projects. See the [Get Started](http://cocoapods.org/#get_started) section for more details.
#### Podfile
First,
```ruby
pod 'Spotlight'
```
then in your root project,
```ruby
pod install
```### Installation with Swift Package Manager (Xcode 11+)
[Swift Package Manager](https://swift.org/package-manager/) (SwiftPM) is a tool for managing the distribution of Swift code as well as C-family dependency. From Xcode 11, SwiftPM got natively integrated with Xcode.
Spotlight support SwiftPM from version 5.1.0. To use SwiftPM, you should use Xcode 11 to open your project. Click `File` -> `Swift Packages` -> `Add Package Dependency`, enter [Spotlight repo's URL](https://github.com/boraseoksoon/Spotlight). Or you can login Xcode with your GitHub account and just type `Spotlight` to search.
After select the package, you can choose the dependency type (tagged version, branch or commit). Then Xcode will setup all the stuff for you.
If you're a framework author and use Spotlight as a dependency, update your `Package.swift` file:
```swift
let package = Package(
dependencies: [
.package(url: "https://github.com/boraseoksoon/Spotlight", from: "0.1.1")
],
// ...
)
```## Author
## License
Spotlight is available under the MIT license. See the LICENSE file for more info.
## References
[PhotoCell](https://apps.apple.com/us/app/observable/id1488022000?ls=1) :
Photos browsing iOS app where you can download the photos for free as you like.
![]()
![]()
![]()