Skip to content

Commit

Permalink
Add refresher id and winWidth onchange
Browse files Browse the repository at this point in the history
  • Loading branch information
eonist committed Oct 24, 2024
1 parent aba1f76 commit f8eb35b
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 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" : "6af591d8e37e5d3a50ece47284f575ef92da42e8"
"revision" : "aba1f7662313432f377c8b75621b114a8622abdb"
}
}
],
Expand Down
6 changes: 6 additions & 0 deletions Sources/SplitViewKit/SplitViewContainer+Content.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ extension SplitViewContainer {
} else if newValue == .regular {
print("👉 Switched to regular size class")
}
refreshID = UUID()
}
.onChange(of: winWidth) { oldValue, newValue in
Swift.print("winWidth changed - oldValue: \(oldValue), newValue: \(newValue)")
refreshID = UUID()
}
}
}
Expand Down Expand Up @@ -58,6 +63,7 @@ extension SplitViewContainer {
}
}()
navigationSplitView()
.id(refreshID)
}
}
/**
Expand Down
2 changes: 1 addition & 1 deletion Sources/SplitViewKit/SplitViewContainer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public struct SplitViewContainer<SideBar: View, Content: View, Detail: View>: Vi
// /*@State */internal var geometryChange: GeometryChange?
// As a last resort, you can force a view to redraw by changing its identity:
// add .id(refreshID) on view and call refreshID = UUID() in an update
// @State internal var refreshID = UUID()
@State internal var refreshID = UUID()
@State internal var winWidth: CGFloat = .zero
/**
* Init
Expand Down

0 comments on commit f8eb35b

Please sign in to comment.