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

Paywalls: don't apply dark appearance with no dark mode colors #3184

Merged
merged 2 commits into from
Sep 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions RevenueCatUI/Helpers/ColorInformation+MultiScheme.swift
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,16 @@ extension PaywallData.Configuration.ColorInformation {

#endif

@available(iOS 15.0, macOS 12.0, tvOS 15.0, *)
extension TemplateViewConfiguration {

/// Whether dark mode colors have been configured in this paywall.
var hasDarkMode: Bool {
return self.configuration.colors.dark != nil
}

}

#if canImport(SwiftUI)

import SwiftUI
Expand Down
10 changes: 9 additions & 1 deletion RevenueCatUI/Templates/TemplateViewType.swift
Original file line number Diff line number Diff line change
Expand Up @@ -90,12 +90,20 @@ extension PaywallData {
fonts: fonts,
locale: locale) {
case let .success(configuration):
Self.createView(template: template, configuration: configuration)
let view = Self.createView(template: template, configuration: configuration)
.task(id: offering) {
await introEligibility.computeEligibility(for: configuration.packages)
}
.background(configuration.backgroundView)

if configuration.hasDarkMode {
view
} else {
// If paywall has no dark mode configured, prevent materials
// and other SwiftUI elements from automatically taking a dark appearance.
view.environment(\.colorScheme, .light)
}

case let .failure(error):
DebugErrorView(error, releaseBehavior: .emptyView)
}
Expand Down