Skip to content

Commit

Permalink
Add animation for sidebar visibility toggling macos
Browse files Browse the repository at this point in the history
  • Loading branch information
eonist committed Oct 26, 2024
1 parent 08fbf1e commit 39378c4
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,13 @@ 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
#if os(macOS)
withAnimation(.easeInOut(duration: 0.3)) {
splitConfig.columnVisibility = .all // Shows all 3 columns
}
#else
splitConfig.columnVisibility = .all // Shows all 3 columns without animation for other platforms
#endif
}) {}
.iconButtonStyle(iconName: "square.righthalf.fill") // - Fixme: ⚠️️ describe what this icon looks like
.opacity(splitConfig.isShowingSideBar(sizeClass: sizeClass) ? 0.0 : 1.0) // Only show this if sidebar is hidden
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,14 @@ 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 os(macOS)
let animation = Animation.easeInOut(duration: 0.3)
withAnimation(animation) {
splitConfig.columnVisibility = .doubleColumn // Go to double column, this effectively hides the sidebar
}
#else
splitConfig.columnVisibility = .doubleColumn // Change without animation for other platforms
#endif
}) {}
if splitConfig.isShowingSideBar(sizeClass: sizeClass)/*sizeClass == .regular*/ { // If 3 column
button
Expand Down

0 comments on commit 39378c4

Please sign in to comment.