mirror of https://github.com/oxen-io/session-ios
				
				
				
			
			You cannot select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
		
			
		
			
	
	
		
			65 lines
		
	
	
		
			1.4 KiB
		
	
	
	
		
			Swift
		
	
		
		
			
		
	
	
			65 lines
		
	
	
		
			1.4 KiB
		
	
	
	
		
			Swift
		
	
| 
								 
											7 years ago
										 
									 | 
							
								//
							 | 
						||
| 
								 
											7 years ago
										 
									 | 
							
								//  Copyright (c) 2019 Open Whisper Systems. All rights reserved.
							 | 
						||
| 
								 
											7 years ago
										 
									 | 
							
								//
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								import UIKit
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								@objc
							 | 
						||
| 
								 | 
							
								public class OWSButton: UIButton {
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								    @objc
							 | 
						||
| 
								 | 
							
								    var block: () -> Void = { }
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								    // MARK: -
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								    @objc
							 | 
						||
| 
								 
											7 years ago
										 
									 | 
							
								    public init(block: @escaping () -> Void = { }) {
							 | 
						||
| 
								 
											7 years ago
										 
									 | 
							
								        super.init(frame: .zero)
							 | 
						||
| 
								 
											7 years ago
										 
									 | 
							
								
							 | 
						||
| 
								 | 
							
								        self.block = block
							 | 
						||
| 
								 | 
							
								        addTarget(self, action: #selector(didTap), for: .touchUpInside)
							 | 
						||
| 
								 | 
							
								    }
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								    @objc
							 | 
						||
| 
								 
											7 years ago
										 
									 | 
							
								    public init(title: String, block: @escaping () -> Void = { }) {
							 | 
						||
| 
								 
											7 years ago
										 
									 | 
							
								        super.init(frame: .zero)
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 
											7 years ago
										 
									 | 
							
								        self.block = block
							 | 
						||
| 
								 
											7 years ago
										 
									 | 
							
								        addTarget(self, action: #selector(didTap), for: .touchUpInside)
							 | 
						||
| 
								 | 
							
								        setTitle(title, for: .normal)
							 | 
						||
| 
								 
											7 years ago
										 
									 | 
							
								    }
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 
											7 years ago
										 
									 | 
							
								    @objc
							 | 
						||
| 
								 
											7 years ago
										 
									 | 
							
								    public init(imageName: String,
							 | 
						||
| 
								 | 
							
								         tintColor: UIColor?,
							 | 
						||
| 
								 
											7 years ago
										 
									 | 
							
								         block: @escaping () -> Void = { }) {
							 | 
						||
| 
								 | 
							
								        super.init(frame: .zero)
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								        self.block = block
							 | 
						||
| 
								 | 
							
								        addTarget(self, action: #selector(didTap), for: .touchUpInside)
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 
											7 years ago
										 
									 | 
							
								        setImage(imageName: imageName)
							 | 
						||
| 
								 | 
							
								        self.tintColor = tintColor
							 | 
						||
| 
								 | 
							
								    }
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								    @objc
							 | 
						||
| 
								 | 
							
								    public func setImage(imageName: String) {
							 | 
						||
| 
								 
											7 years ago
										 
									 | 
							
								        if let image = UIImage(named: imageName) {
							 | 
						||
| 
								 | 
							
								            setImage(image.withRenderingMode(.alwaysTemplate), for: .normal)
							 | 
						||
| 
								 | 
							
								        } else {
							 | 
						||
| 
								 | 
							
								            owsFailDebug("Missing asset: \(imageName)")
							 | 
						||
| 
								 | 
							
								        }
							 | 
						||
| 
								 | 
							
								    }
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 
											7 years ago
										 
									 | 
							
								    public required init?(coder aDecoder: NSCoder) {
							 | 
						||
| 
								 
											7 years ago
										 
									 | 
							
								        fatalError("init(coder:) has not been implemented")
							 | 
						||
| 
								 | 
							
								    }
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								    // MARK: -
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								    @objc
							 | 
						||
| 
								 | 
							
								    func didTap() {
							 | 
						||
| 
								 | 
							
								        block()
							 | 
						||
| 
								 | 
							
								    }
							 | 
						||
| 
								 | 
							
								}
							 |