- Move AnnotationColor enum to Constants.swift for centralized color management - Add hexColor property to provide hex values for JavaScript overlays - Add cssColorWithOpacity method for flexible opacity control - Update NativeWebView and WebView to use centralized color values - Replace modal color picker with inline overlay for better UX - Implement annotation creation directly from text selection - Add API endpoint for creating annotations with selectors
46 lines
1.3 KiB
Swift
46 lines
1.3 KiB
Swift
import SwiftUI
|
|
|
|
struct AnnotationColorOverlay: View {
|
|
let onColorSelected: (AnnotationColor) -> Void
|
|
@Environment(\.colorScheme) private var colorScheme
|
|
|
|
var body: some View {
|
|
HStack(spacing: 8) {
|
|
ForEach(Constants.annotationColors, id: \.self) { color in
|
|
ColorButton(color: color, onTap: onColorSelected)
|
|
}
|
|
}
|
|
.padding(8)
|
|
.background(
|
|
RoundedRectangle(cornerRadius: 12)
|
|
.fill(.ultraThinMaterial)
|
|
.shadow(color: Color.black.opacity(0.2), radius: 8, x: 0, y: 2)
|
|
)
|
|
}
|
|
|
|
private struct ColorButton: View {
|
|
let color: AnnotationColor
|
|
let onTap: (AnnotationColor) -> Void
|
|
@Environment(\.colorScheme) private var colorScheme
|
|
|
|
var body: some View {
|
|
Button(action: { onTap(color) }) {
|
|
Circle()
|
|
.fill(color.swiftUIColor(isDark: colorScheme == .dark))
|
|
.frame(width: 36, height: 36)
|
|
.overlay(
|
|
Circle()
|
|
.stroke(Color.primary.opacity(0.15), lineWidth: 1)
|
|
)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
#Preview {
|
|
AnnotationColorOverlay { color in
|
|
print("Selected: \(color)")
|
|
}
|
|
.padding()
|
|
}
|