-
Notifications
You must be signed in to change notification settings - Fork 328
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Apply state and conditions ONLY for text component (#4417)
* 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 * PurchaseButton is now a stack like button * Added image partials * Added stack partials * Apply localized partials (state and conditions) for text component * Added visible and updated example in paywalls tester to test things out * A bit more cleanup * Code improvements * Fix tests and lint * Partials are now in one ComponenOverrides struct with states, conditions, and intro offer * Improvements * Fix lint
- Loading branch information
1 parent
bcef02a
commit 54f4583
Showing
15 changed files
with
664 additions
and
132 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
// | ||
// 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 | ||
// | ||
// LocalizedPartials.swift | ||
// | ||
// Created by Josh Holtz on 10/27/24. | ||
// | ||
// swiftlint:disable missing_docs | ||
|
||
import Foundation | ||
import RevenueCat | ||
|
||
#if PAYWALL_COMPONENTS | ||
|
||
protocol LocalizedPartial {} | ||
|
||
struct LocalizedOverrides<T: LocalizedPartial> { | ||
|
||
public let introOffer: LocalizedPartial? | ||
public let states: LocalizedStates<T>? | ||
public let conditions: LocalizedConditions<T>? | ||
|
||
} | ||
|
||
struct LocalizedStates<T: LocalizedPartial> { | ||
|
||
let selected: T? | ||
|
||
} | ||
|
||
struct LocalizedConditions<T: LocalizedPartial> { | ||
|
||
let compact: T? | ||
let medium: T? | ||
let expanded: T? | ||
|
||
} | ||
|
||
#endif |
39 changes: 39 additions & 0 deletions
39
RevenueCatUI/Templates/Components/Packages/Package/ComponentViewState.swift
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,39 @@ | ||
// | ||
// 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 | ||
// | ||
// ComponentViewState.swift | ||
// | ||
// Created by Josh Holtz on 10/26/24. | ||
|
||
import Foundation | ||
import SwiftUI | ||
|
||
#if PAYWALL_COMPONENTS | ||
|
||
enum ComponentViewState { | ||
case `default` | ||
case selected | ||
} | ||
|
||
struct ComponentViewStateKey: EnvironmentKey { | ||
|
||
static let defaultValue: ComponentViewState = .default | ||
|
||
} | ||
|
||
extension EnvironmentValues { | ||
|
||
var componentViewState: ComponentViewState { | ||
get { self[ComponentViewStateKey.self] } | ||
set { self[ComponentViewStateKey.self] = newValue } | ||
} | ||
|
||
} | ||
|
||
#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
File renamed without changes.
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.