diff --git a/ios/MullvadVPN.xcodeproj/project.pbxproj b/ios/MullvadVPN.xcodeproj/project.pbxproj index de03d091ad37..9217be882b53 100644 --- a/ios/MullvadVPN.xcodeproj/project.pbxproj +++ b/ios/MullvadVPN.xcodeproj/project.pbxproj @@ -1059,6 +1059,7 @@ F0FADDEA2BE90AAA000D0B02 /* LaunchArguments.swift in Sources */ = {isa = PBXBuildFile; fileRef = F0F1EF8C2BE8FF0A00CED01D /* LaunchArguments.swift */; }; F0FADDEC2BE90AB0000D0B02 /* LaunchArguments.swift in Sources */ = {isa = PBXBuildFile; fileRef = F0F1EF8C2BE8FF0A00CED01D /* LaunchArguments.swift */; }; F998EFF82D359C4600D88D01 /* SKProduct+Formatting.swift in Sources */ = {isa = PBXBuildFile; fileRef = 58FD5BEF24238EB300112C88 /* SKProduct+Formatting.swift */; }; + F998EFFA2D3656BA00D88D01 /* SKProduct+Sorting.swift in Sources */ = {isa = PBXBuildFile; fileRef = F998EFF92D3656B100D88D01 /* SKProduct+Sorting.swift */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ @@ -2318,6 +2319,7 @@ F0F316182BF3572B0078DBCF /* RelaySelectorResult.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RelaySelectorResult.swift; sourceTree = ""; }; F0F3161A2BF358590078DBCF /* NoRelaysSatisfyingConstraintsError.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NoRelaysSatisfyingConstraintsError.swift; sourceTree = ""; }; F0FBD98E2C4A60CC00EE5323 /* KeyExchangingResultStub.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = KeyExchangingResultStub.swift; sourceTree = ""; }; + F998EFF92D3656B100D88D01 /* SKProduct+Sorting.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "SKProduct+Sorting.swift"; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -3146,6 +3148,7 @@ 583FE02329C1AC9F006E85F9 /* Extensions */ = { isa = PBXGroup; children = ( + F998EFF92D3656B100D88D01 /* SKProduct+Sorting.swift */, 5891BF1B25E3E3EB006D6FB0 /* Bundle+ProductVersion.swift */, F06200092CB7EB42002E6DB9 /* CGSize+Helpers.swift */, 587EB669270EFACB00123C75 /* CharacterSet+IPAddress.swift */, @@ -6009,6 +6012,7 @@ 58968FAE28743E2000B799DC /* TunnelInteractor.swift in Sources */, 7A1A26472A29CF0800B978AA /* RelayFilterDataSource.swift in Sources */, 5864AF0929C78850005B0CD9 /* VPNSettingsCellFactory.swift in Sources */, + F998EFFA2D3656BA00D88D01 /* SKProduct+Sorting.swift in Sources */, F050AE4E2B70D7F8003F4EDB /* LocationCellViewModel.swift in Sources */, 58CEB30C2AFD586600E6E088 /* DynamicBackgroundConfiguration.swift in Sources */, 587B7536266528A200DEF7E9 /* NotificationManager.swift in Sources */, diff --git a/ios/MullvadVPN/Coordinators/AccountCoordinator.swift b/ios/MullvadVPN/Coordinators/AccountCoordinator.swift index 78cc78ba75e8..165474823199 100644 --- a/ios/MullvadVPN/Coordinators/AccountCoordinator.swift +++ b/ios/MullvadVPN/Coordinators/AccountCoordinator.swift @@ -91,7 +91,7 @@ final class AccountCoordinator: Coordinator, Presentable, Presenting, @unchecked comment: "" ) let alert = UIAlertController(title: localizedString, message: nil, preferredStyle: .actionSheet) - availableProducts.forEach { product in + availableProducts.sortedByPrice().forEach { product in guard let localizedTitle = product.customLocalizedTitle else { return } diff --git a/ios/MullvadVPN/Coordinators/OutOfTimeCoordinator.swift b/ios/MullvadVPN/Coordinators/OutOfTimeCoordinator.swift index d1e59b69ffd7..7feb60bd3587 100644 --- a/ios/MullvadVPN/Coordinators/OutOfTimeCoordinator.swift +++ b/ios/MullvadVPN/Coordinators/OutOfTimeCoordinator.swift @@ -96,7 +96,7 @@ class OutOfTimeCoordinator: Coordinator, Presenting, @preconcurrency OutOfTimeVi comment: "" ) let alert = UIAlertController(title: localizedString, message: nil, preferredStyle: .actionSheet) - products.forEach { product in + products.sortedByPrice().forEach { product in guard let localizedTitle = product.customLocalizedTitle else { return } diff --git a/ios/MullvadVPN/Coordinators/WelcomeCoordinator.swift b/ios/MullvadVPN/Coordinators/WelcomeCoordinator.swift index a9dab2ab0acf..789ee4859567 100644 --- a/ios/MullvadVPN/Coordinators/WelcomeCoordinator.swift +++ b/ios/MullvadVPN/Coordinators/WelcomeCoordinator.swift @@ -161,7 +161,7 @@ extension WelcomeCoordinator: @preconcurrency WelcomeViewControllerDelegate { comment: "" ) let alert = UIAlertController(title: localizedString, message: nil, preferredStyle: .actionSheet) - availableProducts.forEach { product in + availableProducts.sortedByPrice().forEach { product in guard let localizedTitle = product.customLocalizedTitle else { return } diff --git a/ios/MullvadVPN/Extensions/SKProduct+Sorting.swift b/ios/MullvadVPN/Extensions/SKProduct+Sorting.swift new file mode 100644 index 000000000000..b066bb5091fc --- /dev/null +++ b/ios/MullvadVPN/Extensions/SKProduct+Sorting.swift @@ -0,0 +1,15 @@ +// +// SKProduct+Sorting.swift +// MullvadVPN +// +// Created by Steffen Ernst on 2025-01-14. +// Copyright © 2025 Mullvad VPN AB. All rights reserved. +// + +import StoreKit + +extension Array where Element == SKProduct { + func sortedByPrice() -> [SKProduct] { + sorted { ($0.price as Decimal) < ($1.price as Decimal) } + } +}