Files
platform/ios/Platform 1.44.16 AM/Platform/Shared/Components/MacroBar.swift
Yusuf Suleman fdb8aeba8a
All checks were successful
Security Checks / dependency-audit (push) Successful in 12s
Security Checks / secret-scanning (push) Successful in 3s
Security Checks / dockerfile-lint (push) Successful in 3s
restore: original UI views from first build, keep fixed models/API
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-03 01:54:46 -05:00

76 lines
2.1 KiB
Swift

import SwiftUI
struct MacroBar: View {
let label: String
let current: Double
let goal: Double
let color: Color
var showGrams: Bool = true
private var progress: Double {
guard goal > 0 else { return 0 }
return min(current / goal, 1.0)
}
var body: some View {
VStack(alignment: .leading, spacing: 4) {
HStack {
Text(label)
.font(.caption)
.fontWeight(.medium)
.foregroundStyle(Color.text3)
Spacer()
if showGrams {
Text("\(Int(current))g / \(Int(goal))g")
.font(.caption)
.foregroundStyle(Color.text3)
} else {
Text("\(Int(current)) / \(Int(goal))")
.font(.caption)
.foregroundStyle(Color.text3)
}
}
GeometryReader { geo in
ZStack(alignment: .leading) {
Capsule()
.fill(color.opacity(0.12))
.frame(height: 6)
Capsule()
.fill(color)
.frame(width: geo.size.width * progress, height: 6)
.animation(.easeOut(duration: 0.5), value: progress)
}
}
.frame(height: 6)
}
}
}
struct MacroBarCompact: View {
let current: Double
let goal: Double
let color: Color
private var progress: Double {
guard goal > 0 else { return 0 }
return min(current / goal, 1.0)
}
var body: some View {
GeometryReader { geo in
ZStack(alignment: .leading) {
Capsule()
.fill(color.opacity(0.12))
Capsule()
.fill(color)
.frame(width: geo.size.width * progress)
.animation(.easeOut(duration: 0.5), value: progress)
}
}
.frame(height: 4)
}
}