From 1528f6f705b4403e6202161db2ca79e01fb77afa Mon Sep 17 00:00:00 2001 From: Michael Kirk Date: Fri, 22 Jun 2018 11:00:19 -0600 Subject: [PATCH] Fix archive/outage banner. // FREEBIE --- Signal/src/views/ReminderView.swift | 51 +++++++++++------------------ 1 file changed, 19 insertions(+), 32 deletions(-) diff --git a/Signal/src/views/ReminderView.swift b/Signal/src/views/ReminderView.swift index 2e50473ac..adb5ec6e7 100644 --- a/Signal/src/views/ReminderView.swift +++ b/Signal/src/views/ReminderView.swift @@ -73,49 +73,36 @@ class ReminderView: UIView { let tapGesture = UITapGestureRecognizer(target: self, action: #selector(handleTap(gestureRecognizer:))) self.addGestureRecognizer(tapGesture) - let container = UIView() + let container = UIStackView() + container.axis = .horizontal + container.alignment = .center + container.isLayoutMarginsRelativeArrangement = true self.addSubview(container) - container.autoPinWidthToSuperview(withMargin: 16) - switch (mode) { - case .nag: - container.autoPinHeightToSuperview(withMargin: 16) - case .explanation: - container.autoPinHeightToSuperview(withMargin: 12) - } - - // Margin: top and bottom 12 left and right 16. + container.layoutMargins = UIEdgeInsets(top: 12, left: 16, bottom: 12, right: 16) + container.autoPinToSuperviewEdges() // Label label.font = UIFont.ows_dynamicTypeSubheadline - container.addSubview(label) + container.addArrangedSubview(label) label.textColor = UIColor.black.withAlphaComponent(0.9) label.numberOfLines = 0 label.lineBreakMode = .byWordWrapping - label.autoPinLeadingToSuperviewMargin() - label.autoPinEdge(toSuperviewEdge: .top) - label.autoPinEdge(toSuperviewEdge: .bottom) // Show the disclosure indicator if this reminder has a tap action. - if tapAction == nil { - return - } - - // Icon - let iconName = (self.isRTL() ? "system_disclosure_indicator_rtl" : "system_disclosure_indicator") - guard let iconImage = UIImage(named: iconName) else { - owsFail("\(logTag) missing icon.") - return + if tapAction != nil { + // Icon + let iconName = (self.isRTL() ? "system_disclosure_indicator_rtl" : "system_disclosure_indicator") + guard let iconImage = UIImage(named: iconName) else { + owsFail("\(logTag) missing icon.") + return + } + let iconView = UIImageView(image: iconImage.withRenderingMode(.alwaysTemplate)) + iconView.contentMode = .scaleAspectFit + iconView.tintColor = UIColor.black.withAlphaComponent(0.6) + iconView.autoSetDimension(.width, toSize: 13) + container.addArrangedSubview(iconView) } - let iconView = UIImageView(image: iconImage.withRenderingMode(.alwaysTemplate)) - iconView.contentMode = .scaleAspectFit - iconView.tintColor = UIColor.black.withAlphaComponent(0.6) - container.addSubview(iconView) - - iconView.autoPinLeading(toTrailingEdgeOf: label, offset: 28) - iconView.autoPinTrailingToSuperviewMargin() - iconView.autoVCenterInSuperview() - iconView.autoSetDimension(.width, toSize: 13) } @objc func handleTap(gestureRecognizer: UIGestureRecognizer) {