-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathSearchResultRow.swift
57 lines (49 loc) · 1.66 KB
/
SearchResultRow.swift
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
//
// SearchResultRow.swift
// PowerSyncExample
//
// Created by Wade Morris on 4/9/25.
//
import SwiftUI
struct SearchResultRow: View {
let item: SearchResultItem
var body: some View {
HStack {
Image(systemName: item.type == .list ? "list.bullet" : "checkmark.circle")
.foregroundColor(.secondary)
if let list = item.listContent {
Text(list.name)
} else if let todo = item.todo {
Text(todo.description)
.strikethrough(todo.isComplete, color: .secondary)
.foregroundColor(todo.isComplete ? .secondary : .primary)
} else {
Text("Unknown item")
}
Spacer()
Image(systemName: "chevron.right")
.font(.caption.weight(.bold))
.foregroundColor(.secondary.opacity(0.5))
}
.contentShape(Rectangle())
}
}
#Preview {
List {
SearchResultRow(item: SearchResultItem(
id: UUID().uuidString,
type: .list,
content: ListContent(id: UUID().uuidString, name: "Groceries", createdAt: "now", ownerId: "user1")
))
SearchResultRow(item: SearchResultItem(
id: UUID().uuidString,
type: .todo,
content: Todo(id: UUID().uuidString, listId: "list1", description: "Buy milk", isComplete: false)
))
SearchResultRow(item: SearchResultItem(
id: UUID().uuidString,
type: .todo,
content: Todo(id: UUID().uuidString, listId: "list1", description: "Walk the dog", isComplete: true)
))
}
}