Files
ProxyIOS/UI/Pin/PinView.swift
2026-04-06 11:28:40 -05:00

47 lines
1.5 KiB
Swift

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
}
}
}
}
}