Skip to content

Commit

Permalink
[TIMOB-23837] Expose iOS10 UITabBar / UITab APIs
Browse files Browse the repository at this point in the history
  • Loading branch information
hansemannn committed Aug 29, 2016
1 parent bf74ff9 commit f07a4f1
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 6 deletions.
11 changes: 11 additions & 0 deletions apidoc/Titanium/UI/Tab.yml
Expand Up @@ -191,6 +191,17 @@ properties:
type: String
platforms: [iphone,ipad]

- name: badgeColor
summary: |
If this item displays a badge, this color will be used for the badge's background.
If set to null, the default background color will be used instead.
description: |
For information about color values, see the "Colors" section of <Titanium.UI>.
type: String
since: 6.1.0
osver: {ios: {min: "10.0"}}
platforms: [iphone, ipad]

- name: icon
summary: Icon URL for this tab.
description: |
Expand Down
11 changes: 11 additions & 0 deletions apidoc/Titanium/UI/TabGroup.yml
Expand Up @@ -439,6 +439,17 @@ properties:
since: { mobileweb: "2.0.0", iphone: "3.1.0", ipad: "3.1.0" }
osver: {ios: {min: "5.0"}}

- name: unselectedItemTintColor
summary: |
Unselected items in this tab group will be tinted with this color. Setting this value to null
indicates that the tab group should use its default value instead.
description: |
For information about color values, see the "Colors" section of <Titanium.UI>.
type: String
since: 6.1.0
osver: {ios: {min: "10.0"}}
platforms: [iphone, ipad]

- name: shadowImage
summary: Image of the shadow placed between the tab bar and the content area.
description: |
Expand Down
13 changes: 10 additions & 3 deletions iphone/Classes/TiUITabGroup.m
Expand Up @@ -386,10 +386,17 @@ -(void)setTabsBackgroundColor_:(id)value

-(void)setTabsTintColor_:(id)value
{
TiColor* color = [TiUtils colorValue:value];
UITabBar* tabBar = [controller tabBar];
tabBar.tintColor = [color color];
ENSURE_TYPE_OR_NIL(value, NSString);
[[controller tabBar] setTintColor:[[TiUtils colorValue:value] color]];
}

#if IS_XCODE_8
-(void)setUnselectedItemTintColor_:(id)value
{
ENSURE_TYPE_OR_NIL(value, NSString);
[[controller tabBar] setUnselectedItemTintColor:[[TiUtils colorValue:value] color]];
}
#endif

-(void)setTabsBackgroundImage_:(id)value
{
Expand Down
19 changes: 16 additions & 3 deletions iphone/Classes/TiUITabProxy.m
Expand Up @@ -497,8 +497,11 @@ -(void)updateTabBarItem
ENSURE_UI_THREAD_0_ARGS;

UIViewController* rootController = [rootWindow hostingController];
id badgeValue = [TiUtils stringValue:[self valueForKey:@"badge"]];
id iconInsets = [self valueForKey:@"iconInsets"];
id badgeValue = [TiUtils stringValue:[self valueForKey:@"badge"]];
#if IS_XCODE_8
id badgeColor = [self valueForKey:@"badgeColor"];
#endif
id iconInsets = [self valueForKey:@"iconInsets"];
id icon = [self valueForKey:@"icon"];

if ([icon isKindOfClass:[NSNumber class]])
Expand Down Expand Up @@ -575,6 +578,12 @@ -(void)updateTabBarItem
}
}

#if IS_XCODE_8
if (badgeColor != nil && [TiUtils isIOS10OrGreater]) {
[ourItem setBadgeColor:[[TiUtils colorValue:badgeColor] color]];
}
#endif

[ourItem setBadgeValue:badgeValue];
[rootController setTabBarItem:ourItem];
}
Expand Down Expand Up @@ -702,7 +711,11 @@ -(void)setBadge:(id)badge
[self updateTabBarItem];
}


-(void)setBadgeColor:(id)value
{
[self replaceValue:value forKey:@"badgeColor" notification:NO];
[self updateTabBarItem];
}

-(void)willChangeSize
{
Expand Down

0 comments on commit f07a4f1

Please sign in to comment.