|
|
@@ -0,0 +1,71 @@
|
|
|
+import SwiftUI
|
|
|
+
|
|
|
+struct QuickActionChip: View {
|
|
|
+ let action: QuickAction
|
|
|
+ let isSelected: Bool
|
|
|
+ let onSelect: () -> Void
|
|
|
+
|
|
|
+ private let iconBadgeSize: CGFloat = 26
|
|
|
+ private let iconSize: CGFloat = 13
|
|
|
+
|
|
|
+ var body: some View {
|
|
|
+ Button(action: onSelect) {
|
|
|
+ HStack(spacing: 7) {
|
|
|
+ iconBadge
|
|
|
+
|
|
|
+ Text(action.title)
|
|
|
+ .font(.system(size: 12.5, weight: .medium))
|
|
|
+ .foregroundStyle(foregroundColor)
|
|
|
+ }
|
|
|
+ .padding(.leading, 6)
|
|
|
+ .padding(.trailing, 12)
|
|
|
+ .padding(.vertical, 5)
|
|
|
+ .background(
|
|
|
+ RoundedRectangle(cornerRadius: AppTheme.cornerRadiusPill, style: .continuous)
|
|
|
+ .fill(backgroundColor)
|
|
|
+ )
|
|
|
+ .overlay(
|
|
|
+ RoundedRectangle(cornerRadius: AppTheme.cornerRadiusPill, style: .continuous)
|
|
|
+ .stroke(borderColor, lineWidth: isSelected ? 0 : 1)
|
|
|
+ )
|
|
|
+ .shadow(
|
|
|
+ color: isSelected ? AppTheme.accent.opacity(0.22) : AppTheme.cardShadow,
|
|
|
+ radius: isSelected ? 8 : 3,
|
|
|
+ y: isSelected ? 3 : 1
|
|
|
+ )
|
|
|
+ }
|
|
|
+ .buttonStyle(.plain)
|
|
|
+ .accessibilityLabel(action.title)
|
|
|
+ .accessibilityAddTraits(isSelected ? .isSelected : [])
|
|
|
+ }
|
|
|
+
|
|
|
+ private var iconBadge: some View {
|
|
|
+ RoundedRectangle(cornerRadius: 8, style: .continuous)
|
|
|
+ .fill(iconBadgeBackground)
|
|
|
+ .frame(width: iconBadgeSize, height: iconBadgeSize)
|
|
|
+ .overlay {
|
|
|
+ Image(systemName: action.symbol)
|
|
|
+ .font(.system(size: iconSize, weight: .semibold))
|
|
|
+ .foregroundStyle(foregroundColor)
|
|
|
+ .symbolRenderingMode(.hierarchical)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private var backgroundColor: Color {
|
|
|
+ isSelected ? AppTheme.accent : AppTheme.quickActionBackground
|
|
|
+ }
|
|
|
+
|
|
|
+ private var borderColor: Color {
|
|
|
+ AppTheme.quickActionBorder
|
|
|
+ }
|
|
|
+
|
|
|
+ private var foregroundColor: Color {
|
|
|
+ isSelected ? AppTheme.quickActionSelectedForeground : AppTheme.quickActionForeground
|
|
|
+ }
|
|
|
+
|
|
|
+ private var iconBadgeBackground: Color {
|
|
|
+ isSelected
|
|
|
+ ? Color.white.opacity(0.22)
|
|
|
+ : AppTheme.quickActionIconBackground
|
|
|
+ }
|
|
|
+}
|