Skip to content

Commit

Permalink
Fix a bug in search that would cause search results to stop returning…
Browse files Browse the repository at this point in the history
…. Update the README. Bump to version 1.0.2
  • Loading branch information
amyleecodes committed Mar 10, 2017
1 parent 487e45e commit 3433018
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 11 deletions.
11 changes: 5 additions & 6 deletions Library/SwiftyGiphyViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,9 @@ public class SwiftyGiphyViewController: UIViewController {
}

guard let searchText = searchController.searchBar.text, searchText.characters.count > 0 else {

self.searchCounter += 1
self.currentGifs = combinedTrendingGifs
return
}

Expand All @@ -269,15 +272,15 @@ public class SwiftyGiphyViewController: UIViewController {

SwiftyGiphyAPI.shared.getSearch(searchTerm: searchText, limit: 100, rating: self.contentRating, offset: self.currentSearchPageOffset) { [weak self] (error, response) in

self?.isSearchPageLoadInProgress = false

guard currentCounter == self?.searchCounter else {

return
}

self?.isTrendingPageLoadInProgress = false
self?.loadingIndicator.stopAnimating()
self?.errorLabel.isHidden = true
self?.isSearchPageLoadInProgress = false

guard error == nil else {

Expand Down Expand Up @@ -394,10 +397,6 @@ extension SwiftyGiphyViewController: UISearchResultsUpdating {

public func updateSearchResults(for searchController: UISearchController) {

guard searchController.searchBar.text?.characters.count ?? 0 > 0 else {
return
}

// Destroy current results
searchCounter += 1
latestSearchResponse = nil
Expand Down
21 changes: 17 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#SwiftyGiphy
SwiftyGiphy is a library to allow you to easily integrate Giphy image search into your app.

The library includes a view controller you can present that shows trending giphy images, and allows search. The controller also supports paging so your users can contiously scroll and see results.
The library includes a view controller you can present that shows trending Giphy images, and allows search. The controller also supports paging so your users can contiously scroll and see results.

The SwiftyGiphy view controller provides a delegate hook so you can be notified of what gif a user has selected.

Expand All @@ -17,7 +17,12 @@ SwiftyGiphy supports Cocoapods and manual includes.
`pod 'SwiftyGiphy', '~> 1.0'`

####Manual Include
Add the files in the Library and Assets folder to your project.
Add the files in the Library and Assets folder to your project. You'll also need to include the dependencies:

* [ObjectMapper](https://github.com/Hearst-DD/ObjectMapper) - v2.2
* [SDWebImage/GIF](https://github.com/rs/SDWebImage)
* [NSTimer-Blocks](https://github.com/jivadevoe/NSTimer-Blocks)
* [FLAnimatedImage](https://github.com/Flipboard/FLAnimatedImage) - v1.0

####Carthage / Swift Package Manager
Carthage and Swift Package Manager are not currently supported. But, if you'd like to create a pull request with support for either of these I'd be happy to consider including it.
Expand All @@ -34,7 +39,7 @@ You'll need to configure SwiftyGiphy with your Giphy API key. We recommend you d
`SwiftyGiphyAPI.shared.apiKey = SwiftyGiphyAPI.publicBetaKey`

###Recommendations
Recommended usage is to present SwiftyGiphyViewController modally, with another object (such as the presenting view controller) assigned as the delegate of SwiftyGiphyViewController.
Recommended usage is to present SwiftyGiphyViewController modally in a UINavigationController, with another object (such as the presenting view controller) assigned as the delegate of SwiftyGiphyViewController.

You should dismiss SwiftyGiphyViewController in the delegate methods, when you need to.

Expand All @@ -46,4 +51,12 @@ SwiftyGiphy provides a few useful things for your Giphy integration:
* **SwiftyGiphyViewController** (outlined above) gives you an easy to use UI for interacting with Giphy image search.
* **SwiftyGiphyViewControllerDelegate** is called by SwiftyGiphyViewController to notify you when the user selects GIFs, or is ready to close the screen.
* **SwiftyGiphyAPI** provides easy access to the Giphy API. Currently the search and trending endpoints are implemented. Hint: I'd welcome pull requests with this component more fleshed out.
* **SwiftyGiphy Data Models** are provided by the API layer so you can interact with real objects instead of dictionaries and arrays.
* **SwiftyGiphy Data Models** are provided by the API layer so you can interact with real objects instead of dictionaries and arrays.

##Questions
If you have questions on how to integrate SwiftyGiphy into your project, feel free to create an issue and we'll try to help the best we can. Please note that we'll only be able to provide assistance for SwiftyGiphy in its 'stock' form, and we won't assist with problems you have due to custom modifications.

Pull requests are encouraged, especially if you feel like assisting in more full implementing the Giphy API layer.

##Apps using SwiftyGiphy
If you have an app using SwiftyGiphy, let me know and I'll link to it here.
2 changes: 1 addition & 1 deletion SwiftyGiphy.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

Pod::Spec.new do |s|
s.name = 'SwiftyGiphy'
s.version = '1.0.1'
s.version = '1.0.2'
s.summary = 'Provides a UI and API layer for Giphy discovery and integration.'

# This description is used to generate tags and improve search results.
Expand Down

0 comments on commit 3433018

Please sign in to comment.