-
Notifications
You must be signed in to change notification settings - Fork 319
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Improved JSON format for ButtonComponent codables * Started to remove PackageGroup * Removed PackageGroup and added Template 5 SwiftUI preview * Remove PackageGroup * Fixed some thread, lint, and selection stuff * Made renames and some code improvements
- Loading branch information
1 parent
3dfd43e
commit ee3fb18
Showing
20 changed files
with
476 additions
and
378 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
// | ||
// Copyright RevenueCat Inc. All Rights Reserved. | ||
// | ||
// Licensed under the MIT License (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// https://opensource.org/licenses/MIT | ||
// | ||
// PackageValidator.swift | ||
// | ||
// Created by Josh Holtz on 10/25/24. | ||
|
||
import Foundation | ||
import RevenueCat | ||
|
||
#if PAYWALL_COMPONENTS | ||
|
||
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *) | ||
class PackageValidator { | ||
|
||
typealias PackageInfo = (package: Package, isSelectedByDefault: Bool) | ||
|
||
private var packageInfos: [PackageInfo] = [] | ||
|
||
func add(_ package: Package, isSelectedByDefault: Bool) { | ||
self.packageInfos.append((package, isSelectedByDefault)) | ||
} | ||
|
||
var isValid: Bool { | ||
!packageInfos.isEmpty | ||
} | ||
|
||
var defaultSelectedPackage: Package? { | ||
let defaultSelectedPackage = packageInfos.first(where: { pkg in | ||
return pkg.isSelectedByDefault | ||
}) | ||
|
||
// Set selected package | ||
if let defaultSelectedPackage { | ||
return defaultSelectedPackage.package | ||
} | ||
|
||
Logger.warning(Strings.paywall_could_not_find_default_package) | ||
return packageInfos.first?.package | ||
} | ||
|
||
} | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.