diff --git a/LeCountdown.xcodeproj/project.pbxproj b/LeCountdown.xcodeproj/project.pbxproj index 260401d..6099853 100644 --- a/LeCountdown.xcodeproj/project.pbxproj +++ b/LeCountdown.xcodeproj/project.pbxproj @@ -116,7 +116,6 @@ C473C32C29AA330E0056B38A /* Localizable.strings in Resources */ = {isa = PBXBuildFile; fileRef = C473C32A29AA330E0056B38A /* Localizable.strings */; }; C473C33029ACADC80056B38A /* Localizable.strings in Resources */ = {isa = PBXBuildFile; fileRef = C473C32A29AA330E0056B38A /* Localizable.strings */; }; C473C33929ACDBD70056B38A /* TipView.swift in Sources */ = {isa = PBXBuildFile; fileRef = C473C33829ACDBD70056B38A /* TipView.swift */; }; - C473C33A29ACDBD70056B38A /* TipView.swift in Sources */ = {isa = PBXBuildFile; fileRef = C473C33829ACDBD70056B38A /* TipView.swift */; }; C473C33C29ACEC4F0056B38A /* Tip.swift in Sources */ = {isa = PBXBuildFile; fileRef = C473C33B29ACEC4F0056B38A /* Tip.swift */; }; C473C33D29ACEC4F0056B38A /* Tip.swift in Sources */ = {isa = PBXBuildFile; fileRef = C473C33B29ACEC4F0056B38A /* Tip.swift */; }; C4742B5729840F6400D5D950 /* CoolPic.swift in Sources */ = {isa = PBXBuildFile; fileRef = C4742B5629840F6400D5D950 /* CoolPic.swift */; }; @@ -1469,7 +1468,6 @@ C473C2F029A8CFFC0056B38A /* TimerRouter.swift in Sources */, C4286EAD2A1775390070D075 /* AppError.swift in Sources */, C438C800298130E900BF3EF9 /* IntentDataProvider.swift in Sources */, - C473C33A29ACDBD70056B38A /* TipView.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/LeCountdown/LeCountdownApp.swift b/LeCountdown/LeCountdownApp.swift index e37f648..b9d3ceb 100644 --- a/LeCountdown/LeCountdownApp.swift +++ b/LeCountdown/LeCountdownApp.swift @@ -50,8 +50,8 @@ struct LeCountdownApp: App { Conductor.maestro.stopMainPlayersIfPossible() Conductor.maestro.memoryWarningReceived = false case .active: - Logger.log("onChange(of: scenePhase) active") - Logger.log(Conductor.maestro.currentCountdowns.count) +// Logger.log("onChange(of: scenePhase) active") +// Logger.log(Conductor.maestro.currentCountdowns.count) Conductor.maestro.restoreSoundPlayers() Conductor.maestro.cleanup() default: @@ -160,4 +160,10 @@ struct LeCountdownApp: App { } + static func askPermissions() { + UNUserNotificationCenter.current().requestAuthorization(options: [.alert, .sound]) { success, error in + print("requestAuthorization > success = \(success), error = \(String(describing: error))") + } + } + } diff --git a/LeCountdown/Utils/Tip.swift b/LeCountdown/Utils/Tip.swift index 739081c..48795de 100644 --- a/LeCountdown/Utils/Tip.swift +++ b/LeCountdown/Utils/Tip.swift @@ -26,4 +26,10 @@ enum Tip: Int, CaseIterable, Identifiable { case .widget: return "app.badge" } } + + var link: URL? { + switch self { + case .widget: return URL(string: "https://support.apple.com/en-us/HT207122") + } + } } diff --git a/LeCountdown/Views/ContentView.swift b/LeCountdown/Views/ContentView.swift index fe60dc6..dd2b877 100644 --- a/LeCountdown/Views/ContentView.swift +++ b/LeCountdown/Views/ContentView.swift @@ -19,7 +19,7 @@ struct ContentView: View { @State private var isEditing: Bool = false - @State private var tipsShown: Bool = false + @State private var showTip: Tip? = nil @State private var siriTipShown: Bool = false @@ -56,6 +56,11 @@ struct ContentView: View { .foregroundColor(.black) .background(self._backgroundColor) .cornerRadius(32.0, corners: [.topRight, .topLeft]) + } else if let tip = self.showTip { + TipView(tip: tip) { + Preferences.lastShownTip = tip.rawValue + self.showTip = nil + }.padding() } } .navigationTitle(Bundle.main.applicationName) @@ -71,7 +76,7 @@ struct ContentView: View { MainToolbarView(isEditing: self.$isEditing) } .onAppear { - self._askPermissions() + self.showTip = Preferences.tipToShow } .onOpenURL { url in self._performActionIfPossible(url: url) @@ -97,16 +102,10 @@ struct ContentView: View { // MARK: - Business - fileprivate func _hideTip(_ tip: Tip) { - Preferences.lastShownTip = tip.rawValue - self.tipsShown = true - } - - fileprivate func _askPermissions() { - UNUserNotificationCenter.current().requestAuthorization(options: [.alert, .sound]) { success, error in - print("requestAuthorization > success = \(success), error = \(String(describing: error))") - } - } +// fileprivate func _hideTip(_ tip: Tip) { +// Preferences.lastShownTip = tip.rawValue +// self.tipsShown = true +// } fileprivate func _performActionIfPossible(url: URL) { diff --git a/LeCountdown/Views/DialView.swift b/LeCountdown/Views/DialView.swift index 3595f91..bbb91fb 100644 --- a/LeCountdown/Views/DialView.swift +++ b/LeCountdown/Views/DialView.swift @@ -127,6 +127,8 @@ struct DialView: View { self.handler?(self.timer) + LeCountdownApp.askPermissions() + TimerRouter.performAction(timer: self.timer) { result in switch result { case .success: diff --git a/LeCountdown/Views/Reusable/TipView.swift b/LeCountdown/Views/Reusable/TipView.swift index f6a105c..0a44507 100644 --- a/LeCountdown/Views/Reusable/TipView.swift +++ b/LeCountdown/Views/Reusable/TipView.swift @@ -17,8 +17,16 @@ struct TipView: View { HStack { Image(systemName: tip.pictoName) - Text(tip.localizedString) - .font(.footnote) + VStack(alignment: .leading) { + Text(tip.localizedString) + if let link = tip.link { + Button { + UIApplication.shared.canOpenURL(link) + } label: { + Text("Learn more") + }.buttonStyle(.bordered) + } + }.font(.footnote) Spacer() Image(systemName: "xmark.circle.fill") .padding(8.0) @@ -27,9 +35,10 @@ struct TipView: View { self.handler() } } + .monospaced() .padding(12.0) .foregroundColor(.white) - .background(.cyan) + .background(Color.accentColor) .cornerRadius(16.0) } } diff --git a/LeCountdown/fr.lproj/Localizable.strings b/LeCountdown/fr.lproj/Localizable.strings index df63f5d..5377740 100644 --- a/LeCountdown/fr.lproj/Localizable.strings +++ b/LeCountdown/fr.lproj/Localizable.strings @@ -220,7 +220,7 @@ /* No comment provided by engineer. */ "Yes" = "Oui"; -"You can add widget for your timers and countdowns by modifying your home or lock screen" = "You pouvez ajouter des widgets pour vos minuteurs et chronomètres en modifiant votre écran verrouillé ou votre page d'accueil"; +"You can add widget for your timers and countdowns by modifying your home or lock screen" = "Lancez rapidement vos minuteurs avec les widgets ! Ajoutez les à votre écran verrouillé ou votre page d'accueil"; /* No comment provided by engineer. */ "You can ask Siri to create and launch countdowns and stopwatches" = "Vous pouvez demander à Siri de vous lancer les minuteurs et les chronos";