Skip to content

Commit

Permalink
feat: SwiftUI support (#167)
Browse files Browse the repository at this point in the history
### InstantSearch SwiftUI

A collection of basic search SwiftUI views

- `SearchBar` - a specialised view for receiving search query text from the user.
- `HitsList` - a view presenting the list of search hits
- `FacetList` – a view presenting the list of facets
- `HierarchicalList` - a view presenting the list of hierarchical facets
- `FacetRow` - a view presenting the facet value and its selection state
- `Text+Highlighting` - `Text` extensions allowing to build an attributed `Text` view with `HighlightedString` and `TaggedString` components provided by InstantSearch

### InstantSearch Core

The Core provides the implementations of `Controller` protocols adapted for SwiftUI which can be easily connected to the existing Interactors. 
- `QueryInputObservableController`
- `HitsObservableController`
- `FacetListObservableController`
- `HierarchicalObservableController`
- `StatsObservableController`
- `FilterClearObservableController`
- `SwitchIndexObservableController`
  • Loading branch information
VladislavFitz committed Apr 30, 2021
1 parent a362a11 commit 2b027f2
Show file tree
Hide file tree
Showing 43 changed files with 1,079 additions and 110 deletions.
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ source "https://rubygems.org"
git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }

gem 'cocoapods', '~> 1.10'
gem 'fastlane', '~> 2.174'
gem 'fastlane', '~> 2.181'
gem 'xcov'
75 changes: 40 additions & 35 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ GEM
remote: https://rubygems.org/
specs:
CFPropertyList (3.0.3)
activesupport (5.2.4.5)
activesupport (5.2.5)
concurrent-ruby (~> 1.0, >= 1.0.2)
i18n (>= 0.7, < 2)
minitest (~> 5.1)
Expand All @@ -14,21 +14,21 @@ GEM
json (>= 1.5.1)
artifactory (3.0.15)
atomos (0.1.3)
aws-eventstream (1.1.0)
aws-partitions (1.427.0)
aws-sdk-core (3.112.0)
aws-eventstream (1.1.1)
aws-partitions (1.447.0)
aws-sdk-core (3.114.0)
aws-eventstream (~> 1, >= 1.0.2)
aws-partitions (~> 1, >= 1.239.0)
aws-sigv4 (~> 1.1)
jmespath (~> 1.0)
aws-sdk-kms (1.42.0)
aws-sdk-kms (1.43.0)
aws-sdk-core (~> 3, >= 3.112.0)
aws-sigv4 (~> 1.1)
aws-sdk-s3 (1.88.1)
aws-sdk-s3 (1.93.1)
aws-sdk-core (~> 3, >= 3.112.0)
aws-sdk-kms (~> 1)
aws-sigv4 (~> 1.1)
aws-sigv4 (1.2.2)
aws-sigv4 (1.2.3)
aws-eventstream (~> 1, >= 1.0.2)
babosa (1.0.4)
claide (1.0.3)
Expand Down Expand Up @@ -75,29 +75,32 @@ GEM
highline (~> 1.7.2)
concurrent-ruby (1.1.8)
declarative (0.0.20)
declarative-option (0.1.0)
digest-crc (0.6.3)
rake (>= 12.0.0, < 14.0.0)
domain_name (0.5.20190701)
unf (>= 0.0.5, < 1.0.0)
dotenv (2.7.6)
emoji_regex (3.2.1)
emoji_regex (3.2.2)
escape (0.0.4)
ethon (0.12.0)
ffi (>= 1.3.0)
excon (0.79.0)
faraday (1.3.0)
ethon (0.13.0)
ffi (>= 1.15.0)
excon (0.80.1)
faraday (1.4.1)
faraday-excon (~> 1.1)
faraday-net_http (~> 1.0)
faraday-net_http_persistent (~> 1.1)
multipart-post (>= 1.2, < 3)
ruby2_keywords
ruby2_keywords (>= 0.0.4)
faraday-cookie_jar (0.0.7)
faraday (>= 0.8.0)
http-cookie (~> 1.0.0)
faraday-excon (1.1.0)
faraday-net_http (1.0.1)
faraday-net_http_persistent (1.1.0)
faraday_middleware (1.0.0)
faraday (~> 1.0)
fastimage (2.2.2)
fastlane (2.174.0)
fastimage (2.2.3)
fastlane (2.181.0)
CFPropertyList (>= 2.3, < 4.0.0)
addressable (>= 2.3, < 3.0.0)
artifactory (~> 3.0)
Expand All @@ -121,6 +124,7 @@ GEM
jwt (>= 2.1.0, < 3)
mini_magick (>= 4.9.4, < 5.0.0)
multipart-post (~> 2.0.0)
naturally (~> 2.2)
plist (>= 3.1.0, < 4.0.0)
rubyzip (>= 2.0.0, < 3.0.0)
security (= 0.1.3)
Expand All @@ -134,7 +138,7 @@ GEM
xcodeproj (>= 1.13.0, < 2.0.0)
xcpretty (~> 0.3.0)
xcpretty-travis-formatter (>= 0.0.3)
ffi (1.14.2)
ffi (1.15.0)
fourflusher (2.3.1)
fuzzy_match (2.0.4)
gh_inspector (1.1.3)
Expand All @@ -146,7 +150,7 @@ GEM
representable (~> 3.0)
retriable (>= 2.0, < 4.0)
signet (~> 0.12)
google-apis-core (0.2.1)
google-apis-core (0.3.0)
addressable (~> 2.5, >= 2.5.1)
googleauth (~> 0.14)
httpclient (>= 2.8.1, < 3.0)
Expand All @@ -156,25 +160,25 @@ GEM
rexml
signet (~> 0.14)
webrick
google-apis-iamcredentials_v1 (0.1.0)
google-apis-iamcredentials_v1 (0.3.0)
google-apis-core (~> 0.1)
google-apis-storage_v1 (0.2.0)
google-apis-storage_v1 (0.3.0)
google-apis-core (~> 0.1)
google-cloud-core (1.5.0)
google-cloud-core (1.6.0)
google-cloud-env (~> 1.0)
google-cloud-errors (~> 1.0)
google-cloud-env (1.4.0)
google-cloud-env (1.5.0)
faraday (>= 0.17.3, < 2.0)
google-cloud-errors (1.0.1)
google-cloud-storage (1.30.0)
google-cloud-errors (1.1.0)
google-cloud-storage (1.31.0)
addressable (~> 2.5)
digest-crc (~> 0.4)
google-apis-iamcredentials_v1 (~> 0.1)
google-apis-storage_v1 (~> 0.1)
google-cloud-core (~> 1.2)
googleauth (~> 0.9)
mini_mime (~> 1.0)
googleauth (0.15.1)
googleauth (0.16.1)
faraday (>= 0.17.3, < 2.0)
jwt (>= 1.4, < 3.0)
memoist (~> 0.16)
Expand All @@ -185,15 +189,15 @@ GEM
http-cookie (1.0.3)
domain_name (~> 0.5)
httpclient (2.8.3)
i18n (1.8.9)
i18n (1.8.10)
concurrent-ruby (~> 1.0)
jmespath (1.4.0)
json (2.5.1)
jwt (2.2.2)
jwt (2.2.3)
memoist (0.16.2)
mini_magick (4.11.0)
mini_mime (1.0.2)
minitest (5.14.3)
mini_mime (1.1.0)
minitest (5.14.4)
molinillo (0.6.6)
multi_json (1.15.0)
multipart-post (2.0.0)
Expand All @@ -205,18 +209,18 @@ GEM
plist (3.6.0)
public_suffix (4.0.6)
rake (13.0.3)
representable (3.0.4)
representable (3.1.1)
declarative (< 0.1.0)
declarative-option (< 0.2.0)
trailblazer-option (>= 0.1.1, < 0.2.0)
uber (< 0.2.0)
retriable (3.1.2)
rexml (3.2.4)
rexml (3.2.5)
rouge (2.0.7)
ruby-macho (1.4.0)
ruby2_keywords (0.0.4)
rubyzip (2.3.0)
security (0.1.3)
signet (0.14.1)
signet (0.15.0)
addressable (~> 2.3)
faraday (>= 0.17.3, < 2.0)
jwt (>= 1.5, < 3.0)
Expand All @@ -229,6 +233,7 @@ GEM
terminal-table (1.8.0)
unicode-display_width (~> 1.1, >= 1.1.1)
thread_safe (0.3.6)
trailblazer-option (0.1.1)
tty-cursor (0.7.1)
tty-screen (0.8.1)
tty-spinner (0.9.3)
Expand All @@ -250,7 +255,7 @@ GEM
claide (>= 1.0.2, < 2.0)
colored2 (~> 3.1)
nanaimo (~> 0.3.0)
xcov (1.7.3)
xcov (1.7.5)
fastlane (>= 2.141.0, < 3.0.0)
multipart-post
slack-notifier
Expand All @@ -268,7 +273,7 @@ PLATFORMS

