Skip to content

Commit

Permalink
Add UserSettings.compactLocalTimeSecondsFontSize
Browse files Browse the repository at this point in the history
  • Loading branch information
tekezo committed Jan 29, 2025
1 parent bf70eb7 commit e416fdc
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 9 deletions.
1 change: 1 addition & 0 deletions src/TrueWidget/swift/UserSettings.swift
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ final class UserSettings: ObservableObject {

@AppStorage("compactShowLocalTime") var compactShowLocalTime: Bool = true
@AppStorage("compactLocalTimeFontSize") var compactLocalTimeFontSize: Double = 24.0
@AppStorage("compactLocalTimeSecondsFontSize") var compactLocalTimeSecondsFontSize: Double = 12.0
@AppStorage("compactShowCPUUsage") var compactShowCPUUsage: Bool = true
@AppStorage("compactCPUUsageFontSize") var compactCPUUsageFontSize: Double = 12.0
}
20 changes: 11 additions & 9 deletions src/TrueWidget/swift/Views/Main/CompactTimeView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,17 @@ struct CompactTimeView: View {
)
.font(.custom("Menlo", size: userSettings.compactLocalTimeFontSize))

Text(
time.localTime == nil
? "---"
: String(
format: " %02d",
time.localTime?.second ?? 0
)
)
.font(.custom("Menlo", size: userSettings.compactLocalTimeFontSize / 2))
if userSettings.compactLocalTimeSecondsFontSize > 0 {
Text(
time.localTime == nil
? "---"
: String(
format: " %02d",
time.localTime?.second ?? 0
)
)
.font(.custom("Menlo", size: userSettings.compactLocalTimeSecondsFontSize))
}
}
.frame(maxWidth: .infinity, alignment: .trailing)
.onDisappear {
Expand Down
15 changes: 15 additions & 0 deletions src/TrueWidget/swift/Views/Settings/SettingsCompactView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,21 @@ struct SettingsCompactView: View {
Text("(Default: 24 pt)")
}

HStack {
Text("Local time font size for seconds:")

DoubleTextField(
value: $userSettings.compactLocalTimeSecondsFontSize,
range: 0...1000,
step: 2,
maximumFractionDigits: 1,
width: 40)

Text("pt")

Text("(Default: 12 pt)")
}

Toggle(isOn: $userSettings.compactShowCPUUsage) {
Text("Show CPU usage")
}
Expand Down

0 comments on commit e416fdc

Please sign in to comment.