From f07a4f1504febd52cda58aef84d2c4f528eefaa9 Mon Sep 17 00:00:00 2001 From: Hans Knoechel Date: Tue, 30 Aug 2016 00:26:03 +0200 Subject: [PATCH] [TIMOB-23837] Expose iOS10 UITabBar / UITab APIs --- apidoc/Titanium/UI/Tab.yml | 11 +++++++++++ apidoc/Titanium/UI/TabGroup.yml | 11 +++++++++++ iphone/Classes/TiUITabGroup.m | 13 ++++++++++--- iphone/Classes/TiUITabProxy.m | 19 ++++++++++++++++--- 4 files changed, 48 insertions(+), 6 deletions(-) diff --git a/apidoc/Titanium/UI/Tab.yml b/apidoc/Titanium/UI/Tab.yml index 09ad79df9a4..b6ca56cb7b3 100644 --- a/apidoc/Titanium/UI/Tab.yml +++ b/apidoc/Titanium/UI/Tab.yml @@ -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 . + type: String + since: 6.1.0 + osver: {ios: {min: "10.0"}} + platforms: [iphone, ipad] + - name: icon summary: Icon URL for this tab. description: | diff --git a/apidoc/Titanium/UI/TabGroup.yml b/apidoc/Titanium/UI/TabGroup.yml index 6afcb6bae5e..48cba244a5e 100644 --- a/apidoc/Titanium/UI/TabGroup.yml +++ b/apidoc/Titanium/UI/TabGroup.yml @@ -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 . + 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: | diff --git a/iphone/Classes/TiUITabGroup.m b/iphone/Classes/TiUITabGroup.m index e120457bf8b..4ed76db7a5e 100644 --- a/iphone/Classes/TiUITabGroup.m +++ b/iphone/Classes/TiUITabGroup.m @@ -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 { diff --git a/iphone/Classes/TiUITabProxy.m b/iphone/Classes/TiUITabProxy.m index e07615f9207..dc2b195cb3a 100644 --- a/iphone/Classes/TiUITabProxy.m +++ b/iphone/Classes/TiUITabProxy.m @@ -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]]) @@ -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]; } @@ -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 {