Skip to content

Commit

Permalink
Remove id refresh
Browse files Browse the repository at this point in the history
  • Loading branch information
eonist committed Oct 24, 2024
1 parent 78d108c commit e9c6144
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 9 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" : "bdcbe07aafe7225825a8d616535a981550d05b93"
"revision" : "78d108ca8bff22400c1e547b6a5b736af0927b11"
}
}
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ extension ExampleView {
sizeClass: sizeClass,
splitConfig: splitConfig
)
.onChange(of: selectedSideBarIndex) {
.onChange(of: selectedSideBarIndex) { // - Fixme: ⚠️️ doc this line
handleSideBarChange(splitConfig, sizeClass)
} // Forward state change to handleSideBarChange
}
Expand Down
8 changes: 4 additions & 4 deletions Sources/SplitViewKit/SplitViewContainer+Content.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ extension SplitViewContainer {
public var body: some View {
splitViewContainer
.onChange(of: sizeClass) { oldValue, newValue in // This works when we move from compact to regular or regular to compact.
// Swift.print("onChange - oldValue: \(String(describing: oldValue)) newValue: \(String(describing: newValue))")
// refreshID = UUID() // Force redraw of navSplitView
Swift.print("onChange - oldValue: \(String(describing: oldValue)) newValue: \(String(describing: newValue))")
// refreshID = UUID() // Force redraw of navSplitView
// sizingClass = sizeClass
}
.overlay { // We add overlay if debug closure returns a view, if not its skipped
Expand Down Expand Up @@ -51,8 +51,8 @@ extension SplitViewContainer {
.id(refreshID) // used to refresh view when sizeClass change, and winSize change
.onChange(of: geometry.size) { oldSize, newSize in // - Fixme: ⚠️️ add doc
if /*sizeClass*/sizeClass == .regular && oldSize != newSize { // only repaint view if size has actually changed, avoids infinite loop etc, we only need this in regular mode, it causes issues with popup sheet in compact mode
// Swift.print("size is new")
refreshID = UUID() // Re-generate view
Swift.print("size is new")
// refreshID = UUID() // Re-generate view
}
}
}
Expand Down
3 changes: 0 additions & 3 deletions Sources/SplitViewKit/SplitViewContainer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,6 @@ public struct SplitViewContainer<SideBar: View, Content: View, Detail: View, Deb
* - Important: ⚠️ Needs to be called from the correct scope. Jumps to compact when it should be regular in the wrong scope etc. so param drilling is probably better to avoid future hard to find bugs
*/
@Environment(\.horizontalSizeClass) internal var sizeClass: UserInterfaceSizeClass?
// - Fixme: ⚠️️ add dispatch async main to see if that works in the onchange
// - Fixme: ⚠️️ It seem very tricky to make horizontalSizeClass a binding. @Bindable seems to be the best way. But it doesnt work on this environment variable for some reason. There could be a way. update when discovered. for now. we sync on onChange.
// @State internal var sizingClass: UserInterfaceSizeClass? // = .regular // - Fixme: ⚠️️ make this non optional later, maybe the optiality is holding back the refresh to take effect?
/**
* State object for managing the configuration of the split view.
* - Description: `splitConfig` holds the state for various configuration settings of the split view such as column visibility and dimensions. It is crucial for dynamically adjusting the layout based on the device's orientation and size class changes.
Expand Down
1 change: 1 addition & 0 deletions Sources/SplitViewKit/ext/UserInterfaceSizeClass+Ext.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ extension UserInterfaceSizeClass {
extension Optional where Wrapped == UserInterfaceSizeClass {
/**
* Convenient rebinder (Environtment -> Binding)
* - Note: It seem very tricky to make horizontalSizeClass a two way binding. @Bindable seems to be the best way. But it doesnt work on this environment variable for some reason. There could be a way. update when discovered. for now. we sync on onChange.
* - Fixme: ⚠️️ Add description
*/
var reBind: Binding<Self> {
Expand Down

0 comments on commit e9c6144

Please sign in to comment.