Adds tip view

main
Laurent 3 years ago
parent 9f760ea874
commit f0850bea64
  1. 2
      LeCountdown.xcodeproj/project.pbxproj
  2. 10
      LeCountdown/LeCountdownApp.swift
  3. 6
      LeCountdown/Utils/Tip.swift
  4. 23
      LeCountdown/Views/ContentView.swift
  5. 2
      LeCountdown/Views/DialView.swift
  6. 15
      LeCountdown/Views/Reusable/TipView.swift
  7. 2
      LeCountdown/fr.lproj/Localizable.strings

@ -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;
};

@ -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))")
}
}
}

@ -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")
}
}
}

@ -19,7 +19,7 @@ struct ContentView<T : AbstractTimer>: 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<T : AbstractTimer>: 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<T : AbstractTimer>: 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<T : AbstractTimer>: 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) {

@ -127,6 +127,8 @@ struct DialView: View {
self.handler?(self.timer)
LeCountdownApp.askPermissions()
TimerRouter.performAction(timer: self.timer) { result in
switch result {
case .success:

@ -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)
}
}

@ -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";

Loading…
Cancel
Save