Skip to content

Commit

Permalink
Sort purchase options by price
Browse files Browse the repository at this point in the history
  • Loading branch information
Steffen Ernst authored and SteffenErn committed Jan 15, 2025
1 parent 3057243 commit 1f51d38
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 3 deletions.
4 changes: 4 additions & 0 deletions ios/MullvadVPN.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down Expand Up @@ -2318,6 +2319,7 @@
F0F316182BF3572B0078DBCF /* RelaySelectorResult.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RelaySelectorResult.swift; sourceTree = "<group>"; };
F0F3161A2BF358590078DBCF /* NoRelaysSatisfyingConstraintsError.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NoRelaysSatisfyingConstraintsError.swift; sourceTree = "<group>"; };
F0FBD98E2C4A60CC00EE5323 /* KeyExchangingResultStub.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = KeyExchangingResultStub.swift; sourceTree = "<group>"; };
F998EFF92D3656B100D88D01 /* SKProduct+Sorting.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "SKProduct+Sorting.swift"; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
Expand Down Expand Up @@ -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 */,
Expand Down Expand Up @@ -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 */,
Expand Down
2 changes: 1 addition & 1 deletion ios/MullvadVPN/Coordinators/AccountCoordinator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
2 changes: 1 addition & 1 deletion ios/MullvadVPN/Coordinators/OutOfTimeCoordinator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
2 changes: 1 addition & 1 deletion ios/MullvadVPN/Coordinators/WelcomeCoordinator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
15 changes: 15 additions & 0 deletions ios/MullvadVPN/Extensions/SKProduct+Sorting.swift
Original file line number Diff line number Diff line change
@@ -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) }
}
}

0 comments on commit 1f51d38

Please sign in to comment.