Skip to content
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

[WIP] PoC: Emergetools snapshot testing #1359

Draft
wants to merge 168 commits into
base: main
Choose a base branch
from

Conversation

tonidero
Copy link
Contributor

Description

This branch has a PoC of emerge tools snapshot tests.

tonidero and others added 30 commits September 5, 2023 08:42
### Description
This PR creates a new `Paywall tester` app in `examples/paywall-tester`.
It also adds some basic initial UI (just the bottom tab) to mimic what
we do in iOS.

This app is part of the main project (not a separate project like
MagicWeather/MagicWeatherCompose)

![Screenshot_20230904_122254](https://github.com/RevenueCat/purchases-android/assets/808417/4e3e36cd-bbe2-41e8-94b7-138e5f441f98)
### Description
This PR creates a new module `:ui:revenuecatui` as a starting point for
paywalls. Additionally, it adds some initial code for the public API.
…ew screen (#1220)

### Description
This PR displays the list of offerings in the `Offerings` tab and allows
to navigate to a new screen with the offering ID.


https://github.com/RevenueCat/purchases-android/assets/808417/bd1f6e61-49bc-4e59-91be-9d1ba7511691
### Description
This PR adds a simple paywall to the revenuecatui library and uses it to
display the paywall in paywall tester. Still pretty barebones but it's a
start :P


https://github.com/RevenueCat/purchases-android/assets/808417/b4a4b85c-68dc-4cc0-9019-2baefb50e2e3
### Description
We can and should be using coroutines to interact with the main SDK.
This updates the paywall tester app and the `revenuecatui ` sdk to use
the coroutine versions of the SDK methods.
### Description
This just adds a couple of text views as a PoC of setting a paywall in
the dashboard and seeing the data in the UI.

![image](https://github.com/RevenueCat/purchases-android/assets/808417/ec95eef0-63e1-4ece-8432-9b521bcfdbdf)
Submits paywall tester to Google Play nightly
…all (#1232)

### Description
Mostly a bunch of cleanup and improving the UI in this PR.
- Start using colors for texts and buttons.
- Start using device locale
- Move code to extensions for reusability
- Move paywall view UI to `Template2`. First template we're working on
- Improve Template2 to look closer to actual UI.
- Extract conversion from `Offering` to `PaywallViewState` for easier
testing and reusability
- Make sure visibility of elements is correct.

![image](https://github.com/RevenueCat/purchases-android/assets/808417/b6b06544-5e53-4e46-b1e0-e14e6fe62694)

---------

Co-authored-by: NachoSoto <[email protected]>
### Description
Added `Logger` class with some static methods to be able to unify the
behavior for logs in the RevenueCatUI sdk.
### Description
This PR adds `Coil` as a dependency for the new `RevenueCatUI` library.
We will be using this library to load images for now. We may reconsider
and implement our own image loader in the future, but this is the
quickest for now.

![image](https://github.com/RevenueCat/purchases-android/assets/808417/6388aa66-d00d-4410-a9f4-4c8009bc2569)
### Description
This PR reorganizes the the new RevenueCatUI module files. The packages
are:
- `composables`: For generic composables used in multiple UI locations
- `helpers`: Generic helpers
- `extensions`: Extensions for existing classes
- `data`: Data used to drive the UI and view model
This creates a generic `PaywallBackground` that can be used in any
template.


![image](https://github.com/RevenueCat/purchases-android/assets/685609/9b800c1c-705a-4b72-9ba7-153b18ab9b4c)

### Other changes:
- Created `Modifier.conditional`
- Changed `PaywallData.getUrlStringFromImage` to return `String?`
(images are optional)
- Added `PaywallBackground` to `Template2`
This allows us to create previews for each template so we can easily
iterate on them.

---------

Co-authored-by: Toni Rico <[email protected]>
…#1242)

### Description
This PR adds code to map different data sources including offerings +
paywall data + locale to build a new `TemplateConfiguration` model,
which is modeled to be consumed by the UI more easily.
### Description
This was a bit annoying so I decided to fix it. We don't want to show an
error dialog when the user just cancelled the purchase.
…ay debug menu (#1253)

### Description
This improves PaywallTester so we can logIn/logOut and display the debug
menu from the app.

![image](https://github.com/RevenueCat/purchases-android/assets/808417/04b7592a-5c5a-4002-b7fc-eb111e8f44a9)
### Description
To help with the variables work needed for paywalls, this adds a helper
function `valueInMonths` for the `Period` class. This will be used to
calculate the price per month.
…se` (#1255)

### Description
While working on paywalls in #1251, we needed to calculate the price per
month for products to get the value of a variable.
This PR extracts that logic to the main SDK, providing an optional
`Locale` parameter which will be `Locale.getDefault()` by default. This
function has been added to the `PricingPhase` class and the
`StoreProduct` interface for convenience.

#### API Changes
- Added `fun formattedPricePerMonth(locale: Locale =
Locale.getDefault()): String?` to `StoreProduct`, `GoogleStoreProduct`
and `AmazonStoreProduct`.
- Added `fun formattedPricePerMonth(locale: Locale =
Locale.getDefault()): String` to `PricingPhase`.
NachoSoto and others added 28 commits October 26, 2023 09:00
#1386)

`PaywallDialog` works by presenting paywalls automatically based on a
provided condition. Because of this, it should also know how to dismiss
itself. I changed it to implement this automatically, but also provide a
way to optionally pass a block for it.

Also updated the docs to reflect the new APIs:
RevenueCat/revenuecat-docs#450
https://github.com/RevenueCat/purchases-android/assets/664544/0e6745dc-dac0-49b4-82e6-310111b574f8

Discount labels are automatically resized to fit

<img width="646" alt="Screenshot 2023-10-25 at 16 24 48"
src="https://github.com/RevenueCat/purchases-android/assets/664544/c316c883-39fc-4fb7-8c68-f7739a0a28eb">

<img width="651" alt="Screenshot 2023-10-25 at 16 25 40"
src="https://github.com/RevenueCat/purchases-android/assets/664544/67a3d49a-96ae-472b-8e5f-81c20d49e181">

For three or less packages, this is how it looks

<img width="350" alt="Screenshot 2023-10-25 at 16 29 59"
src="https://github.com/RevenueCat/purchases-android/assets/664544/ff33925c-e5e3-4e78-8bea-ebe9cda8f95b">

---------

Co-authored-by: Cesar de la Vega <[email protected]>
…t UI (#1400)

### Description
This adds a new `ExperimentalPreviewRevenueCatUIPurchasesAPI` annotation
for `RevenueCatUI` experimental APIs, and marks all current public APIs
in this library as experimental. We plan to move from using a beta
version of the package to using these experimental APIs until we're
ready for stable release.

---------

Co-authored-by: NachoSoto <[email protected]>
### Description
Allow triggering paywall tester upload to play console manually.
Note that this is only for the optional URLs, `assetBaseURL` is still
required, but I'll handle errors there in a separate PR.
### Description
This adds a close button to the paywall that can be displayed when using
the `Paywall` composable, the `PaywallDialog` or the
`PaywallActivityLauncher`.

![image](https://github.com/RevenueCat/purchases-android/assets/808417/8bb00201-6d1f-45a5-a6cd-8d8cbb241a03)
Unless it needs to be blur, to match iOS behavior.
Equivalent to RevenueCat/purchases-ios#2818

`IntroEligibilityStateView` relies on strings being `null` to determine what string is available, therefore we need to make sure we don't have empty strings in `PaywallData`.
…ecode (#1402)

This also adds coverage for `PaywallData` deserialization inside of
`Offering`
These are needed for template 4 and 5.
…ckage (#1416)

### Description
In some cases, the purchase button text doesn't change when selecting
different packages. However, we were still animating the text resulting
in a small flash in the purchase button when changing the selected
package.

This makes it so, if the purchase button text doesn't change between all
the packages, we don't animate it.
### Description
Using downloadable Google fonts when displaying the paywall has a small
delay where the default font is first used, then changed to the new font
the first time the font is used. While we could predownload the font
during the initial paywall tester app, this switches to using a bundled
font which is loaded immediately. This is the same font we were using
previously through google fonts.
### Description
I noticed that after a configuration change (for example moving from
landscape to portrait), the close button didn't work as expected on the
dialogs. I tracked it down to the fact that the view model kept the
first version of the dismiss callback, so it wasn't calling the new one
created after the configuration change.

I decided to remove the current approach of using keys to create
individual view models and instead I'm adding a method to the view model
that gets called every time we try to get the view model. If we detect
that the PaywallOptions have changed, we will update it on the view
model, ensuring we have the latest version of the callbacks.
@tonidero tonidero force-pushed the poc_emergetools_snapshot_testing branch from 9ee79f0 to cc0b9e8 Compare October 31, 2023 13:21
Base automatically changed from paywalls to main October 31, 2023 17:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
RevenueCatUI test Adding missing tests or correcting existing tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants