This commit is contained in:
Alin
2024-10-18 10:00:12 -06:00
parent 94b1292fc6
commit adc146278a
2 changed files with 56 additions and 32 deletions
+48
View File
@@ -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})
)
}
}
+8 -32
View File
@@ -70,7 +70,7 @@ struct RegularMode: View {
Spacer() Spacer()
Group { Group {
if appState.currentView == .empty || appState.currentView == .apps { if appState.currentView == .empty || appState.currentView == .apps {
AppDetailsEmptyView(showPopover: $showPopover) AppDetailsEmptyView()
} else if appState.currentView == .files { } else if appState.currentView == .files {
FilesView(showPopover: $showPopover, search: $search) FilesView(showPopover: $showPopover, search: $search)
.id(appState.appInfo.id) .id(appState.appInfo.id)
@@ -139,12 +139,10 @@ struct RegularMode: View {
struct AppDetailsEmptyView: View { struct AppDetailsEmptyView: View {
@Environment(\.colorScheme) var colorScheme // @Environment(\.colorScheme) var colorScheme
@EnvironmentObject var appState: AppState // @EnvironmentObject var appState: AppState
@EnvironmentObject var locations: Locations // @EnvironmentObject var locations: Locations
// @AppStorage("settings.general.animateLogo") private var animateLogo: Bool = true // @Binding var showPopover: Bool
@Binding var showPopover: Bool
// @State private var animationStart = false
var body: some View { var body: some View {
VStack(alignment: .center) { VStack(alignment: .center) {
@@ -152,34 +150,12 @@ struct AppDetailsEmptyView: View {
Spacer() Spacer()
PearDropView() PearDropView()
// if #available(macOS 14, *) {
// if animateLogo && animationStart { // GlowGradientButton()
// PearDropView()
// .phaseAnimator([false, true]) { wwdc24, chromaRotate in
// wwdc24
// .hueRotation(.degrees(chromaRotate ? 420 : 0))
// } animation: { chromaRotate in
// .easeInOut(duration: 6)
// }
// } else {
// PearDropView()
// }
//
// } else {
// PearDropView()
// }
Spacer() Spacer()
// Text("Drop an app here")
// .font(.title3)
// .padding(.bottom, 25)
// .opacity(0.5)
} }
// .onAppear {
// DispatchQueue.main.asyncAfter(deadline: .now() + 1) {
// animationStart = true
// }
// }
} }
} }