-
Notifications
You must be signed in to change notification settings - Fork 44
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[EXTERNAL] Exposing fontprovider setter in PaywallView
and PaywallFooterView
by @Jjastiny
#1589
Conversation
…oseview can listen to the state change.
…to exposing-fontprovider # Conflicts: # ui/revenuecatui/src/main/kotlin/com/revenuecat/purchases/ui/revenuecatui/views/PaywallFooterView.kt
…ew(context)) expose the font provider. set a private getter and setter to reduce some boilerplate
…function out. Expose fontProvider.
### Checklist - [ ] If applicable, create follow-up issues for `purchases-ios` and hybrids ### Motivation - It's not possible for us to change the font family in react-native-purchase. - My hope was to expose this font provider methods for the RN Bridge so that we can at least set custom font family. ### Description - Exposing fontProviders for PaywallFooterView and PaywallView. - theme composition local provider should update this autmoatically. Need to add something like this on the React Native side. If user did link the font via ```xml <font-family xmlns:app="http://schemas.android.com/apk/res/android"> <font app:fontStyle="normal" android:fontWeight="200" android:font="@font/montserrat" /> </font-family> ``` ```kotlin ReactFontManager.getInstance().addCustomFont(this, "Montserrat", R.font.montserrat); ``` We could just bring the font family ```kotlin @ReactProp(name= "fontFamily") fun setFontFamily(view: PaywallFooterView, fontFamily: String?){ val typeface = ReactFontManager.getInstance() .getTypeface(fontFamily /** Montserrat in this case. **/, ReactFontManager.TypefaceStyle.NORMAL, assets) view.setFontProvider(CustomFontProvider(FontFamily(typeface))) } ``` <img width="350" alt="Screenshot 2024-01-26 at 10 04 03 PM" src="https://github.com/RevenueCat/purchases-android/assets/6516487/e8e41b0d-c1fd-4446-8d5b-11cb9de200e5">
@@ -14,7 +15,7 @@ import com.revenuecat.purchases.ui.revenuecatui.views.PaywallFooterView | |||
private class PaywallFooterViewAPI { | |||
|
|||
fun checkType(context: Context) { | |||
val paywallFooterView: FrameLayout = PaywallFooterView(context) | |||
val paywallFooterView: AbstractComposeView = PaywallFooterView(context) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a breaking change... But feels that it should be ok... Any thoughts?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If it works I think we should go for it, it will simplify the views
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Paywalls is still experimental so :)
PaywallView
and PaywallFooterView
by @JjastinyPaywallView
and PaywallFooterView
by @Jjastiny
2cb4572
to
4cf3a8e
Compare
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #1589 +/- ##
=======================================
Coverage 83.71% 83.71%
=======================================
Files 218 218
Lines 7260 7260
Branches 1011 1011
=======================================
Hits 6078 6078
Misses 788 788
Partials 394 394 ☔ View full report in Codecov by Sentry. |
@@ -113,16 +126,6 @@ class PaywallView : FrameLayout { | |||
.setOfferingId(initialOfferingId) | |||
.setShouldDisplayDismissButton(shouldDisplayDismissButton ?: false) | |||
.build() | |||
addView( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we change line 123 to be paywallOptions = PaywallOptions.Builder
?
@@ -133,4 +136,12 @@ class PaywallView : FrameLayout { | |||
this.initialFontProvider = fontProvider | |||
this.shouldDisplayDismissButton = shouldDisplayDismissButton | |||
} | |||
|
|||
@Composable | |||
override fun Content() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is much nicer
…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>
@Jjastiny) (#3628) Original PR: #3626. This is the iOS counterpart to RevenueCat/purchases-android#1589 This exposes the `fontName` as a parameter and sets `CustomFontProvider`. ### Changes: - 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: Justin Yang <jjastiny@gmail.com>
#1589 made `PaywallFooterView` an `AbstractComposeView`, which broke React Native's implementation because we override `onMeasure` which is final in `AbstractComposeView`
**This is an automatic release.** ### New Features * [EXTERNAL] Exposing fontprovider setter in `PaywallView` and `PaywallFooterView` by @Jjastiny (#1589) via Toni Rico (@tonidero) ### RevenueCatUI * `Paywalls`: add 4 new variables (#1599) via NachoSoto (@NachoSoto) ### Bugfixes * Catch Exception instead of only IllegalArgumentException when decoding paywallData (#1601) via Cesar de la Vega (@vegaro) * Revert making PaywallFooterView an AbstractComposeView (#1598) via Cesar de la Vega (@vegaro) * Add missing forwarding to `PaywallListener.onPurchaseCancelled` (#1590) via Cesar de la Vega (@vegaro) ### Dependency Updates * Bump danger from 9.4.2 to 9.4.3 (#1597) via dependabot[bot] (@dependabot[bot]) ### Other Changes * Update CHANGELOG with 6.9.6 release notes (#1596) via Toni Rico (@tonidero) Co-authored-by: revenuecat-ops <ops@revenuecat.com>
…View (contributed by @Jjastiny) (#916) Thank you for contributing to react-native-purchases. Before pressing the "Create Pull Request" button, please provide the following: - [x] A description about what and why you are contributing, even if it's trivial. - [x] The issue number(s) or PR number(s) in the description if you are contributing in response to those. - [ ] If applicable, unit tests. This PR adds a fontFamily string in PaywallOptions Prop, which enables the developers to change the font for the paywall to their custom font. ```typescript export interface PaywallViewOptions { offering?: PurchasesOffering | null; fontFamily?: String | null; // New } ``` This is the RN native module update for following PR's RevenueCat/purchases-ios#3628 AND RevenueCat/purchases-android#1589 --------- Co-authored-by: Jjastiny <jjastiny@gmail.com>
External contribution from #1588
Checklist
purchases-ios
and hybridsMotivation
Description
Need to add something like this on the React Native side.
If user did link the font via
We could just bring the font family