Signed-off-by: Matt Bruce <mbrucedogs@gmail.com>
This commit is contained in:
parent
8e2f9c11c1
commit
ebcc18db6a
@ -15,7 +15,6 @@ class ClockStyle: Codable, Equatable {
|
|||||||
// MARK: - Time Format Settings
|
// MARK: - Time Format Settings
|
||||||
var use24Hour: Bool = true
|
var use24Hour: Bool = true
|
||||||
var showSeconds: Bool = false
|
var showSeconds: Bool = false
|
||||||
var showAmPmBadge: Bool = false
|
|
||||||
|
|
||||||
// MARK: - Visual Settings
|
// MARK: - Visual Settings
|
||||||
var digitColorHex: String = AppConstants.Defaults.digitColorHex
|
var digitColorHex: String = AppConstants.Defaults.digitColorHex
|
||||||
@ -45,7 +44,6 @@ class ClockStyle: Codable, Equatable {
|
|||||||
private enum CodingKeys: String, CodingKey {
|
private enum CodingKeys: String, CodingKey {
|
||||||
case use24Hour
|
case use24Hour
|
||||||
case showSeconds
|
case showSeconds
|
||||||
case showAmPmBadge
|
|
||||||
case digitColorHex
|
case digitColorHex
|
||||||
case randomizeColor
|
case randomizeColor
|
||||||
case glowIntensity
|
case glowIntensity
|
||||||
@ -73,7 +71,6 @@ class ClockStyle: Codable, Equatable {
|
|||||||
|
|
||||||
self.use24Hour = try container.decodeIfPresent(Bool.self, forKey: .use24Hour) ?? self.use24Hour
|
self.use24Hour = try container.decodeIfPresent(Bool.self, forKey: .use24Hour) ?? self.use24Hour
|
||||||
self.showSeconds = try container.decodeIfPresent(Bool.self, forKey: .showSeconds) ?? self.showSeconds
|
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.digitColorHex = try container.decodeIfPresent(String.self, forKey: .digitColorHex) ?? self.digitColorHex
|
||||||
self.randomizeColor = try container.decodeIfPresent(Bool.self, forKey: .randomizeColor) ?? self.randomizeColor
|
self.randomizeColor = try container.decodeIfPresent(Bool.self, forKey: .randomizeColor) ?? self.randomizeColor
|
||||||
self.glowIntensity = try container.decodeIfPresent(Double.self, forKey: .glowIntensity) ?? self.glowIntensity
|
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)
|
var container = encoder.container(keyedBy: CodingKeys.self)
|
||||||
try container.encode(use24Hour, forKey: .use24Hour)
|
try container.encode(use24Hour, forKey: .use24Hour)
|
||||||
try container.encode(showSeconds, forKey: .showSeconds)
|
try container.encode(showSeconds, forKey: .showSeconds)
|
||||||
try container.encode(showAmPmBadge, forKey: .showAmPmBadge)
|
|
||||||
try container.encode(digitColorHex, forKey: .digitColorHex)
|
try container.encode(digitColorHex, forKey: .digitColorHex)
|
||||||
try container.encode(randomizeColor, forKey: .randomizeColor)
|
try container.encode(randomizeColor, forKey: .randomizeColor)
|
||||||
try container.encode(glowIntensity, forKey: .glowIntensity)
|
try container.encode(glowIntensity, forKey: .glowIntensity)
|
||||||
@ -142,7 +138,6 @@ class ClockStyle: Codable, Equatable {
|
|||||||
static func == (lhs: ClockStyle, rhs: ClockStyle) -> Bool {
|
static func == (lhs: ClockStyle, rhs: ClockStyle) -> Bool {
|
||||||
lhs.use24Hour == rhs.use24Hour &&
|
lhs.use24Hour == rhs.use24Hour &&
|
||||||
lhs.showSeconds == rhs.showSeconds &&
|
lhs.showSeconds == rhs.showSeconds &&
|
||||||
lhs.showAmPmBadge == rhs.showAmPmBadge &&
|
|
||||||
lhs.digitColorHex == rhs.digitColorHex &&
|
lhs.digitColorHex == rhs.digitColorHex &&
|
||||||
lhs.randomizeColor == rhs.randomizeColor &&
|
lhs.randomizeColor == rhs.randomizeColor &&
|
||||||
lhs.glowIntensity == rhs.glowIntensity &&
|
lhs.glowIntensity == rhs.glowIntensity &&
|
||||||
|
|||||||
@ -36,12 +36,6 @@ struct ClockSettingsView: View {
|
|||||||
onCommit: onCommit
|
onCommit: onCommit
|
||||||
)
|
)
|
||||||
OverlaySection(style: $style)
|
OverlaySection(style: $style)
|
||||||
BackgroundSection(
|
|
||||||
style: $style,
|
|
||||||
backgroundColor: $backgroundColor,
|
|
||||||
digitColor: $digitColor,
|
|
||||||
onCommit: onCommit
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
.navigationTitle("Clock Settings")
|
.navigationTitle("Clock Settings")
|
||||||
.navigationBarTitleDisplayMode(.inline)
|
.navigationBarTitleDisplayMode(.inline)
|
||||||
@ -115,10 +109,6 @@ private struct TimeFormatSection: View {
|
|||||||
Section(header: Text("Time")) {
|
Section(header: Text("Time")) {
|
||||||
Toggle("24‑Hour", isOn: $style.use24Hour)
|
Toggle("24‑Hour", isOn: $style.use24Hour)
|
||||||
Toggle("Show Seconds", isOn: $style.showSeconds)
|
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 {
|
var body: some View {
|
||||||
Section(header: Text("Appearance")) {
|
Section(header: Text("Appearance")) {
|
||||||
|
ColorPicker("Background Color", selection: $backgroundColor, supportsOpacity: true)
|
||||||
ColorPicker("Digit Color", selection: $digitColor, supportsOpacity: false)
|
ColorPicker("Digit Color", selection: $digitColor, supportsOpacity: false)
|
||||||
Toggle("Randomize Color (every minute)", isOn: $style.randomizeColor)
|
Toggle("Randomize Color (every minute)", isOn: $style.randomizeColor)
|
||||||
|
|
||||||
@ -159,6 +150,10 @@ private struct AppearanceSection: View {
|
|||||||
.frame(width: 50, alignment: .trailing)
|
.frame(width: 50, alignment: .trailing)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
.onChange(of: backgroundColor) { _, newValue in
|
||||||
|
style.backgroundHex = newValue.toHex() ?? AppConstants.Defaults.backgroundColorHex
|
||||||
|
style.clearColorCache()
|
||||||
|
}
|
||||||
.onChange(of: digitColor) { _, newValue in
|
.onChange(of: digitColor) { _, newValue in
|
||||||
style.digitColorHex = newValue.toHex() ?? AppConstants.Defaults.digitColorHex
|
style.digitColorHex = newValue.toHex() ?? AppConstants.Defaults.digitColorHex
|
||||||
style.clearColorCache()
|
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
|
// MARK: - Preview
|
||||||
#Preview {
|
#Preview {
|
||||||
|
|||||||
@ -23,10 +23,14 @@ struct BatteryOverlayView: View {
|
|||||||
let batteryIcon = getBatteryIcon()
|
let batteryIcon = getBatteryIcon()
|
||||||
let batteryColor = getBatteryColor()
|
let batteryColor = getBatteryColor()
|
||||||
|
|
||||||
Label("\(batteryLevel)%", systemImage: batteryIcon)
|
HStack(spacing: 4) {
|
||||||
.foregroundColor(batteryColor)
|
Image(systemName: batteryIcon)
|
||||||
.opacity(clamped)
|
.foregroundColor(batteryColor)
|
||||||
.font(.callout.weight(.semibold))
|
Text("\(batteryLevel)%")
|
||||||
|
.foregroundColor(color)
|
||||||
|
}
|
||||||
|
.opacity(clamped)
|
||||||
|
.font(.callout.weight(.semibold))
|
||||||
.onAppear {
|
.onAppear {
|
||||||
enableBatteryMonitoring()
|
enableBatteryMonitoring()
|
||||||
updateBattery()
|
updateBattery()
|
||||||
|
|||||||
@ -38,7 +38,6 @@ struct ClockDisplayContainer: View {
|
|||||||
glowIntensity: style.glowIntensity,
|
glowIntensity: style.glowIntensity,
|
||||||
manualScale: style.digitScale,
|
manualScale: style.digitScale,
|
||||||
stretched: style.stretched,
|
stretched: style.stretched,
|
||||||
showAmPmBadge: style.showAmPmBadge,
|
|
||||||
clockOpacity: style.clockOpacity,
|
clockOpacity: style.clockOpacity,
|
||||||
fontFamily: style.fontFamily,
|
fontFamily: style.fontFamily,
|
||||||
fontWeight: style.fontWeight,
|
fontWeight: style.fontWeight,
|
||||||
|
|||||||
@ -18,7 +18,6 @@ struct TimeDisplayView: View {
|
|||||||
let glowIntensity: Double
|
let glowIntensity: Double
|
||||||
let manualScale: Double
|
let manualScale: Double
|
||||||
let stretched: Bool
|
let stretched: Bool
|
||||||
let showAmPmBadge: Bool
|
|
||||||
let clockOpacity: Double
|
let clockOpacity: Double
|
||||||
let fontFamily: String
|
let fontFamily: String
|
||||||
let fontWeight: String
|
let fontWeight: String
|
||||||
@ -81,14 +80,14 @@ struct TimeDisplayView: View {
|
|||||||
containerHeight: fullScreenSize.height,
|
containerHeight: fullScreenSize.height,
|
||||||
isPortrait: portrait,
|
isPortrait: portrait,
|
||||||
showSeconds: showSeconds,
|
showSeconds: showSeconds,
|
||||||
showAmPm: !use24Hour && showAmPmBadge
|
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: !use24Hour && showAmPmBadge
|
showAmPm: false
|
||||||
)
|
)
|
||||||
let ampmFontSize = FontUtils.ampmFontSize(baseFontSize: baseFontSize)
|
let ampmFontSize = FontUtils.ampmFontSize(baseFontSize: baseFontSize)
|
||||||
|
|
||||||
@ -97,7 +96,7 @@ struct TimeDisplayView: View {
|
|||||||
let minute = Self.minuteDF.string(from: date)
|
let minute = Self.minuteDF.string(from: date)
|
||||||
let secondsText = Self.secondDF.string(from: date)
|
let secondsText = Self.secondDF.string(from: date)
|
||||||
let ampmText = Self.ampmDF.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
|
// Calculate sizes using fixed-width approach to prevent jumping
|
||||||
let digitUIFont = FontUtils.customUIFont(
|
let digitUIFont = FontUtils.customUIFont(
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user