mirror of
https://github.com/yattee/yattee.git
synced 2026-02-20 01:39:46 +00:00
Yattee v2 rewrite
This commit is contained in:
40
Yattee/Views/Home/TVHomeButtonStyles.swift
Normal file
40
Yattee/Views/Home/TVHomeButtonStyles.swift
Normal file
@@ -0,0 +1,40 @@
|
||||
//
|
||||
// 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
|
||||
Reference in New Issue
Block a user