mirror of
https://codeberg.org/comaps/comaps
synced 2025-12-23 14:43:43 +00:00
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
This commit is contained in:
67
iphone/Maps/UI/Help/AboutController/Views/DonationView.swift
Normal file
67
iphone/Maps/UI/Help/AboutController/Views/DonationView.swift
Normal file
@@ -0,0 +1,67 @@
|
||||
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
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user