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 clockOpacity = 0.5
|
||||||
static let overlayOpacity = 0.5
|
static let overlayOpacity = 0.5
|
||||||
static let maxFontSize = 220.0
|
static let maxFontSize = 220.0
|
||||||
static let safeInset = 4.0 // Reasonable safe inset
|
static let safeInset = 16.0 // Reasonable safe inset
|
||||||
}
|
}
|
||||||
|
|
||||||
// MARK: - System Sounds
|
// MARK: - System Sounds
|
||||||
|
|||||||
@ -32,18 +32,13 @@ enum FontUtils {
|
|||||||
containerWidth: CGFloat,
|
containerWidth: CGFloat,
|
||||||
containerHeight: CGFloat,
|
containerHeight: CGFloat,
|
||||||
isPortrait: Bool,
|
isPortrait: Bool,
|
||||||
showSeconds: Bool = false,
|
showSeconds: Bool = false
|
||||||
showAmPm: Bool = false
|
|
||||||
) -> CGFloat {
|
) -> CGFloat {
|
||||||
// Account for safe areas and padding
|
// Account for safe areas and padding
|
||||||
let safeInset = AppConstants.Defaults.safeInset
|
let safeInset = AppConstants.Defaults.safeInset
|
||||||
let availableWidth = max(1, containerWidth - safeInset * 2)
|
let availableWidth = max(1, containerWidth - safeInset * 2)
|
||||||
let availableHeight = max(1, containerHeight - 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
|
// Calculate optimal size based on orientation and content
|
||||||
let optimalSize: CGFloat
|
let optimalSize: CGFloat
|
||||||
if isPortrait {
|
if isPortrait {
|
||||||
@ -432,8 +427,7 @@ enum FontUtils {
|
|||||||
containerWidth: CGFloat,
|
containerWidth: CGFloat,
|
||||||
containerHeight: CGFloat,
|
containerHeight: CGFloat,
|
||||||
isPortrait: Bool,
|
isPortrait: Bool,
|
||||||
showSeconds: Bool = false,
|
showSeconds: Bool = false
|
||||||
showAmPm: Bool = false
|
|
||||||
) -> CGFloat {
|
) -> CGFloat {
|
||||||
// Use reasonable safe areas
|
// Use reasonable safe areas
|
||||||
let safeInset = AppConstants.Defaults.safeInset
|
let safeInset = AppConstants.Defaults.safeInset
|
||||||
|
|||||||
@ -30,7 +30,6 @@ struct DigitView: View {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
.frame(width: digitWidth, height: digitHeight)
|
.frame(width: digitWidth, height: digitHeight)
|
||||||
.border(Color.blue, width: 2) // DEBUG: Blue border around individual digits
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// MARK: - Computed Properties
|
// MARK: - Computed Properties
|
||||||
|
|||||||
@ -59,30 +59,26 @@ struct TimeDisplayView: View {
|
|||||||
let size = proxy.size
|
let size = proxy.size
|
||||||
let portrait = size.height >= size.width
|
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
|
// Get safe area information for font sizing to avoid Dynamic Island overlap
|
||||||
let safeAreaInsets = proxy.safeAreaInsets
|
let safeAreaInsets = proxy.safeAreaInsets
|
||||||
let _ = size.width - safeAreaInsets.leading - safeAreaInsets.trailing // availableWidth
|
let safeWidth = size.width - safeAreaInsets.leading - safeAreaInsets.trailing // availableWidth
|
||||||
let _ = size.height - safeAreaInsets.top - safeAreaInsets.bottom // availableHeight
|
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
|
// Use optimal font sizing that maximizes space usage with full screen
|
||||||
let baseFontSize = stretched ?
|
let baseFontSize = stretched ?
|
||||||
FontUtils.maximumStretchedFontSize(
|
FontUtils.maximumStretchedFontSize(
|
||||||
containerWidth: fullScreenSize.width,
|
containerWidth: fullScreenSize.width,
|
||||||
containerHeight: fullScreenSize.height,
|
containerHeight: fullScreenSize.height,
|
||||||
isPortrait: portrait,
|
isPortrait: portrait,
|
||||||
showSeconds: showSeconds,
|
showSeconds: showSeconds
|
||||||
showAmPm: false
|
) :
|
||||||
) :
|
FontUtils.optimalFontSize(
|
||||||
FontUtils.optimalFontSize(
|
containerWidth: fullScreenSize.width,
|
||||||
containerWidth: fullScreenSize.width,
|
containerHeight: fullScreenSize.height,
|
||||||
containerHeight: fullScreenSize.height,
|
isPortrait: portrait,
|
||||||
isPortrait: portrait,
|
showSeconds: showSeconds
|
||||||
showSeconds: showSeconds,
|
)
|
||||||
showAmPm: false
|
|
||||||
)
|
|
||||||
|
|
||||||
// Time components
|
// Time components
|
||||||
let hour = use24Hour ? Self.hour24DF.string(from: date) : Self.hour12DF.string(from: date)
|
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
|
// 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
|
// Separators - reasonable spacing with extra padding in landscape
|
||||||
let dotDiameter = baseFontSize * 0.20
|
let dotDiameter = baseFontSize * 0.20
|
||||||
@ -126,8 +122,8 @@ struct TimeDisplayView: View {
|
|||||||
|
|
||||||
// For stretched mode, use reasonable scaling
|
// For stretched mode, use reasonable scaling
|
||||||
let effectiveScale = stretched ?
|
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, 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, max(0.1, min(widthScale, heightScale)) * CGFloat(max(0.1, min(manualScale, 1.0))))
|
||||||
|
|
||||||
let finalScale = effectiveScale
|
let finalScale = effectiveScale
|
||||||
|
|
||||||
@ -155,14 +151,14 @@ struct TimeDisplayView: View {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.border(Color.red, width: 3) // DEBUG: Red border to check positioning
|
.frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .center)
|
||||||
.frame(width: fullScreenSize.width, height: fullScreenSize.height, alignment: .center)
|
|
||||||
.scaleEffect(finalScale, anchor: .center)
|
.scaleEffect(finalScale, anchor: .center)
|
||||||
.animation(UIConstants.AnimationCurves.smooth, value: finalScale)
|
.animation(UIConstants.AnimationCurves.smooth, value: finalScale)
|
||||||
.animation(UIConstants.AnimationCurves.smooth, value: showSeconds) // Smooth animation for seconds toggle
|
.animation(UIConstants.AnimationCurves.smooth, value: showSeconds) // Smooth animation for seconds toggle
|
||||||
.minimumScaleFactor(0.1)
|
.minimumScaleFactor(0.1)
|
||||||
.clipped() // Prevent overflow beyond bounds
|
.clipped() // Prevent overflow beyond bounds
|
||||||
}
|
}
|
||||||
|
.border(.blue, width: 1)
|
||||||
.frame(maxWidth: .infinity, maxHeight: .infinity)
|
.frame(maxWidth: .infinity, maxHeight: .infinity)
|
||||||
.onOrientationChange() // Force updates on orientation changes
|
.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
|
// MARK: - Computed Properties
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user