After considerable review of the Done button operation, I noticed that I could get the button to reappear by selecting another tab and then returning to the expense entry tab.
I added some breakpoints and noticed that some of the state parameters were not getting reset upon saving the data.
Finally, I moved the state parameter reset logic outside the getLocation closure and this appears to have fixed the state parameters for the next entry and the Done button. The weird Done button behavior is no longer occurring!
func saveButton() {
if moneyD == 0.0 {
zeroEntry = true
} else {
withAnimation {
// get coordinates and address
getLocation { addr in
self.addr = addr
// address
if let city = addr.locality {
entryLocCity = city
}
if let state = addr.administrativeArea {
entryLocState = state
}
if let countryL = addr.countryL {
entryLocCountryL = countryL
}
if let countryS = addr.countryS {
entryLocCountryS = countryS
}
guard let moneyD else { return }
let moneyH = categories.saveCategoryTotal(entryCat: self.entryCat, rate: rate, moneyD: moneyD)
modelContext.insert(TravelEntries(
id: UUID(),
entryDate: entryDT,
...
entryLocCity: entryLocCity,
entryLocState: entryLocState,
entryLocCountryS: entryLocCountryS,
entryLocCountryL: entryLocCountryL
))
dtTotals.addToDailyTotal(gotDate: entryDT, gotTotal: moneyH)
}
// reset parameters for next entry
self.entryDT = Date()
self.entryCat = 0
self.entryPT = 0
self.entryDsc = ""
self.moneyD = nil
}
}
Topic:
UI Frameworks
SubTopic:
SwiftUI
Tags: