Sfoglia il codice sorgente

Add hover feedback and red delete styling on the history page.

Co-authored-by: Cursor <cursoragent@cursor.com>
AhtashamShahzad1 1 mese fa
parent
commit
5cdf5a2e10

+ 39 - 0
Reddit App/Utilities/InteractiveHoverStyle.swift

@@ -64,6 +64,45 @@ struct AppSecondaryButtonStyle: ButtonStyle {
     }
 }
 
+struct AppDestructiveButtonStyle: ButtonStyle {
+    private static let destructiveColor = Color(hex: 0xEF4444)
+
+    @State private var isHovered = false
+
+    func makeBody(configuration: Configuration) -> some View {
+        configuration.label
+            .foregroundStyle(Self.destructiveColor)
+            .padding(.horizontal, 12)
+            .padding(.vertical, 8)
+            .background(destructiveBackground(isPressed: configuration.isPressed))
+            .clipShape(RoundedRectangle(cornerRadius: 8))
+            .overlay(
+                RoundedRectangle(cornerRadius: 8)
+                    .stroke(
+                        isHovered || configuration.isPressed
+                            ? Self.destructiveColor.opacity(0.55)
+                            : Self.destructiveColor.opacity(0.25),
+                        lineWidth: 1
+                    )
+            )
+            .scaleEffect(configuration.isPressed ? AppTheme.hoverPressScale : (isHovered ? AppTheme.hoverLiftScale : 1))
+            .animation(AppTheme.hoverAnimation, value: isHovered)
+            .animation(AppTheme.hoverAnimation, value: configuration.isPressed)
+            .onHover { isHovered = $0 }
+            .hoverCursor()
+    }
+
+    private func destructiveBackground(isPressed: Bool) -> Color {
+        if isPressed {
+            return Self.destructiveColor.opacity(0.18)
+        }
+        if isHovered {
+            return Self.destructiveColor.opacity(0.12)
+        }
+        return Self.destructiveColor.opacity(0.08)
+    }
+}
+
 struct AppPrimaryButtonStyle: ButtonStyle {
     @State private var isHovered = false
 

+ 3 - 2
Reddit App/Views/AIHistoryView.swift

@@ -80,7 +80,7 @@ struct AIHistoryView: View {
                         Label("Delete All", systemImage: "trash")
                             .font(.system(size: 11, weight: .medium))
                     }
-                    .buttonStyle(AppSecondaryButtonStyle())
+                    .buttonStyle(AppDestructiveButtonStyle())
                 }
             }
             .padding(.horizontal, Layout.horizontalPadding)
@@ -233,7 +233,7 @@ private struct AIHistoryRowView: View {
                     Image(systemName: "trash")
                         .font(.system(size: 10, weight: .medium))
                 }
-                .buttonStyle(AppSecondaryButtonStyle())
+                .buttonStyle(AppDestructiveButtonStyle())
             }
         }
         .padding(14)
@@ -245,6 +245,7 @@ private struct AIHistoryRowView: View {
                         .stroke(AppTheme.cardBorder, lineWidth: 1)
                 )
         )
+        .hoverCard(cornerRadius: AppTheme.cornerRadiusSmall)
     }
 }