Something went wrong. Try again.
Something went wrong. Try again.
730 B · 32 lines
Swift
at main
123456789101112131415161718192021222324252627282930313233//// LoadingButtonStyle.swift// shortcut//// Created by Bailey Townsend on 7/21/25.//
import Foundationimport SwiftUI
struct LoadingButtonStyle: ButtonStyle { @Environment(\.isEnabled) private var isEnabled private var isLoading: Bool
init(isLoading: Bool) { self.isLoading = isLoading }
func makeBody(configuration: Configuration) -> some View { HStack(spacing: 8) { if isLoading { ProgressView() }
configuration.label } .foregroundStyle(Color.accentColor) .opacity(configuration.isPressed ? 0.2 : 1) .animation(.default, value: isEnabled) .animation(.default, value: isLoading) }}