Skip to content

Commit

Permalink
Merge pull request tidev#5391 from vishalduggal/timob-16507
Browse files Browse the repository at this point in the history
[TIMOB-16507] iOS: Change pullView default background color in listView, tableView
  • Loading branch information
srahim committed Feb 28, 2014
2 parents 91dcf05 + a77728f commit 25bc22b
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 2 deletions.
17 changes: 17 additions & 0 deletions apidoc/Titanium/UI/ListView.yml
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,21 @@ events:
summary: false. This event does not bubble.
type: Boolean

- name: noresults
summary: Fired when the search using either [searchView](Titanium.UI.ListView.searchView) or [searchText](Titanium.UI.ListView.searchText) has no results.
description: |
When items are filtered in a list view using either the `searchView` or `searchText`, it is possible that the search
returns an empty set.
While the `searchView` API automatically shows a **No Results** cell in the list view, the `searchText` API does not do so.
Developers can listen to this event and perform appropriate actions when the search result set is empty.
platforms: [iphone, ipad]
since: "3.3.0"
properties:
- name: bubbles
summary: false. This event does not bubble.
type: Boolean

- name: pull
summary: Fired when the user drags the list view past the top edge of the [pullView](Titanium.UI.ListView.pullView).
platforms: [iphone, ipad]
Expand Down Expand Up @@ -436,6 +451,8 @@ properties:
A `pullView` is a UI control that is often used to provide a convenient way for the user to refresh a table's data.
Typically used in conjunction with [setContentInsets](Titanium.UI.ListView.setContentInsets) method and [pull](Titanium.UI.ListView.pull) and [pullend](Titanium.UI.ListView.pullend) events.
To specify the wrapper color see <Titanium.UI.View.pullBackgroundColor>.
In Alloy you can assign this property with a `<PullView>` child element of a `<ListView>`
element:
Expand Down
2 changes: 2 additions & 0 deletions apidoc/Titanium/UI/TableView.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1138,6 +1138,8 @@ properties:
user to refresh a table's data. Typically used with the
[setContentInsets](Titanium.UI.TableView.setContentInsets) method.
To specify the wrapper color see <Titanium.UI.View.pullBackgroundColor>.
For an example, see the "Pull to refresh" section in the
[TableViews guide](http://docs.appcelerator.com/titanium/latest/#!/guide/TableViews).
Expand Down
7 changes: 7 additions & 0 deletions apidoc/Titanium/UI/View.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1192,6 +1192,13 @@ properties:
type: Number
default: 1.0 (opaque)

- name: pullBackgroundColor
summary: Background color of the wrapper view when this view is used as either <Titanium.UI.ListView.pullView> or <Titanium.UI.TableView.headerPullView>.
type: String
default: Undefined. Results in a light grey background color on the wrapper view.
since: "3.3.0"
platforms: [iphone,ipad]

- name: right
summary: View's right position, in platform-specific units.
description: |
Expand Down
10 changes: 9 additions & 1 deletion iphone/Classes/TiUIListView.m
Original file line number Diff line number Diff line change
Expand Up @@ -393,6 +393,7 @@ -(void)buildResultsForSearchText
RELEASE_TO_NIL(filteredIndices);
RELEASE_TO_NIL(filteredTitles);
if (searchActive) {
BOOL hasResults = NO;
//Initialize
if(_searchResults == nil) {
_searchResults = [[NSMutableArray alloc] init];
Expand All @@ -413,6 +414,7 @@ -(void)buildResultsForSearchText
id theValue = [self valueWithKey:@"searchableText" atIndexPath:thePath];
if (theValue!=nil && [[TiUtils stringValue:theValue] rangeOfString:self.searchString options:searchOpts].location != NSNotFound) {
(thisSection != nil) ? [thisSection addObject:thePath] : [singleSection addObject:thePath];
hasResults = YES;
}
}
if (thisSection != nil) {
Expand Down Expand Up @@ -443,6 +445,11 @@ -(void)buildResultsForSearchText
}
[singleSection release];
}
if (!hasResults) {
if ([(TiViewProxy*)self.proxy _hasListeners:@"noresults" checkParent:NO]) {
[self.proxy fireEvent:@"noresults" withObject:nil propagate:NO reportSuccess:NO errorCode:0 message:nil];
}
}

} else {
RELEASE_TO_NIL(_searchResults);
Expand Down Expand Up @@ -640,12 +647,13 @@ -(void)setPullView_:(id)args
}
if (_pullViewWrapper == nil) {
_pullViewWrapper = [[UIView alloc] init];
_pullViewWrapper.backgroundColor = [UIColor lightGrayColor];
[_tableView addSubview:_pullViewWrapper];
}
CGSize refSize = _tableView.bounds.size;
[_pullViewWrapper setFrame:CGRectMake(0.0, 0.0 - refSize.height, refSize.width, refSize.height)];
_pullViewProxy = [args retain];
TiColor* pullBgColor = [TiUtils colorValue:[_pullViewProxy valueForUndefinedKey:@"pullBackgroundColor"]];
_pullViewWrapper.backgroundColor = ((pullBgColor == nil) ? [UIColor lightGrayColor] : [pullBgColor color]);
LayoutConstraint *viewLayout = [_pullViewProxy layoutProperties];
//If height is not dip, explicitly set it to SIZE
if (viewLayout->height.type != TiDimensionTypeDip) {
Expand Down
3 changes: 2 additions & 1 deletion iphone/Classes/TiUITableView.m
Original file line number Diff line number Diff line change
Expand Up @@ -1976,7 +1976,8 @@ -(void)setHeaderPullView_:(id)value
return;
}
tableHeaderPullView = [[UIView alloc] initWithFrame:CGRectMake(0.0f, 0.0f - self.tableView.bounds.size.height, self.tableView.bounds.size.width, self.tableView.bounds.size.height)];
tableHeaderPullView.backgroundColor = [UIColor lightGrayColor];
TiColor* pullBgColor = [TiUtils colorValue:[value valueForUndefinedKey:@"pullBackgroundColor"]];
tableHeaderPullView.backgroundColor = ((pullBgColor == nil) ? [UIColor lightGrayColor] : [pullBgColor color]);
UIView *view = [value view];
[[self tableView] addSubview:tableHeaderPullView];
[tableHeaderPullView addSubview:view];
Expand Down

0 comments on commit 25bc22b

Please sign in to comment.