mirror of
https://github.com/FBukovina/Atoll.git
synced 2026-10-27 15:14:33 +00:00
46 lines
1.3 KiB
Swift
46 lines
1.3 KiB
Swift
//
|
|
// HoverButton.swift
|
|
// boringNotch
|
|
//
|
|
// Created by Kraigo on 04.09.2024.
|
|
//
|
|
|
|
import SwiftUI
|
|
|
|
struct HoverButton: View {
|
|
var icon: String
|
|
var iconColor: Color = .white;
|
|
var scale: Image.Scale = .medium
|
|
var action: () -> Void
|
|
var contentTransition: ContentTransition = .symbolEffect;
|
|
|
|
@State private var isHovering = false
|
|
|
|
var body: some View {
|
|
let size = CGFloat(scale == .large ? 40 : 30)
|
|
|
|
Button(action: action) {
|
|
Rectangle()
|
|
.fill(.clear)
|
|
.contentShape(Rectangle())
|
|
.frame(width: size, height: size)
|
|
.overlay {
|
|
Capsule()
|
|
.fill(isHovering ? Color.gray.opacity(0.2) : .clear)
|
|
.frame(width: size, height: size)
|
|
.overlay {
|
|
Image(systemName: icon)
|
|
.foregroundColor(iconColor)
|
|
.contentTransition(contentTransition)
|
|
.font(scale == .large ? .largeTitle : .body)
|
|
}
|
|
}
|
|
}
|
|
.buttonStyle(PlainButtonStyle())
|
|
.onHover { hovering in
|
|
withAnimation(.smooth(duration: 0.3)) {
|
|
isHovering = hovering
|
|
}
|
|
}
|
|
}
|
|
}
|