mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-06-16 05:55:20 +00:00
25 lines
832 B
Swift
25 lines
832 B
Swift
import Foundation
|
|
|
|
public enum ActionSheetButtonColor {
|
|
case accent
|
|
case destructive
|
|
}
|
|
|
|
public class ActionSheetButtonItem: ActionSheetItem {
|
|
public let title: String
|
|
public let color: ActionSheetButtonColor
|
|
public let action: () -> Void
|
|
|
|
public init(title: String, color: ActionSheetButtonColor = .accent, action: @escaping () -> Void) {
|
|
self.title = title
|
|
self.color = color
|
|
self.action = action
|
|
}
|
|
|
|
public func node() -> ActionSheetItemNode {
|
|
let textColorIsAccent = self.color == ActionSheetButtonColor.accent
|
|
let textColor = textColorIsAccent ? UIColor(0x007ee5) : UIColor.red
|
|
return ActionSheetButtonNode(title: NSAttributedString(string: title, font: ActionSheetButtonNode.defaultFont, textColor: textColor), action: self.action)
|
|
}
|
|
}
|