mirror of
https://github.com/kean/Pulse.git
synced 2026-05-30 21:07:33 +00:00
28 lines
726 B
Swift
28 lines
726 B
Swift
// The MIT License (MIT)
|
||
//
|
||
// Copyright (c) 2020–2023 Alexander Grebenyuk (github.com/kean).
|
||
|
||
#if os(macOS)
|
||
|
||
import SwiftUI
|
||
|
||
struct SelectableButton: View {
|
||
let image: Image
|
||
@Binding var isSelected: Bool
|
||
@State private var isHovering = false
|
||
|
||
var body: some View {
|
||
Button(action: { isSelected.toggle() }) {
|
||
image
|
||
.foregroundColor(isSelected ? .white : .secondary)
|
||
.padding(2)
|
||
.padding(.horizontal, 2)
|
||
.onHover { isHovering = $0 }
|
||
.background(isSelected ? Color.blue.opacity(0.8) : (isHovering ? Color.blue.opacity(0.25) : nil))
|
||
.cornerRadius(4)
|
||
}.buttonStyle(.plain)
|
||
}
|
||
}
|
||
|
||
#endif
|