Updates to scan QR code button in Find by Username screen.

• use shared "smallSecondary" button configuration.
• use Symbols font to show qr code icon.
This commit is contained in:
Igor Solomennikov 2026-05-29 06:22:42 -07:00 committed by GitHub
parent 832f2b06eb
commit 6d78ec66e1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 32 additions and 23 deletions

View File

@ -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}"

View File

@ -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
}),
])