mirror of
https://github.com/FBukovina/Atoll.git
synced 2026-10-27 15:14:33 +00:00
35 lines
1.1 KiB
Swift
35 lines
1.1 KiB
Swift
//
|
|
// Button+Bouncing.swift
|
|
// boringNotch
|
|
//
|
|
// Created by Harsh Vardhan Goswami on 19/08/24.
|
|
//
|
|
import SwiftUI
|
|
import Defaults
|
|
|
|
struct BouncingButtonStyle: ButtonStyle {
|
|
let vm: DynamicIslandViewModel
|
|
@State private var isPressed = false
|
|
|
|
func makeBody(configuration: Configuration) -> some View {
|
|
configuration.label
|
|
.padding(12)
|
|
.background(
|
|
RoundedRectangle(cornerRadius: Defaults[.cornerRadiusScaling] ? 10 : MusicPlayerImageSizes.cornerRadiusInset.closed)
|
|
.fill(Color(red: 20/255, green: 20/255, blue: 20/255))
|
|
.strokeBorder(.white.opacity(0.04), lineWidth: 1)
|
|
)
|
|
.scaleEffect(isPressed ? 0.9 : 1.0)
|
|
.onChange(of: configuration.isPressed) { _, _ in
|
|
withAnimation(.spring(response: 0.3, dampingFraction: 0.3, blendDuration: 0.3)) {
|
|
isPressed.toggle()
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
extension Button {
|
|
func bouncingStyle(vm: DynamicIslandViewModel) -> some View {
|
|
self.buttonStyle(BouncingButtonStyle(vm: vm))
|
|
}
|
|
}
|