This commit is contained in:
Ali
2023-09-01 22:07:30 +04:00
parent f0336cd98a
commit 03122c136d
33 changed files with 561 additions and 288 deletions

View File

@@ -288,6 +288,7 @@ public final class ButtonComponent: Component {
public let background: Background
public let content: AnyComponentWithIdentity<Empty>
public let isEnabled: Bool
public let tintWhenDisabled: Bool
public let allowActionWhenDisabled: Bool
public let displaysProgress: Bool
public let action: () -> Void
@@ -296,6 +297,7 @@ public final class ButtonComponent: Component {
background: Background,
content: AnyComponentWithIdentity<Empty>,
isEnabled: Bool,
tintWhenDisabled: Bool = true,
allowActionWhenDisabled: Bool = false,
displaysProgress: Bool,
action: @escaping () -> Void
@@ -303,6 +305,7 @@ public final class ButtonComponent: Component {
self.background = background
self.content = content
self.isEnabled = isEnabled
self.tintWhenDisabled = tintWhenDisabled
self.allowActionWhenDisabled = allowActionWhenDisabled
self.displaysProgress = displaysProgress
self.action = action
@@ -318,6 +321,9 @@ public final class ButtonComponent: Component {
if lhs.isEnabled != rhs.isEnabled {
return false
}
if lhs.tintWhenDisabled != rhs.tintWhenDisabled {
return false
}
if lhs.allowActionWhenDisabled != rhs.allowActionWhenDisabled {
return false
}
@@ -389,7 +395,7 @@ public final class ButtonComponent: Component {
var contentAlpha: CGFloat = 1.0
if component.displaysProgress {
contentAlpha = 0.0
} else if !component.isEnabled {
} else if !component.isEnabled && component.tintWhenDisabled {
contentAlpha = 0.7
}