From bee4567daceca905d68eca4cb6d69ff96645db54 Mon Sep 17 00:00:00 2001 From: Igor Solomennikov Date: Fri, 29 Apr 2022 14:11:12 -0700 Subject: [PATCH] Address PR feedback. --- .../UserInterface/Group/GroupCallErrorView.swift | 9 ++++----- .../ViewControllers/OWSPinSetupViewController.swift | 13 ++++++------- .../OnboardingPhoneNumberViewController.swift | 5 ++--- .../Attachments/OWSAttachmentDownloads.swift | 2 ++ .../src/Messages/Attachments/TSAttachmentPointer.h | 2 +- 5 files changed, 15 insertions(+), 16 deletions(-) diff --git a/Signal/src/Calls/UserInterface/Group/GroupCallErrorView.swift b/Signal/src/Calls/UserInterface/Group/GroupCallErrorView.swift index 99b143fb8e..8a345052d2 100644 --- a/Signal/src/Calls/UserInterface/Group/GroupCallErrorView.swift +++ b/Signal/src/Calls/UserInterface/Group/GroupCallErrorView.swift @@ -46,7 +46,7 @@ class GroupCallErrorView: UIView { return label }() - private let button: UIButton = { + private lazy var button: UIButton = { let buttonLabel = NSLocalizedString( "GROUP_CALL_ERROR_DETAILS", comment: "A button to receive more info about not seeing a participant in group call grid") @@ -62,14 +62,16 @@ class GroupCallErrorView: UIView { button.titleLabel?.font = UIFont.ows_dynamicTypeSubheadline.ows_semibold button.setTitle(buttonLabel, for: .normal) + button.addTarget(self, action: #selector(didTapButton), for: .touchUpInside) return button }() - private let miniButton: UIButton = { + private lazy var miniButton: UIButton = { let button = UIButton() button.contentVerticalAlignment = .fill button.contentHorizontalAlignment = .fill + button.addTarget(self, action: #selector(didTapButton), for: .touchUpInside) return button }() @@ -105,9 +107,6 @@ class GroupCallErrorView: UIView { button.autoSetDimension(.height, toSize: 24, relation: .greaterThanOrEqual) miniButton.autoSetDimensions(to: CGSize(width: 24, height: 24)) - button.addTarget(self, action: #selector(didTapButton), for: .touchUpInside) - miniButton.addTarget(self, action: #selector(didTapButton), for: .touchUpInside) - configure() } diff --git a/Signal/src/ViewControllers/OWSPinSetupViewController.swift b/Signal/src/ViewControllers/OWSPinSetupViewController.swift index 1a904973e1..b954ba8f46 100644 --- a/Signal/src/ViewControllers/OWSPinSetupViewController.swift +++ b/Signal/src/ViewControllers/OWSPinSetupViewController.swift @@ -100,7 +100,7 @@ public class PinSetupViewController: OWSViewController { return pinTypeToggle }() - private let nextButton: OWSFlatButton = { + private lazy var nextButton: OWSFlatButton = { let nextButton = OWSFlatButton() nextButton.setTitle( title: CommonStrings.nextButton, @@ -112,6 +112,7 @@ public class PinSetupViewController: OWSViewController { nextButton.button.layer.cornerRadius = 14 nextButton.contentEdgeInsets = UIEdgeInsets(hMargin: 4, vMargin: 14) + nextButton.addTarget(target: self, selector: #selector(nextPressed)) nextButton.accessibilityIdentifier = "pinCreation.nextButton" return nextButton }() @@ -136,17 +137,19 @@ public class PinSetupViewController: OWSViewController { return recommendationLabel }() - private let backButton: UIButton = { + private lazy var backButton: UIButton = { let topButtonImage = CurrentAppContext().isRTL ? #imageLiteral(resourceName: "NavBarBackRTL") : #imageLiteral(resourceName: "NavBarBack") let backButton = UIButton.withTemplateImage(topButtonImage, tintColor: Theme.secondaryTextAndIconColor) backButton.autoSetDimensions(to: CGSize(square: 40)) + backButton.addTarget(self, action: #selector(navigateBack), for: .touchUpInside) return backButton }() - private let moreButton: UIButton = { + private lazy var moreButton: UIButton = { let moreButton = UIButton.withTemplateImageName("more-horiz-24", tintColor: Theme.primaryIconColor) moreButton.autoSetDimensions(to: CGSize(square: 40)) + moreButton.addTarget(self, action: #selector(didTapMoreButton), for: .touchUpInside) return moreButton }() @@ -369,10 +372,6 @@ public class PinSetupViewController: OWSViewController { if #available(iOS 13, *) { isModalInPresentation = true } - - nextButton.addTarget(target: self, selector: #selector(nextPressed)) - backButton.addTarget(self, action: #selector(navigateBack), for: .touchUpInside) - moreButton.addTarget(self, action: #selector(didTapMoreButton), for: .touchUpInside) } var titleText: String { diff --git a/Signal/src/ViewControllers/Registration/Onboarding/OnboardingPhoneNumberViewController.swift b/Signal/src/ViewControllers/Registration/Onboarding/OnboardingPhoneNumberViewController.swift index d22ebf6229..0769fb8786 100644 --- a/Signal/src/ViewControllers/Registration/Onboarding/OnboardingPhoneNumberViewController.swift +++ b/Signal/src/ViewControllers/Registration/Onboarding/OnboardingPhoneNumberViewController.swift @@ -71,11 +71,12 @@ public class RegistrationPhoneNumberViewController: OnboardingBaseViewController return imageView }() - private let callingCodeLabel: UILabel = { + private lazy var callingCodeLabel: UILabel = { let label = UILabel() label.textColor = Theme.primaryTextColor label.font = UIFont.ows_dynamicTypeBodyClamped label.isUserInteractionEnabled = true + label.addGestureRecognizer(UITapGestureRecognizer(target: self, action: #selector(countryCodeTapped))) label.accessibilityIdentifier = "onboarding.phoneNumber." + "callingCodeLabel" return label }() @@ -255,8 +256,6 @@ public class RegistrationPhoneNumberViewController: OnboardingBaseViewController phoneNumberTextField.delegate = self phoneNumberTextField.addTarget(self, action: #selector(textFieldDidChange(_:)), for: .editingChanged) populateDefaults() - - callingCodeLabel.addGestureRecognizer(UITapGestureRecognizer(target: self, action: #selector(countryCodeTapped))) } var isAppearing = false diff --git a/SignalServiceKit/src/Messages/Attachments/OWSAttachmentDownloads.swift b/SignalServiceKit/src/Messages/Attachments/OWSAttachmentDownloads.swift index d7555237f5..d88f3fe01d 100644 --- a/SignalServiceKit/src/Messages/Attachments/OWSAttachmentDownloads.swift +++ b/SignalServiceKit/src/Messages/Attachments/OWSAttachmentDownloads.swift @@ -555,6 +555,8 @@ public class OWSAttachmentDownloads: NSObject { } else { attachmentPointer.updateAttachmentPointerState(.failed, transaction: transaction) } + @unknown default: + owsFailDebug("Invalid value.") } if let message = job.message { diff --git a/SignalServiceKit/src/Messages/Attachments/TSAttachmentPointer.h b/SignalServiceKit/src/Messages/Attachments/TSAttachmentPointer.h index 619394329a..ff0a0e3855 100644 --- a/SignalServiceKit/src/Messages/Attachments/TSAttachmentPointer.h +++ b/SignalServiceKit/src/Messages/Attachments/TSAttachmentPointer.h @@ -18,7 +18,7 @@ typedef NS_ENUM(NSUInteger, TSAttachmentPointerType) { TSAttachmentPointerTypeRestoring = 2, }; -typedef NS_CLOSED_ENUM(NSUInteger, TSAttachmentPointerState) { +typedef NS_ENUM(NSUInteger, TSAttachmentPointerState) { TSAttachmentPointerStateEnqueued = 0, TSAttachmentPointerStateDownloading = 1, TSAttachmentPointerStateFailed = 2,