diff --git a/ApplicationLibrary/Views/Connections/ConnectionListView.swift b/ApplicationLibrary/Views/Connections/ConnectionListView.swift index f45f897..a27b003 100644 --- a/ApplicationLibrary/Views/Connections/ConnectionListView.swift +++ b/ApplicationLibrary/Views/Connections/ConnectionListView.swift @@ -16,13 +16,13 @@ public struct ConnectionListView: View { Text("Empty connections") } else { ScrollView { - LazyVGrid(columns: [GridItem(.flexible())], alignment: .leading) { + VStack { ForEach(viewModel.filteredConnections(), id: \.id) { it in ConnectionView(it) } } + .padding() } - .padding() } } } diff --git a/ApplicationLibrary/Views/Connections/ConnectionView.swift b/ApplicationLibrary/Views/Connections/ConnectionView.swift index cc93c52..4dfcae9 100644 --- a/ApplicationLibrary/Views/Connections/ConnectionView.swift +++ b/ApplicationLibrary/Views/Connections/ConnectionView.swift @@ -19,71 +19,67 @@ public struct ConnectionView: View { } @State private var alert: AlertState? + @State private var showDetails = false public var body: some View { - FormNavigationLink { - ConnectionDetailsView(connection) + Button { + showDetails = true } label: { - VStack { - HStack { - VStack(alignment: .leading) { - HStack(alignment: .center) { - Text("\(connection.network.uppercased()) \(connection.displayDestination)") - Spacer() - if connection.closedAt == nil { - Text("Active").foregroundStyle(.green) - } else { - Text("Closed").foregroundStyle(.red) - } + HStack { + VStack(alignment: .leading) { + HStack(alignment: .center) { + Text("\(connection.network.uppercased()) \(connection.displayDestination)") + Spacer() + if connection.closedAt == nil { + Text("Active").foregroundStyle(.green) + } else { + Text("Closed").foregroundStyle(.red) } - .font(.caption2.monospaced().bold()) - .padding([.bottom], 4) - HStack { - if let closedAt = connection.closedAt { - VStack(alignment: .leading) { - Text("↑ \(LibboxFormatBytes(connection.uploadTotal))") - Text("↓ \(LibboxFormatBytes(connection.downloadTotal))") - } - .font(.caption2) - VStack(alignment: .leading) { - Text(format(connection.createdAt)) - Text(formatInterval(connection.createdAt, closedAt)) - } - Spacer() - VStack(alignment: .trailing) { - Text(connection.inboundType + "/" + connection.inbound) - Text(connection.chain.reversed().joined(separator: "/")) - } - } else { - VStack(alignment: .leading) { - Text("↑ \(LibboxFormatBytes(connection.upload))/s") - Text("↓ \(LibboxFormatBytes(connection.download))/s") - } - .font(.caption2) - VStack(alignment: .leading) { - Text(LibboxFormatBytes(connection.uploadTotal)) - Text(LibboxFormatBytes(connection.downloadTotal)) - } - Spacer() - VStack(alignment: .trailing) { - Text(connection.inboundType + "/" + connection.inbound) - Text(connection.chain[0]) - } - } - } - .font(.caption2.monospaced()) } + .font(.caption2.monospaced().bold()) + .padding([.bottom], 4) + HStack { + if let closedAt = connection.closedAt { + VStack(alignment: .leading) { + Text("↑ \(LibboxFormatBytes(connection.uploadTotal))") + Text("↓ \(LibboxFormatBytes(connection.downloadTotal))") + } + .font(.caption2) + VStack(alignment: .leading) { + Text(format(connection.createdAt)) + Text(formatInterval(connection.createdAt, closedAt)) + } + Spacer() + VStack(alignment: .trailing) { + Text(connection.inboundType + "/" + connection.inbound) + Text(connection.chain.reversed().joined(separator: "/")) + } + } else { + VStack(alignment: .leading) { + Text("↑ \(LibboxFormatBytes(connection.upload))/s") + Text("↓ \(LibboxFormatBytes(connection.download))/s") + } + .font(.caption2) + VStack(alignment: .leading) { + Text(LibboxFormatBytes(connection.uploadTotal)) + Text(LibboxFormatBytes(connection.downloadTotal)) + } + Spacer() + VStack(alignment: .trailing) { + Text(connection.inboundType + "/" + connection.inbound) + Text(connection.chain[0]) + } + } + } + .font(.caption2.monospaced()) } - .foregroundColor(.textColor) - #if !os(tvOS) - .padding(16) - .cardStyle() - #endif } - .background(.clear) + .foregroundColor(.textColor) } #if !os(tvOS) - .buttonStyle(.borderless) + .buttonStyle(.plain) + .padding(16) + .cardStyle() #endif .alert($alert) .contextMenu { @@ -96,6 +92,14 @@ public struct ConnectionView: View { .frame(maxWidth: .infinity, alignment: .leading) } } + .background { + NavigationLink(isActive: $showDetails) { + ConnectionDetailsView(connection) + } label: { + EmptyView() + } + .opacity(0) + } } private nonisolated func closeConnection() async {