diff --git a/SignalUI/Appearance/SignalSymbols.swift b/SignalUI/Appearance/SignalSymbols.swift index 5c29e81304..3ae2baf63e 100644 --- a/SignalUI/Appearance/SignalSymbols.swift +++ b/SignalUI/Appearance/SignalSymbols.swift @@ -98,6 +98,7 @@ public enum SignalSymbol: Character { case plus = "\u{E1D1}" case plusCircle = "\u{E1D2}" case poll = "\u{E082}" + case qrcode = "\u{E0C2}" case refresh = "\u{E0C4}" case reply = "\u{E06D}" case safetyNumber = "\u{E06F}" diff --git a/SignalUI/Usernames/FindByUsernameViewController.swift b/SignalUI/Usernames/FindByUsernameViewController.swift index 648d8b41c9..8d7c6e5d9d 100644 --- a/SignalUI/Usernames/FindByUsernameViewController.swift +++ b/SignalUI/Usernames/FindByUsernameViewController.swift @@ -93,31 +93,39 @@ public class FindByUsernameViewController: OWSTableViewController2 { let qrButtonSection = OWSTableSection(items: [ OWSTableItem(customCellBlock: { [weak self] in let cell = OWSTableItem.newCell() - let button = OWSRoundedButton { - self?.findByUsernameDelegate?.openQRCodeScanner() - } - let font = UIFont.dynamicTypeSubheadline - let title = NSAttributedString.composed(of: [ - NSAttributedString.with(image: Theme.iconImage(.qrCode), font: font), - " ", - OWSLocalizedString( - "FIND_BY_USERNAME_SCAN_QR_CODE_BUTTON", - comment: "A button below the username text field which opens a username QR code scanner", + + // Font taken from UIButton.Configuration.smallSecondary + let buttonTitleFont = UIFont.dynamicTypeSubheadlineClamped.medium() + var attributedButtonTitle = AttributedString( + SignalSymbol.qrcode.attributedString( + dynamicTypeBaseSize: buttonTitleFont.pointSize, ), - ]).styled( - with: .font(font.medium()), - .color(Theme.primaryTextColor), ) - button.setAttributedTitle(title, for: .normal) - button.backgroundColor = Theme.tableCell2PresentedBackgroundColor - button.dimsWhenHighlighted = true - button.ows_contentEdgeInsets = .init(hMargin: 16, vMargin: 6) - cell.addSubview(button) - button.autoPinEdge(toSuperviewMargin: .top) - button.autoPinEdge(toSuperviewMargin: .bottom) - button.autoCenterInSuperviewMargins() - button.autoPinEdge(toSuperviewMargin: .leading, relation: .greaterThanOrEqual) - button.autoPinEdge(toSuperviewMargin: .trailing, relation: .greaterThanOrEqual) + attributedButtonTitle.append(AttributedString(" ")) + attributedButtonTitle.append(AttributedString(OWSLocalizedString( + "FIND_BY_USERNAME_SCAN_QR_CODE_BUTTON", + comment: "A button below the username text field which opens a username QR code scanner", + ))) + var defaults = AttributeContainer() + defaults.font = buttonTitleFont + attributedButtonTitle.mergeAttributes(defaults, mergePolicy: .keepCurrent) + + let button = UIButton( + configuration: .smallSecondary(title: ""), + primaryAction: UIAction { [weak self] _ in + self?.findByUsernameDelegate?.openQRCodeScanner() + }, + ) + button.configuration?.titleTextAttributesTransformer = nil // otherwise `attributedTitle` won't work. + button.configuration?.attributedTitle = attributedButtonTitle + button.translatesAutoresizingMaskIntoConstraints = false + cell.contentView.addSubview(button) + NSLayoutConstraint.activate([ + button.topAnchor.constraint(equalTo: cell.contentView.layoutMarginsGuide.topAnchor), + button.leadingAnchor.constraint(greaterThanOrEqualTo: cell.contentView.layoutMarginsGuide.leadingAnchor), + button.centerXAnchor.constraint(equalTo: cell.contentView.layoutMarginsGuide.centerXAnchor), + button.bottomAnchor.constraint(equalTo: cell.contentView.layoutMarginsGuide.bottomAnchor), + ]) return cell }), ])