Add PaywallWarning type for fallback paywall#3131
Conversation
…lt.Legacy Introduces PaywallWarning sealed class that maps PaywallValidationErrors to user-facing warning messages with titles, body text, and help URLs. Adds a warning computed property on PaywallValidationResult.Legacy to surface the first error as a displayable warning. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
tonidero
left a comment
There was a problem hiding this comment.
I think we should remove the else clause, but other than that, this looks good to me!
| * Helper to get the first warning for display in the default paywall. | ||
| */ | ||
| val warning: PaywallWarning? | ||
| get() = errors?.head?.let { PaywallWarning.from(it) } |
There was a problem hiding this comment.
[Not for this PR!]
We should definitely send an event when we display the default paywall so it's easier to figure out when it's happening on our side as well, and possibly notify the developer down the line.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #3131 +/- ##
=======================================
Coverage 79.22% 79.22%
=======================================
Files 347 347
Lines 13911 13911
Branches 1884 1884
=======================================
Hits 11021 11021
Misses 2109 2109
Partials 781 781 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
Spoke with @tonidero offline, good to merge as is. |
> [!IMPORTANT] > This PR is all dark code, nothing is used yet. PR 5 will wire it all together This PR is prepping for color extraction and paywall styling. Unused code. ## Summary - Adds ColorComputationHelpers with WCAG 2.0 contrast ratio and luminance calculations - Adds AppStyleExtractor to extract app name, icon bitmap, and prominent colors from the app icon at runtime - Adds CircleOutlined vector icon for unselected product cells - Includes tests for color extraction, contrast computation, and luminance Part 2 of the fallback paywall feature breaking up #2945. Stacked on #3131. - Add PaywallWarning type for fallback paywall #3131 - Add color helpers, AppStyleExtractor, and CircleOutlined icon #3132 (This PR) - Add default paywall UI components #3133 - Wire validation warning through paywall state pipeline #3134 - Plug in Paywall - Remove Big background image and clean up CI <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Low Risk** > Adds new, currently-unused helper utilities and a vector icon with unit tests; no changes to runtime paywall flow or persisted data. > > **Overview** > Prepares groundwork for styling by adding `AppStyleExtractor` to fetch app name/icon and to asynchronously extract a small set of prominent colors from a bitmap via sampling, quantization, and similarity/brightness/alpha filtering. > > Introduces `ColorComputationHelpers` with WCAG-based luminance/contrast utilities (plus best-contrast selection) and adds a new `CircleOutlined` Compose `ImageVector`. > > Adds Robolectric tests covering prominent-color extraction edge cases and the new color math helpers (distance, luminance, contrast, and selection). > > <sup>Written by [Cursor Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit 3619218. This will update automatically on new commits. Configure [here](https://cursor.com/dashboard?tab=bugbot).</sup> <!-- /CURSOR_SUMMARY --> --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
<!-- Thank you for contributing to Purchases! Before pressing the "Create Pull Request" button, please provide the following: --> Wires in the default paywall into the sdk for use. Adds previews for emerge snapshot testing Part 5 of the fallback paywall feature breaking up #2945. Stacked on #3134 - Add PaywallWarning type for fallback paywall #3131 - Add color helpers, AppStyleExtractor, and CircleOutlined icon #3132 - Add default paywall UI components #3133 - Wire validation warning through paywall state pipeline #3134 - Plug in Paywall #3178 (This PR) - Remove Big background image and clean up CI <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Medium Risk** > Introduces a new paywall rendering path that can trigger purchase/restore actions from the fallback UI, so regressions could affect paywall display and transaction initiation when validation warnings occur. > > **Overview** > Adds a *fallback “default paywall”* flow: `InternalPaywall` now renders `DefaultPaywallView` whenever a legacy paywall loads with a `validationWarning`, wiring its purchase/restore actions through the existing `PaywallViewModel` and reusing a shared `screenModeBackground` modifier. > > Refactors `DefaultPaywallView` layout to use `Scaffold` with a fixed footer and `LazyColumn`, adds preview-only overrides plus new Compose previews, and introduces a deterministic `DualColorImageGenerator` used by previews and a new `AppStyleExtractor` prominent-colors test. Also removes developer-facing debug strings from `strings.xml` in favor of local constants, and updates `.gitignore` to exclude `.cursor/`. > > <sup>Written by [Cursor Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit 42d3af2. This will update automatically on new commits. Configure [here](https://cursor.com/dashboard?tab=bugbot).</sup> <!-- /CURSOR_SUMMARY -->
## Summary - Adds validationWarning: PaywallWarning? field to PaywallState.Loaded.Legacy - Threads validationWarning through OfferingToStateMapper.toLegacyPaywallState - Passes validationResult.warning from PaywallViewModel.calculateState to the state mapper When a paywall fails validation, the warning is now carried on the loaded state, ready for the UI layer (PR 5) to check and render the DefaultPaywallView instead of the template paywall. Part 4 of the fallback paywall feature breaking up #2945. Stacked on #3133. - Add PaywallWarning type for fallback paywall #3131 - Add color helpers, AppStyleExtractor, and CircleOutlined icon #3132 - Add default paywall UI components #3133 - Wire validation warning through paywall state pipeline #3134 (This PR) - Plug in Paywall #3178 - Remove Big background image and clean up CI <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Low Risk** > Low risk additive change: it only carries an optional `PaywallWarning` through state creation and does not alter validation or rendering logic yet. > > **Overview** > **Threads paywall validation warnings through the Legacy paywall state.** `PaywallState.Loaded.Legacy` now includes an optional `validationWarning: PaywallWarning?`. > > `PaywallViewModel.calculateState` passes `validationResult.warning` into `Offering.toLegacyPaywallState`, and the mapper stores it on the created legacy state so the UI can later decide to show a fallback/default paywall when validation issues occur. > > <sup>Written by [Cursor Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit 64f72f8. This will update automatically on new commits. Configure [here](https://cursor.com/dashboard?tab=bugbot).</sup> <!-- /CURSOR_SUMMARY --> --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
## Summary - Adds DefaultPaywallView composable: the main fallback paywall with dynamic app icon theming, package list, purchase and restore buttons - Adds DefaultPaywallWarning: debug-only warning panel showing what went wrong, with RevenueCat branding and dashboard links - Adds DefaultProductCell: selectable product row with animated color transitions - Adds RevenueCat branding image and string resources for the default paywall Part 3 of the fallback paywall feature breaking up #2945. Stacked on #3132. - Add PaywallWarning type for fallback paywall #3131 - Add color helpers, AppStyleExtractor, and CircleOutlined icon #3132 - Add default paywall UI components #3133 (This PR) - Wire validation warning through paywall state pipeline #3134 - Plug in Paywall #3178 - Remove Big background image and clean up CI <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Medium Risk** > Adds a new fallback paywall UI path for legacy paywalls and threads a new `validationWarning` through state mapping, which can change what users see when paywall validation fails (though warning UI is debug-only). Main risk is UI/behavior regressions around package selection, purchase/restore entrypoints, and full-screen vs sheet background handling. > > **Overview** > Adds a new **default/fallback paywall** Compose UI (`DefaultPaywallView`) that themes itself from the app icon, shows a selectable package list, and provides localized *Purchase*/*Restore* actions, plus a debug-only `DefaultPaywallWarning` panel (with a Dashboard link) and preview/test utilities. > > Wires a new `validationWarning: PaywallWarning?` through `PaywallValidationResult` mapping into `PaywallState.Loaded.Legacy`, and updates `InternalPaywall` to render the new default paywall when the warning is present (including refactoring background handling via `screenModeBackground`). > > Updates test/mocks to support the new legacy fallback flow (selection mutates state; purchase captures selected package id; restore uses `restorePurchases()` entrypoint) and adds string resources for the default paywall across locales; also ignores `.cursor/` in `.gitignore`. > > <sup>Written by [Cursor Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit 6ca1786. This will update automatically on new commits. Configure [here](https://cursor.com/dashboard?tab=bugbot).</sup> <!-- /CURSOR_SUMMARY --> --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
Summary
(stacked PRs) breaking up #2945.
Note
Low Risk
Low risk: adds an internal warning type and a derived property without changing validation or paywall rendering logic. Main risk is minor mismatches in error-to-message mapping affecting debug-only messaging.
Overview
Adds an internal sealed
PaywallWarningthat mapsPaywallValidationErrorto user-facingtitle,bodyText, and optionalhelpUrlfor displaying debug warnings on the default/fallback paywall.Extends
PaywallValidationResult.Legacywith awarningcomputed property that converts the first validation error into aPaywallWarningfor easy consumption by the default paywall UI.Written by Cursor Bugbot for commit 800e7fe. This will update automatically on new commits. Configure here.