53b4f60da1
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
43 lines
1.4 KiB
Swift
43 lines
1.4 KiB
Swift
import Foundation
|
|
|
|
/// Resting island dimensions, using a physical notch only when the screen has one.
|
|
struct IslandScreenGeometry {
|
|
static let fallbackNotchWidth: CGFloat = 184
|
|
private static let noNotchWidth: CGFloat = 80
|
|
private static let noNotchHeight: CGFloat = 24
|
|
|
|
let hasNotch: Bool
|
|
let width: CGFloat
|
|
let height: CGFloat
|
|
|
|
init(screenWidth: CGFloat, safeAreaTop: CGFloat,
|
|
auxiliaryLeftWidth: CGFloat?, auxiliaryRightWidth: CGFloat?,
|
|
menuBarHeight: CGFloat) {
|
|
hasNotch = safeAreaTop > 0
|
|
if hasNotch {
|
|
if let left = auxiliaryLeftWidth, let right = auxiliaryRightWidth {
|
|
let measuredWidth = screenWidth - left - right
|
|
width = measuredWidth > 0 && measuredWidth < screenWidth
|
|
? measuredWidth : Self.fallbackNotchWidth
|
|
} else {
|
|
width = Self.fallbackNotchWidth
|
|
}
|
|
height = safeAreaTop
|
|
} else {
|
|
width = Self.noNotchWidth
|
|
height = min(Self.noNotchHeight, menuBarHeight)
|
|
}
|
|
}
|
|
}
|
|
|
|
/// Shared by the compact view and the greeting's collapse destination.
|
|
struct IslandRestingLayout {
|
|
let width: CGFloat
|
|
let height: CGFloat
|
|
|
|
var botDiameter: CGFloat { min(20, max(0, height - 6)) }
|
|
var botCenterY: CGFloat { height / 2 }
|
|
var miniGridScale: CGFloat { min(1, max(0, height - 4) / 28) }
|
|
var miniGridCenterX: CGFloat { width - 40 }
|
|
}
|