Skip to content

26.10.18

@markbattistella markbattistella tagged this 18 Oct 21:15
- Applied swift-format styling

Add per-corner bezels for multi-screen devices (iPhone Duo)

`CGFloat.deviceBezel` is one number, which can't describe iPhone Duo: its
outer screen is tight on one edge and round on the other, and its inner
screen differs again. `UIScreen._displayCornerRadius` also reports 59 on both
screens, which is wrong for the inner one (55).

Notes:
- New `CGFloat.deviceBezelCorners` returns a `BezelCorners` (topLeft, topRight,
  bottomLeft, bottomRight). It picks the screen the app is on and turns that
  screen's corners to match the interface orientation, so callers need no
  rotation or screen detection of their own. Every other device returns the
  same radius on all four corners. Read it again when the scene's size or
  orientation changes; a static property can't notify.
- Measured on an iPhone Duo (iOS 27.1) with a full-window view using
  `.containerConcentric()`: outer 8 / 59 / 8 / 59 in portrait, inner 55 on all
  four, in every orientation. The rotation maths is tested against those
  values for portrait, landscape left and landscape right.
- Data: bezel.min.json gains an optional `screens` list per device (nativeSize
  in pixels, plus four physical corners with the device upright). Devices
  without it are unchanged, and older package versions ignore it.
- The active screen is matched by native pixel size, so rotation and fold
  state don't matter. The window scene is read through `UIApplication` by
  selector, because `UIApplication.shared` is unavailable to app extensions
  and this package must keep building for them. Not yet exercised from inside
  an extension.
- `deviceBezel` now returns the largest corner of the active screen: 59 on the
  Duo's outer screen and 55 on its inner screen (previously 59 on both).
  Behaviour on every other device is unchanged.
- These are the display's own corners. A window that doesn't reach the screen
  edge, such as one beside the Duo's system bar, has rounder corners of its
  own, and only ConcentricRectangle / UICornerConfiguration follows those. The
  README says so and still recommends them on iOS 26 and later.
- The outer-screen path is verified by tests using the measured values, not by
  a live run: the inner screen was checked live on the simulator, but the
  simulator couldn't be folded from the command line.
- Adds ScreenCornersTests (11 tests): rotation, screen matching, fallbacks and
  the shipped Duo data.
- Adds update-devices.sh: scan, apply, regenerate docs and show what changed in
  one command. --release commits both repos, pushes, tags and publishes;
  --check reports without changing anything (exit 1 if out of date, 2 if a
  device needs measuring by hand); --xcode and --verify are also available.
  --release refuses to publish when a multi-screen device is missing
  per-screen data unless --force is given.
- Each run writes its summary to LastDeviceScan.md at the repo root,
  overwritten every time. It sits outside every package target, so it is not
  part of the library.
- Updates the Generator submodule: per-screen detection read from Xcode's
  device profiles, a warning for multi-screen devices with incomplete data,
  and generator tests.
- Docs: README (multi-screen section) and MAINTAINING.md (new-device runbook,
  per-screen devices, script reference).
Assets 2
Loading