DroppyWashChoiceButtonStyle

One option of a two- or three-way choice drawn on the shelf: Pomodoro's Focus / Break pill, Droppy's own ShelfWashChoiceButtonStyle (1.22.0).

@MainActor struct DroppyWashChoiceButtonStyle

Every switch a built-in widget draws is this pill (the Agents widget's Progress / Usage, the Notifications filter, Pomodoro's phases), never a segmented Picker, a slider with a glass thumb, or two accent and quiet buttons swapping styles. 24pt high (height), 12pt semibold rounded type 9pt in from each end; the chosen option in the widget's colour at 25% under ink of that colour, the others white at 12% under 55% ink. With a symbol and no title (a paired card, a band too narrow for the words) it is the same choice on Pomodoro's 24pt disc: pass isIconOnly. Lay the options out spacing apart, Focus and Break's gap:

HStack(spacing: DroppyWashChoiceButtonStyle.spacing) {
    ForEach(Mode.allCases) { mode in
        Button(mode.title) { selection = mode }
            .buttonStyle(DroppyWashChoiceButtonStyle(
                isSelected: selection == mode,
                accent: .orange,
                usesAdaptiveForegrounds: context.usesAdaptiveForegrounds
            ))
    }
}

The pill carries the selected trait for VoiceOver; give the option an accessibility label when it is icon-only. A boolean on the shelf is a single DroppyWashCircleButtonStyle that takes the accent while it is on, not a two-option choice; on a Settings page it is a Toggle.

Added in 1.22.0; a droplet that uses it declares minAPI 1.22.0.

Initializers

init(isSelected:accent:isIconOnly:usesAdaptiveForegrounds:)

@MainActor init(isSelected: Bool, accent: Color, isIconOnly: Bool = false, usesAdaptiveForegrounds: Bool = false)

Creates the style for one option.

  • Parameters:
  • isSelected: Whether this option is the chosen one.
  • accent: The widget's own colour, which the chosen option takes (Pomodoro: the phase's).
  • isIconOnly: true draws the option as a 24pt disc for a symbol with no title.
  • usesAdaptiveForegrounds: Pass usesAdaptiveForegrounds.

Type properties

height

@MainActor static let height: CGFloat

The pill's and the disc's height: row.

spacing

@MainActor static let spacing: CGFloat

Focus and Break's gap between two options.

Methods

makeBody(configuration:)

@MainActor func makeBody(configuration: Configuration) -> some View