// A contact sheet's square: the cell the grid gives it, and the one frame its // button takes — drawn, touched and read out alike. // // WHY THIS EXISTS (295 rough rows 91/94, walker294). A sheet's picture fills // its square (`scaledToFill`), so a wide photograph or a tall film is laid out // LARGER than the square and only drawn inside it by `.clipped()`. Clipping is // paint: it does not shrink the hit area or the accessibility frame, and the // picture sat at the top-leading corner of its reader, so each tile's button // reached right and down over its neighbours — 0.46, 0.71 and 0.59 of the // screen wide in a four-across grid. The grid looked right and spoke wrong. // // So the picture is framed to its cell and centred there, and the tile says // its shape is the cell's rectangle for touch and for VoiceOver. The geometry // is here, as values, so a test can hold the rule without drawing a pixel. import CoreGraphics import SwiftUI extension View { /// A contact sheet square's shape, for touch and for VoiceOver: the cell's /// rectangle, however far its filled picture was laid out past it. func sheetTile() -> some View { clipped() .contentShape(.interaction, Rectangle()) .contentShape(.accessibility, Rectangle()) } }