Files
sing-box-for-apple/ApplicationLibrary/Views/Dashboard/Cards/TrafficTotalCard.swift
T
2025-11-26 22:25:52 +08:00

27 lines
1.1 KiB
Swift

import Libbox
import Library
import SwiftUI
public struct TrafficTotalCard: View {
@EnvironmentObject private var commandClient: CommandClient
public init() {}
public var body: some View {
DashboardCardView(title: String(localized: "Traffic Total"), isHalfWidth: true) {
VStack(alignment: .leading, spacing: 8) {
if ApplicationLibrary.inPreview {
DashboardCardLine(String(localized: "Uplink"), "52 MB")
DashboardCardLine(String(localized: "Downlink"), "5.6 GB")
} else if let message = commandClient.status, message.trafficAvailable {
DashboardCardLine(String(localized: "Uplink"), LibboxFormatBytes(message.uplinkTotal))
DashboardCardLine(String(localized: "Downlink"), LibboxFormatBytes(message.downlinkTotal))
} else {
DashboardCardLine(String(localized: "Uplink"), "...")
DashboardCardLine(String(localized: "Downlink"), "...")
}
}
}
}
}