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
|
return df
|
||||||
}()
|
}()
|
||||||
|
|
||||||
|
|
||||||
// MARK: - Body
|
// MARK: - Body
|
||||||
var body: some View {
|
var body: some View {
|
||||||
GeometryReader { proxy in
|
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)
|
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)
|
.frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .center)
|
||||||
|
|||||||
@ -20,9 +20,23 @@ struct TimeSegment: View {
|
|||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
HStack(alignment: .center, spacing: 0) {
|
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(
|
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,
|
fontSize: fontSize,
|
||||||
opacity: clampedOpacity,
|
opacity: clampedOpacity,
|
||||||
digitColor: digitColor,
|
digitColor: digitColor,
|
||||||
@ -31,9 +45,28 @@ struct TimeSegment: View {
|
|||||||
fontWeight: fontWeight,
|
fontWeight: fontWeight,
|
||||||
fontDesign: fontDesign
|
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
|
// 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