Fixed that executeMutatingMethod() got executed on each view update

This commit is contained in:
dankito 2020-09-27 00:51:44 +02:00
parent 3be297c0d3
commit b5756c909f
2 changed files with 17 additions and 4 deletions

View File

@ -47,6 +47,8 @@ struct AccountTransactionsDialog: View {
@State private var errorMessage: Message? = nil
@State private var isInitialized = false
@Inject private var presenter: BankingPresenterSwift
@ -142,8 +144,12 @@ struct AccountTransactionsDialog: View {
.systemGroupedBackground()
}
.executeMutatingMethod {
if isInitialized == false {
isInitialized = true
self.setInitialValues()
}
}
.alert(message: $errorMessage)
.showNavigationBarTitle(LocalizedStringKey(title))
.navigationBarItems(trailing: UpdateButton { _, executingDone in self.updateTransactions(executingDone) })

View File

@ -72,6 +72,9 @@ struct FlickerCodeTanView: View {
}
@State private var isInitialized = false
init(_ tanChallenge: BankingUiSwift.FlickerCodeTanChallenge) {
self.tanChallenge = tanChallenge
@ -149,11 +152,15 @@ struct FlickerCodeTanView: View {
}
// what a hack to be able to call animator.animate() (otherwise compiler would throw 'use of immutable self in closure' error)
.executeMutatingMethod {
if isInitialized == false {
isInitialized = true
self.calculateStripeWidth()
self.animator.animate(self.tanChallenge.flickerCode.parsedDataSet, self.showStep)
}
}
}
private func showStep(_ step: Step) {