Skip to content

Commit f70f1d6

Browse files
update a method to calculate component's background color
1 parent 461826f commit f70f1d6

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

Sources/ComponentsKit/Components/Modal/Models/ModalVM.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public protocol ModalVM: ComponentVM {
3737

3838
extension ModalVM {
3939
var preferredBackgroundColor: UniversalColor {
40-
return self.backgroundColor?.blended(with: .background) ?? .themed(
40+
return self.backgroundColor ?? .themed(
4141
light: UniversalColor.background.light,
4242
dark: UniversalColor.secondaryBackground.dark
4343
)

Sources/ComponentsKit/Shared/Colors/ComponentColor.swift

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,11 @@ public struct ComponentColor: Hashable {
1111
public let contrast: UniversalColor
1212

1313
/// The background color for the component.
14-
public let background: UniversalColor
14+
public var background: UniversalColor {
15+
return self._background ?? self.main.withOpacity(0.15).blended(with: .background)
16+
}
17+
18+
private let _background: UniversalColor?
1519

1620
// MARK: - Initialization
1721

@@ -28,6 +32,6 @@ public struct ComponentColor: Hashable {
2832
) {
2933
self.main = main
3034
self.contrast = contrast
31-
self.background = background ?? main.withOpacity(0.15)
35+
self._background = background
3236
}
3337
}

0 commit comments

Comments
 (0)