Skip to content

Commit

Permalink
Toggle on sizeClass change
Browse files Browse the repository at this point in the history
  • Loading branch information
eonist committed Oct 23, 2024
1 parent 696cc27 commit c962718
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
4 changes: 2 additions & 2 deletions ExampleProject/ExampleProject/ExampleProjectApp.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ struct ExampleProjectApp: App { // App Protocol: Conforms to the App protocol wh
.background(Color.blackOrWhite.opacity(1))
.environment(\.colorScheme, .dark) // dark
.statusBar(hidden: true) // Hide the status bar (looks better for demos)
.persistentSystemOverlays(.hidden) // Hide the Home Indicator (looks better for demos)
// .persistentSystemOverlays(.hidden) // Hide the Home Indicator (looks better for demos)
}
}
}
}
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,11 @@ Add this to xcode or your SPM package file:

## Gotchas:

- In SplitView, when in Portrait it can either occupy 40% of 60% of the screen
- In SplitView, when in Portrait it can either occupy 40% of 60% of the screen ("Slide-over-mode" on iPad is the same as 30% split-view)
- In Landscape it can occupy 30%, 50%, and 70% of the screen
- There are some bugs in `NavigationSplitView` [https://forums.developer.apple.com/forums/thread/708721](https://forums.developer.apple.com/forums/thread/708721)
- Using `NavigationSplitView` is highly recommended over building your own SplitView with HStack etc. As a lot of features come toll free with `NavigationSplitView`

## References

Here are some general tutorials and articles on how to use `NavigationSplitView` that was useful to read while building this framework.
Expand Down
6 changes: 5 additions & 1 deletion Sources/SplitViewKit/SplitViewContainer+Content.swift
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,11 @@ extension SplitViewContainer {
let _ = geometry.size.width > geometry.size.height // ⚠️️ For some reason we have to have this here, elaborate?: I thinkn its just because we have to reference geomtryreader to activate some internal mechanism etc
// - Fixme: ⚠️️ maybe if we load new view on size change?
if isLandscape { // - Fixme: ⚠️️ Add doc
navigationSplitView(winWidth: geometry.size.width) // ⚠️️ This is the same as the other, but it refreshes the view, and recalculates columnwidths etc, which is what we need
if sizeClass == .compact {
navigationSplitView(winWidth: geometry.size.width) // ⚠️️ This is the same as the other, but it refreshes the view, and recalculates columnwidths etc, which is what we need
} else { //if sizeClass == .regular
navigationSplitView(winWidth: geometry.size.width) // ⚠️️ This is the same as the other, but it refreshes the view, and recalculates columnwidths etc, which is what we need
}
} else {
navigationSplitView(winWidth: geometry.size.width) // ⚠️️ We can't load the same variable, or else it will not refresh. so we reference it again like this to referesh. seems strange but it is what it is, there might be another solution to this stange behaviour, more exploration could be ideal
}
Expand Down

0 comments on commit c962718

Please sign in to comment.