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

@ -46,6 +46,8 @@ struct AccountTransactionsDialog: View {
@State private var errorMessage: Message? = nil
@State private var isInitialized = false
@Inject private var presenter: BankingPresenterSwift
@ -142,7 +144,11 @@ struct AccountTransactionsDialog: View {
.systemGroupedBackground()
}
.executeMutatingMethod {
self.setInitialValues()
if isInitialized == false {
isInitialized = true
self.setInitialValues()
}
}
.alert(message: $errorMessage)
.showNavigationBarTitle(LocalizedStringKey(title))

View File

@ -72,6 +72,9 @@ struct FlickerCodeTanView: View {
}
@State private var isInitialized = false
init(_ tanChallenge: BankingUiSwift.FlickerCodeTanChallenge) {
self.tanChallenge = tanChallenge
@ -149,9 +152,13 @@ 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 {
self.calculateStripeWidth()
self.animator.animate(self.tanChallenge.flickerCode.parsedDataSet, self.showStep)
if isInitialized == false {
isInitialized = true
self.calculateStripeWidth()
self.animator.animate(self.tanChallenge.flickerCode.parsedDataSet, self.showStep)
}
}
}