Skip to content
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

Merged
merged 23 commits into from Aug 8, 2017

Conversation

vijaysingh-axway
Copy link
Contributor

@hansemannn hansemannn changed the title [TIMOB-16622]:Replace UISearchDisplayController to UISearchController [TIMOB-16622] iOS:Replace UISearchDisplayController with UISearchController May 17, 2017
@hansemannn hansemannn self-requested a review May 17, 2017 10:18
@hansemannn hansemannn added this to the 6.2.0 milestone May 17, 2017
Copy link
Collaborator

@hansemannn hansemannn left a 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;
Copy link
Collaborator

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.

Copy link
Contributor Author

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.

@@ -528,9 +526,6 @@ - (void)updateSearchResults:(id)unused
[self buildResultsForSearchText];
}
[_tableView reloadData];
if ([searchController isActive]) {
[[searchController searchResultsTableView] reloadData];
}
Copy link
Collaborator

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?

Copy link
Contributor Author

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.

[_tableView reloadData];
}
Copy link
Collaborator

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];
Copy link
Collaborator

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?

Copy link
Contributor Author

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.

@@ -2004,7 +1993,7 @@ - (void)searchBarTextDidBeginEditing:(UISearchBar *)searchBar
}
self.searchString = (searchBar.text == nil) ? @"" : searchBar.text;
[self buildResultsForSearchText];
[[searchController searchResultsTableView] reloadData];
[_tableView reloadData];
Copy link
Collaborator

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.

Copy link
Contributor Author

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.

searchController.searchResultsDataSource = self;
searchController.searchResultsDelegate = self;
if (sender == self && searchController == nil)
{
Copy link
Collaborator

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

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

searchController.searchResultsDelegate = self;
if (sender == self && searchController == nil)
{
searchController = [[UISearchController alloc] initWithSearchResultsController:nil];
Copy link
Collaborator

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.

Copy link
Contributor Author

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.

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);
Copy link
Collaborator

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?

Copy link
Contributor Author

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.

searchController.delegate = self;
searchController.searchResultsUpdater = self;
searchController.hidesNavigationBarDuringPresentation = NO;
Copy link
Collaborator

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?

Copy link
Contributor Author

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];
}
Copy link
Collaborator

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.

Copy link
Contributor Author

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.

constants: Titanium.UI.iPhone.ListViewSeparatorStyle.*
since: 6.1.0
platforms: [iphone, ipad]
availability: creation
Copy link
Collaborator

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?

Copy link
Contributor Author

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.

Copy link
Collaborator

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.

[_tableView reloadData];
}

- (void)presentSearchController:(UISearchController *)controller
{
id dimBgValue = [[self proxy] valueForKey:@"dimsBackground"];
searchController.dimsBackgroundDuringPresentation = [TiUtils boolValue:dimBgValue def:NO];
Copy link
Collaborator

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).

Copy link
Contributor Author

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.

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.

Copy link
Collaborator

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.

Copy link
Collaborator

@hansemannn hansemannn left a 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.

@hansemannn
Copy link
Collaborator

hansemannn commented Jun 1, 2017

In my FT right now. I noticed that the old behavior dimmed the background by default, now it doesn't (setting dimsBackgroundDuringPresentation to NO, which is against the default behavior). Was there a special reason you did it that way? Maybe I am overseeing something, thanks!

EDIT: Happening for both listview and tableview. All other tests are looking good!

@vijaysingh-axway
Copy link
Contributor Author

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.

@hansemannn
Copy link
Collaborator

Well, I tried it with dimsBackgroundDuringPresentation and was able to select rows. However, show the edit actions did work with both cases.

@vijaysingh-axway
Copy link
Contributor Author

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.

@hansemannn
Copy link
Collaborator

Yep, inside the Obj-C code :-)

@vijaysingh-axway
Copy link
Contributor Author

@hansemannn As we discussed, I have implemented this using new UITableViewController and a table view in order to show dim background while searching.

@vijaysingh-axway
Copy link
Contributor Author

@hansemannn Ping!

@vijaysingh-axway
Copy link
Contributor Author

@hansemannn Can you please review a minor fix in this PR , which I found while working for edit action for search result. Thanks!

[_tableView reloadData];
[_tableView reloadData];
if ([searchController isActive]) {
[resultViewController.tableView reloadData];
Copy link
Collaborator

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?

Copy link
Contributor Author

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 -

  1. add searcbar on window, and show search result in same table view (see last test case in ticket)
  2. 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.

[[resultViewController tableView] reloadData];
} else {
[_tableView reloadData];
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same question as above.

@mukherjee2 mukherjee2 self-requested a review August 2, 2017 16:47
Copy link
Contributor

@ewieberappc ewieberappc left a 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

@hansemannn hansemannn modified the milestones: 7.0.0, 6.2.0 Aug 8, 2017
@ewieberappc ewieberappc merged commit ce8b417 into tidev:master Aug 8, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants