Skip to content

Add PaywallWarning model and validation documentation#6341

Merged
JZDesign merged 15 commits intomainfrom
jzdesign/fallback-paywall-3-paywall-warning
Feb 27, 2026
Merged

Add PaywallWarning model and validation documentation#6341
JZDesign merged 15 commits intomainfrom
jzdesign/fallback-paywall-3-paywall-warning

Conversation

@JZDesign
Copy link
Copy Markdown
Contributor

@JZDesign JZDesign commented Feb 23, 2026

Summary

  • Adds PaywallWarning enum mapping PaywallValidationError cases to user-facing titles, body text, and help URLs (RevenueCat dashboard/docs links)
  • Adds comprehensive documentation to PaywallData+Validation.swift explaining each error case, when it occurs, and how to resolve it

Stacked PRs breaking up #5930

This is PR 3 of 5 for the fallback paywall feature:

  1. Color computation helpers Add color computation helpers for fallback paywall #6339
  2. App style extractor + tests Add app style extractor for icon color extraction #6340
  3. PaywallWarning model + docs Add PaywallWarning model and validation documentation #6341 (this PR)
  4. DefaultPaywall UI + assets ← base: PR 3 Add default/fallback paywall UI components and assets #6342
  5. Wire into PaywallView - Feature: Update fallback paywall #6359
  6. Remove giant image and update snapshots

Test plan

  • Build succeeds on all platforms
  • No functional changes — data model and documentation only

🤖 Generated with Claude Code


Note

Low Risk
Low risk: adds a new warning model and documentation only, with no changes to paywall validation logic or runtime behavior.

Overview
Adds a new PaywallWarning enum that converts Offering.PaywallValidationError (and a few non-validation states like missing offering/products) into user-facing title, bodyText, and optional helpURL for linking to relevant RevenueCat docs.

Expands inline documentation for PaywallValidationError in PaywallData+Validation.swift, describing when each validation error occurs and how fallback paywall behavior is handled.

Written by Cursor Bugbot for commit d3cc5f4. This will update automatically on new commits. Configure here.

JZDesign and others added 2 commits February 23, 2026 14:15
Adds ColorComputationHelpers.swift with pure utility functions for:
- WCAG 2.1 relative luminance and contrast ratio calculations
- sRGB linearization (gamma correction removal)
- Platform-agnostic RGB component extraction
- Best-contrast color selection from a candidate set

These will be used by the upcoming fallback paywall to adaptively
choose text colors with sufficient contrast against backgrounds.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Adds AppStyleExtractor which extracts the app icon, display name,
and prominent colors from the host app bundle. Uses pixel sampling
with color quantization to identify 1-2 dominant colors from the
app icon, filtering transparent/extreme brightness pixels.

Also adds:
- DualColorImageGenerator (DEBUG only) for creating deterministic
  test images with known color splits
- AppStyleExtractorTests covering accuracy for multiple color
  combinations and edge cases (nil, transparent, dark/bright)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@JZDesign JZDesign requested a review from a team as a code owner February 23, 2026 20:28
Comment thread RevenueCatUI/Helpers/PaywallWarning.swift Outdated
Comment thread RevenueCatUI/Helpers/PaywallWarning.swift
JZDesign and others added 5 commits February 24, 2026 07:56
…nto jzdesign/fallback-paywall-2-app-style-extractor
Remove unreachable non-static instance methods from
ColorComputationHelpers enum (dead code left over from
global-to-enum conversion). Update tests to use qualified
ColorComputationHelpers.method() calls.

Co-authored-by: Cursor <cursoragent@cursor.com>
@JZDesign JZDesign force-pushed the jzdesign/fallback-paywall-3-paywall-warning branch from 8e25223 to 606081b Compare February 24, 2026 21:01
@JZDesign JZDesign requested a review from a team as a code owner February 24, 2026 21:01
Comment thread RevenueCatUI/Helpers/PaywallWarning.swift
Comment thread RevenueCatUI/Helpers/PaywallWarning.swift
…nto jzdesign/fallback-paywall-2-app-style-extractor
@facumenzella
Copy link
Copy Markdown
Member

The Set ordering in bodyText for .invalidVariables and .invalidIcons is non-deterministic — Set<String>.joined() can produce different output on each run.

Consider sorting before joining:

case .invalidVariables(let set):
    return "The following variables are not recognized: \(set.sorted().joined(separator: ", "))..."
case .invalidIcons(let set):
    return "The following icon names are not valid: \(set.sorted().joined(separator: ", "))..."

This ensures consistent UX and avoids potential flaky snapshot tests if the warning UI is ever snapshotted.

- Add @mainactor to AppIconDetailProvider since it is an
  ObservableObject with @published properties
- Add #if !os(watchOS) guards in AppStyleExtractor for icon
  loading — watchOS app icons are system-managed with no
  runtime API to load them
- Fix toAppIconDetailprovider -> toAppIconDetailProvider typo

Co-authored-by: Cursor <cursoragent@cursor.com>
@JZDesign JZDesign force-pushed the jzdesign/fallback-paywall-3-paywall-warning branch from 606081b to 5e9167b Compare February 25, 2026 13:43
@JZDesign JZDesign force-pushed the jzdesign/fallback-paywall-3-paywall-warning branch from 5e9167b to 4202bca Compare February 25, 2026 14:45
JZDesign and others added 4 commits February 25, 2026 09:01
Adds PaywallWarning enum that maps PaywallValidationError cases to
user-facing titles, body text, and help URLs linking to the
RevenueCat dashboard or docs. This model will power the debug
warning banner in the upcoming fallback paywall.

Also adds comprehensive documentation to PaywallData+Validation.swift
explaining each validation error case, when it occurs, and how to
resolve it.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Fix "Unkown" -> "Unknown" in invalidTemplate title.
Add .missingLocalization to the helpURL case group so it
returns the paywalls docs URL instead of nil.

Co-authored-by: Cursor <cursoragent@cursor.com>
@JZDesign JZDesign force-pushed the jzdesign/fallback-paywall-3-paywall-warning branch from 4202bca to 1f253ce Compare February 25, 2026 15:18
Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

case .invalidVariables:
return URL(string: "https://www.revenuecat.com/docs/tools/paywalls/creating-paywalls/variables")
default:
return nil
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing help links for some warnings

Low Severity

helpURL falls through to nil for invalidTemplate and invalidIcons, so those validation warnings have no documentation link while other paywall validation warnings do. This creates inconsistent warning behavior and removes in-context guidance for two known error cases.

Fix in Cursor Fix in Web

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This are not things that the user can work on, so no link was Hidde's thought IIRC

Base automatically changed from jzdesign/fallback-paywall-2-app-style-extractor to main February 25, 2026 20:01
@JZDesign JZDesign mentioned this pull request Feb 25, 2026
2 tasks
@JZDesign JZDesign merged commit e0ff600 into main Feb 27, 2026
14 of 15 checks passed
@JZDesign JZDesign deleted the jzdesign/fallback-paywall-3-paywall-warning branch February 27, 2026 12:53
facumenzella pushed a commit that referenced this pull request Mar 5, 2026
* Add color computation helpers for WCAG-compliant contrast calculations

Adds ColorComputationHelpers.swift with pure utility functions for:
- WCAG 2.1 relative luminance and contrast ratio calculations
- sRGB linearization (gamma correction removal)
- Platform-agnostic RGB component extraction
- Best-contrast color selection from a candidate set

These will be used by the upcoming fallback paywall to adaptively
choose text colors with sufficient contrast against backgrounds.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* Add app style extractor for icon color extraction

Adds AppStyleExtractor which extracts the app icon, display name,
and prominent colors from the host app bundle. Uses pixel sampling
with color quantization to identify 1-2 dominant colors from the
app icon, filtering transparent/extreme brightness pixels.

Also adds:
- DualColorImageGenerator (DEBUG only) for creating deterministic
  test images with known color splits
- AppStyleExtractorTests covering accuracy for multiple color
  combinations and edge cases (nil, transparent, dark/bright)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* PR Feedback

* Create AppIconDetailProvider.swift

* Update project.pbxproj

* Remove duplicate instance methods and qualify test calls

Remove unreachable non-static instance methods from
ColorComputationHelpers enum (dead code left over from
global-to-enum conversion). Update tests to use qualified
ColorComputationHelpers.method() calls.

Co-authored-by: Cursor <cursoragent@cursor.com>

* Add @mainactor, fix watchOS icon guards, fix typo

- Add @mainactor to AppIconDetailProvider since it is an
  ObservableObject with @published properties
- Add #if !os(watchOS) guards in AppStyleExtractor for icon
  loading — watchOS app icons are system-managed with no
  runtime API to load them
- Fix toAppIconDetailprovider -> toAppIconDetailProvider typo

Co-authored-by: Cursor <cursoragent@cursor.com>

* correct use of main actor

* address cursor comment about brightness filter

* import Combine needed for watchos to compile and build -> @published

* Add PaywallWarning model and validation documentation

Adds PaywallWarning enum that maps PaywallValidationError cases to
user-facing titles, body text, and help URLs linking to the
RevenueCat dashboard or docs. This model will power the debug
warning banner in the upcoming fallback paywall.

Also adds comprehensive documentation to PaywallData+Validation.swift
explaining each validation error case, when it occurs, and how to
resolve it.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* Fix typo and add missing helpURL for missingLocalization

Fix "Unkown" -> "Unknown" in invalidTemplate title.
Add .missingLocalization to the helpURL case group so it
returns the paywalls docs URL instead of nil.

Co-authored-by: Cursor <cursoragent@cursor.com>

---------

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants