You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
session-ios/Session/Calls/Views & Modals/CallMissedTipsModal.swift

114 lines
3.8 KiB
Swift

// Copyright © 2022 Rangeproof Pty Ltd. All rights reserved.
import UIKit
import SessionUIKit
final class CallMissedTipsModal: Modal {
private let caller: String
// MARK: - UI
private lazy var tipsIconContainerView: UIView = UIView()
private lazy var tipsIconImageView: UIImageView = {
let result: UIImageView = UIImageView(
image: UIImage(named: "Tips")?.withRenderingMode(.alwaysTemplate)
)
result.themeTintColor = .textPrimary
result.set(.width, to: 19)
result.set(.height, to: 28)
return result
}()
private lazy var titleLabel: UILabel = {
let result: UILabel = UILabel()
result.font = .boldSystemFont(ofSize: Values.mediumFontSize)
result.text = "callsMissedCallFrom"
.put(key: "name", value: caller)
.localized()
result.themeTextColor = .textPrimary
result.textAlignment = .center
return result
}()
private lazy var messageLabel: UILabel = {
let result: UILabel = UILabel()
result.font = .systemFont(ofSize: Values.smallFontSize)
result.themeTextColor = .textPrimary
result.textAlignment = .natural
result.lineBreakMode = .byWordWrapping
result.numberOfLines = 0
result.attributedText = "callsYouMissedCallPermissions"
.put(key: "name", value: caller)
.localizedFormatted(in: result)
return result
}()
private lazy var contentStackView: UIStackView = {
let result = UIStackView(arrangedSubviews: [ tipsIconContainerView, titleLabel, messageLabel ])
result.axis = .vertical
result.spacing = Values.smallSpacing
result.isLayoutMarginsRelativeArrangement = true
result.layoutMargins = UIEdgeInsets(
top: Values.largeSpacing,
leading: Values.largeSpacing,
bottom: Values.verySmallSpacing,
trailing: Values.largeSpacing
)
return result
}()
private lazy var mainStackView: UIStackView = {
let result = UIStackView(arrangedSubviews: [ contentStackView, cancelButton ])
result.axis = .vertical
result.spacing = Values.largeSpacing - Values.smallFontSize / 2
return result
}()
// MARK: - Lifecycle
init(caller: String, presentingViewController: UIViewController?) {
self.caller = caller
super.init(
afterClosed: {
let navController: UINavigationController = StyledNavigationController(
rootViewController: SessionTableViewController(
viewModel: PrivacySettingsViewModel(
shouldShowCloseButton: true,
shouldAutomaticallyShowCallModal: true
)
)
)
navController.modalPresentationStyle = .fullScreen
presentingViewController?.present(navController, animated: true, completion: nil)
}
)
self.modalPresentationStyle = .overFullScreen
self.modalTransitionStyle = .crossDissolve
}
required init?(coder: NSCoder) {
preconditionFailure("Use init(caller:) instead.")
}
override func populateContentView() {
cancelButton.setTitle("sessionSettings".localized(), for: .normal)
contentView.addSubview(mainStackView)
tipsIconContainerView.addSubview(tipsIconImageView)
mainStackView.pin(to: contentView)
tipsIconImageView.pin(.top, to: .top, of: tipsIconContainerView)
tipsIconImageView.pin(.bottom, to: .bottom, of: tipsIconContainerView)
tipsIconImageView.center(in: tipsIconContainerView)
}
}