Signed-off-by: Matt Bruce <mbrucedogs@gmail.com>
This commit is contained in:
parent
ed6e8c2635
commit
dbaf570ab7
@ -54,7 +54,7 @@ enum AppConstants {
|
||||
static let clockOpacity = 0.5
|
||||
static let overlayOpacity = 0.5
|
||||
static let maxFontSize = 220.0
|
||||
static let safeInset = 4.0 // Reasonable safe inset
|
||||
static let safeInset = 16.0 // Reasonable safe inset
|
||||
}
|
||||
|
||||
// MARK: - System Sounds
|
||||
|
||||
@ -32,18 +32,13 @@ enum FontUtils {
|
||||
containerWidth: CGFloat,
|
||||
containerHeight: CGFloat,
|
||||
isPortrait: Bool,
|
||||
showSeconds: Bool = false,
|
||||
showAmPm: Bool = false
|
||||
showSeconds: Bool = false
|
||||
) -> CGFloat {
|
||||
// Account for safe areas and padding
|
||||
let safeInset = AppConstants.Defaults.safeInset
|
||||
let availableWidth = max(1, containerWidth - safeInset * 2)
|
||||
let availableHeight = max(1, containerHeight - safeInset * 2)
|
||||
|
||||
// Estimate text content requirements (for future use)
|
||||
_ = showSeconds ? 6 : 4 // HH:MM or HH:MM:SS
|
||||
_ = showAmPm ? 2 : 0 // AM/PM
|
||||
|
||||
// Calculate optimal size based on orientation and content
|
||||
let optimalSize: CGFloat
|
||||
if isPortrait {
|
||||
@ -432,8 +427,7 @@ enum FontUtils {
|
||||
containerWidth: CGFloat,
|
||||
containerHeight: CGFloat,
|
||||
isPortrait: Bool,
|
||||
showSeconds: Bool = false,
|
||||
showAmPm: Bool = false
|
||||
showSeconds: Bool = false
|
||||
) -> CGFloat {
|
||||
// Use reasonable safe areas
|
||||
let safeInset = AppConstants.Defaults.safeInset
|
||||
|
||||
@ -30,7 +30,6 @@ struct DigitView: View {
|
||||
}
|
||||
}
|
||||
.frame(width: digitWidth, height: digitHeight)
|
||||
.border(Color.blue, width: 2) // DEBUG: Blue border around individual digits
|
||||
}
|
||||
|
||||
// MARK: - Computed Properties
|
||||
|
||||
@ -59,30 +59,26 @@ struct TimeDisplayView: View {
|
||||
let size = proxy.size
|
||||
let portrait = size.height >= size.width
|
||||
|
||||
// Use the full GeometryReader size for maximum space usage
|
||||
let fullScreenSize = size
|
||||
|
||||
// Get safe area information for font sizing to avoid Dynamic Island overlap
|
||||
let safeAreaInsets = proxy.safeAreaInsets
|
||||
let _ = size.width - safeAreaInsets.leading - safeAreaInsets.trailing // availableWidth
|
||||
let _ = size.height - safeAreaInsets.top - safeAreaInsets.bottom // availableHeight
|
||||
let safeWidth = size.width - safeAreaInsets.leading - safeAreaInsets.trailing // availableWidth
|
||||
let safeHeight = size.height - safeAreaInsets.top - safeAreaInsets.bottom // availableHeight
|
||||
let fullScreenSize = CGSize(width: safeWidth, height: safeHeight)
|
||||
|
||||
// Use optimal font sizing that maximizes space usage with full screen
|
||||
let baseFontSize = stretched ?
|
||||
FontUtils.maximumStretchedFontSize(
|
||||
containerWidth: fullScreenSize.width,
|
||||
containerHeight: fullScreenSize.height,
|
||||
isPortrait: portrait,
|
||||
showSeconds: showSeconds,
|
||||
showAmPm: false
|
||||
) :
|
||||
FontUtils.optimalFontSize(
|
||||
containerWidth: fullScreenSize.width,
|
||||
containerHeight: fullScreenSize.height,
|
||||
isPortrait: portrait,
|
||||
showSeconds: showSeconds,
|
||||
showAmPm: false
|
||||
)
|
||||
FontUtils.maximumStretchedFontSize(
|
||||
containerWidth: fullScreenSize.width,
|
||||
containerHeight: fullScreenSize.height,
|
||||
isPortrait: portrait,
|
||||
showSeconds: showSeconds
|
||||
) :
|
||||
FontUtils.optimalFontSize(
|
||||
containerWidth: fullScreenSize.width,
|
||||
containerHeight: fullScreenSize.height,
|
||||
isPortrait: portrait,
|
||||
showSeconds: showSeconds
|
||||
)
|
||||
|
||||
// Time components
|
||||
let hour = use24Hour ? Self.hour24DF.string(from: date) : Self.hour12DF.string(from: date)
|
||||
@ -98,7 +94,7 @@ struct TimeDisplayView: View {
|
||||
)
|
||||
|
||||
// Calculate consistent sizes for layout
|
||||
let _ = measureText("8", font: digitUIFont).height // Use 8 as reference height
|
||||
let textHeight = measureText("8", font: digitUIFont).height // Use 8 as reference height
|
||||
|
||||
// Separators - reasonable spacing with extra padding in landscape
|
||||
let dotDiameter = baseFontSize * 0.20
|
||||
@ -126,8 +122,8 @@ struct TimeDisplayView: View {
|
||||
|
||||
// For stretched mode, use reasonable scaling
|
||||
let effectiveScale = stretched ?
|
||||
max(0.1, min(min(widthScale, heightScale), 1.5)) : // Use min scale and cap at 1.5x to prevent overflow
|
||||
max(0.1, max(0.1, min(widthScale, heightScale)) * CGFloat(max(0.1, min(manualScale, 1.0))))
|
||||
max(0.1, min(min(widthScale, heightScale), 1.5)) : // Use min scale and cap at 1.5x to prevent overflow
|
||||
max(0.1, max(0.1, min(widthScale, heightScale)) * CGFloat(max(0.1, min(manualScale, 1.0))))
|
||||
|
||||
let finalScale = effectiveScale
|
||||
|
||||
@ -155,14 +151,14 @@ struct TimeDisplayView: View {
|
||||
}
|
||||
}
|
||||
}
|
||||
.border(Color.red, width: 3) // DEBUG: Red border to check positioning
|
||||
.frame(width: fullScreenSize.width, height: fullScreenSize.height, alignment: .center)
|
||||
.frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .center)
|
||||
.scaleEffect(finalScale, anchor: .center)
|
||||
.animation(UIConstants.AnimationCurves.smooth, value: finalScale)
|
||||
.animation(UIConstants.AnimationCurves.smooth, value: showSeconds) // Smooth animation for seconds toggle
|
||||
.minimumScaleFactor(0.1)
|
||||
.clipped() // Prevent overflow beyond bounds
|
||||
}
|
||||
.border(.blue, width: 1)
|
||||
.frame(maxWidth: .infinity, maxHeight: .infinity)
|
||||
.onOrientationChange() // Force updates on orientation changes
|
||||
}
|
||||
|
||||
@ -35,7 +35,6 @@ struct TimeSegment: View {
|
||||
)
|
||||
}
|
||||
}
|
||||
.border(Color.green, width: 2) // DEBUG: Green border around time segments
|
||||
}
|
||||
|
||||
// MARK: - Computed Properties
|
||||
|
||||
Loading…
Reference in New Issue
Block a user