feat: Product card fade-in animation

This commit is contained in:
X1a0He
2025-03-27 20:51:02 +08:00
parent bdc698b3e4
commit febf8d4a45
4 changed files with 26 additions and 4 deletions

View File

@@ -48,8 +48,8 @@
endingColumnNumber = "9223372036854775807" endingColumnNumber = "9223372036854775807"
startingLineNumber = "724" startingLineNumber = "724"
endingLineNumber = "724" endingLineNumber = "724"
landmarkName = "alertAction()" landmarkName = "errorDescription"
landmarkType = "7"> landmarkType = "24">
</BreakpointContent> </BreakpointContent>
</BreakpointProxy> </BreakpointProxy>
</Breakpoints> </Breakpoints>

View File

@@ -36,7 +36,7 @@ class AppDelegate: NSObject, NSApplicationDelegate {
} }
if let window = NSApp.windows.first { if let window = NSApp.windows.first {
window.minSize = NSSize(width: 792, height: 600) window.minSize = NSSize(width: 800, height: 765)
} }
eventMonitor = NSEvent.addLocalMonitorForEvents(matching: .keyDown) { [weak self] event in eventMonitor = NSEvent.addLocalMonitorForEvents(matching: .keyDown) { [weak self] event in

View File

@@ -81,6 +81,8 @@ struct ProductGridView: View {
) { ) {
ForEach(products, id: \.id) { uniqueProduct in ForEach(products, id: \.id) { uniqueProduct in
AppCardView(uniqueProduct: uniqueProduct) AppCardView(uniqueProduct: uniqueProduct)
.id(uniqueProduct.id)
.modifier(AppearAnimationModifier())
} }
} }
.padding() .padding()
@@ -97,4 +99,24 @@ struct ProductGridView: View {
} }
.background(Color(.clear)) .background(Color(.clear))
} }
}
struct AppearAnimationModifier: ViewModifier {
@State private var opacity: Double = 0
@State private var offset: CGFloat = 20
@State private var scale: CGFloat = 0.95
func body(content: Content) -> some View {
content
.opacity(opacity)
.offset(y: offset)
.scaleEffect(scale)
.onAppear {
withAnimation(.easeInOut(duration: 0.5)) {
opacity = 1
offset = 0
scale = 1
}
}
}
} }

View File

@@ -25,7 +25,7 @@ struct BeautifulSearchField: View {
.padding(8) .padding(8)
.background( .background(
RoundedRectangle(cornerRadius: 8) RoundedRectangle(cornerRadius: 8)
.fill(Color(NSColor.controlBackgroundColor).opacity(0.8)) .fill(Color(NSColor.controlBackgroundColor).opacity(0.3))
.overlay( .overlay(
RoundedRectangle(cornerRadius: 8) RoundedRectangle(cornerRadius: 8)
.stroke(Color.secondary.opacity(0.1), lineWidth: 1) .stroke(Color.secondary.opacity(0.1), lineWidth: 1)