Signal-iOS/SignalUI/Views/TappableStackView.swift
Jordan Rose b0de59f2e2 Remove required from every init that is not dynamically dispatched
This included:
- Removing unavailable inits wholesale if no longer `required`
- Marking a few classes `final` so they could continue using
  `Self(...)` rather than `OWSWhatever(...)`
2024-04-01 15:27:20 -07:00

36 lines
901 B
Swift

//
// Copyright 2018 Signal Messenger, LLC
// SPDX-License-Identifier: AGPL-3.0-only
//
import SignalCoreKit
public class TappableStackView: UIStackView {
let actionBlock: (() -> Void)
// MARK: - Initializers
@available(*, unavailable, message: "use other constructor instead.")
public required init(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
public init(actionBlock: @escaping () -> Void) {
self.actionBlock = actionBlock
super.init(frame: CGRect.zero)
self.isUserInteractionEnabled = true
self.addGestureRecognizer(UITapGestureRecognizer(target: self, action: #selector(wasTapped)))
}
@objc
private func wasTapped(sender: UIGestureRecognizer) {
Logger.info("")
guard sender.state == .recognized else {
return
}
actionBlock()
}
}