121 lines
5.4 KiB
Swift
121 lines
5.4 KiB
Swift
//
|
|
// AlertsSeismicNotificationCompactTableViewCell.swift
|
|
// Earthquake Network
|
|
//
|
|
// Created by Busi Andrea on 05/10/2020.
|
|
// Copyright © 2020 Earthquake Network. All rights reserved.
|
|
//
|
|
|
|
import UIKit
|
|
|
|
|
|
@objc
|
|
class AlertsSeismicNotificationCompactTableViewCell: EQNBaseContainerTableViewCell {
|
|
|
|
typealias DefaultCompletion = () -> Void
|
|
|
|
@objc var onTapAlertTest: DefaultCompletion?
|
|
@objc var onTapSimulator: DefaultCompletion?
|
|
@objc var onTapHowItWorks: DefaultCompletion?
|
|
@objc var onTapShareApp: DefaultCompletion?
|
|
|
|
override var isHeaderVisible: Bool { false }
|
|
|
|
// MARK: - UI
|
|
|
|
private lazy var descriptionLabel: UILabel = {
|
|
let label = UILabel()
|
|
label.translatesAutoresizingMaskIntoConstraints = false
|
|
label.textColor = AppTheme.Colors.green
|
|
label.font = .preferredFont(forTextStyle: .title3)
|
|
label.textAlignment = .center
|
|
label.numberOfLines = 0
|
|
return label
|
|
}()
|
|
|
|
private lazy var testAlertButton: UIButton = {
|
|
let button = EQNRoundedButton.make(target: self, action: #selector(testAlertTapped(_:)))
|
|
return button
|
|
}()
|
|
|
|
private lazy var simulatorAlertButton: UIButton = {
|
|
let button = EQNRoundedButton.make(target: self, action: #selector(simulatorTapped(_:)))
|
|
return button
|
|
}()
|
|
|
|
private lazy var howItWorksAlertButton: UIButton = {
|
|
let button = EQNRoundedButton.make(target: self, action: #selector(howItWorksTapped(_:)))
|
|
return button
|
|
}()
|
|
|
|
private lazy var shareAppButton: UIButton = {
|
|
let button = EQNRoundedButton.make(target: self, action: #selector(shareAppTapped(_:)))
|
|
return button
|
|
}()
|
|
|
|
// MARK: - Internal
|
|
|
|
override func setupUI() {
|
|
super.setupUI()
|
|
|
|
containerView.addSubview(descriptionLabel)
|
|
containerView.addSubview(testAlertButton)
|
|
containerView.addSubview(simulatorAlertButton)
|
|
containerView.addSubview(howItWorksAlertButton)
|
|
containerView.addSubview(shareAppButton)
|
|
|
|
descriptionLabel.topAnchor.constraint(equalTo: topView.bottomAnchor, constant: .cardPadding).isActive = true
|
|
descriptionLabel.leadingAnchor.constraint(equalTo: containerView.leadingAnchor, constant: .cardPadding).isActive = true
|
|
descriptionLabel.trailingAnchor.constraint(equalTo: containerView.trailingAnchor, constant: .cardPadding.negative).isActive = true
|
|
|
|
testAlertButton.heightAnchor.constraint(greaterThanOrEqualToConstant: 40.0).isActive = true
|
|
simulatorAlertButton.heightAnchor.constraint(equalTo: testAlertButton.heightAnchor).isActive = true
|
|
howItWorksAlertButton.heightAnchor.constraint(equalTo: testAlertButton.heightAnchor).isActive = true
|
|
shareAppButton.heightAnchor.constraint(equalTo: testAlertButton.heightAnchor).isActive = true
|
|
|
|
testAlertButton.topAnchor.constraint(equalTo: descriptionLabel.bottomAnchor, constant: .cardVerticalSpacing).isActive = true
|
|
testAlertButton.leadingAnchor.constraint(equalTo: descriptionLabel.leadingAnchor).isActive = true
|
|
testAlertButton.trailingAnchor.constraint(equalTo: simulatorAlertButton.leadingAnchor, constant: .cardPadding.negative).isActive = true
|
|
simulatorAlertButton.trailingAnchor.constraint(equalTo: descriptionLabel.trailingAnchor).isActive = true
|
|
simulatorAlertButton.centerYAnchor.constraint(equalTo: testAlertButton.centerYAnchor).isActive = true
|
|
simulatorAlertButton.widthAnchor.constraint(equalTo: testAlertButton.widthAnchor).isActive = true
|
|
|
|
howItWorksAlertButton.topAnchor.constraint(equalTo: testAlertButton.bottomAnchor, constant: .cardVerticalSpacing).isActive = true
|
|
howItWorksAlertButton.leadingAnchor.constraint(equalTo: testAlertButton.leadingAnchor).isActive = true
|
|
howItWorksAlertButton.trailingAnchor.constraint(equalTo: shareAppButton.leadingAnchor, constant: .cardPadding.negative).isActive = true
|
|
shareAppButton.trailingAnchor.constraint(equalTo: descriptionLabel.trailingAnchor).isActive = true
|
|
shareAppButton.centerYAnchor.constraint(equalTo: howItWorksAlertButton.centerYAnchor).isActive = true
|
|
shareAppButton.widthAnchor.constraint(equalTo: howItWorksAlertButton.widthAnchor).isActive = true
|
|
shareAppButton.bottomAnchor.constraint(equalTo: containerView.bottomAnchor, constant: .cardPadding.negative).isActive = true
|
|
}
|
|
|
|
override func updateUI() {
|
|
super.updateUI()
|
|
|
|
backgroundColor = AppTheme.Colors.cardBackgroundGreen
|
|
descriptionLabel.text = NSLocalizedString("main_nodetection", comment: "")
|
|
testAlertButton.setLocalizedTitle(key: "main_alerttest", uppercased: true, emoji: "🚨")
|
|
simulatorAlertButton.setLocalizedTitle(key: "main_simulator", uppercased: true, emoji: "⏱")
|
|
howItWorksAlertButton.setLocalizedTitle(key: "main_how_it_work", uppercased: true, emoji: "💡")
|
|
shareAppButton.setLocalizedTitle(key: "main_share_app", uppercased: true, emoji: "👥")
|
|
}
|
|
|
|
// MARK: - Actions
|
|
|
|
@objc private func testAlertTapped(_ sender: UIButton) {
|
|
onTapAlertTest?()
|
|
}
|
|
|
|
@objc private func simulatorTapped(_ sender: UIButton) {
|
|
onTapSimulator?()
|
|
}
|
|
|
|
@objc private func howItWorksTapped(_ sender: UIButton) {
|
|
onTapHowItWorks?()
|
|
}
|
|
|
|
@objc private func shareAppTapped(_ sender: UIButton) {
|
|
onTapShareApp?()
|
|
}
|
|
}
|