mirror of
https://github.com/Dimillian/IceCubesApp.git
synced 2025-01-27 08:18:08 +00:00
Better TabView support
This commit is contained in:
parent
f377e5970e
commit
30c5c36aa1
1 changed files with 29 additions and 72 deletions
|
@ -53,7 +53,6 @@ struct AppView: View {
|
|||
|
||||
@ViewBuilder
|
||||
var tabBarView: some View {
|
||||
if #available(iOS 18.0, *) {
|
||||
TabView(selection: .init(get: {
|
||||
selectedTab
|
||||
}, set: { newTab in
|
||||
|
@ -76,30 +75,6 @@ struct AppView: View {
|
|||
}
|
||||
.id(appAccountsManager.currentClient.id)
|
||||
.withSheetDestinations(sheetDestinations: $appRouterPath.presentedSheet)
|
||||
} else {
|
||||
TabView(selection: .init(get: {
|
||||
selectedTab
|
||||
}, set: { newTab in
|
||||
updateTab(with: newTab)
|
||||
})) {
|
||||
ForEach(availableTabs) { tab in
|
||||
tab.makeContentView(selectedTab: $selectedTab)
|
||||
.tabItem {
|
||||
if userPreferences.showiPhoneTabLabel {
|
||||
tab.label
|
||||
.environment(\.symbolVariants, tab == selectedTab ? .fill : .none)
|
||||
} else {
|
||||
Image(systemName: tab.iconName)
|
||||
}
|
||||
}
|
||||
.tag(tab)
|
||||
.badge(badgeFor(tab: tab))
|
||||
.toolbarBackground(theme.primaryBackgroundColor.opacity(0.30), for: .tabBar)
|
||||
}
|
||||
}
|
||||
.id(appAccountsManager.currentClient.id)
|
||||
.withSheetDestinations(sheetDestinations: $appRouterPath.presentedSheet)
|
||||
}
|
||||
}
|
||||
|
||||
private func updateTab(with newTab: AppTab) {
|
||||
|
@ -133,40 +108,22 @@ struct AppView: View {
|
|||
tabs: availableTabs)
|
||||
{
|
||||
HStack(spacing: 0) {
|
||||
if #available(iOS 18.0, *) {
|
||||
TabView(selection: $selectedTab) {
|
||||
ForEach(availableTabs) { tab in
|
||||
Tab(value: tab) {
|
||||
tab.makeContentView(selectedTab: $selectedTab)
|
||||
} label: {
|
||||
tab.label
|
||||
}
|
||||
.defaultVisibility(.hidden, for: .automatic)
|
||||
}
|
||||
}
|
||||
.tabViewStyle(.tabBarOnly)
|
||||
.introspect(.tabView, on: .iOS(.v18)) { (tabview: UITabBarController) in
|
||||
tabview.tabBar.isHidden = horizontalSizeClass == .regular
|
||||
tabview.customizableViewControllers = []
|
||||
tabview.moreNavigationController.isNavigationBarHidden = true
|
||||
}
|
||||
} else {
|
||||
TabView(selection: $selectedTab) {
|
||||
ForEach(availableTabs) { tab in
|
||||
tab
|
||||
.makeContentView(selectedTab: $selectedTab)
|
||||
.toolbar(horizontalSizeClass == .regular ? .hidden : .visible, for: .tabBar)
|
||||
.tabItem {
|
||||
tab.label
|
||||
}
|
||||
.tag(tab)
|
||||
}
|
||||
}
|
||||
.introspect(.tabView, on: .iOS(.v17)) { (tabview: UITabBarController) in
|
||||
.introspect(.tabView, on: .iOS(.v17, .v18)) { (tabview: UITabBarController) in
|
||||
tabview.tabBar.isHidden = horizontalSizeClass == .regular
|
||||
tabview.customizableViewControllers = []
|
||||
tabview.moreNavigationController.isNavigationBarHidden = true
|
||||
}
|
||||
}
|
||||
if horizontalSizeClass == .regular,
|
||||
appAccountsManager.currentClient.isAuth,
|
||||
userPreferences.showiPadSecondaryColumn
|
||||
|
|
Loading…
Reference in a new issue