Skip to content

fix(tabs): handle removing, re-adding, and changing visibility of tabstrip #430

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

Merged
merged 1 commit into from
Jan 13, 2023
Merged
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
61 changes: 35 additions & 26 deletions src/tabs/index.ios.ts
Original file line number Diff line number Diff line change
Expand Up @@ -162,34 +162,43 @@ class UIPageViewControllerImpl extends UIPageViewController {
let scrollViewHeight = this.view.bounds.size.height + conditionalSafeAreaBottom;

if (owner.tabStrip && this.tabBar) {
const viewWidth = this.view.bounds.size.width;
const viewHeight = this.view.bounds.size.height;
const tabBarHeight = this.tabBar.frame.size.height;
let tabBarTop = safeAreaInsetsTop;

scrollViewTop = tabBarHeight;
scrollViewHeight = this.view.bounds.size.height - tabBarHeight + conditionalSafeAreaBottom;

const tabsPosition = owner.tabsPosition;
if (tabsPosition === TabsPosition.Bottom) {
tabBarTop = viewHeight - tabBarHeight - safeAreaInsetsBottom;
scrollViewTop = this.view.frame.origin.y;
scrollViewHeight = viewHeight - tabBarHeight;
}

let parent = owner.parent;

// Handle Angular scenario where Tabs is in a ProxyViewContainer
// It is possible to wrap components in ProxyViewContainers indefinitely
while (parent && !parent.nativeViewProtected) {
parent = parent.parent;
if (owner.tabStrip.visibility === 'visible') {
this.tabBar.hidden = false;
} else {
this.tabBar.hidden = true;
}

if (parent && majorVersion > 10) {
// TODO: Figure out a better way to handle ViewController nesting/Safe Area nesting
tabBarTop = Math.max(tabBarTop, parent.nativeView.safeAreaInsets.top);
// failsafe with !this.tabBar.hidden just in some really odd case where hidden is false and collapse is true
// which should never happen
if (!owner.tabStrip.isCollapsed || !this.tabBar.hidden) {
const viewWidth = this.view.bounds.size.width;
const viewHeight = this.view.bounds.size.height;
const tabBarHeight = this.tabBar.frame.size.height;
let tabBarTop = safeAreaInsetsTop;

scrollViewTop = tabBarHeight;
scrollViewHeight = this.view.bounds.size.height - tabBarHeight + conditionalSafeAreaBottom;

const tabsPosition = owner.tabsPosition;
if (tabsPosition === TabsPosition.Bottom) {
tabBarTop = viewHeight - tabBarHeight - safeAreaInsetsBottom;
scrollViewTop = this.view.frame.origin.y;
scrollViewHeight = viewHeight - tabBarHeight;
}

let parent = owner.parent;

// Handle Angular scenario where Tabs is in a ProxyViewContainer
// It is possible to wrap components in ProxyViewContainers indefinitely
while (parent && !parent.nativeViewProtected) {
parent = parent.parent;
}

if (parent && majorVersion > 10) {
// TODO: Figure out a better way to handle ViewController nesting/Safe Area nesting
tabBarTop = Math.max(tabBarTop, parent.nativeView.safeAreaInsets.top);
}
this.tabBar.frame = CGRectMake(0, tabBarTop, viewWidth, tabBarHeight);
}
this.tabBar.frame = CGRectMake(0, tabBarTop, viewWidth, tabBarHeight);
} else {
this.tabBar.hidden = true;
}
Expand Down