From 2259a151d93ad0ed034fc77f8ab7ea3f92101113 Mon Sep 17 00:00:00 2001 From: Igor Solomennikov Date: Sun, 31 May 2026 10:12:11 -0700 Subject: [PATCH] Delete unused OWSButton methods / properties. --- .../ConversationInputToolbar.swift | 1 - SignalUI/ConversationView/CVUtils.swift | 2 - .../UIButton+DeprecationWorkaround.h | 2 - .../UIButton+DeprecationWorkaround.m | 20 ----- SignalUI/Views/OWSButton.swift | 90 +------------------ SignalUI/Views/OWSFlatButton.swift | 18 ---- 6 files changed, 1 insertion(+), 132 deletions(-) diff --git a/Signal/ConversationView/ConversationInputToolbar.swift b/Signal/ConversationView/ConversationInputToolbar.swift index 505f1f69ce..5545aaebfc 100644 --- a/Signal/ConversationView/ConversationInputToolbar.swift +++ b/Signal/ConversationView/ConversationInputToolbar.swift @@ -1219,7 +1219,6 @@ public class ConversationInputToolbar: UIView, QuotedReplyPreviewDelegate { lazy var sendButton: UIButton = { let button = UIButton(type: .system) button.accessibilityLabel = MessageStrings.sendButton - button.ows_adjustsImageWhenDisabled = true button.isPointerInteractionEnabled = true button.accessibilityIdentifier = UIView.accessibilityIdentifier(in: self, name: "sendButton") button.setImage(UIImage(imageLiteralResourceName: "send-blue-28"), for: .normal) diff --git a/SignalUI/ConversationView/CVUtils.swift b/SignalUI/ConversationView/CVUtils.swift index 34efa814ac..2139903add 100644 --- a/SignalUI/ConversationView/CVUtils.swift +++ b/SignalUI/ConversationView/CVUtils.swift @@ -66,10 +66,8 @@ open class CVButton: OWSButton, CVView { public func reset() { self.block = {} - self.dimsWhenDisabled = false self.dimsWhenHighlighted = false self.ows_contentEdgeInsets = .zero - self.ows_titleEdgeInsets = .zero [ UIControl.State.normal, .highlighted, diff --git a/SignalUI/UIKitExtensions/UIButton+DeprecationWorkaround.h b/SignalUI/UIKitExtensions/UIButton+DeprecationWorkaround.h index 9266162e8d..61b3ba4a5b 100644 --- a/SignalUI/UIKitExtensions/UIButton+DeprecationWorkaround.h +++ b/SignalUI/UIKitExtensions/UIButton+DeprecationWorkaround.h @@ -9,12 +9,10 @@ NS_ASSUME_NONNULL_BEGIN @interface UIButton (DeprecationWorkaround) -@property (nonatomic, setter=ows_setAdjustsImageWhenDisabled:) BOOL ows_adjustsImageWhenDisabled; @property (nonatomic, setter=ows_setAdjustsImageWhenHighlighted:) BOOL ows_adjustsImageWhenHighlighted; @property (nonatomic, setter=ows_setContentEdgeInsets:) UIEdgeInsets ows_contentEdgeInsets; @property (nonatomic, setter=ows_setImageEdgeInsets:) UIEdgeInsets ows_imageEdgeInsets; -@property (nonatomic, setter=ows_setTitleEdgeInsets:) UIEdgeInsets ows_titleEdgeInsets; @end diff --git a/SignalUI/UIKitExtensions/UIButton+DeprecationWorkaround.m b/SignalUI/UIKitExtensions/UIButton+DeprecationWorkaround.m index cfec3efdff..94371ba332 100644 --- a/SignalUI/UIKitExtensions/UIButton+DeprecationWorkaround.m +++ b/SignalUI/UIKitExtensions/UIButton+DeprecationWorkaround.m @@ -10,16 +10,6 @@ @implementation UIButton (DeprecationWorkaround) -- (BOOL)ows_adjustsImageWhenDisabled -{ - return self.adjustsImageWhenDisabled; -} - -- (void)ows_setAdjustsImageWhenDisabled:(BOOL)adjustsImageWhenDisabled -{ - self.adjustsImageWhenDisabled = adjustsImageWhenDisabled; -} - - (BOOL)ows_adjustsImageWhenHighlighted { return self.adjustsImageWhenHighlighted; @@ -50,16 +40,6 @@ self.imageEdgeInsets = imageEdgeInsets; } -- (UIEdgeInsets)ows_titleEdgeInsets -{ - return self.titleEdgeInsets; -} - -- (void)ows_setTitleEdgeInsets:(UIEdgeInsets)titleEdgeInsets -{ - self.titleEdgeInsets = titleEdgeInsets; -} - @end #pragma clang diagnostic pop diff --git a/SignalUI/Views/OWSButton.swift b/SignalUI/Views/OWSButton.swift index 51e06663e9..e6fe6a4094 100644 --- a/SignalUI/Views/OWSButton.swift +++ b/SignalUI/Views/OWSButton.swift @@ -14,18 +14,10 @@ open class OWSButton: UIButton { didSet { updateAlpha() } } - public var dimsWhenDisabled = false { - didSet { updateAlpha() } - } - override public var isHighlighted: Bool { didSet { updateAlpha() } } - override public var isEnabled: Bool { - didSet { updateAlpha() } - } - // MARK: - public init(block: @escaping () -> Void = { }) { @@ -69,34 +61,6 @@ open class OWSButton: UIButton { self.tintColor = tintColor } - /// Creates a button with a title and image. - /// - Parameters: - /// - title: The title for the button label. - /// - imageName: The image for the button. - /// - tintColor: The tint color for the image. - /// Note that this does not tint the text. - /// - spacing: The spacing between the image and title. - /// - block: The action to perform on tap. - public init( - title: String, - imageName: String, - tintColor: UIColor?, - spacing: CGFloat, - block: @escaping () -> Void = {}, - ) { - super.init(frame: .zero) - - setTitle(title, for: .normal) - - setImage(imageName: imageName) - self.tintColor = tintColor - - addImageTitleSpacing(spacing) - - self.block = block - addTarget(self, action: #selector(didTap), for: .touchUpInside) - } - public func setImage(imageName: String?) { guard let imageName else { setImage(nil, for: .normal) @@ -109,35 +73,10 @@ open class OWSButton: UIButton { } } - /// Configure the button for a potentially multiline label. - /// - /// UIButton's intrinsic content size won't respect a multiline label, and - /// consequently the label might grow outside the bounds of the button. - /// - /// Note that this method uses autolayout. - public func configureForMultilineTitle(lineBreakMode: NSLineBreakMode = .byCharWrapping) { - titleLabel!.numberOfLines = 0 - titleLabel!.lineBreakMode = lineBreakMode - - // Without this, the label may grow taller than the button, which won't - // grow its intrinsic content size to compensate for a multiline label. - autoPinHeight(toHeightOf: titleLabel!, relation: .greaterThanOrEqual) - } - public required init?(coder aDecoder: NSCoder) { fatalError("init(coder:) has not been implemented") } - /// Adds spacing between the image and title. - /// - /// Does so by modifying `contentEdgeInsets` and `titleEdgeInsets`, - /// so call this after setting those. - public func addImageTitleSpacing(_ spacing: CGFloat) { - ows_contentEdgeInsets.trailing += spacing - ows_titleEdgeInsets.leading += spacing - ows_titleEdgeInsets.trailing -= spacing - } - // MARK: - Common Style Reuse public class func sendButton(imageName: String, block: @escaping () -> Void) -> OWSButton { @@ -152,30 +91,6 @@ open class OWSButton: UIButton { return button } - /// Mimics a UIBarButtonItem of type .cancel, but with a shadow. - public class func shadowedCancelButton(block: @escaping () -> Void) -> OWSButton { - let cancelButton = OWSButton(title: CommonStrings.cancelButton, block: block) - cancelButton.setTitleColor(.white, for: .normal) - if let titleLabel = cancelButton.titleLabel { - titleLabel.font = UIFont.systemFont(ofSize: 18.0) - titleLabel.layer.shadowColor = UIColor.black.cgColor - titleLabel.setShadow() - } else { - owsFailDebug("Missing titleLabel.") - } - cancelButton.sizeToFit() - return cancelButton - } - - public class func navigationBarButton(imageName: String, block: @escaping () -> Void) -> OWSButton { - let button = OWSButton(imageName: imageName, tintColor: .white, block: block) - button.layer.shadowColor = UIColor.black.cgColor - button.layer.shadowRadius = 2 - button.layer.shadowOpacity = 0.66 - button.layer.shadowOffset = .zero - return button - } - // MARK: - @objc @@ -184,10 +99,7 @@ open class OWSButton: UIButton { } private func updateAlpha() { - let isDimmed = ( - (dimsWhenHighlighted && isHighlighted) || - (dimsWhenDisabled && !isEnabled), - ) + let isDimmed = (dimsWhenHighlighted && isHighlighted) alpha = isDimmed ? 0.4 : 1 } } diff --git a/SignalUI/Views/OWSFlatButton.swift b/SignalUI/Views/OWSFlatButton.swift index c4d480229e..f96c22ad81 100644 --- a/SignalUI/Views/OWSFlatButton.swift +++ b/SignalUI/Views/OWSFlatButton.swift @@ -40,24 +40,6 @@ open class OWSFlatButton: UIView { } } - public var titleEdgeInsets: UIEdgeInsets { - get { - return button.ows_titleEdgeInsets - } - set { - button.ows_titleEdgeInsets = newValue - } - } - - public var contentEdgeInsets: UIEdgeInsets { - get { - return button.ows_contentEdgeInsets - } - set { - button.ows_contentEdgeInsets = newValue - } - } - override public var tintColor: UIColor! { get { return button.tintColor