Signed-off-by: Matt Bruce <mbrucedogs@gmail.com>
This commit is contained in:
parent
38469f4ca8
commit
a74d90cc8e
@ -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)
|
||||
|
||||
@ -20,6 +20,35 @@ struct TimeSegment: View {
|
||||
|
||||
var body: some View {
|
||||
HStack(alignment: .center, spacing: 0) {
|
||||
if text.count == 1 {
|
||||
// For single digits, center them by adding empty space on both sides
|
||||
DigitView(
|
||||
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,
|
||||
glowIntensity: glowIntensity,
|
||||
fontFamily: fontFamily,
|
||||
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),
|
||||
@ -31,9 +60,13 @@ struct TimeSegment: View {
|
||||
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
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user