3.6 KiB
Cooldown Quick Action Buttons — Design Spec
Overview
When a cooldown (drug, medical, booster) reaches 0 ("Ready"), the cooldown cell transforms into a clickable button that opens the corresponding Items subsection on Torn's website. For the booster cooldown, the user can configure in Settings whether the link targets boosters or alcohol.
UI Changes
Cooldown Cells (LiveCooldownItem / CooldownItem)
Both views gain new optional parameters: actionURL: URL? and actionLabel: String?. The existing icon parameter remains unused (no change). Both views add @Environment(\.reduceTransparency) private var reduceTransparency to read the accessibility setting, consistent with how other views in the project access it.
When remaining == 0 and actionURL is provided:
- Background:
Color.green.opacity(reduceTransparency ? 0.25 : 0.12)fill - Border:
Color.green.opacity(reduceTransparency ? 0.4 : 0.25),cornerRadius(6) - Action label: Below "Ready" text, the
actionLabelrendered in.caption2font atopacity(0.7). The label includes a trailing arrow for visual display:- Drug: "Use Drug →"
- Medical: "Use Medical →"
- Booster: "Use Booster →" or "Use Alcohol →" (depending on setting)
- Behavior: Entire cell wrapped in a
Buttonwith.buttonStyle(.plain)that callsBrowserManager.shared.open(url) - Accessibility:
.accessibilityLabel("Use \(label)")(without the arrow) and.accessibilityHint("Opens Torn items page in browser")
When cooldown > 0 or no actionURL: no visual or behavioral change from current implementation.
CooldownItem (the non-live fallback used when appState.lastUpdated is nil) receives the same actionURL/actionLabel parameters and renders the button treatment identically when seconds == 0.
Target URLs
| Cooldown | URL |
|---|---|
| Drug | https://www.torn.com/item.php#drugs-items |
| Medical | https://www.torn.com/item.php#medical-items |
| Booster (boosters) | https://www.torn.com/item.php#boosters-items |
| Booster (alcohol) | https://www.torn.com/item.php#alcohol-items |
Settings
New option in SettingsView: "Booster cooldown link"
Pickerwith two choices: "Boosters" (default), "Alcohol"- Stored in
@AppStorage("boosterCooldownTarget")asString— value"boosters"or"alcohol" - Placed after the existing Reduce Transparency toggle in the settings layout
- Uses an icon following the existing HStack icon pattern (e.g.,
"arrow.up.circle.fill") - Always visible (does not depend on cooldown state or API connection)
Data Flow
- Add
@AppStorage("boosterCooldownTarget") private var boosterCooldownTarget: String = "boosters"as a property onStatusView cooldownsSectioninStatusViewconstructs the URLs and labels:- Drug and Medical: static URLs and labels
- Booster: reads
boosterCooldownTargetto determine which URL and label to use
LiveCooldownItemandCooldownItemreceiveactionURLandactionLabelas parameters — they don't read settings themselves- URL opening is delegated to
BrowserManager.shared.open()(respects preferred browser setting)
Scope — What Does NOT Change
- Cooldown notifications in
AppState— unchanged AppStatelogic — no modifications (feature is view-layer only)- Quick Links section — unchanged
- Cooldown behavior when timer > 0 — unchanged
- The
iconparameter on cooldown views — remains accepted but unused
Visual Reference
Style C from brainstorming: entire cooldown cell becomes a clickable button with green background, border, and subtle action text when ready.