Skip to content
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): add support to show/hide iOS 18+ elevated tab bar #14173

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
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
2 changes: 1 addition & 1 deletion apidoc/Titanium/UI/NavigationWindow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ platforms: [android, iphone, ipad, macos]
extends: Titanium.UI.Window
since: "8.0.0"
excludes:
methods: [removeAllChildren, setToolbar, hideTabBar]
methods: [removeAllChildren, setToolbar]
properties: [navBarHidden, tabBarHidden, navTintColor, translucent, toolbar,
barColor, barImage, leftNavButton, rightNavButton, title, titleControl,
titlePrompt, titleImage, titleid, titlepromptid, url, backButtonTitle,
Expand Down
19 changes: 19 additions & 0 deletions apidoc/Titanium/UI/TabGroup.yml
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,22 @@ methods:
since: "10.0.0"
removed: "10.0.0"
notes: Use the <Titanium.UI.TabGroup.tabs> property instead.

- name: showTabBar
summary: Shows the tab bar with animation.
description: |
This method also updates iOS 18+ [Elevated Tab Bar on iPad](https://developer.apple.com/documentation/uikit/elevating-your-ipad-app-with-a-tab-bar-and-sidebar).
To show tab bar without animation, set [tabBarVisible](Titanium.UI.TabGroup.tabBarVisible) property to `false`.
platforms: [iphone, ipad, macos]
since: "12.7.0"

- name: hideTabBar
summary: Hides the tab bar with animation.
description: |
This method also updates iOS 18+ [Elevated Tab Bar on iPad](https://developer.apple.com/documentation/uikit/elevating-your-ipad-app-with-a-tab-bar-and-sidebar).
To hide tab bar without animation, set [tabBarVisible](Titanium.UI.TabGroup.tabBarVisible) property to `true`.
platforms: [iphone, ipad, macos]
since: "12.7.0"

properties:
- name: activeTab
Expand Down Expand Up @@ -614,7 +630,10 @@ properties:

- name: tabBarVisible
summary: Programmatically shows / hides the bottom tab bar of the tab group.
description: |
This method also updates iOS 18+ [Elevated Tab Bar on iPad](https://developer.apple.com/documentation/uikit/elevating-your-ipad-app-with-a-tab-bar-and-sidebar).
type: Boolean
default: true
platforms: [android, iphone, ipad, macos]
since: "12.1.0"

Expand Down
9 changes: 0 additions & 9 deletions apidoc/Titanium/UI/Window.yml
Original file line number Diff line number Diff line change
Expand Up @@ -535,15 +535,6 @@ methods:
default: "{ animated: true }"
platforms: [iphone, ipad, macos]

- name: hideTabBar
summary: Hides the tab bar. Must be called before opening the window.
description: |
To hide the tab bar when opening a window as a child of a tab, call
`hideTabBar` or set `tabBarHidden` to `true` **before** opening the window.

If the window is not a child of a tab, this method has no effect.
platforms: [iphone, ipad, macos]

- name: open
summary: Opens the window.
parameters:
Expand Down
2 changes: 1 addition & 1 deletion apidoc/Titanium/UI/iOS/NavigationWindow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ deprecated:
notes: Use [Titanium.UI.NavigationWindow](Titanium.UI.NavigationWindow) instead.
removed: "10.0.0"
excludes:
methods: [removeAllChildren, setToolbar, hideTabBar]
methods: [removeAllChildren, setToolbar]
properties: [navBarHidden, tabBarHidden, navTintColor, translucent, toolbar,
barColor, barImage, leftNavButton, rightNavButton, title, titleControl,
titlePrompt, titleImage, titleid, titlepromptid, url, backButtonTitle,
Expand Down
1 change: 1 addition & 0 deletions iphone/Classes/TiUITabGroup.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@

- (void)open:(id)args;
- (void)close:(id)args;
- (void)hideTabBar:(BOOL)hidden animated:(BOOL)animated;

- (NSDictionary *)focusEvent;

Expand Down
20 changes: 8 additions & 12 deletions iphone/Classes/TiUITabGroup.m
Original file line number Diff line number Diff line change
Expand Up @@ -370,20 +370,16 @@ - (void)tabBarController:(UITabBarController *)tabBarController didEndCustomizin

- (void)setTabBarVisible_:(id)value
{
BOOL visible = [TiUtils boolValue:value];
[self hideTabBar:[TiUtils boolValue:value] animated:NO];
}

if ([self tabBarIsVisible] == visible) {
return;
- (void)hideTabBar:(BOOL)hidden animated:(BOOL)animated
{
if (@available(iOS 18.0, *)) {
[self.tabController setTabBarHidden:hidden animated:animated];
} else {
self.tabController.tabBar.hidden = hidden;
}

CGRect frame = self.tabController.tabBar.frame;
CGFloat height = frame.size.height;

[UIView animateWithDuration:0.3
animations:^{
self.tabController.tabBar.frame = CGRectOffset(frame, 0, visible ? -height : height);
}
completion:nil];
}

- (BOOL)tabBarIsVisible
Expand Down
10 changes: 10 additions & 0 deletions iphone/Classes/TiUITabGroupProxy.m
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,16 @@ - (void)_resetTabArray:(NSArray *)newTabOrder
tabs = [newTabOrder mutableCopy];
}

- (void)hideTabBar:(id)args
{
[(TiUITabGroup *)[self view] hideTabBar:YES animated:YES];
}

- (void)showTabBar:(id)args
{
[(TiUITabGroup *)[self view] hideTabBar:NO animated:YES];
}

#pragma mark Window Management

- (void)windowWillOpen
Expand Down
10 changes: 0 additions & 10 deletions iphone/TitaniumKit/TitaniumKit/Sources/Modules/TiUIWindowProxy.m
Original file line number Diff line number Diff line change
Expand Up @@ -694,16 +694,6 @@ - (void)setTabBarHidden:(id)value
NO);
}

- (void)hideTabBar:(id)value
{
[self setTabBarHidden:[NSNumber numberWithBool:YES]];
}

- (void)showTabBar:(id)value
{
[self setTabBarHidden:[NSNumber numberWithBool:NO]];
}

- (void)refreshBackButton
{
ENSURE_UI_THREAD_0_ARGS;
Expand Down
Loading