feat: memory overview item

This commit is contained in:
mrFq1
2023-05-29 20:13:33 +08:00
parent b49cc39c78
commit 4e738d8ea3
2 changed files with 20 additions and 1 deletions

View File

@@ -41,6 +41,15 @@ extension ClashApiDatasStorage: ApiRequestStreamDelegate {
}
}
}
func didUpdateMemory(memory: Int64) {
let v = ByteCountFormatter().string(fromByteCount: memory)
if overviewData.memory != v {
overviewData.memory = v
}
}
}
fileprivate let TrafficHistoryLimit = 120
@@ -56,6 +65,8 @@ class ClashOverviewData: ObservableObject, Identifiable {
@Published var activeConns = "0"
@Published var memory = "0 MB"
@Published var downloadHistories = [CGFloat](repeating: 0, count: TrafficHistoryLimit)
@Published var uploadHistories = [CGFloat](repeating: 0, count: TrafficHistoryLimit)

View File

@@ -15,13 +15,21 @@ struct OverviewView: View {
var body: some View {
VStack(spacing: 25) {
HStack() {
LazyVGrid(columns: Array(repeating: GridItem(.flexible(minimum: 155)), count: 4)) {
OverviewTopItemView(name: "Upload", value: $data.uploadString)
OverviewTopItemView(name: "Download", value: $data.downloadString)
OverviewTopItemView(name: "Upload Total", value: $data.uploadTotal)
OverviewTopItemView(name: "Download Total", value: $data.downloadTotal)
OverviewTopItemView(name: "Active Connections", value: $data.activeConns)
OverviewTopItemView(name: "Memory Usage", value: $data.memory)
}
HStack {
RoundedRectangle(cornerRadius: 2)