Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IOS-7945 Custom fee fileds #3879

Merged
merged 2 commits into from
Sep 18, 2024
Merged

Conversation

Balashov152
Copy link
Contributor

Была проблема что мы проставляем decimalValue раньше чем TextFiled показывается на экране, и по этому onChange не вызывается и UI не меняется

@Balashov152 Balashov152 requested review from tureck1y and a team as code owners September 18, 2024 10:10
@Balashov152 Balashov152 added the release ASAP to look label Sep 18, 2024
Comment on lines +49 to +62
if #available(iOS 17.0, *) {
view
.onChange(of: viewModel.decimalValue, initial: true) { _, newDecimalValue in
updateValues(decimalValue: newDecimalValue)
}
} else {
view
.onChange(of: viewModel.decimalValue) { newDecimalValue in
updateValues(decimalValue: newDecimalValue)
}
.onAppear {
updateValues(decimalValue: viewModel.decimalValue)
}
}
Copy link
Contributor

@m3g0byt3 m3g0byt3 Sep 18, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Мне кстати абсолютно тоже самое понадобилось в шторке:

        if #available(iOS 17.0, *) {
            content
                .onChange(of: token, initial: true) { oldValue, newValue in
                    updateObserver(oldToken: oldValue, newToken: newValue)
                }
        } else {
            content
                .onChange(of: token) { [oldValue = token] newValue in
                    updateObserver(oldToken: oldValue, newToken: newValue)
                }
                .onAppear {
                    guard !isAppeared else {
                        return
                    }

                    /// Prevents warnings like "Modifying state during view update, this will cause undefined behavior."
                    DispatchQueue.main.async {
                        isAppeared = true
                    }

                    updateObserver(oldToken: token, newToken: token)
                }
        }

Только с одной доработкой - onAppear может дергаться два раза в некоторых кейсах, сам лично встречал такое

Выглядит так, что надо завести тех задачу на бэкпорт .onChange(of:initial:) на иос ниже 17 и написать один общий модификатор - благо весь код для него уже есть
Как думаешь?

@Balashov152 Balashov152 enabled auto-merge (squash) September 18, 2024 17:33
@tureck1y tureck1y merged commit f6f11d0 into releases/5.15 Sep 18, 2024
2 of 3 checks passed
@tureck1y tureck1y deleted the bugfix/IOS-7945-Custom-Fee branch September 18, 2024 18:18
Balashov152 added a commit that referenced this pull request Sep 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release ASAP to look
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants