Skip to content

Instantly share code, notes, and snippets.

@ole
Last active September 6, 2022 15:33
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ole/72e147e3006ae64fdfee134fb3b4a4c9 to your computer and use it in GitHub Desktop.
Save ole/72e147e3006ae64fdfee134fb3b4a4c9 to your computer and use it in GitHub Desktop.
Structure of _StackLayoutCache and related types, used by SwiftUI as the Cache type for VStackLayout and HStackLayout
// Structure of _StackLayoutCache and related types.
// Used by SwiftUI as the Cache type for VStackLayout and HStackLayout.
//
// As of: iOS 16.0 simulator in Xcode 14.0b6
import SwiftUI
struct _StackLayoutCache {
var stack: StackLayout
}
struct StackLayout {
var header: Header
var children: Array<Child>
struct Header {
let minorAxisAlignment: AlignmentKey
let uniformSpacing: Optional<CGFloat>
let majorAxis: Axis
var internalSpacing: CGFloat
var lastProposedSize: ProposedViewSize
var stackSize: CGSize
let proxies: LayoutSubviews
let resizeChildrenWithTrailingOverflow: Bool
}
struct Child {
var layoutPriority: Double
var majorAxisRangeCache: MajorAxisRangeCache
let distanceToPrevious: CGFloat
var fittingOrder: Int
var geometry: ViewGeometry
}
struct MajorAxisRangeCache {
var min: Optional<CGFloat>
var max: Optional<CGFloat>
}
}
struct AlignmentKey: Hashable /*, Comparable */ {
let bits: UInt
}
struct ViewGeometry /*: Equatable */ {
var origin: ViewOrigin
var dimensions: ViewDimensions
}
struct ViewOrigin: Equatable /*, Animatable */ {
var value: CGPoint
}
struct ViewDimensions /*: Equatable*/ {
let guideComputer: LayoutComputer
var size: ViewSize
}
struct ViewSize: Equatable /*, Animatable */ {
var value: CGSize
var _proposal: CGSize
}
struct LayoutComputer /*: Equatable, Defaultable */ {
var engine: AnyLayoutEngineBox
var seed: Int
}
class AnyLayoutEngineBox {
// My reflection code shows no stored properties. Is this true?
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment