1
0
mirror of https://github.com/mastodon/mastodon-ios.git synced 2025-01-23 22:11:22 +01:00

Refactor layout to center checkmark (IOS-130)

This commit is contained in:
Nathan Mattes 2023-11-04 23:33:02 +01:00
parent 6e22868f55
commit c0bdcc43a1

View File

@ -76,29 +76,32 @@ extension ProfileFieldCollectionViewCell {
containerStackView.preservesSuperviewLayoutMargins = true
containerStackView.isLayoutMarginsRelativeArrangement = true
containerStackView.translatesAutoresizingMaskIntoConstraints = false
addSubview(containerStackView)
contentView.addSubview(containerStackView)
NSLayoutConstraint.activate([
containerStackView.topAnchor.constraint(equalTo: topAnchor, constant: 11),
containerStackView.leadingAnchor.constraint(equalTo: leadingAnchor),
containerStackView.trailingAnchor.constraint(equalTo: trailingAnchor),
bottomAnchor.constraint(equalTo: containerStackView.bottomAnchor, constant: 11),
containerStackView.topAnchor.constraint(equalTo: contentView.topAnchor, constant: 11),
containerStackView.leadingAnchor.constraint(equalTo: contentView.leadingAnchor),
contentView.trailingAnchor.constraint(equalTo: containerStackView.trailingAnchor),
contentView.bottomAnchor.constraint(equalTo: containerStackView.bottomAnchor, constant: 11),
])
// metaContainer: V - [ keyMetaLabel | valueContainer ]
// metaContainer: h - [ keyValueContainer | checkmark ]
let metaContainer = UIStackView()
metaContainer.axis = .vertical
metaContainer.axis = .horizontal
metaContainer.spacing = 2
metaContainer.alignment = .center
// valueContainer: v - [ keyMetaLabel | valueMetaLabel ]
let keyValueContainer = UIStackView()
keyValueContainer.axis = .vertical
keyValueContainer.alignment = .leading
keyValueContainer.spacing = 2
containerStackView.addArrangedSubview(metaContainer)
keyValueContainer.addArrangedSubview(keyMetaLabel)
keyValueContainer.addArrangedSubview(valueMetaLabel)
// valueContainer: H - [ valueMetaLabel | checkmark ]
let valueContainer = UIStackView()
valueContainer.axis = .horizontal
valueContainer.spacing = 2
metaContainer.addArrangedSubview(keyMetaLabel)
valueContainer.addArrangedSubview(valueMetaLabel)
valueContainer.addArrangedSubview(checkmark)
metaContainer.addArrangedSubview(valueContainer)
metaContainer.addArrangedSubview(keyValueContainer)
metaContainer.addArrangedSubview(checkmark)
keyMetaLabel.linkDelegate = self
valueMetaLabel.linkDelegate = self