Skip to content

Commit

Permalink
Use switch
Browse files Browse the repository at this point in the history
  • Loading branch information
eonist committed Oct 23, 2024
1 parent 0d6b805 commit 55b2580
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 22 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" : "5cea6fd943e8f9dcc70902091bf856070c2abae2"
"revision" : "0d6b805d6bf9c4fbe530c0627166f53d8d0203a9"
}
}
],
Expand Down
55 changes: 34 additions & 21 deletions Sources/SplitViewKit/SplitViewContainer+Content.swift
Original file line number Diff line number Diff line change
Expand Up @@ -53,28 +53,20 @@ extension SplitViewContainer {
Swift.print("📐 Geometry changed: \(geometry.size) ")
}()
// let closure: (_ winWidth: CGFloat) -> some View = navigationSplitView

geometryChange(
// isLandscape: ,
//sizeClass: sizeClass.reBind,
geometry: geometry
// closure: navigationSplitView
)
}
}
func geometryChange(/*isLandscape: Bool, */geometry: GeometryProxy /*closure: (_ winWidth: CGFloat) -> some View*/) -> some View {
if isLandscape { // - Fixme: ⚠️️ Add doc
if sizeClass == .compact { // this fixes things going into compact. but not 70% to regular
navigationSplitView(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
if isNarrow(isLandscape: isLandscape, winWidth: geometry.size.width) {
navigationSplitView(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(geometry.size.width) // ⚠️️ This is the same as the other, but it refreshes the view, and recalculates columnwidths etc, which is what we need
}
switch true {
case isLandscape, sizeClass == .compact:
Swift.print("👉 isLandscape, compact")
return navigationSplitView(geometry.size.width)
case isLandscape, sizeClass == .regular, isNarrow(isLandscape: isLandscape, winWidth: geometry.size.width):
Swift.print("👉 isLandscape, regular, isNarrow")
return navigationSplitView(geometry.size.width)
case isLandscape, sizeClass == .regular, !isNarrow(isLandscape: isLandscape, winWidth: geometry.size.width):
Swift.print("👉 isLandscape, regular, fullscreen")
return navigationSplitView(geometry.size.width)
default:
Swift.print("👉 default")
return navigationSplitView(geometry.size.width) // else regular, not narrow, not landscape
}
} else {
navigationSplitView(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 Expand Up @@ -136,3 +128,24 @@ extension SplitViewContainer {
// isLandscape: isLandscape,
// winSize: winSize
// )
// func geometryChange(/*isLandscape: Bool, */geometry: GeometryProxy /*closure: (_ winWidth: CGFloat) -> some View*/) -> some View {
// if isLandscape { // - Fixme: ⚠️️ Add doc
// if sizeClass == .compact { // this fixes things going into compact. but not 70% to regular
// navigationSplitView(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
// if isNarrow(isLandscape: isLandscape, winWidth: geometry.size.width) {
// navigationSplitView(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(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(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
// }
// }
// geometryChange(
//// isLandscape: ,
// //sizeClass: sizeClass.reBind,
// geometry: geometry
//// closure: navigationSplitView
// )

0 comments on commit 55b2580

Please sign in to comment.