Initial project setup - Phases 1-3 complete
This commit is contained in:
46
UI/Pin/PinView.swift
Normal file
46
UI/Pin/PinView.swift
Normal file
@@ -0,0 +1,46 @@
|
||||
import SwiftUI
|
||||
import ProxyCore
|
||||
import GRDB
|
||||
|
||||
struct PinView: View {
|
||||
@State private var pinnedRequests: [CapturedTraffic] = []
|
||||
@State private var observation: AnyDatabaseCancellable?
|
||||
|
||||
private let trafficRepo = TrafficRepository()
|
||||
|
||||
var body: some View {
|
||||
Group {
|
||||
if pinnedRequests.isEmpty {
|
||||
EmptyStateView(
|
||||
icon: "pin.slash",
|
||||
title: "No Pinned Requests",
|
||||
subtitle: "Pin requests from the Home tab to save them here for quick access."
|
||||
)
|
||||
} else {
|
||||
List {
|
||||
ForEach(pinnedRequests) { request in
|
||||
NavigationLink(value: request.id) {
|
||||
TrafficRowView(traffic: request)
|
||||
}
|
||||
}
|
||||
}
|
||||
.navigationDestination(for: Int64?.self) { id in
|
||||
if let id {
|
||||
RequestDetailView(trafficId: id)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
.navigationTitle("Pin")
|
||||
.task {
|
||||
observation = trafficRepo.observePinnedTraffic()
|
||||
.start(in: DatabaseManager.shared.dbPool) { error in
|
||||
print("Pin observation error: \(error)")
|
||||
} onChange: { pinned in
|
||||
withAnimation {
|
||||
pinnedRequests = pinned
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user