Adding more logs

main
Laurent 3 years ago
parent 2cca84e670
commit 78b43f5f63
  1. 3
      LeCountdown/AppDelegate.swift
  2. 2
      LeCountdown/Conductor.swift
  3. 8
      LeCountdown/Utils/Date+Extensions.swift
  4. 4
      LeCountdown/Views/ContentView.swift
  5. 2
      LeCountdown/Views/LiveTimerListView.swift
  6. 4
      LeCountdown/Views/LogsView.swift

@ -9,6 +9,7 @@ import Foundation
import UIKit
import AVFoundation
import FirebaseCore
import FirebaseCrashlytics
class AppDelegate : NSObject, UIApplicationDelegate {
@ -84,8 +85,8 @@ extension AppDelegate: UNUserNotificationCenterDelegate {
func userNotificationCenter(_ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse) async {
print("didReceive notification")
FileLogger.log("userNotificationCenter didReceive > cancelling sound player")
let timerId = self._timerId(notificationId: response.notification.request.identifier)
// Conductor.maestro.cancelCountdown(id: timerId)
Conductor.maestro.cancelSoundPlayer(id: timerId)
}

@ -166,6 +166,8 @@ class Conductor: ObservableObject {
}
func cancelCountdown(id: TimerID) {
FileLogger.log("Cancel \(id)")
CountdownScheduler.master.cancelCurrentNotifications(countdownId: id)
self.cancelSoundPlayer(id: id)
self.cancelledCountdowns.append(id)

@ -22,6 +22,13 @@ extension Date {
return df
}()
static let dateTimeFormatter = {
let df = DateFormatter()
df.dateStyle = .short
df.timeStyle = .short
return df
}()
var startOfDay: Date {
return Calendar.current.startOfDay(for: self)
}
@ -36,5 +43,6 @@ extension Date {
var formattedYear: String { return "\(self.year)" }
var formattedMonth: String { return Date.monthYearFormatter.string(from: self) }
var formattedDay: String { return Date.dayFormatter.string(from: self) }
var formattedDateTime: String { return Date.dateTimeFormatter.string(from: self) }
}

@ -196,7 +196,9 @@ struct MainToolbarView: ToolbarContent {
Image(systemName: "list.dash")
}
.sheet(isPresented: self.$showLogsSheet, content: {
LogsView()
NavigationStack {
LogsView().navigationTitle("Logs")
}
})
if self.haveRecords() {
Button {

@ -203,6 +203,8 @@ struct LiveCountdownView: View {
}
fileprivate func _actionHandler() {
FileLogger.log("_actionHandler")
withAnimation {
if conductor.currentCountdowns[self.countdown.stringId] != nil {
self._cancelCountdown()

@ -10,7 +10,7 @@ import SwiftUI
struct LogsView: View {
var body: some View {
List {
ForEach(FileLogger.main.logs) { log in
ForEach(FileLogger.main.logs.reversed()) { log in
LogView(log: log)
}
}
@ -24,7 +24,7 @@ struct LogView: View {
var body: some View {
VStack(alignment: .leading) {
Text(log.date, style: .time)
Text(log.date.formattedDateTime)
.foregroundColor(.gray)
Text(log.content)
}.font(.footnote)

Loading…
Cancel
Save