Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions iphone/Classes/TiUITabProxy.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
BOOL hasFocus;
BOOL iconOriginal;
BOOL activeIconOriginal;
UITraitCollection *lastTabBarTraitCollection;

id<TiOrientationController> parentOrientationController;

Expand Down
41 changes: 40 additions & 1 deletion iphone/Classes/TiUITabProxy.m
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ - (void)_destroy
RELEASE_TO_NIL(rootWindow);
RELEASE_TO_NIL(controller);
RELEASE_TO_NIL(current);
RELEASE_TO_NIL(lastTabBarTraitCollection);
RELEASE_TO_NIL(fullWidthBackGestureRecognizer);

[super _destroy];
Expand Down Expand Up @@ -79,7 +80,36 @@ - (void)_configure

- (void)didChangeTraitCollection:(NSNotification *)info
{
[self updateTabBarItem];
__weak TiUITabProxy *weakSelf = self;
TiThreadPerformOnMainThread(
^{
TiUITabProxy *strongSelf = weakSelf;
if (strongSelf == nil) {
return;
}

// If a modal is being dismissed, trait collection changes from UIKit
// are spurious — the tab bar item doesn't need rebuilding.
if (strongSelf->controller.presentedViewController != nil) {
return;
}

UITraitCollection *currentTraitCollection = strongSelf->controller.traitCollection;
if (currentTraitCollection == nil) {
currentTraitCollection = strongSelf->rootWindow.hostingController.traitCollection;
}
if (currentTraitCollection == nil) {
return;
}
if ((strongSelf->lastTabBarTraitCollection != nil)
&& ![currentTraitCollection hasDifferentColorAppearanceComparedToTraitCollection:strongSelf->lastTabBarTraitCollection]
&& (currentTraitCollection.horizontalSizeClass == strongSelf->lastTabBarTraitCollection.horizontalSizeClass)
&& (currentTraitCollection.verticalSizeClass == strongSelf->lastTabBarTraitCollection.verticalSizeClass)) {
return;
}
[strongSelf updateTabBarItem];
},
NO); // NO = non-blocking, since this is a notification handler
}

- (NSString *)apiName
Expand Down Expand Up @@ -558,6 +588,10 @@ - (void)updateTabBarItem
ENSURE_UI_THREAD_0_ARGS;

UIViewController *rootController = [rootWindow hostingController];
UITraitCollection *currentTraitCollection = controller.traitCollection;
if (currentTraitCollection == nil) {
currentTraitCollection = rootController.traitCollection;
}
id badgeValue = [TiUtils stringValue:[self valueForKey:@"badge"]];
id badgeColor = [self valueForKey:@"badgeColor"];
id iconInsets = [self valueForKey:@"iconInsets"];
Expand All @@ -581,6 +615,8 @@ - (void)updateTabBarItem
[newItem release];

systemTab = YES;
[lastTabBarTraitCollection release];
lastTabBarTraitCollection = [currentTraitCollection retain];
return;
}

Expand Down Expand Up @@ -707,6 +743,9 @@ - (void)updateTabBarItem
[tabBarItem setBadgeValue:badgeValue];

systemTab = NO;

[lastTabBarTraitCollection release];
lastTabBarTraitCollection = [currentTraitCollection retain];
}

- (UIEdgeInsets)calculateIconInsets:(id)value
Expand Down
Loading