Fix FloatingTabState crash + landscape layout on iPhone

Use UIDevice.userInterfaceIdiom instead of hSizeClass so large iPhones
in landscape keep the iPhone layout. Move tabState environmentObject to
the top-level Group so both layouts always have it in scope.
This commit is contained in:
kutesir
2026-05-29 11:01:58 +03:00
parent 8210cbf487
commit b6c90a4177

View File

@@ -61,14 +61,17 @@ struct ContentView: View {
} }
} }
private var isIPad: Bool { UIDevice.current.userInterfaceIdiom == .pad }
var body: some View { var body: some View {
Group { Group {
if hSizeClass == .regular { if isIPad {
iPadLayout() iPadLayout()
} else { } else {
iPhoneLayout() iPhoneLayout()
} }
} }
.environmentObject(tabState)
.preferredColorScheme(preferredScheme) .preferredColorScheme(preferredScheme)
.fullScreenCover(isPresented: $showOnboarding) { .fullScreenCover(isPresented: $showOnboarding) {
OnboardingView(isPresented: $showOnboarding) OnboardingView(isPresented: $showOnboarding)
@@ -144,7 +147,6 @@ struct ContentView: View {
.padding(.horizontal, 24) .padding(.horizontal, 24)
.padding(.bottom, 8) .padding(.bottom, 8)
} }
.environmentObject(tabState)
.onAppear { UITabBar.appearance().isHidden = true } .onAppear { UITabBar.appearance().isHidden = true }
} }