Branchwell

Jotley / app / macOS / Views / ButtonStyles.swift

1//
2// ButtonStyles.swift
3// Jotley
4//
5// Button styles extracted from NoteDetailPlaceholderView+Body.swift
6//
7
8import SwiftUI
9import AppKit
10
11
12// MARK: - Create Note Button Style
13
14struct CreateNoteButtonStyle: ButtonStyle {
15 let isPrimary: Bool
16 @State private var isHovering = false
17
18 func makeBody(configuration: Configuration) -> some View {
19 configuration.label
20 .brightness(isHovering ? (isPrimary ? 0.08 : 0.05) : 0)
21 .scaleEffect(configuration.isPressed ? 0.97 : 1.0)
22 .animation(.spring(response: 0.25, dampingFraction: 0.7), value: configuration.isPressed)
23 .animation(.easeOut(duration: 0.2), value: isHovering)
24 .onHover { hovering in
25 isHovering = hovering
26 if hovering {
27 NSCursor.pointingHand.set()
28 } else {
29 NSCursor.arrow.set()
30 }
31 }
32 }
33}