mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-24 07:05:35 +00:00
Camera improvements
This commit is contained in:
@@ -9,20 +9,24 @@ public final class Button: Component {
|
||||
public let isEnabled: Bool
|
||||
public let action: () -> Void
|
||||
public let holdAction: (() -> Void)?
|
||||
public let highlightedAction: ActionSlot<Bool>?
|
||||
|
||||
convenience public init(
|
||||
content: AnyComponent<Empty>,
|
||||
isEnabled: Bool = true,
|
||||
action: @escaping () -> Void
|
||||
automaticHighlight: Bool = true,
|
||||
action: @escaping () -> Void,
|
||||
highlightedAction: ActionSlot<Bool>? = nil
|
||||
) {
|
||||
self.init(
|
||||
content: content,
|
||||
minSize: nil,
|
||||
tag: nil,
|
||||
automaticHighlight: true,
|
||||
automaticHighlight: automaticHighlight,
|
||||
isEnabled: isEnabled,
|
||||
action: action,
|
||||
holdAction: nil
|
||||
holdAction: nil,
|
||||
highlightedAction: highlightedAction
|
||||
)
|
||||
}
|
||||
|
||||
@@ -33,7 +37,8 @@ public final class Button: Component {
|
||||
automaticHighlight: Bool = true,
|
||||
isEnabled: Bool = true,
|
||||
action: @escaping () -> Void,
|
||||
holdAction: (() -> Void)?
|
||||
holdAction: (() -> Void)?,
|
||||
highlightedAction: ActionSlot<Bool>?
|
||||
) {
|
||||
self.content = content
|
||||
self.minSize = minSize
|
||||
@@ -42,6 +47,7 @@ public final class Button: Component {
|
||||
self.isEnabled = isEnabled
|
||||
self.action = action
|
||||
self.holdAction = holdAction
|
||||
self.highlightedAction = highlightedAction
|
||||
}
|
||||
|
||||
public func minSize(_ minSize: CGSize?) -> Button {
|
||||
@@ -52,7 +58,8 @@ public final class Button: Component {
|
||||
automaticHighlight: self.automaticHighlight,
|
||||
isEnabled: self.isEnabled,
|
||||
action: self.action,
|
||||
holdAction: self.holdAction
|
||||
holdAction: self.holdAction,
|
||||
highlightedAction: self.highlightedAction
|
||||
)
|
||||
}
|
||||
|
||||
@@ -64,7 +71,8 @@ public final class Button: Component {
|
||||
automaticHighlight: self.automaticHighlight,
|
||||
isEnabled: self.isEnabled,
|
||||
action: self.action,
|
||||
holdAction: holdAction
|
||||
holdAction: holdAction,
|
||||
highlightedAction: self.highlightedAction
|
||||
)
|
||||
}
|
||||
|
||||
@@ -76,7 +84,8 @@ public final class Button: Component {
|
||||
automaticHighlight: self.automaticHighlight,
|
||||
isEnabled: self.isEnabled,
|
||||
action: self.action,
|
||||
holdAction: self.holdAction
|
||||
holdAction: self.holdAction,
|
||||
highlightedAction: self.highlightedAction
|
||||
)
|
||||
}
|
||||
|
||||
@@ -105,11 +114,14 @@ public final class Button: Component {
|
||||
private var component: Button?
|
||||
private var currentIsHighlighted: Bool = false {
|
||||
didSet {
|
||||
guard let component = self.component, component.automaticHighlight else {
|
||||
guard let component = self.component else {
|
||||
return
|
||||
}
|
||||
if self.currentIsHighlighted != oldValue {
|
||||
self.updateAlpha(transition: .immediate)
|
||||
if component.automaticHighlight {
|
||||
self.updateAlpha(transition: .immediate)
|
||||
}
|
||||
component.highlightedAction?.invoke(self.currentIsHighlighted)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,13 +4,16 @@ import UIKit
|
||||
public final class Image: Component {
|
||||
public let image: UIImage?
|
||||
public let tintColor: UIColor?
|
||||
public let size: CGSize?
|
||||
|
||||
public init(
|
||||
image: UIImage?,
|
||||
tintColor: UIColor? = nil
|
||||
tintColor: UIColor? = nil,
|
||||
size: CGSize? = nil
|
||||
) {
|
||||
self.image = image
|
||||
self.tintColor = tintColor
|
||||
self.size = size
|
||||
}
|
||||
|
||||
public static func ==(lhs: Image, rhs: Image) -> Bool {
|
||||
@@ -20,6 +23,9 @@ public final class Image: Component {
|
||||
if lhs.tintColor != rhs.tintColor {
|
||||
return false
|
||||
}
|
||||
if lhs.size != rhs.size {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
@@ -36,7 +42,7 @@ public final class Image: Component {
|
||||
self.image = component.image
|
||||
self.tintColor = component.tintColor
|
||||
|
||||
return availableSize
|
||||
return component.size ?? availableSize
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user