51 lines
1.1 KiB
Swift
51 lines
1.1 KiB
Swift
//
|
|
// UsageBarCell.swift
|
|
// iKeyMon
|
|
//
|
|
// Created by tracer on 01.04.25.
|
|
//
|
|
|
|
import SwiftUI
|
|
|
|
struct UsageBarCell: View {
|
|
let free: Int
|
|
let used: Int
|
|
let total: Int
|
|
let percent: Double
|
|
var subtext: String? = nil
|
|
|
|
var body: some View {
|
|
VStack(alignment: .leading) {
|
|
HStack {
|
|
Text("Free:")
|
|
.fontWeight(.bold)
|
|
Text(free.toNiceBinaryUnit())
|
|
|
|
Text("Used:")
|
|
.fontWeight(.bold)
|
|
Text(used.toNiceBinaryUnit())
|
|
|
|
Text("Total:")
|
|
.fontWeight(.bold)
|
|
Text(total.toNiceBinaryUnit())
|
|
|
|
}
|
|
if let subtext {
|
|
Text(subtext)
|
|
.font(.caption)
|
|
.foregroundColor(.secondary)
|
|
}
|
|
HStack {
|
|
Spacer()
|
|
Text(String(format: "%.2f %%", percent))
|
|
}
|
|
ProgressView(value: percent / 100)
|
|
.progressViewStyle(.linear)
|
|
}
|
|
}
|
|
}
|
|
|
|
#Preview {
|
|
UsageBarCell(free: 1024, used: 16238, total: 1232312323123, percent: 33.33)
|
|
}
|