Skip to content

Commit

Permalink
Hide time if font size is zero
Browse files Browse the repository at this point in the history
  • Loading branch information
tekezo committed Jan 29, 2025
1 parent e416fdc commit 971f221
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 30 deletions.
22 changes: 12 additions & 10 deletions src/TrueWidget/swift/Views/Main/CompactTimeView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,18 @@ struct CompactTimeView: View {

var body: some View {
HStack(alignment: .firstTextBaseline, spacing: 0) {
Text(
time.localTime == nil
? "---"
: String(
format: " %02d:%02d",
time.localTime?.hour ?? 0,
time.localTime?.minute ?? 0
)
)
.font(.custom("Menlo", size: userSettings.compactLocalTimeFontSize))
if userSettings.compactLocalTimeFontSize > 0 {
Text(
time.localTime == nil
? "---"
: String(
format: " %02d:%02d",
time.localTime?.hour ?? 0,
time.localTime?.minute ?? 0
)
)
.font(.custom("Menlo", size: userSettings.compactLocalTimeFontSize))
}

if userSettings.compactLocalTimeSecondsFontSize > 0 {
Text(
Expand Down
44 changes: 24 additions & 20 deletions src/TrueWidget/swift/Views/Main/MainTimeView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,18 @@ struct MainTimeView: View {

if userSettings.showLocalTime {
HStack(alignment: .firstTextBaseline, spacing: 0) {
Text(
time.localTime == nil
? "---"
: String(
format: " %02d:%02d",
time.localTime?.hour ?? 0,
time.localTime?.minute ?? 0
)
)
.font(.custom("Menlo", size: userSettings.localTimeFontSize))
if userSettings.localTimeFontSize > 0 {
Text(
time.localTime == nil
? "---"
: String(
format: " %02d:%02d",
time.localTime?.hour ?? 0,
time.localTime?.minute ?? 0
)
)
.font(.custom("Menlo", size: userSettings.localTimeFontSize))
}

if userSettings.localTimeSecondsFontSize > 0 {
Text(
Expand Down Expand Up @@ -57,16 +59,18 @@ struct MainTimeView: View {
.font(.custom("Menlo", size: userSettings.timeZoneDateFontSize))
}

Text(
dateTime == nil
? "---"
: String(
format: "%02d:%02d:%02d",
dateTime?.hour ?? 0,
dateTime?.minute ?? 0,
dateTime?.second ?? 0)
)
.font(.custom("Menlo", size: userSettings.timeZoneTimeFontSize))
if userSettings.timeZoneTimeFontSize > 0 {
Text(
dateTime == nil
? "---"
: String(
format: "%02d:%02d:%02d",
dateTime?.hour ?? 0,
dateTime?.minute ?? 0,
dateTime?.second ?? 0)
)
.font(.custom("Menlo", size: userSettings.timeZoneTimeFontSize))
}
}
}
}
Expand Down

0 comments on commit 971f221

Please sign in to comment.