Fixes loading

release
Laurent 3 years ago
parent 73b1cf09c0
commit 8c0bc4e585
  1. 2
      LeCountdown/Sound/Sound.swift
  2. 20
      LeCountdown/Views/Countdown/NewCountdownView.swift

@ -79,7 +79,7 @@ enum Sound: Int, CaseIterable, Identifiable, Localized {
switch self {
case .trainhorn: return NSLocalizedString("Train horn", comment: "")
case .forestStream: return NSLocalizedString("Forest stream", comment: "")
case .sbSEM_Synths_Loop4_Nothing_Like_You: return "Nothing_Like_You"
case .sbSEM_Synths_Loop4_Nothing_Like_You: return "Nothing Like You"
case .sbClave_Loop_LLL: return "LLL"
case .sbLoop_ToneSD_Boavista: return "Boavista"
case .sbArpeggio_Loop_River: return "River 1"

@ -54,8 +54,13 @@ struct CountdownEditView : View {
private var countdowns: FetchedResults<Countdown>
@State var _isAdding: Bool = false
@State var _hasLoaded = false
@Environment(\.isPresented) var envIsPresented
//
// init() {
// self._load()
// }
var body: some View {
NavigationStack {
@ -63,7 +68,7 @@ struct CountdownEditView : View {
.frame(width: 0.0, height: 0.0)
.onChange(of: envIsPresented) { newValue in
if !newValue && !self._isAdding {
self._save()
self._save() // save when leaving an edit screen
}
}
CountdownFormView(
@ -141,14 +146,16 @@ struct CountdownEditView : View {
fileprivate func _onAppear() {
// self.playlists = PlaylistSelection.allPlaylists()
self._isAdding = (self.countdown == nil)
if !self._hasLoaded {
self._load()
self._hasLoaded = true
}
}
fileprivate func _load() {
if let countdown {
print("self.soundList = \(countdown.soundList)")
let minutes = Int(countdown.duration / 60.0)
let seconds = countdown.duration - Double(minutes * 60)
@ -175,7 +182,6 @@ struct CountdownEditView : View {
self.image = coolpic
}
}
}
fileprivate let _numberFormatter = NumberFormatter()

Loading…
Cancel
Save