Files
comaps/iphone/Maps/UI/Help/AboutController/Views/DonationView.swift
Kiryl Kaveryn 103d660603 [ios] refactor Toast class and improve toast message style
1. update style: bigger fonts and insets
2. update background blur
3. get rid of MWM prefix
4. replace the timer with the simplier dispatch async after. In this case there is no needed to create a timer for each toasts message just to add a timeout
5. reorder Toast class methods
6. replace the instance `show` method with a `static show`. Because there non needed to call show every time. We do not have stored toast that will be showed in different places thane created.
Signed-off-by: Kiryl Kaveryn <kirylkaveryn@gmail.com>

Signed-off-by: Kiryl Kaveryn <kirylkaveryn@gmail.com>
2025-05-19 10:52:42 +02: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?()
}
}
extension NSLayoutConstraint {
func withPriority(_ priority: UILayoutPriority) -> NSLayoutConstraint {
self.priority = priority
return self
}
}