We explain SwiftUI's layout system by re-implementing parts of it from scratch. We start with the basic view protocols and implement fixed and flexible frames, alignment, stacks and much more.
@Alexbbrown@krzyzanowskim yes, the fixedSize makes sure we measure something that's independent of whatever it was proposed. The frame both proposes that width as well as makes sure the entire button becomes that width.
@krzyzanowskim the key problem is that the layout system is top-down, and you cannot size yourself according to siblings. So some parent is responsible to make them the same width (based on their individual widths!). This is the simplest way I know of doing this that's backwards-compatible (you could abstract this further btw). https://gist.github.com/chriseidhof/51076f16b6725ff8b17f99cc656d17be
maxwidth.swift
GitHub Gist: instantly share code, notes, and snippets.