AndyDentFree / AndyDentFree/SpriteKittenly

ResizingRemit needs sample with GeometryReader

Aperta
#4 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub
Lingua principale
Swift
Stelle
8
Fork
0
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Descrizione

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)
}
}
```

Guida per i contributori

Nessuna guida per i contributori indicizzata per questo repository

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.