Skip to content

Conversation

mikhailChelbaev
Copy link
Collaborator

@mikhailChelbaev mikhailChelbaev commented Dec 27, 2024

Originally, if the component's background color was not provided, it was calculated as main.withOpacity(0.15). This caused an issue where underlying content in cards and modals could be visible when a transparent color was used. To address this, a second non-transparent background view with .background color was added.

To avoid having second views in these components, this pull request introduces a new .blend method that blends an original color with a provided color using the following formula:

red = self.red * self.alpha + other.red * (1.0 - self.alpha)
green = self.green * self.alpha + other.green * (1.0 - self.alpha)
blue = self.blue * self.alpha + other.blue * (1.0 - self.alpha)

This ensures that the resulting color's alpha is always 1.0.

The calculation for the component's background color has been updated to main.withOpacity(0.15).blend(with: .background), ensuring it is always opaque.

As a result, the secondary backgrounds from modals and cards have been removed.

Base automatically changed from refactor/previews to dev January 1, 2025 19:36
@mikhailChelbaev mikhailChelbaev merged commit 44350ca into dev Jan 1, 2025
1 check passed
@mikhailChelbaev mikhailChelbaev deleted the refactor/blend-colors branch January 1, 2025 19:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants