From dc32cf53c69544d1b07bb78efaf9d1a3aa0c6b24 Mon Sep 17 00:00:00 2001 From: Aaron Brethorst Date: Sat, 30 Nov 2024 11:41:09 -0800 Subject: [PATCH] Fix deprecation warnings for onChange(of:perform:) in iOS 17.0 Fixes #762 Co-authored-by: Manu R --- OBAKit/Controls/Navigation/RenamableNavigationTitle.swift | 4 ++-- OBAKit/Donations/DonationLearnMoreView.swift | 2 +- OBAKit/Onboarding/RegionPicker/RegionPickerView.swift | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/OBAKit/Controls/Navigation/RenamableNavigationTitle.swift b/OBAKit/Controls/Navigation/RenamableNavigationTitle.swift index c410252f5..5d5d9fea2 100644 --- a/OBAKit/Controls/Navigation/RenamableNavigationTitle.swift +++ b/OBAKit/Controls/Navigation/RenamableNavigationTitle.swift @@ -34,10 +34,10 @@ fileprivate struct RenamableNavigationTitle: ViewModifier { // way to have an `onChange` to fire on initial value. textFieldValue = title } - .onChange(of: title) { newValue in + .onChange(of: title) { _, newValue in textFieldValue = newValue } - .onChange(of: isEditing) { newIsEditing in + .onChange(of: isEditing) { _, newIsEditing in isFocusedOnTextField = newIsEditing } } diff --git a/OBAKit/Donations/DonationLearnMoreView.swift b/OBAKit/Donations/DonationLearnMoreView.swift index f66522300..2fc174eba 100644 --- a/OBAKit/Donations/DonationLearnMoreView.swift +++ b/OBAKit/Donations/DonationLearnMoreView.swift @@ -76,7 +76,7 @@ struct DonationLearnMoreView: View { .alert("Enter an amount in U.S. dollars", isPresented: otherAmountSelected) { buildOtherAmountAlert() } - .onChange(of: donationModel.donationComplete) { newValue in + .onChange(of: donationModel.donationComplete) { _, newValue in guard newValue else { return } let shouldDismiss: Bool diff --git a/OBAKit/Onboarding/RegionPicker/RegionPickerView.swift b/OBAKit/Onboarding/RegionPicker/RegionPickerView.swift index c674383a0..111cf83c5 100644 --- a/OBAKit/Onboarding/RegionPicker/RegionPickerView.swift +++ b/OBAKit/Onboarding/RegionPicker/RegionPickerView.swift @@ -79,11 +79,11 @@ public struct RegionPickerView: View, OnboardingView { // Lifecycle-related modifiers .onAppear(perform: setCurrentRegionIfPresent) - .onChange(of: regionProvider.currentRegion) { [regionProvider] _ in + .onChange(of: regionProvider.currentRegion, initial: false) { _, newRegion in // When the user selects to automatically select a region, update // selectedRegion with the new current region. if regionProvider.automaticallySelectRegion { - self.selectedRegion = regionProvider.currentRegion + self.selectedRegion = newRegion } }