New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[TIMOB-16622] iOS:Replace UISearchDisplayController with UISearchController #9066
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Major changes required, please address those before going into the next review phase.
@@ -39,9 +39,8 @@ @implementation TiUIListView { | |||
TiUIRefreshControlProxy* _refreshControlProxy; | |||
#endif | |||
|
|||
TiUISearchBarProxy *searchViewProxy; | |||
UITableViewController *tableController; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should not be removed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In UISearchController there is option to pass nil for result controller. In this case it will use the current tableview for showing the search result. We can not use different controller to show the result because it will create similar problem which is mentioned in TIMOB-16622 and TIMOB-16826. So there is no need of tableViewController.
searchViewProxy is there.
iphone/Classes/TiUIListView.m
Outdated
@@ -528,9 +526,6 @@ - (void)updateSearchResults:(id)unused | |||
[self buildResultsForSearchText]; | |||
} | |||
[_tableView reloadData]; | |||
if ([searchController isActive]) { | |||
[[searchController searchResultsTableView] reloadData]; | |||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why did this move away?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SearchViewController is using current tableView. And it do not have searchResultsTableView.
iphone/Classes/TiUIListView.m
Outdated
[_tableView reloadData]; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why did this move away?
@@ -871,6 +861,7 @@ -(void)setSearchView_:(id)args | |||
[[searchViewProxy searchBar] setPlaceholder:@"Search"]; | |||
} | |||
self.searchString = [[searchViewProxy searchBar] text]; | |||
[self initSearchController:self]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What happens if the search-view is set multiple times?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not a problem . Every time searchViewController is released and new searchViewController is created.
iphone/Classes/TiUIListView.m
Outdated
@@ -2004,7 +1993,7 @@ - (void)searchBarTextDidBeginEditing:(UISearchBar *)searchBar | |||
} | |||
self.searchString = (searchBar.text == nil) ? @"" : searchBar.text; | |||
[self buildResultsForSearchText]; | |||
[[searchController searchResultsTableView] reloadData]; | |||
[_tableView reloadData]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
_tableView
is the main table view, but the deleted line reloaded the search-results table view.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In this case both tableView is same.
iphone/Classes/TiUIListView.m
Outdated
searchController.searchResultsDataSource = self; | ||
searchController.searchResultsDelegate = self; | ||
if (sender == self && searchController == nil) | ||
{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We put brackets in the same line
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
iphone/Classes/TiUIListView.m
Outdated
searchController.searchResultsDelegate = self; | ||
if (sender == self && searchController == nil) | ||
{ | ||
searchController = [[UISearchController alloc] initWithSearchResultsController:nil]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are you initializing it with nil
? I guess we should rather manage an own table-view for it, maybe even in an own helper-class.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In UISearchController there is option to pass nil for result controller. In this case it will use the current tableview for showing the search result. We can not use different controller to show the result because it will create similar problem which is mentioned in TIMOB-16622 and TIMOB-16826.
iphone/Classes/TiUIListView.m
Outdated
searchController.delegate = self; | ||
searchController.searchResultsUpdater = self; | ||
searchController.hidesNavigationBarDuringPresentation = NO; | ||
searchController.searchBar.frame = CGRectMake(searchController.searchBar.frame.origin.x, searchController.searchBar.frame.origin.y, searchController.searchBar.frame.size.width, 44.0); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm sceptical about giving it a fixed size. Have you tried this on landscape / multiple orientation changes?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried but don't found. If you face please let me know.
iphone/Classes/TiUIListView.m
Outdated
searchController.delegate = self; | ||
searchController.searchResultsUpdater = self; | ||
searchController.hidesNavigationBarDuringPresentation = NO; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should stick to the default values, is setting this value necessary?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Default value will hide navigation bar and is misaligning the tableview.
searchView = searchBar; | ||
[searchView setDelegate:self]; | ||
[self addSubview:searchView]; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure what's this used for. It's used in https://github.com/appcelerator/titanium_mobile/pull/9066/files#diff-c25f31a8654c7459f7b97be688ab44efR2210 but using a setter seems to be the wrong way. I'm curious if we should o that way, especially because it will add a new sub-view every time it's called. So if the user changes the search-bar over time (using searchView
/ searchBar
, multiple search-bars will just be added above each other.
Also brackets miss-formatted again, that needs to be checked in general.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
First it is removing the search bar then adding it as a subview. So not a problem.
apidoc/Titanium/UI/ListView.yml
Outdated
constants: Titanium.UI.iPhone.ListViewSeparatorStyle.* | ||
since: 6.1.0 | ||
platforms: [iphone, ipad] | ||
availability: creation |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removing them is not an option. Can't we just grab the values and style the search-tableview accordingly?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it really necessary? Problem mentioned in ticket will not arise.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agree, but we need to state that, by using:
removed:
since: "6.2.0"
notes: |
The styling of the search table-view is determined by it's table-view, so there
is no additional styling required.
iphone/Classes/TiUIListView.m
Outdated
[_tableView reloadData]; | ||
} | ||
|
||
- (void)presentSearchController:(UISearchController *)controller | ||
{ | ||
id dimBgValue = [[self proxy] valueForKey:@"dimsBackground"]; | ||
searchController.dimsBackgroundDuringPresentation = [TiUtils boolValue:dimBgValue def:NO]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rather document it and set the value in an appropriate place (like init or here if that's more flexible).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This property is of no use, until searchResultController is passed in UISearchViewController. So removed it and put a default value while initializing searchViewController.
…th UISearchController
apidoc/Titanium/UI/ListView.yml
Outdated
since: "6.2.0" | ||
notes: | | ||
The background color of the search table-view is determined by it's table-view, so there is no additional property required. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not the way the docs are written. Please check how other docs handle removal, also remember to break long lines into separate ones.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is still one (commented in) reference to the UISearchDisplayController
in the searchDisplayControllerDidEndSearch:
delegate, please remove that one as well, although it will not throw a warning anyway.
In my FT right now. I noticed that the old behavior dimmed the background by default, now it doesn't (setting EDIT: Happening for both listview and tableview. All other tests are looking good! |
In our current implementation of UISearchController, we are passing nil for result controller (reason explained in my first comment above). So it is using current table view for showing result. If we use default behaviour of property dimsBackgroundDuringPresentation, we can not be able to select any row from result tableView, as this will be disabled. So dimsBackgroundDuringPresentation is set to NO. |
Well, I tried it with |
Are you saying by setting " dimsBackgroundDuringPresentation = YES" inside TIUIlistView.m, you are able to select row while searching? This property is not exposed to be use with js. |
Yep, inside the Obj-C code :-) |
…hDisplayController in TIUIListView
…ntroller in TIUITableView
@hansemannn As we discussed, I have implemented this using new UITableViewController and a table view in order to show dim background while searching. |
@hansemannn Ping! |
@hansemannn Can you please review a minor fix in this PR , which I found while working for edit action for search result. Thanks! |
iphone/Classes/TiUIListView.m
Outdated
[_tableView reloadData]; | ||
[_tableView reloadData]; | ||
if ([searchController isActive]) { | ||
[resultViewController.tableView reloadData]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indentation. Also, when would searchActive
be NO
but [searchController isActive]
be YES
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
there are 2 ways we can use search in list view -
- add searcbar on window, and show search result in same table view (see last test case in ticket)
- make search bar part of list view (see test case in ticket except last)
In second way, when we click on searchbar [searchController isActive] will be yes.
But for searchActive being to Yes, there should be atleast one character in search bar.
So when second way of search used, user clicked on search bar and not typed any character, [searchController isActive] will be YES and searchActive will be NO.
If you see the old implementation, it is in same way.
Are you sure there is problem in indentation, I don't think so.
iphone/Classes/TiUIListView.m
Outdated
[[resultViewController tableView] reloadData]; | ||
} else { | ||
[_tableView reloadData]; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same question as above.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FR Passed, using:
MacOS 10.12.6 (16G24b)
Studio 4.9.0.201705302345
Ti SDK 7.0.0.v20170802103048
Appc NPM 4.2.9
Appc CLI 6.2.3
Alloy 1.9.13
Xcode 8.3.3 (8E3004b)
Tested searchbar functionality when used with listview and tableview. No issues encountered. Tested using the provided sample code as well as the searchbar suite
https://jira.appcelerator.org/browse/TIMOB-16622