-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
feat(ios) : Added functionality to show search bar in navigation bar for TiUIListView and TiUITableView #10664
Changes from 6 commits
d07c384
5ea390e
a6bb7e0
550aa09
fb269f2
1acf82b
0b6f78d
6380001
8b7f2dd
1083086
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1350,6 +1350,19 @@ properties: | |
platforms: [iphone, ipad] | ||
availability: creation | ||
|
||
- name: showSearchBarInNavigation | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Really quick and minor comment: Usually, the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Agree. Updated PR. |
||
summary: A Boolean indicating whether search bar will be in navigation bar. | ||
description: | | ||
If you want to show the search bar in navigation bar, set this property `true` during creation. | ||
Use the <Titanium.UI.Window.hidesSearchBarWhenScrolling> property to control the visibility of the | ||
searchbar when scrolling. | ||
type: Boolean | ||
default: false | ||
since: 8.1.0 | ||
platforms: [iphone, ipad] | ||
osver: {ios: {min: "11.0"}} | ||
availability: creation | ||
|
||
- name: searchAsChild | ||
summary: Determines whether the [SearchBar](Titanium.UI.SearchBar) or [SearchView](Titanium.UI.Android.SearchView) appears as part of the TableView. | ||
description: Set to false if the search view will be displayed in the action bar. | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -77,6 +77,7 @@ @implementation TiUIListView { | |
CGPoint tableContentOffset; | ||
BOOL isSearched; | ||
UIView *dimmingView; | ||
BOOL isSearchBarInNavigation; | ||
} | ||
|
||
#ifdef TI_USE_AUTOLAYOUT | ||
|
@@ -193,7 +194,10 @@ - (void)configureHeaders | |
_searchWrapper = [self initWrapperProxy]; | ||
_headerWrapper = [self initWrapperProxy]; | ||
|
||
[_headerViewProxy add:_searchWrapper]; | ||
isSearchBarInNavigation = [TiUtils boolValue:[(TiViewProxy *)self.proxy valueForUndefinedKey:@"showSearchBarInNavigation"] def:NO] && [TiUtils isIOSVersionOrGreater:@"11.0"]; | ||
if (!isSearchBarInNavigation) { | ||
[_headerViewProxy add:_searchWrapper]; | ||
} | ||
[_headerViewProxy add:_headerWrapper]; | ||
} | ||
|
||
|
@@ -575,7 +579,11 @@ - (void)updateSearchControllerFrames | |
if (![searchController isActive]) { | ||
return; | ||
} | ||
[dimmingView setFrame:CGRectMake(0, searchController.searchBar.frame.size.height, self.frame.size.width, self.frame.size.height - searchController.searchBar.frame.size.height)]; | ||
if (isSearchBarInNavigation) { | ||
dimmingView.frame = CGRectMake(0, 0, self.frame.size.width, self.frame.size.height); | ||
} else { | ||
dimmingView.frame = CGRectMake(0, searchController.searchBar.frame.size.height, self.frame.size.width, self.frame.size.height - searchController.searchBar.frame.size.height); | ||
} | ||
CGPoint convertedOrigin = [self.superview convertPoint:self.frame.origin toView:searchControllerPresenter.view]; | ||
|
||
UIView *searchSuperView = [searchController.view superview]; | ||
|
@@ -2188,6 +2196,22 @@ - (void)viewResignFocus | |
|
||
- (void)viewGetFocus | ||
{ | ||
if (isSearchBarInNavigation) { | ||
id proxy = [(TiViewProxy *)self.proxy parent]; | ||
while ([proxy isKindOfClass:[TiViewProxy class]] && ![proxy isKindOfClass:[TiWindowProxy class]]) { | ||
proxy = [proxy parent]; | ||
} | ||
UIViewController *controller; | ||
if ([proxy isKindOfClass:[TiWindowProxy class]]) { | ||
controller = [proxy windowHoldingController]; | ||
} else { | ||
controller = [[TiApp app] controller]; | ||
} | ||
if (!controller.navigationItem.searchController) { | ||
controller.navigationItem.searchController = searchController; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think the iOS 11 guard is required here. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's already taken care while assigning value to variable 'isSearchBarInNavigation'. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @vijaysingh-axway Since we still support older Xcode and SDK versions that don't have the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @janvennemann Wrapped under macro IS_XCODE_9. |
||
} | ||
} | ||
|
||
if (isSearched && self.searchedString && ![searchController isActive]) { | ||
isSearched = NO; | ||
[searchController performSelector:@selector(setActive:) withObject:@YES afterDelay:.1]; | ||
|
@@ -2356,7 +2380,11 @@ - (void)createDimmingView | |
|
||
- (void)showDimmingView | ||
{ | ||
dimmingView.frame = CGRectMake(0, searchController.searchBar.frame.size.height, self.frame.size.width, self.frame.size.height - searchController.searchBar.frame.size.height); | ||
if (isSearchBarInNavigation) { | ||
dimmingView.frame = CGRectMake(0, 0, self.frame.size.width, self.frame.size.height); | ||
} else { | ||
dimmingView.frame = CGRectMake(0, searchController.searchBar.frame.size.height, self.frame.size.width, self.frame.size.height - searchController.searchBar.frame.size.height); | ||
} | ||
if (!dimmingView.superview) { | ||
[self addSubview:dimmingView]; | ||
[self bringSubviewToFront:dimmingView]; | ||
|
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.
osver: {ios: {min: "11.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.
Updated. Thanks!