From adc146278a2f16ef85e8d63f52cfb17f17bec9e0 Mon Sep 17 00:00:00 2001 From: Alin Date: Fri, 18 Oct 2024 10:00:12 -0600 Subject: [PATCH] Cleanup --- Pearcleaner/Logic/Styles.swift | 48 +++++++++++++++++++++++++++++ Pearcleaner/Views/RegularMode.swift | 40 +++++------------------- 2 files changed, 56 insertions(+), 32 deletions(-) diff --git a/Pearcleaner/Logic/Styles.swift b/Pearcleaner/Logic/Styles.swift index 94acdbc..61e2ded 100644 --- a/Pearcleaner/Logic/Styles.swift +++ b/Pearcleaner/Logic/Styles.swift @@ -341,3 +341,51 @@ func backgroundView(themeManager: ThemeManager = ThemeManager.shared, darker: Bo } } + + +struct GlowGradientButton: View { + // Define gradient colors for the button + let gradientColors = Gradient(colors: [.blue,.purple,.pink,.red,.blue]) + + // State variables to control animation and press state + @State var isAnimating = false + @State var isPressed = false + + var body: some View { + ZStack{ + // Background of the button with stroke, blur, and offset effects + RoundedRectangle(cornerRadius: 20) + .stroke(AngularGradient(gradient: gradientColors, center: .center, angle: .degrees(isAnimating ? 360 : 0)), lineWidth: 10) + .blur(radius: 30) + // .offset(y: 30) // Move the glow up or down + .frame(width: 230, height: 30) + + // Text label for the button + Text(verbatim: "Hello") + .font(.system(size: 24)) + .frame(width: 280, height: 60) + .background(.quinary.opacity(0.2), in: RoundedRectangle(cornerRadius: 20)) + .foregroundStyle(.white) + .overlay( + // Overlay to create glow effect + RoundedRectangle(cornerRadius: 20) + .stroke(AngularGradient(gradient: gradientColors, center: .center, angle: .degrees(isAnimating ? 360 : 0)), lineWidth: 2) + ) + } + // Scale effect when pressed + .scaleEffect(isPressed ? 0.95 : 1) + .animation(.easeInOut(duration: 0.2), value: isPressed) + .onAppear() { + // Animation to rotate gradient colors infinitely + withAnimation(.linear(duration: 3).repeatForever(autoreverses: false)) { + isAnimating = true + } + } + // Gesture to detect button press + .simultaneousGesture( + DragGesture(minimumDistance: 0) + .onChanged({_ in isPressed = true}) + .onEnded({_ in isPressed = false}) + ) + } +} diff --git a/Pearcleaner/Views/RegularMode.swift b/Pearcleaner/Views/RegularMode.swift index 9562e57..d3c3bb0 100644 --- a/Pearcleaner/Views/RegularMode.swift +++ b/Pearcleaner/Views/RegularMode.swift @@ -70,7 +70,7 @@ struct RegularMode: View { Spacer() Group { if appState.currentView == .empty || appState.currentView == .apps { - AppDetailsEmptyView(showPopover: $showPopover) + AppDetailsEmptyView() } else if appState.currentView == .files { FilesView(showPopover: $showPopover, search: $search) .id(appState.appInfo.id) @@ -139,12 +139,10 @@ struct RegularMode: View { struct AppDetailsEmptyView: View { - @Environment(\.colorScheme) var colorScheme - @EnvironmentObject var appState: AppState - @EnvironmentObject var locations: Locations - // @AppStorage("settings.general.animateLogo") private var animateLogo: Bool = true - @Binding var showPopover: Bool - // @State private var animationStart = false +// @Environment(\.colorScheme) var colorScheme +// @EnvironmentObject var appState: AppState +// @EnvironmentObject var locations: Locations +// @Binding var showPopover: Bool var body: some View { VStack(alignment: .center) { @@ -152,34 +150,12 @@ struct AppDetailsEmptyView: View { Spacer() PearDropView() - // if #available(macOS 14, *) { - // if animateLogo && animationStart { - // PearDropView() - // .phaseAnimator([false, true]) { wwdc24, chromaRotate in - // wwdc24 - // .hueRotation(.degrees(chromaRotate ? 420 : 0)) - // } animation: { chromaRotate in - // .easeInOut(duration: 6) - // } - // } else { - // PearDropView() - // } - // - // } else { - // PearDropView() - // } + +// GlowGradientButton() Spacer() - // Text("Drop an app here") - // .font(.title3) - // .padding(.bottom, 25) - // .opacity(0.5) } - // .onAppear { - // DispatchQueue.main.asyncAfter(deadline: .now() + 1) { - // animationStart = true - // } - // } + } }