mirror of
https://github.com/yattee/yattee.git
synced 2026-02-20 09:49:46 +00:00
41 lines
1.3 KiB
Swift
41 lines
1.3 KiB
Swift
//
|
|
// TVHomeButtonStyles.swift
|
|
// Yattee
|
|
//
|
|
// Button styles for tvOS Home view.
|
|
//
|
|
|
|
#if os(tvOS)
|
|
import SwiftUI
|
|
|
|
/// Button style for Home cards with scale + opacity focus effect.
|
|
struct TVHomeCardButtonStyle: ButtonStyle {
|
|
@Environment(\.isFocused) private var isFocused
|
|
|
|
func makeBody(configuration: Configuration) -> some View {
|
|
configuration.label
|
|
.scaleEffect(configuration.isPressed ? 0.95 : (isFocused ? 1.05 : 1.0))
|
|
.animation(.easeInOut(duration: 0.15), value: isFocused)
|
|
.animation(.easeInOut(duration: 0.1), value: configuration.isPressed)
|
|
}
|
|
}
|
|
|
|
/// Button style for list rows with card background + focus effect.
|
|
struct TVHomeRowButtonStyle: ButtonStyle {
|
|
@Environment(\.isFocused) private var isFocused
|
|
|
|
func makeBody(configuration: Configuration) -> some View {
|
|
configuration.label
|
|
.padding(.horizontal, 20)
|
|
.padding(.vertical, 16)
|
|
.background(
|
|
RoundedRectangle(cornerRadius: 12)
|
|
.fill(isFocused ? .white.opacity(0.15) : .white.opacity(0.05))
|
|
)
|
|
.scaleEffect(configuration.isPressed ? 0.98 : (isFocused ? 1.02 : 1.0))
|
|
.animation(.easeInOut(duration: 0.15), value: isFocused)
|
|
.animation(.easeInOut(duration: 0.1), value: configuration.isPressed)
|
|
}
|
|
}
|
|
#endif
|