AndyDentFree / AndyDentFree/SpriteKittenly
ResizingRemit needs sample with GeometryReader
- Dominant language
- Swift
- Stars
- 8
- Forks
- 0
- PR merge metrics
- No merged PRs in 30d
Description
Alternative that I explored using a GeometryReader should be added on another tab, with copies of classes alongside.
Relevant code below, needs rewrite to apply the technique to ResizingRemit
## Snippet (from old Purrticles code)
```
struct MainDocWindow: View {
...
@State private var previewSize = CGSize.zero
...
VStack(spacing: 0) {
GeometryReader { previewGeom in
PreviewView(document: $document)
.padding(showFullScreen ? [] : .horizontal)
#if os(macOS)
// impossible to get here
.frame(width: geometry.size.width, height: geometry.size.height * min(previewRatio, 0.33))
#else
.frame(width: showFullScreen ? UIScreen.main.bounds.width : outerGeom.size.width,
height: showFullScreen ? UIScreen.main.bounds.height : outerGeom.size.height * min(previewRatio, 0.33))
#endif
.animation(.easeInOut(duration: 0.5), value: showFullScreen)
.onAppear {
previewSize = previewGeom.size
}
.onChange(of: previewGeom.size) { newSize in
guard previewSize.height != 0 else {return} // don't react to initial set
print(".onChange(of: previewGeom.size) Changed preview from (\(previewSize.width), \(previewSize.height)) to \(newSize)")
previewSize = newSize
document.previewResized(to: newSize)
}
}
```
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.