DEPENDENCIES
cocoapods (~> 1.10)
fastlane (~> 2.174)
fastlane (~> 2.181)
xcov

BUNDLED WITH
Expand Down
17 changes: 15 additions & 2 deletions InstantSearch.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Pod::Spec.new do |s|

s.subspec "Insights" do |ss|
ss.source_files = 'Sources/InstantSearchInsights/**/*.{swift}'
ss.dependency 'AlgoliaSearchClient', '~> 8.7'
ss.dependency 'AlgoliaSearchClient', '~> 8.8'
ss.ios.deployment_target = '9.0'
ss.osx.deployment_target = '10.10'
ss.watchos.deployment_target = '3.0'
Expand All @@ -24,7 +24,8 @@ Pod::Spec.new do |s|

s.subspec "Core" do |ss|
ss.source_files = 'Sources/InstantSearchCore/**/*.{swift}'
ss.dependency 'AlgoliaSearchClient', '~> 8.7'
ss.exclude_files = 'Sources/InstantSearchCore/SwiftUI/**/*.{swift}'
ss.dependency 'AlgoliaSearchClient', '~> 8.8'
ss.dependency 'InstantSearch/Insights'
ss.ios.deployment_target = '9.0'
ss.osx.deployment_target = '10.10'
Expand All @@ -35,6 +36,7 @@ Pod::Spec.new do |s|

