diff --git a/TheNoiseClock/Views/Clock/Components/TimeDisplayView.swift b/TheNoiseClock/Views/Clock/Components/TimeDisplayView.swift index 537dd19..cc3e44e 100644 --- a/TheNoiseClock/Views/Clock/Components/TimeDisplayView.swift +++ b/TheNoiseClock/Views/Clock/Components/TimeDisplayView.swift @@ -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) diff --git a/TheNoiseClock/Views/Clock/Components/TimeSegment.swift b/TheNoiseClock/Views/Clock/Components/TimeSegment.swift index 72e494a..4269905 100644 --- a/TheNoiseClock/Views/Clock/Components/TimeSegment.swift +++ b/TheNoiseClock/Views/Clock/Components/TimeSegment.swift @@ -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 + } + }