Skip to content

Commit

Permalink
Add support for macOS for isShowingSideBar pt2
Browse files Browse the repository at this point in the history
  • Loading branch information
eonist committed Oct 26, 2024
1 parent 5be64ca commit 41dff1d
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"location" : "https://github.com/sentryco/SplitViewKit",
"state" : {
"branch" : "main",
"revision" : "e7f7b8e838b27c23c46afa39ecc76525b3f0c180"
"revision" : "5be64ca5c1a7b0f0d8fd7a6c98060e8aba74f1f5"
}
}
],
Expand Down
1 change: 1 addition & 0 deletions ExampleProject/ExampleProject/ExampleProjectApp.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import HybridColor
* - Note: To hide the title bar for a macOS app in SwiftUI, you can use the .windowStyle() modifier on the WindowGroup within your App structure. Specifically, you can apply the HiddenTitleBarWindowStyle() to achieve this effect. This will remove the title bar from the window, giving your app a more modern, clean appearance.
* - Note: More info regarding windowStyle: https://developer.apple.com/documentation/swiftui/windowgroup/windowstyle(_:)
* - Note: More info regarding windowStyle: https://stackoverflow.com/questions/70501890/how-can-i-hide-title-bar-in-swiftui-for-macos-app
* - Note: The Xcode preview doesn't accurately reflect the hidden title bar. However, when you build and run the project, the title bar should be hidden as expected
*/
@main
struct ExampleProjectApp: App { // App Protocol: Conforms to the App protocol which is required for SwiftUI apps.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ extension MainHeader {
* SideBarToggleButton or backbutton
*/
@ViewBuilder var button: some View {
if sizeClass == .regular { // if regular-mode
if !splitConfig.isShowingSideBar(sizeClass: sizeClass)/*sizeClass == .regular*/ { // if regular-mode
sideBarToggleButton
} else { // if compact-mode
backButton
Expand All @@ -48,6 +48,7 @@ extension MainHeader {
*/
var sideBarToggleButton: some View {
Button(action: { // Show sidebar
// - Fixme: ⚠️️ animate this transition, but only for macOS
splitConfig.columnVisibility = .all // shows all 3 columns
}) {}
.iconButtonStyle(iconName: "square.righthalf.fill") // - Fixme: ⚠️️ describe what this icon looks like
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,10 @@ extension SideBarHeader {
*/
@ViewBuilder var sideBarToggleButton: some View {
let button = Button(action: { // Hide sidebar
// - Fixme: ⚠️️ animate this transition, but only for macOS
splitConfig.columnVisibility = .doubleColumn // Go to double column, this effectivly hides sidebar
}) {}
if sizeClass == .regular { // If 3 column
if splitConfig.isShowingSideBar(sizeClass: sizeClass)/*sizeClass == .regular*/ { // If 3 column
button
.iconButtonStyle(iconName: "square.lefthalf.fill") // Applies an icon style with a half-filled square, indicating a partial collapse or expansion state.
.opacity(splitConfig.columnVisibility == .all ? 1.0 : 0.0) // Only show this if sidebar is hidden
Expand Down
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,12 @@ These are some of the resources that was founds when solving edge cases for the

## Todo:
- Test to see if macOS works out of the box
- Test detail fullscreen button on macos
- Move the debug view a bit up from the bottom of the app for macOS
- Show ghost buttons for main and detail headers macos
- Figure out sidebar header height on macos
- Add animation for sidebar visibility toggling macos
- Remove default styling for list items in detaillist macos

## Future improvements:

Expand Down

0 comments on commit 41dff1d

Please sign in to comment.