crossmate

A collaborative crossword app for iOS
Log | Files | Refs | LICENSE

commit 3f15d7853e38859f2c01cad82170d1f216a8ad9b
parent 2e94cc30f10317ea8ca519fb23e549c59ca2d982
Author: Michael Camilleri <[email protected]>
Date:   Mon, 22 Jun 2026 01:20:03 +0900

Separate the random puzzle trigger from its menus

This commit reworks the random puzzle browser control so the
capsule itself no longer fetches a puzzle. Previously the whole
capsule carried the tap gesture while the weekday and year menus sat
inside it, so a tap meant for either menu — or a near-miss on the
surrounding surface — started a random puzzle instead of opening the
menu the user was attempting to hit.

Now the sentence and its two menus form an inert capsule that only
configures the choice, and a separate shuffle button beside it is the
sole trigger for fetching. The two controls no longer share a tap
target, so adjusting the day or year can no longer fire a fetch by
accident.

Co-Authored-By: Claude Opus 4.8 <[email protected]>

Diffstat:
MCrossmate/Views/Browse/NYTBrowseView.swift | 54+++++++++++++++++++++++++++++++++++-------------------
1 file changed, 35 insertions(+), 19 deletions(-)

diff --git a/Crossmate/Views/Browse/NYTBrowseView.swift b/Crossmate/Views/Browse/NYTBrowseView.swift @@ -280,30 +280,46 @@ struct NYTBrowseView: View { } private var randomButton: some View { - HStack(spacing: 4) { - Text("Random") - weekdayMenu - Text("in") - yearMenu - } - .font(.headline) - .lineLimit(1) - .minimumScaleFactor(0.7) - .foregroundStyle(Self.randomButtonForeground) - .frame(maxWidth: .infinity) - .padding(.vertical, 14) - .background(Self.randomButtonTint, in: .capsule) - .contentShape(.capsule) - .onTapGesture { - if let date = randomDate() { - fetch(date) + HStack(spacing: 12) { + HStack(spacing: 4) { + Text("Random") + weekdayMenu + Text("in") + yearMenu } + .font(.headline) + .lineLimit(1) + .minimumScaleFactor(0.7) + .foregroundStyle(Self.randomButtonForeground) + .frame(maxWidth: .infinity) + .padding(.vertical, 14) + .padding(.horizontal, 16) + .background(Self.randomButtonConfigTint, in: .capsule) + + Button { + if let date = randomDate() { + fetch(date) + } + } label: { + Image(systemName: "shuffle") + .font(.title3) + .foregroundStyle(Color.accentColor) + .frame(width: 52, height: 52) + .background(Self.randomButtonTint, in: .circle) + .contentShape(.circle) + } + .buttonStyle(.plain) + .accessibilityLabel(randomButtonAccessibilityLabel) } - .accessibilityElement(children: .combine) - .accessibilityAddTraits(.isButton) + } + + private var randomButtonAccessibilityLabel: String { + let scope = randomWeekday.map { "\(Self.weekdayName($0)) " } ?? "" + return "Fetch a random \(scope)puzzle from \(randomYear)" } private static let randomButtonTint = Color.accentColor.opacity(0.15) + private static let randomButtonConfigTint = Color(.tertiarySystemFill) private static let randomButtonForeground = Color.primary private var weekdayMenu: some View {