Files
yattee/Yattee/Views/Home/HomeShortcutRowView.swift
Arkadiusz Fal b47888fe04 Add custom accent color with system color picker
Add a Custom swatch to the appearance settings accent color grid,
backed by a hex value stored in settings (synced via iCloud like the
rest). iOS uses the native ColorPicker wheel; macOS uses a circular
swatch that opens NSColorPanel, since the SwiftUI color well looks out
of place among the circles. All accent consumers now read the resolved
color through SettingsManager.resolvedAccentColor.

The indigo preset is retired from the grid but kept in the enum, so
users who selected it keep their color until they pick another one.

Claude-Session: https://claude.ai/code/session_0154KH8RAVAvm6iVanhmoW8o
2026-07-04 23:57:59 +02:00

84 lines
2.1 KiB
Swift

//
// HomeShortcutRowView.swift
// Yattee
//
// Row component for home shortcuts in list layout.
//
import SwiftUI
struct HomeShortcutRowView<StatusIndicator: View>: View {
@Environment(\.appEnvironment) private var appEnvironment
let icon: String
let title: String
let subtitle: String
var statusIndicator: StatusIndicator?
private var accentColor: Color {
appEnvironment?.settingsManager.resolvedAccentColor ?? .accentColor
}
init(
icon: String,
title: String,
subtitle: String,
statusIndicator: StatusIndicator?
) {
self.icon = icon
self.title = title
self.subtitle = subtitle
self.statusIndicator = statusIndicator
}
var body: some View {
HStack(spacing: 12) {
Image(systemName: icon)
.font(.title3)
.foregroundStyle(accentColor)
.frame(width: 28)
VStack(alignment: .leading, spacing: 2) {
HStack(spacing: 4) {
Text(title)
.font(.body)
.fontWeight(.medium)
.foregroundStyle(.primary)
if let statusIndicator {
statusIndicator
}
}
if !subtitle.isEmpty {
Text(subtitle)
.font(.caption)
.foregroundStyle(.secondary)
}
}
Spacer()
Image(systemName: "chevron.right")
.font(.caption)
.fontWeight(.semibold)
.foregroundStyle(.tertiary)
}
.contentShape(Rectangle())
}
}
// MARK: - Convenience Initializer (no status indicator)
extension HomeShortcutRowView where StatusIndicator == EmptyView {
init(
icon: String,
title: String,
subtitle: String
) {
self.icon = icon
self.title = title
self.subtitle = subtitle
self.statusIndicator = nil
}
}