AndyDentFree / AndyDentFree/SpriteKittenly

ResizingRemit needs sample with GeometryReader

Abierto
#4 0 comentarios 0 reacciones 0 asignados Ver en GitHub
Lenguaje dominante
Swift
Estrellas
8
Forks
0
Métricas de merge de PR
Sin PR fusionados en 30 d

Descripción

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

Guía de contribución

No hay ninguna guía de contribución indexada para este repositorio

Evaluación

Este issue todavía no se ha evaluado.

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.