diff --git a/Passepartout/App/Constants/Theme.swift b/Passepartout/App/Constants/Theme.swift index 5f4f8078..d71a34ac 100644 --- a/Passepartout/App/Constants/Theme.swift +++ b/Passepartout/App/Constants/Theme.swift @@ -310,6 +310,20 @@ extension View { } } +// MARK: Animations + +extension View { + func themeAnimation(on value: V) -> some View { + animation(.default, value: value) + } +} + +extension Binding { + func themeAnimation() -> Binding { + animation(.default) + } +} + // MARK: Shortcuts extension View { diff --git a/Passepartout/App/Views/AddHostView.swift b/Passepartout/App/Views/AddHostView.swift index 1a0c757d..d776cf87 100644 --- a/Passepartout/App/Views/AddHostView.swift +++ b/Passepartout/App/Views/AddHostView.swift @@ -61,7 +61,7 @@ struct AddHostView: View { } else { completeView } - }.animation(.default, value: viewModel) + }.themeAnimation(on: viewModel) }.toolbar { themeCloseItem(isPresented: bindings.$isPresented) ToolbarItem(placement: .primaryAction) { diff --git a/Passepartout/App/Views/AddProviderView.swift b/Passepartout/App/Views/AddProviderView.swift index 547d3e40..c65d9a43 100644 --- a/Passepartout/App/Views/AddProviderView.swift +++ b/Passepartout/App/Views/AddProviderView.swift @@ -84,7 +84,7 @@ struct AddProviderView: View { }.onChange(of: viewModel.errorMessage) { onErrorMessage($0, scrollProxy) }.disabled(viewModel.pendingOperation != nil) - .animation(.default, value: providers) + .themeAnimation(on: providers) } }.toolbar { themeCloseItem(isPresented: bindings.$isPresented) diff --git a/Passepartout/App/Views/DonateView.swift b/Passepartout/App/Views/DonateView.swift index c5b2365b..56d619c0 100644 --- a/Passepartout/App/Views/DonateView.swift +++ b/Passepartout/App/Views/DonateView.swift @@ -73,7 +73,7 @@ struct DonateView: View { if newValue == .active { productManager.refreshProducts() } - }.animation(.default, value: productManager.isRefreshingProducts) + }.themeAnimation(on: productManager.isRefreshingProducts) } private func presentedAlert(_ alertType: AlertType) -> Alert { diff --git a/Passepartout/App/Views/EndpointView+OpenVPN.swift b/Passepartout/App/Views/EndpointView+OpenVPN.swift index d07c09a6..25c419d4 100644 --- a/Passepartout/App/Views/EndpointView+OpenVPN.swift +++ b/Passepartout/App/Views/EndpointView+OpenVPN.swift @@ -132,7 +132,7 @@ extension EndpointView { extension EndpointView.OpenVPNView { private var mainSection: some View { Section { - Toggle(L10n.Global.Strings.automatic, isOn: $isAutomatic.animation()) + Toggle(L10n.Global.Strings.automatic, isOn: $isAutomatic.themeAnimation()) } } diff --git a/Passepartout/App/Views/NetworkSettingsView.swift b/Passepartout/App/Views/NetworkSettingsView.swift index 43016227..3ee3d3e6 100644 --- a/Passepartout/App/Views/NetworkSettingsView.swift +++ b/Passepartout/App/Views/NetworkSettingsView.swift @@ -100,7 +100,7 @@ extension NetworkSettingsView { Section( header: Text(L10n.NetworkSettings.Gateway.title) ) { - Toggle(L10n.Global.Strings.automatic, isOn: $settings.isAutomaticGateway.animation()) + Toggle(L10n.Global.Strings.automatic, isOn: $settings.isAutomaticGateway.themeAnimation()) if !settings.isAutomaticGateway { Toggle(Unlocalized.Network.ipv4, isOn: $settings.gateway.isDefaultIPv4) @@ -119,7 +119,7 @@ extension NetworkSettingsView { Section( header: Text(Unlocalized.Network.dns) ) { - Toggle(L10n.Global.Strings.automatic, isOn: $settings.isAutomaticDNS.animation()) + Toggle(L10n.Global.Strings.automatic, isOn: $settings.isAutomaticDNS.themeAnimation()) if !settings.isAutomaticDNS { themeTextPicker( @@ -212,7 +212,7 @@ extension NetworkSettingsView { Section( header: Text(L10n.Global.Strings.proxy) ) { - Toggle(L10n.Global.Strings.automatic, isOn: $settings.isAutomaticProxy.animation()) + Toggle(L10n.Global.Strings.automatic, isOn: $settings.isAutomaticProxy.themeAnimation()) if !settings.isAutomaticProxy { themeTextPicker( @@ -275,7 +275,7 @@ extension NetworkSettingsView { Section( header: Text(Unlocalized.Network.mtu) ) { - Toggle(L10n.Global.Strings.automatic, isOn: $settings.isAutomaticMTU.animation()) + Toggle(L10n.Global.Strings.automatic, isOn: $settings.isAutomaticMTU.themeAnimation()) if !settings.isAutomaticMTU { themeTextPicker( diff --git a/Passepartout/App/Views/OnDemandView.swift b/Passepartout/App/Views/OnDemandView.swift index f35b0e2d..9e6aecb8 100644 --- a/Passepartout/App/Views/OnDemandView.swift +++ b/Passepartout/App/Views/OnDemandView.swift @@ -72,7 +72,7 @@ struct OnDemandView: View { extension OnDemandView { private var enabledView: some View { Section { - Toggle(L10n.Global.Strings.enabled, isOn: $onDemand.isEnabled.animation()) + Toggle(L10n.Global.Strings.enabled, isOn: $onDemand.isEnabled.themeAnimation()) } } diff --git a/Passepartout/App/Views/OrganizerView+Profiles.swift b/Passepartout/App/Views/OrganizerView+Profiles.swift index 3f9aa92b..5defcfe7 100644 --- a/Passepartout/App/Views/OrganizerView+Profiles.swift +++ b/Passepartout/App/Views/OrganizerView+Profiles.swift @@ -83,7 +83,7 @@ extension OrganizerView { ForEach(otherHeaders, content: profileButton(forHeader:)) .onDelete(perform: removeOtherProfiles) } - }.animation(.default, value: profileManager.headers) + }.themeAnimation(on: profileManager.headers) } private var emptyView: some View { diff --git a/Passepartout/App/Views/PaywallView+Purchase.swift b/Passepartout/App/Views/PaywallView+Purchase.swift index 34e90226..ca1e3295 100644 --- a/Passepartout/App/Views/PaywallView+Purchase.swift +++ b/Passepartout/App/Views/PaywallView+Purchase.swift @@ -83,7 +83,7 @@ extension PaywallView { if newValue == .active { productManager.refreshProducts() } - }.animation(.default, value: productManager.isRefreshingProducts) + }.themeAnimation(on: productManager.isRefreshingProducts) } private func presentedAlert(_ alertType: AlertType) -> Alert { diff --git a/Passepartout/App/Views/ShortcutsView.swift b/Passepartout/App/Views/ShortcutsView.swift index 05488451..12a5a7d5 100644 --- a/Passepartout/App/Views/ShortcutsView.swift +++ b/Passepartout/App/Views/ShortcutsView.swift @@ -73,7 +73,7 @@ struct ShortcutsView: View { // reloading .onAppear { intentsManager.reloadShortcuts() - }.animation(.default, value: intentsManager.isReloadingShortcuts) + }.themeAnimation(on: intentsManager.isReloadingShortcuts) // IntentsUI .onReceive(intentsManager.shouldDismissIntentView) { _ in