Files
comaps/iphone/Maps/UI/Help/AboutController/Views/DonationView.swift
Konstantin Pastbin e3e4a1985a Organic Maps sources as of 02.04.2025 (fad26bbf22ac3da75e01e62aa01e5c8e11861005)
To expand with full Organic Maps and Maps.ME commits history run:
  git remote add om-historic [om-historic.git repo url]
  git fetch --tags om-historic
  git replace squashed-history historic-commits
2025-05-08 21:10:51 +07:00

68 lines
2.1 KiB
Swift

final class DonationView: UIView {
private let donateTextLabel = UILabel()
private let donateButton = UIButton()
var donateButtonDidTapHandler: (() -> Void)?
init() {
super.init(frame: .zero)
setupViews()
arrangeViews()
layoutViews()
}
required init?(coder: NSCoder) {
super.init(coder: coder)
setupViews()
arrangeViews()
layoutViews()
}
private func setupViews() {
donateTextLabel.setFontStyle(.regular14, color: .blackPrimary)
donateTextLabel.text = L("donate_description")
donateTextLabel.textAlignment = .center
donateTextLabel.lineBreakMode = .byWordWrapping
donateTextLabel.numberOfLines = 0
donateButton.setStyle(.flatNormalButton)
donateButton.setTitle(L("donate").localizedUppercase, for: .normal)
donateButton.addTarget(self, action: #selector(donateButtonDidTap), for: .touchUpInside)
}
private func arrangeViews() {
addSubview(donateTextLabel)
addSubview(donateButton)
}
private func layoutViews() {
donateTextLabel.translatesAutoresizingMaskIntoConstraints = false
donateButton.translatesAutoresizingMaskIntoConstraints = false
NSLayoutConstraint.activate([
donateTextLabel.leadingAnchor.constraint(equalTo: leadingAnchor),
donateTextLabel.trailingAnchor.constraint(equalTo: trailingAnchor),
donateTextLabel.topAnchor.constraint(equalTo: topAnchor),
donateButton.topAnchor.constraint(equalTo: donateTextLabel.bottomAnchor, constant: 10),
donateButton.widthAnchor.constraint(equalTo: widthAnchor, constant: -40).withPriority(.defaultHigh),
donateButton.widthAnchor.constraint(lessThanOrEqualToConstant: 400).withPriority(.defaultHigh),
donateButton.centerXAnchor.constraint(equalTo: centerXAnchor),
donateButton.heightAnchor.constraint(equalToConstant: 40),
donateButton.bottomAnchor.constraint(equalTo: bottomAnchor),
])
}
@objc private func donateButtonDidTap() {
donateButtonDidTapHandler?()
}
}
private extension NSLayoutConstraint {
func withPriority(_ priority: UILayoutPriority) -> NSLayoutConstraint {
self.priority = priority
return self
}
}