From cca8ba643dab80f7d680dda14f0cc5f9a9a0b163 Mon Sep 17 00:00:00 2001 From: Laurent Date: Mon, 6 Mar 2023 15:02:29 +0100 Subject: [PATCH] Fixes small issues --- LeCountdown/Conductor.swift | 2 +- .../Model/Model+SharedExtensions.swift | 22 ++++++++++++++++++- LeCountdown/Views/PresetsView.swift | 7 +++--- 3 files changed, 26 insertions(+), 5 deletions(-) diff --git a/LeCountdown/Conductor.swift b/LeCountdown/Conductor.swift index c8419cd..593120c 100644 --- a/LeCountdown/Conductor.swift +++ b/LeCountdown/Conductor.swift @@ -236,7 +236,7 @@ class Conductor: ObservableObject { fileprivate func _createTimerIntent(_ timer: AbstractTimer) { let intent = LaunchTimerIntent() - let invocationPhrase = NSLocalizedString("Launch %@", comment: "") + let invocationPhrase = String(format: NSLocalizedString("Launch %@", comment: ""), timer.displayName) intent.suggestedInvocationPhrase = String(format: invocationPhrase, timer.displayName) intent.timer = TimerIdentifier(identifier: timer.stringId, display: timer.displayName) diff --git a/LeCountdown/Model/Model+SharedExtensions.swift b/LeCountdown/Model/Model+SharedExtensions.swift index 7fcb5a4..adfb835 100644 --- a/LeCountdown/Model/Model+SharedExtensions.swift +++ b/LeCountdown/Model/Model+SharedExtensions.swift @@ -10,12 +10,16 @@ import Foundation extension AbstractTimer { var displayName: String { - return self.name ?? self.coolpic.emoji + return self.name ?? self.defaultName } var name: String? { return self.activity?.name } + + @objc var defaultName: String { + return NSLocalizedString("timer", comment: "") + } var url: URL { if let url = URL(string: self.stringId) { @@ -37,3 +41,19 @@ extension AbstractTimer { } } + +extension Countdown { + + override var defaultName: String { + return NSLocalizedString("Countdown", comment: "") + } + +} + +extension Stopwatch { + + override var defaultName: String { + return NSLocalizedString("Stopwatch", comment: "") + } + +} diff --git a/LeCountdown/Views/PresetsView.swift b/LeCountdown/Views/PresetsView.swift index d185377..b39c0d2 100644 --- a/LeCountdown/Views/PresetsView.swift +++ b/LeCountdown/Views/PresetsView.swift @@ -262,10 +262,11 @@ struct TimerItemView: View { var body: some View { HStack { VStack(alignment: .leading) { - Text(name.uppercased()).multilineTextAlignment(.leading) - Text(duration) - Text(sound.uppercased()).foregroundColor(Color(white: 0.7)) + Text(self.name.uppercased()) + Text(self.duration) + Text(self.sound.uppercased()).foregroundColor(Color(white: 0.7)) }.padding() + .multilineTextAlignment(.leading) Spacer() }.background(Color(white: 0.1)) .cornerRadius(16.0)