Signed-off-by: Matt Bruce <mbrucedogs@gmail.com>

This commit is contained in:
Matt Bruce 2025-09-10 13:19:04 -05:00
parent 38469f4ca8
commit a74d90cc8e
2 changed files with 43 additions and 4 deletions

View File

@ -52,7 +52,6 @@ struct TimeDisplayView: View {
return df
}()
// MARK: - Body
var body: some View {
GeometryReader { proxy in
@ -111,6 +110,7 @@ struct TimeDisplayView: View {
TimeSegment(text: secondsText, fontSize: baseFontSize, opacity: clockOpacity, digitColor: digitColor, glowIntensity: glowIntensity, fontFamily: fontFamily, fontWeight: fontWeight, fontDesign: fontDesign)
}
}
.frame(maxWidth: .infinity)
}
}
.frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .center)

View File

@ -20,9 +20,23 @@ struct TimeSegment: View {
var body: some View {
HStack(alignment: .center, spacing: 0) {
ForEach(Array(text.enumerated()), id: \.offset) { index, character in
if text.count == 1 {
// For single digits, center them by adding empty space on both sides
DigitView(
digit: String(character),
digit: " ",
fontSize: fontSize,
opacity: 0,
digitColor: digitColor,
glowIntensity: glowIntensity,
fontFamily: fontFamily,
fontWeight: fontWeight,
fontDesign: fontDesign
)
.frame(width: digitWidth)
.border(.red, width: 1)
DigitView(
digit: text,
fontSize: fontSize,
opacity: clampedOpacity,
digitColor: digitColor,
@ -31,9 +45,28 @@ struct TimeSegment: View {
fontWeight: fontWeight,
fontDesign: fontDesign
)
.frame(width: digitWidth)
.border(.red, width: 1)
} else {
// For multiple digits, display them normally
ForEach(Array(text.enumerated()), id: \.offset) { index, character in
DigitView(
digit: String(character),
fontSize: fontSize,
opacity: clampedOpacity,
digitColor: digitColor,
glowIntensity: glowIntensity,
fontFamily: fontFamily,
fontWeight: fontWeight,
fontDesign: fontDesign
)
.frame(width: digitWidth)
.border(.red, width: 1)
}
}
}
.frame(maxWidth: .infinity, maxHeight: .infinity)
.border(Color.green, width: 1)
.frame(maxHeight: .infinity)
}
// MARK: - Computed Properties
@ -50,6 +83,12 @@ struct TimeSegment: View {
)
}
private var digitWidth: CGFloat {
// Calculate the width of a single digit based on font size
// This ensures consistent spacing regardless of the actual digit
return fontSize * 0.6 // Approximate width-to-height ratio for monospace digits
}
}