Files
Morgan Pretty f7fd15dae0 Finished removing usages to non-theme colour variables
Updated theming throughout
Fixed a couple of bugs with the media gallery
2022-09-20 16:06:01 +10:00

54 lines
1.3 KiB
Swift

// Copyright (c) 2019 Open Whisper Systems. All rights reserved.
import UIKit
import SessionUIKit
public class OWSButton: UIButton {
var block: () -> Void = { }
// MARK: -
public init(block: @escaping () -> Void = { }) {
super.init(frame: .zero)
self.block = block
addTarget(self, action: #selector(didTap), for: .touchUpInside)
}
public init(title: String, block: @escaping () -> Void = { }) {
super.init(frame: .zero)
self.block = block
addTarget(self, action: #selector(didTap), for: .touchUpInside)
setTitle(title, for: .normal)
}
public init(imageName: String, tintColor: ThemeValue?, block: @escaping () -> Void = { }) {
super.init(frame: .zero)
self.block = block
addTarget(self, action: #selector(didTap), for: .touchUpInside)
setImage(imageName: imageName)
self.themeTintColor = tintColor
}
public func setImage(imageName: String) {
setImage(
UIImage(named: imageName)?
.withRenderingMode(.alwaysTemplate),
for: .normal
)
}
public required init?(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
// MARK: -
@objc func didTap() {
block()
}
}