Files
yattee/Yattee/Views/Home/HomeShortcutRowView.swift
Arkadiusz Fal 6df80c0e79 Use user-selected accent color in Home, Subscriptions, and Downloads
Color.accentColor and .foregroundStyle(.tint) resolve to the asset
catalog accent on macOS, so Home shortcut cards, section header
links, the Subscriptions "All channels" header, and the Downloads
per-channel group headers stayed blue when the user picked a
different accent. Read the color from SettingsManager and apply it
directly, matching the pattern already used for the Play button.
2026-04-23 22:55:48 +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.accentColor.color ?? .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
}
}