Skip to content

Commit

Permalink
PaywallViewController: expose fontName for CustomFontProvider (#…
Browse files Browse the repository at this point in the history
…3626)

This is the iOS counterpart to
RevenueCat/purchases-android#1589
This exposes the `fontName` as a parameter and sets `CustomFontProvider`. 

### Description
- Created `updateFontWithFontName` for `PaywallViewController`
- Created init function for `offerIdentifier` and `fontName`

<img width="450" alt="301765252-95f61abb-10a1-4903-a2ef-12572ae3eaff"
src="https://github.com/RevenueCat/purchases-ios/assets/6516487/56061916-0391-447a-ae74-57f2dddcf7a7">

---------

Co-authored-by: NachoSoto <NachoSoto@users.noreply.github.com>
  • Loading branch information
Jjastiny and NachoSoto committed Feb 2, 2024
1 parent 9b683b0 commit 168acd3
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 0 deletions.
7 changes: 7 additions & 0 deletions RevenueCatUI/UIKit/PaywallFooterViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,13 @@ public final class PaywallFooterViewController: PaywallViewController {
fonts: DefaultPaywallFontProvider(),
displayCloseButton: false)
}

@objc
public init(offeringIdentifier: String, fontName: String) {
super.init(content: .offeringIdentifier(offeringIdentifier),
fonts: CustomPaywallFontProvider(fontName: fontName),
displayCloseButton: false)
}

@available(*, unavailable)
override init(
Expand Down
6 changes: 6 additions & 0 deletions RevenueCatUI/UIKit/PaywallViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,12 @@ public class PaywallViewController: UIViewController {
public func update(with offeringIdentifier: String) {
self.configuration.content = .offeringIdentifier(offeringIdentifier)
}

/// - Warning: For internal use only
@objc(updateFontWithFontName:)
public func updateFont(with fontName: String){
self.configuration.fonts = CustomPaywallFontProvider(fontName: fontName)
}

// MARK: - Internal

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,11 @@ func paywallViewControllerAPI(_ delegate: Delegate, _ offering: Offering?) {
let _: UIViewController = PaywallViewController(offeringIdentifier: "offering",
fonts: fontProvider,
displayCloseButton: true)
let _: UIViewController = PaywallFooterViewController(offeringIdentifier: "offering", fontName:"Papyrus")

controller.update(with: offering!)
controller.update(with: "offering_identifier")
controller.updateFont(with: "Papyrus")
}

@available(iOS 15.0, macOS 12.0, tvOS 15.0, *)
Expand All @@ -43,6 +45,7 @@ func paywallFooterViewControllerAPI(_ delegate: Delegate, _ offering: Offering?)

let _: UIViewController = PaywallFooterViewController(offering: offering)
let _: UIViewController = PaywallFooterViewController(offeringIdentifier: "offering")
let _: UIViewController = PaywallFooterViewController(offeringIdentifier: "offering", fontName: "Papyrus")
}

@available(iOS 15.0, macOS 12.0, tvOS 15.0, *)
Expand Down

0 comments on commit 168acd3

Please sign in to comment.