s.subspec "UI" do |ss|
ss.source_files = 'Sources/InstantSearch/**/*.{swift}'
ss.exclude_files = 'Sources/InstantSearch/SwiftUI/**/*.{swift}'
ss.dependency 'InstantSearch/Core'
ss.ios.deployment_target = '9.0'
ss.osx.deployment_target = '10.10'
Expand All @@ -43,4 +45,15 @@ Pod::Spec.new do |s|
ss.pod_target_xcconfig = { 'OTHER_SWIFT_FLAGS' => '-DInstantSearchCocoaPods' }
end

s.subspec "SwiftUI" do |ss|
ss.source_files = 'Sources/InstantSearchCore/SwiftUI/**/*.{swift}', 'Sources/InstantSearch/SwiftUI/**/*.{swift}'
ss.dependency 'InstantSearch/Core'
ss.ios.deployment_target = '13.0'
ss.osx.deployment_target = '10.15'
ss.watchos.deployment_target = '6.0'
ss.tvos.deployment_target = '13.0'
ss.pod_target_xcconfig = { 'OTHER_SWIFT_FLAGS' => '-DInstantSearchCocoaPods' }
ss.weak_frameworks = 'SwiftUI', 'Combine'
end

end
2 changes: 1 addition & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ let package = Package(
targets: ["InstantSearchInsights"])
],
dependencies: [
.package(name: "AlgoliaSearchClient", url:"https://github.com/algolia/algoliasearch-client-swift", from: "8.7.0")
.package(name: "AlgoliaSearchClient", url: "https://github.com/algolia/algoliasearch-client-swift", from: "8.8.0")
],
targets: [
.target(
Expand Down
11 changes: 6 additions & 5 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ InstantSearch family: **InstantSearch iOS** | [InstantSearch Android][instantsea
**InstantSearch iOS** consists of three products
- *InstantSearch Insights* – library that allows developers to capture search-related events
- *InstantSearch Core* – the business logic modules of InstantSearch without provided UIKit controllers
- *InstantSearch* – the complete InstantSearch toolset including UIKit components
- *InstantSearch* – the complete InstantSearch toolset including UIKit and SwiftUI components

## Demo

Expand All @@ -44,9 +44,9 @@ If you're a framework author and use InstantSearch as a dependency, update your

```swift
let package = Package(
// 7.10.0 ..< 8.0.0
// 7.11.0 ..< 8.0.0
dependencies: [
.package(url: "https://github.com/algolia/instantsearch-ios", from: "7.10.0")
.package(url: "https://github.com/algolia/instantsearch-ios", from: "7.11.0")
],
// ...
)
Expand All @@ -59,9 +59,10 @@ let package = Package(
To install InstantSearch, simply add the following line to your Podfile:

```ruby
pod 'InstantSearch', '~> 7.10'
pod 'InstantSearch', '~> 7.11'
# pod 'InstantSearch/Insights' for access to Insights library only
# pod 'InstantSearch/Core' for access business logic without UIKit components
# pod 'InstantSearch/SwiftUI' for access to SwiftUI components
```

Then, run the following command:
Expand All @@ -76,7 +77,7 @@ $ pod update

- To install InstantSearch, simply add the following line to your Cartfile:
```ruby
github "algolia/instantsearch-ios" ~> 7.10
github "algolia/instantsearch-ios" ~> 7.11
```

- Launch the following commands from the project directory
Expand Down
Loading

0 comments on commit 2b027f2

Please sign in to comment.