Signed-off-by: Matt Bruce <mbrucedogs@gmail.com>

This commit is contained in:
Matt Bruce 2025-09-08 13:05:44 -05:00
parent 8e2f9c11c1
commit ebcc18db6a
5 changed files with 16 additions and 56 deletions

View File

@ -15,7 +15,6 @@ class ClockStyle: Codable, Equatable {
// MARK: - Time Format Settings
var use24Hour: Bool = true
var showSeconds: Bool = false
var showAmPmBadge: Bool = false
// MARK: - Visual Settings
var digitColorHex: String = AppConstants.Defaults.digitColorHex
@ -45,7 +44,6 @@ class ClockStyle: Codable, Equatable {
private enum CodingKeys: String, CodingKey {
case use24Hour
case showSeconds
case showAmPmBadge
case digitColorHex
case randomizeColor
case glowIntensity
@ -73,7 +71,6 @@ class ClockStyle: Codable, Equatable {
self.use24Hour = try container.decodeIfPresent(Bool.self, forKey: .use24Hour) ?? self.use24Hour
self.showSeconds = try container.decodeIfPresent(Bool.self, forKey: .showSeconds) ?? self.showSeconds
self.showAmPmBadge = try container.decodeIfPresent(Bool.self, forKey: .showAmPmBadge) ?? self.showAmPmBadge
self.digitColorHex = try container.decodeIfPresent(String.self, forKey: .digitColorHex) ?? self.digitColorHex
self.randomizeColor = try container.decodeIfPresent(Bool.self, forKey: .randomizeColor) ?? self.randomizeColor
self.glowIntensity = try container.decodeIfPresent(Double.self, forKey: .glowIntensity) ?? self.glowIntensity
@ -96,7 +93,6 @@ class ClockStyle: Codable, Equatable {
var container = encoder.container(keyedBy: CodingKeys.self)
try container.encode(use24Hour, forKey: .use24Hour)
try container.encode(showSeconds, forKey: .showSeconds)
try container.encode(showAmPmBadge, forKey: .showAmPmBadge)
try container.encode(digitColorHex, forKey: .digitColorHex)
try container.encode(randomizeColor, forKey: .randomizeColor)
try container.encode(glowIntensity, forKey: .glowIntensity)
@ -142,7 +138,6 @@ class ClockStyle: Codable, Equatable {
static func == (lhs: ClockStyle, rhs: ClockStyle) -> Bool {
lhs.use24Hour == rhs.use24Hour &&
lhs.showSeconds == rhs.showSeconds &&
lhs.showAmPmBadge == rhs.showAmPmBadge &&
lhs.digitColorHex == rhs.digitColorHex &&
lhs.randomizeColor == rhs.randomizeColor &&
lhs.glowIntensity == rhs.glowIntensity &&

View File

@ -36,12 +36,6 @@ struct ClockSettingsView: View {
onCommit: onCommit
)
OverlaySection(style: $style)
BackgroundSection(
style: $style,
backgroundColor: $backgroundColor,
digitColor: $digitColor,
onCommit: onCommit
)
}
.navigationTitle("Clock Settings")
.navigationBarTitleDisplayMode(.inline)
@ -115,10 +109,6 @@ private struct TimeFormatSection: View {
Section(header: Text("Time")) {
Toggle("24Hour", isOn: $style.use24Hour)
Toggle("Show Seconds", isOn: $style.showSeconds)
if !style.use24Hour {
Toggle("Show AM/PM Badge", isOn: $style.showAmPmBadge)
}
}
}
}
@ -131,6 +121,7 @@ private struct AppearanceSection: View {
var body: some View {
Section(header: Text("Appearance")) {
ColorPicker("Background Color", selection: $backgroundColor, supportsOpacity: true)
ColorPicker("Digit Color", selection: $digitColor, supportsOpacity: false)
Toggle("Randomize Color (every minute)", isOn: $style.randomizeColor)
@ -159,6 +150,10 @@ private struct AppearanceSection: View {
.frame(width: 50, alignment: .trailing)
}
}
.onChange(of: backgroundColor) { _, newValue in
style.backgroundHex = newValue.toHex() ?? AppConstants.Defaults.backgroundColorHex
style.clearColorCache()
}
.onChange(of: digitColor) { _, newValue in
style.digitColorHex = newValue.toHex() ?? AppConstants.Defaults.digitColorHex
style.clearColorCache()
@ -195,38 +190,6 @@ private struct OverlaySection: View {
}
}
private struct BackgroundSection: View {
@Binding var style: ClockStyle
@Binding var backgroundColor: Color
@Binding var digitColor: Color
let onCommit: (ClockStyle) -> Void
var body: some View {
Section(header: Text("Background")) {
ColorPicker("Background Color", selection: $backgroundColor, supportsOpacity: true)
HStack {
Button("Night") {
backgroundColor = .black
digitColor = .white
}
.buttonStyle(isEnabled: true, color: UIConstants.Colors.secondaryText)
Spacer()
Button("Day") {
backgroundColor = .white
digitColor = .black
}
.buttonStyle(isEnabled: true, color: UIConstants.Colors.secondaryText)
}
}
.onChange(of: backgroundColor) { _, newValue in
style.backgroundHex = newValue.toHex() ?? AppConstants.Defaults.backgroundColorHex
style.clearColorCache()
}
}
}
// MARK: - Preview
#Preview {

View File

@ -23,10 +23,14 @@ struct BatteryOverlayView: View {
let batteryIcon = getBatteryIcon()
let batteryColor = getBatteryColor()
Label("\(batteryLevel)%", systemImage: batteryIcon)
.foregroundColor(batteryColor)
.opacity(clamped)
.font(.callout.weight(.semibold))
HStack(spacing: 4) {
Image(systemName: batteryIcon)
.foregroundColor(batteryColor)
Text("\(batteryLevel)%")
.foregroundColor(color)
}
.opacity(clamped)
.font(.callout.weight(.semibold))
.onAppear {
enableBatteryMonitoring()
updateBattery()

View File

@ -38,7 +38,6 @@ struct ClockDisplayContainer: View {
glowIntensity: style.glowIntensity,
manualScale: style.digitScale,
stretched: style.stretched,
showAmPmBadge: style.showAmPmBadge,
clockOpacity: style.clockOpacity,
fontFamily: style.fontFamily,
fontWeight: style.fontWeight,

View File

@ -18,7 +18,6 @@ struct TimeDisplayView: View {
let glowIntensity: Double
let manualScale: Double
let stretched: Bool
let showAmPmBadge: Bool
let clockOpacity: Double
let fontFamily: String
let fontWeight: String
@ -81,14 +80,14 @@ struct TimeDisplayView: View {
containerHeight: fullScreenSize.height,
isPortrait: portrait,
showSeconds: showSeconds,
showAmPm: !use24Hour && showAmPmBadge
showAmPm: false
) :
FontUtils.optimalFontSize(
containerWidth: fullScreenSize.width,
containerHeight: fullScreenSize.height,
isPortrait: portrait,
showSeconds: showSeconds,
showAmPm: !use24Hour && showAmPmBadge
showAmPm: false
)
let ampmFontSize = FontUtils.ampmFontSize(baseFontSize: baseFontSize)
@ -97,7 +96,7 @@ struct TimeDisplayView: View {
let minute = Self.minuteDF.string(from: date)
let secondsText = Self.secondDF.string(from: date)
let ampmText = Self.ampmDF.string(from: date)
let showAMPM = !use24Hour && showAmPmBadge
let showAMPM = false // Always use colon/dots instead of AM/PM
// Calculate sizes using fixed-width approach to prevent jumping
let digitUIFont = FontUtils.customUIFont(