forked from BasedHardware/omi
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCitationCardView.swift
More file actions
75 lines (65 loc) · 2.05 KB
/
Copy pathCitationCardView.swift
File metadata and controls
75 lines (65 loc) · 2.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
import OmiTheme
import SwiftUI
/// A tappable card displaying a citation source (conversation or memory)
struct CitationCardView: View {
let citation: Citation
let onTap: () -> Void
@State private var isHovering = false
var body: some View {
Button(action: onTap) {
HStack(spacing: OmiSpacing.sm) {
// Emoji or icon
Text(citation.emoji ?? "📝")
.scaledFont(size: OmiType.subheading)
.frame(width: 24, height: 24)
VStack(alignment: .leading, spacing: OmiSpacing.hairline) {
// Title
Text(citation.title)
.scaledFont(size: OmiType.caption, weight: .medium)
.foregroundColor(Ink.primary)
.lineLimit(1)
// Preview
Text(citation.preview)
.scaledFont(size: OmiType.caption)
.foregroundColor(Ink.secondary)
.lineLimit(1)
}
Spacer()
// Chevron
Image(systemName: "chevron.right")
.scaledFont(size: OmiType.micro, weight: .medium)
.foregroundColor(Ink.secondary)
}
.padding(.horizontal, OmiSpacing.md)
.padding(.vertical, OmiSpacing.sm)
.glassCard(cornerRadius: PageGlass.chipRadius, emphasized: isHovering)
}
.buttonStyle(.plain)
.onHover { isHovering = $0 }
}
}
/// A view that displays a list of citation cards
struct CitationCardsView: View {
let citations: [Citation]
let onCitationTap: (Citation) -> Void
var body: some View {
VStack(alignment: .leading, spacing: OmiSpacing.xs) {
// Section header
HStack(spacing: OmiSpacing.xxs) {
Image(systemName: "quote.opening")
.scaledFont(size: OmiType.micro)
.foregroundColor(Ink.secondary)
Text("Sources")
.scaledFont(size: OmiType.caption, weight: .medium)
.foregroundColor(Ink.secondary)
}
.padding(.top, OmiSpacing.xxs)
// Citation cards
ForEach(citations) { citation in
CitationCardView(citation: citation) {
onCitationTap(citation)
}
}
}
}
}