Eureka: PushRow with search (performance question)

Created on 11 Feb 2016  路  15Comments  路  Source: xmartlabs/Eureka

I added searchBar to PushRow and in delegate method do:

//MARK: - UISearchBarDelegate

public func searchBar(searchBar: UISearchBar, textDidChange searchText: String) {
    for row in form.allRows {
        let visible = searchText.isEmpty || (row.title ?? "").localizedCaseInsensitiveContainsString(searchText)
        row.hidden = Condition(booleanLiteral: !visible)
        row.evaluateHidden()
    }
}

but evaluateHidden() executes so slow, especially it feels when I have many rows. Please, promt me what I doing wrong.

Hiding & Disabling Rows PushRow question

Most helpful comment

Guys, if anyone interested, I just modified the gist from @bithavoc to follow the simpler SearchablePushRow found in the original post from the author:
http://bithavoc.io/blog/2016/07/04/eureka-search-push-row/

Code:
https://gist.github.com/maxhanglin/032033405a2717a4cdd445bf5190b65f

It can be used as:

<<< SearchablePushRow<Contact>("person") { row in
    row.options = contactsList
}

Contact, in this example, needs to be:
```
public class Contact: CustomStringConvertible, Equatable, SearchableItem { ... }

All 15 comments

give this code a try, not sure if it works...

public func searchBar(searchBar: UISearchBar, textDidChange searchText: String) {
    for row in form.allRows {
        let visible = searchText.isEmpty || (row.title ?? "").localizedCaseInsensitiveContainsString(searchText)
        row.hidden = Condition(booleanLiteral: !visible)
    }
   tableView?.reloadData()
}

It was a first thing what I tried. It doesn't work :(

Hey @Chiliec what about this issue? Is it still so slow with the latest version? Have you found a workaround?

@Chiliec Would you be willing to share the code you have used to create a search bar within the PushRow controller? Did you modify the SelectorViewController.swift file to get this working?

I shared my implementation of a Searchable PushRow here, since the controller is implemented from scratch and is not descendant from FormViewController is far more performant than recreating the whole form, section and items everytime the user types a query in the search box via updateSearchResultsForSearchController.

This issue is very similar to #399 .
And I think this is definitely something that should be implemented using a simple UITableView and not using hidden variable.

Also maybe this row can help with some ideas for in-place selectors

The implementation provided by @bithavoc is a good example of how to accomplish this.

@bithavoc Hey man, thanks for your blog article, but I can't get it to work with the latest Eureka release. Did you keep it updated in your code and wiling to share a gist? Thanks!

@allaire need to update the blog post, this is for swift 3 https://gist.github.com/bithavoc/f5c9d06f024bfb5d9d3bd9452b94849f

@bithavoc Thanks for this! Is it compatible with the latest Eureka version? Looks a bit more "complex", or at least has more lines :)

@allaire yes is a bit more complex, unlike the first version of Eureka in the latest there is no way to inherit from Table view controller so I had To create one from scratch. But it works, I've been using that exact gist in my app since I migrated to Swift 3... In production.

@bithavoc 馃 Thanks so much for this, will give it a spin. Finding hard to wrap my head around Eureka advanced customization.

Guys, if anyone interested, I just modified the gist from @bithavoc to follow the simpler SearchablePushRow found in the original post from the author:
http://bithavoc.io/blog/2016/07/04/eureka-search-push-row/

Code:
https://gist.github.com/maxhanglin/032033405a2717a4cdd445bf5190b65f

It can be used as:

<<< SearchablePushRow<Contact>("person") { row in
    row.options = contactsList
}

Contact, in this example, needs to be:
```
public class Contact: CustomStringConvertible, Equatable, SearchableItem { ... }

I am fairly new to using Eureka forms...Does anyone have a working example of this (that they can share) that can show it in action?

@maxhanglin seconding @RalphEBoy1971's request.

I'm having dififculty implementing the _SearchablePushRow_ in my Eureka form after having imported your _eureka_swift_3:composable_search_row.swift_ file into my project folder.

Can you please provide a sample of the proper project structure, as well as a sample _FormViewController.swift_ file which incorporates your SearchablePushRow? It would be much appreciated!

Was this page helpful?
0 / 5 - 0 ratings