Smaller tabbar if names are hidden, closes #115

Fix spacing for smaller devices
This commit is contained in:
Kylmakalle 2025-04-09 18:24:16 +03:00
parent 247e56d4b8
commit b472ac0ff5
2 changed files with 9 additions and 0 deletions

View File

@ -12,6 +12,7 @@ private extension ToolbarTheme {
final class TabBarControllerNode: ASDisplayNode {
private var navigationBarPresentationData: NavigationBarPresentationData
private let showTabNames: Bool // MARK: Swiftgram
private var theme: TabBarControllerTheme
let tabBarNode: TabBarNode
private let disabledOverlayNode: ASDisplayNode
@ -45,6 +46,7 @@ final class TabBarControllerNode: ASDisplayNode {
init(showTabNames: Bool, theme: TabBarControllerTheme, navigationBarPresentationData: NavigationBarPresentationData, itemSelected: @escaping (Int, Bool, [ASDisplayNode]) -> Void, contextAction: @escaping (Int, ContextExtractedContentContainingNode, ContextGesture) -> Void, swipeAction: @escaping (Int, TabBarItemSwipeDirection) -> Void, toolbarActionSelected: @escaping (ToolbarActionOption) -> Void, disabledPressed: @escaping () -> Void) {
self.theme = theme
self.showTabNames = showTabNames
self.navigationBarPresentationData = navigationBarPresentationData
self.tabBarNode = TabBarNode(showTabNames: showTabNames, theme: theme, itemSelected: itemSelected, contextAction: contextAction, swipeAction: swipeAction)
self.tabBarNode.isHidden = SGSimpleSettings.shared.hideTabBar
@ -103,8 +105,10 @@ final class TabBarControllerNode: ASDisplayNode {
let bottomInset: CGFloat = layout.insets(options: options).bottom
if !layout.safeInsets.left.isZero {
tabBarHeight = 34.0 + bottomInset
if !self.showTabNames { tabBarHeight -= 6.0 } // MARK: Swiftgram
} else {
tabBarHeight = 49.0 + bottomInset
if !self.showTabNames { tabBarHeight -= 12.0 } // MARK: Swiftgram
}
let tabBarFrame = CGRect(origin: CGPoint(x: 0.0, y: layout.size.height - (self.tabBarHidden ? 0.0 : tabBarHeight)), size: CGSize(width: layout.size.width, height: tabBarHeight))

View File

@ -272,6 +272,7 @@ open class TabBarControllerImpl: ViewController, TabBarController {
} else {
tabBarHeight = 49.0 + bottomInset
}
if !strongSelf.showTabNames { tabBarHeight -= 12.0 } // MARK: Swiftgram
updatedLayout.intrinsicInsets.bottom = tabBarHeight
strongSelf.controllers[index].containerLayoutUpdated(updatedLayout, transition: .immediate)
@ -448,8 +449,10 @@ open class TabBarControllerImpl: ViewController, TabBarController {
let bottomInset: CGFloat = updatedLayout.insets(options: options).bottom
if !updatedLayout.safeInsets.left.isZero {
tabBarHeight = 34.0 + bottomInset
if !self.showTabNames { tabBarHeight -= 6.0 } // MARK: Swiftgram
} else {
tabBarHeight = 49.0 + bottomInset
if !self.showTabNames { tabBarHeight -= 12.0 } // MARK: Swiftgram
}
if !self.tabBarControllerNode.tabBarHidden {
updatedLayout.intrinsicInsets.bottom = tabBarHeight
@ -477,8 +480,10 @@ open class TabBarControllerImpl: ViewController, TabBarController {
let bottomInset: CGFloat = updatedLayout.insets(options: options).bottom
if !updatedLayout.safeInsets.left.isZero {
tabBarHeight = 34.0 + bottomInset
if !self.showTabNames { tabBarHeight -= 6.0 } // MARK: Swiftgram
} else {
tabBarHeight = 49.0 + bottomInset
if !self.showTabNames { tabBarHeight -= 12.0 } // MARK: Swiftgram
}
if !self.tabBarControllerNode.tabBarHidden {
updatedLayout.intrinsicInsets.bottom = tabBarHeight