Closed fousa closed 2 years ago
Hi @fousa, this is not the issue of SheeKit. In SwiftUI, NavigationView
is actually a Split View Controller when horizontalSizeClass
is regular. You can check the Demo app of shee kit, where I override horizontal size class to make NavigationView
work as Navigation Controller.
But when I replace the entire .shee(
implementation with .sheet(
it's displayed correctly. Isn't a SplitView shown when multiple views a positioned next to each other?
NavigationView {
SomeMainView()
}
DetailView()
It might be that native .sheet(...)
enforces .compact
horizontal size class - you can verify that by getting it from environment in your sheet content. Shee Kit does not override the size class in environment. Also, please check which size class is in environment of the view from which you present the sheet, and let me know both outcomes.
After investigation, the native SwiftUI.sheet
passes .regular
horizontal size class to the content, but also it passes these private environment values:
EnvironmentPropertyKey<ExpandedSplitViewKey> = false,
EnvironmentPropertyKey<SceneStorageValuesKey> = Optional(SwiftUI.WeakBox<SwiftUI.SceneStorageValues>(base: Optional(SwiftUI.SceneStorageValues))),
EnvironmentPropertyKey<StoreKey<SceneBridge>> = Optional(SceneBridge: rootViewController = Optional(<_TtGC7SwiftUI19UIHostingControllerGVS_15ModifiedContentVS_7AnyViewVS_12RootModifier__: 0x7fe9c070dc80>)),
EnvironmentPropertyKey<AppNavigationAuthorityKey> = Optional(SwiftUI.WeakBox<SwiftUI.AppNavigationAuthority>(base: Optional(SwiftUI.AppNavigationAuthority))),
EnvironmentPropertyKey<Key> = Optional(SwiftUI.NavigationAuthority(host: Optional(<_TtGC7SwiftUI14_UIHostingViewGVS_15ModifiedContentVS_7AnyViewVS_12RootModifier__: 0x7fe9c070e400; frame = (0 0; 1366 1024); autoresize = W+H; gestureRecognizers = <NSArray: 0x600002d7d140>; layer = <CALayer: 0x600002353640>>))),
EnvironmentPropertyKey<SystemColorSchemeKey> = light,
EnvironmentPropertyKey<InputAccessoryKey> = WeakBox<InputAccessoryGenerator<SwiftUIToolbar>>(base: nil),
EnvironmentPropertyKey<CanTakeFocusKey> = true,
EnvironmentPropertyKey<TintAdjustmentModeKey> = Optional(SwiftUI.TintAdjustmentMode.desaturated),
EnvironmentPropertyKey<ExplicitPreferredColorSchemeKey> = nil,
There is an obvious hack out there in SwiftUI with private environment EnvironmentPropertyKey<ExpandedSplitViewKey> = false,
which SheeKit has no access to.
When I use
SheeKit
on my Mac Catalyst app, I noticed that the modal was always presented as a SplitView. While there was no indication in my code that could lead to such a screen.Here is a snippet of the code I wrote to present a modal as a form sheet:
Is this a known issue?