Shows when app receives memory warning

main
Laurent 3 years ago
parent 845b9a7eac
commit 47be480d37
  1. 1
      LeCountdown/AppDelegate.swift
  2. 2
      LeCountdown/Conductor.swift
  3. 5
      LeCountdown/Views/ContentView.swift

@ -46,6 +46,7 @@ class AppDelegate : NSObject, UIApplicationDelegate {
} }
func applicationDidReceiveMemoryWarning(_ application: UIApplication) { func applicationDidReceiveMemoryWarning(_ application: UIApplication) {
Conductor.maestro.memoryWarningReceived = true
Logger.log("applicationDidReceiveMemoryWarning") Logger.log("applicationDidReceiveMemoryWarning")
FileLogger.log("applicationDidReceiveMemoryWarning") FileLogger.log("applicationDidReceiveMemoryWarning")
} }

@ -35,6 +35,8 @@ class Conductor: ObservableObject {
@Published private (set) var liveTimers: [LiveTimer] = [] @Published private (set) var liveTimers: [LiveTimer] = []
@Published var memoryWarningReceived: Bool = false
init() { init() {
self.currentCountdowns = Conductor.savedCountdowns self.currentCountdowns = Conductor.savedCountdowns
self.currentStopwatches = Conductor.savedStopwatches self.currentStopwatches = Conductor.savedStopwatches

@ -83,6 +83,11 @@ struct ContentView<T : AbstractTimer>: View {
// .environment(\.managedObjectContext, viewContext) // .environment(\.managedObjectContext, viewContext)
// }) // })
.toolbar { .toolbar {
if Conductor.maestro.memoryWarningReceived {
ToolbarItemGroup(placement: .navigationBarTrailing) {
Image(systemName: "circle.fill").font(.caption2).foregroundColor(.orange)
}
}
MainToolbarView(isEditing: self.$isEditing) MainToolbarView(isEditing: self.$isEditing)
} }
.onAppear { .onAppear {

Loading…
Cancel
Save