[ad_1]
I’ve a SwiftUI app that makes use of a sidebar on iPad. I can’t work out why the sting spacing doesn’t apply, nonetheless once I pressure shut the app and reopen it seems regular.
Downside:
- When person first indicators in
- rotates gadget
- collapses sidebar and reopens)
The issue goes away when pressure quitting the app and reloading when person is signed in.
ContentView
struct ContentView: View {
var physique: some View {
#if os(iOS)
if horizontalSizeClass == .compact {
AppTabView()
.environmentObject(retailer)
.environmentObject(quickActionSettings)
} else {
AppSideNavView()
.environmentObject(retailer)
}
#else
AppSideNavView()
.environmentObject(retailer)
#endif
}
}
AppSideNavView (For iPad)
struct AppSideNavView: View {
@EnvironmentObject var retailer: Retailer
var physique: some View {
if retailer.userAuthState == .signedOut {
LoginView()
} else if retailer.userAuthState == .signedIn {
AppSidebarNavigation()
.environmentObject(retailer)
} else {
LoginView()
}
}
}
Sidebar
struct AppSidebarNavigation: View {
enum NavigationItem {
case dwelling
case bills
}
@EnvironmentObject var retailer: Retailer
@State non-public var choice: NavigationItem? = .dwelling
var physique: some View {
NavigationView {
sidebar
.navigationTitle("")
.navigationBarTitleDisplayMode(.inline)
.navigationBarHidden(true)
// Predominant View
HomeView()
.environmentObject(retailer)
}
.navigationViewStyle(DoubleColumnNavigationViewStyle())
}
}
extension AppSidebarNavigation {
var sidebar: some View {
Listing(choice: $choice) {
Group {
NavigationLink(vacation spot: HomeView()
.environmentObject(retailer), tag: NavigationItem.dwelling, choice: $choice) {
Label("Houses", systemImage: "home")
.modifier(navText())
}
.tag(NavigationItem.dwelling)
.navigationTitle("")
.navigationBarTitleDisplayMode(.inline)
.navigationBarHidden(true)
NavigationLink(vacation spot: Bills()
.environmentObject(retailer)
.navigationBarTitleDisplayMode(.massive),
tag: NavigationItem.bills, choice: $choice) {
Label("Bills", systemImage: "arrow.proper.arrow.left")
.modifier(navText())
}
.tag(NavigationItem.bills)
.navigationBarTitleDisplayMode(.massive)
}
}
.listRowBackground(Shade("White"))
.background(Shade("White"))
.listStyle(.sidebar)
}
}
[ad_2]