From 1e0d522010ebffd98a7295c530c2667ff19b3517 Mon Sep 17 00:00:00 2001 From: Davide De Rosa Date: Sat, 25 Mar 2023 17:05:53 +0100 Subject: [PATCH] Drop #available condition on iOS 15 (#274) --- Passepartout/App/Constants/Theme.swift | 17 +++-------------- .../App/Reusable/DestructiveButton.swift | 6 +----- .../App/Views/OrganizerView+Profiles.swift | 2 ++ .../App/Views/ProviderLocationView.swift | 14 ++++++-------- Passepartout/App/Views/View+Extensions.swift | 4 +--- .../Managers/ProfileManager.swift | 4 +--- 6 files changed, 14 insertions(+), 33 deletions(-) diff --git a/Passepartout/App/Constants/Theme.swift b/Passepartout/App/Constants/Theme.swift index 2e1cdf5b..cdd3d928 100644 --- a/Passepartout/App/Constants/Theme.swift +++ b/Passepartout/App/Constants/Theme.swift @@ -45,10 +45,7 @@ extension View { #if targetEnvironment(macCatalyst) false #else - guard #available(iOS 15, *) else { - return false - } - return UIDevice.current.userInterfaceIdiom == .pad + UIDevice.current.userInterfaceIdiom == .pad #endif } } @@ -106,11 +103,7 @@ extension View { @ViewBuilder private func themeTint() -> some View { - if #available(iOS 15, *) { - tint(.accentColor) - } else { - self - } + tint(.accentColor) } private func themeListStyleValue() -> some ListStyle { @@ -118,11 +111,7 @@ extension View { } private func themeToggleStyleValue() -> some ToggleStyle { - if #available(iOS 15, *) { - return .switch - } else { - return SwitchToggleStyle(tint: .accentColor) - } + .switch } } diff --git a/Passepartout/App/Reusable/DestructiveButton.swift b/Passepartout/App/Reusable/DestructiveButton.swift index da4661e7..f19e8a12 100644 --- a/Passepartout/App/Reusable/DestructiveButton.swift +++ b/Passepartout/App/Reusable/DestructiveButton.swift @@ -31,10 +31,6 @@ struct DestructiveButton: View { let label: () -> Label var body: some View { - if #available(iOS 15, *) { - Button(role: .destructive, action: action, label: label) - } else { - Button(action: action, label: label) - } + Button(role: .destructive, action: action, label: label) } } diff --git a/Passepartout/App/Views/OrganizerView+Profiles.swift b/Passepartout/App/Views/OrganizerView+Profiles.swift index 4c17fae9..22407153 100644 --- a/Passepartout/App/Views/OrganizerView+Profiles.swift +++ b/Passepartout/App/Views/OrganizerView+Profiles.swift @@ -148,6 +148,8 @@ extension OrganizerView { } var body: some View { + + // XXX: iOS bug, before 16, context menu is not redrawn on VPN state change if #available(iOS 16, *), isActiveProfileNotDisconnected { reconnectButton } diff --git a/Passepartout/App/Views/ProviderLocationView.swift b/Passepartout/App/Views/ProviderLocationView.swift index 3a992b03..a33ffc4a 100644 --- a/Passepartout/App/Views/ProviderLocationView.swift +++ b/Passepartout/App/Views/ProviderLocationView.swift @@ -99,14 +99,12 @@ struct ProviderLocationView: View, ProviderProfileAvailability { EmptyView() } }.toolbar { - if #available(iOS 15, *) { - Button { - withAnimation { - isShowingFavorites.toggle() - } - } label: { - themeFavoritesImage(isShowingFavorites).asSystemImage + Button { + withAnimation { + isShowingFavorites.toggle() } + } label: { + themeFavoritesImage(isShowingFavorites).asSystemImage } }.navigationTitle(L10n.Provider.Location.title) } @@ -133,7 +131,7 @@ struct ProviderLocationView: View, ProviderProfileAvailability { private func categorySection(_ category: ProviderCategory) -> some View { Section { ForEach(filteredLocations(for: category)) { location in - if isEditable, #available(iOS 15, *) { + if isEditable { locationRow(location) .swipeActions(edge: .trailing, allowsFullSwipe: false) { favoriteActions(location) diff --git a/Passepartout/App/Views/View+Extensions.swift b/Passepartout/App/Views/View+Extensions.swift index 698329ab..fc6abc24 100644 --- a/Passepartout/App/Views/View+Extensions.swift +++ b/Passepartout/App/Views/View+Extensions.swift @@ -106,9 +106,7 @@ extension View { extension View { func debugChanges() { - if #available(iOS 15, *), - SwiftyBeaver.destinations.first?.minLevel == .verbose { - + if SwiftyBeaver.destinations.first?.minLevel == .verbose { Self._printChanges() } } diff --git a/PassepartoutLibrary/Sources/PassepartoutProfiles/Managers/ProfileManager.swift b/PassepartoutLibrary/Sources/PassepartoutProfiles/Managers/ProfileManager.swift index fa8c993a..fd6818bf 100644 --- a/PassepartoutLibrary/Sources/PassepartoutProfiles/Managers/ProfileManager.swift +++ b/PassepartoutLibrary/Sources/PassepartoutProfiles/Managers/ProfileManager.swift @@ -230,9 +230,7 @@ extension ProfileManager { if setAsCurrent { // iOS 14 goes crazy when changing binding of a presented NavigationLink - if #available(iOS 15, *) { - internalCurrentProfileId = copy.id - } + internalCurrentProfileId = copy.id // autosaves copy if non-existing in persistent store setCurrentProfile(copy)