mirror of
https://github.com/kean/Pulse.git
synced 2026-05-30 21:07:33 +00:00
42 lines
1.2 KiB
Swift
42 lines
1.2 KiB
Swift
// The MIT License (MIT)
|
|
//
|
|
// Copyright (c) 2020-2026 Alexander Grebenyuk (github.com/kean).
|
|
|
|
import SwiftUI
|
|
import Pulse
|
|
|
|
@available(iOS 18, tvOS 18, macOS 15, watchOS 11, visionOS 1, *)
|
|
struct NetworkRequestBodyCell: View {
|
|
let viewModel: NetworkRequestBodyCellViewModel
|
|
|
|
var body: some View {
|
|
NavigationLink(destination: destination) {
|
|
NetworkMenuCell(
|
|
icon: "arrow.up.circle.fill",
|
|
tintColor: .blue,
|
|
title: "Request Body",
|
|
details: viewModel.details
|
|
)
|
|
}
|
|
.foregroundColor(viewModel.isEnabled ? nil : .secondary)
|
|
.disabled(!viewModel.isEnabled)
|
|
}
|
|
|
|
private var destination: some View {
|
|
NetworkInspectorRequestBodyView(viewModel: viewModel.detailsViewModel)
|
|
}
|
|
}
|
|
|
|
struct NetworkRequestBodyCellViewModel {
|
|
let details: String
|
|
let isEnabled: Bool
|
|
let detailsViewModel: NetworkInspectorRequestBodyViewModel
|
|
|
|
init(task: NetworkTaskEntity) {
|
|
let size = task.requestBodySize
|
|
self.details = size > 0 ? ByteCountFormatter.string(fromByteCount: size) : "Empty"
|
|
self.isEnabled = size > 0
|
|
self.detailsViewModel = NetworkInspectorRequestBodyViewModel(task: task)
|
|
}
|
|
}
|