2019-12-06 04:42:43 +01:00
|
|
|
|
|
|
|
final class LandingVC : UIViewController {
|
|
|
|
|
|
|
|
// MARK: Settings
|
|
|
|
override var preferredStatusBarStyle: UIStatusBarStyle { return .lightContent }
|
|
|
|
|
|
|
|
// MARK: Lifecycle
|
|
|
|
override func viewDidLoad() {
|
|
|
|
// Set gradient background
|
|
|
|
view.backgroundColor = .clear
|
|
|
|
let gradient = Gradients.defaultLokiBackground
|
|
|
|
view.setGradient(gradient)
|
|
|
|
// Set up navigation bar
|
|
|
|
let navigationBar = navigationController!.navigationBar
|
|
|
|
navigationBar.setBackgroundImage(UIImage(), for: UIBarMetrics.default)
|
|
|
|
navigationBar.shadowImage = UIImage()
|
|
|
|
navigationBar.isTranslucent = false
|
|
|
|
navigationBar.barTintColor = Colors.navigationBarBackground
|
|
|
|
// Set up logo image view
|
|
|
|
let logoImageView = UIImageView()
|
|
|
|
logoImageView.image = #imageLiteral(resourceName: "Loki")
|
|
|
|
logoImageView.contentMode = .scaleAspectFit
|
|
|
|
logoImageView.set(.width, to: 32)
|
|
|
|
logoImageView.set(.height, to: 32)
|
|
|
|
navigationItem.titleView = logoImageView
|
|
|
|
// Set up title label
|
|
|
|
let titleLabel = UILabel()
|
|
|
|
titleLabel.textColor = Colors.text
|
|
|
|
titleLabel.font = .boldSystemFont(ofSize: Values.veryLargeFontSize)
|
|
|
|
titleLabel.text = NSLocalizedString("Your Loki Messenger begins here...", comment: "")
|
|
|
|
titleLabel.numberOfLines = 0
|
|
|
|
titleLabel.lineBreakMode = .byWordWrapping
|
|
|
|
// Set up title label container
|
|
|
|
let titleLabelContainer = UIView()
|
|
|
|
titleLabelContainer.addSubview(titleLabel)
|
|
|
|
titleLabel.pin(.leading, to: .leading, of: titleLabelContainer, withInset: Values.veryLargeSpacing)
|
|
|
|
titleLabel.pin(.top, to: .top, of: titleLabelContainer)
|
|
|
|
titleLabelContainer.pin(.trailing, to: .trailing, of: titleLabel, withInset: Values.veryLargeSpacing)
|
|
|
|
titleLabelContainer.pin(.bottom, to: .bottom, of: titleLabel)
|
|
|
|
// Set up fake chat view
|
|
|
|
let fakeChatView = FakeChatView()
|
|
|
|
// Set up main stack view
|
|
|
|
let mainStackView = UIStackView(arrangedSubviews: [ titleLabelContainer, fakeChatView ])
|
|
|
|
mainStackView.axis = .vertical
|
2019-12-06 06:42:28 +01:00
|
|
|
mainStackView.spacing = Values.mediumSpacing // Not largeSpacing as the fake chat view has an internal top margin
|
2019-12-06 04:42:43 +01:00
|
|
|
mainStackView.alignment = .fill
|
|
|
|
view.addSubview(mainStackView)
|
|
|
|
mainStackView.pin(.leading, to: .leading, of: view)
|
|
|
|
view.pin(.trailing, to: .trailing, of: mainStackView)
|
|
|
|
mainStackView.set(.height, to: Values.fakeChatViewHeight)
|
2019-12-06 06:42:28 +01:00
|
|
|
let verticalCenteringConstraint = mainStackView.center(.vertical, in: view)
|
|
|
|
verticalCenteringConstraint.constant = -20
|
2019-12-06 04:42:43 +01:00
|
|
|
// Set up view
|
|
|
|
let screen = UIScreen.main.bounds
|
2019-12-06 06:42:28 +01:00
|
|
|
view.frame = screen
|
2019-12-06 04:42:43 +01:00
|
|
|
view.set(.width, to: screen.width)
|
|
|
|
view.set(.height, to: screen.height)
|
|
|
|
// Set up register button
|
|
|
|
let registerButton = Button(style: .prominentFilled, size: .large)
|
|
|
|
registerButton.setTitle(NSLocalizedString("Create Account", comment: ""), for: UIControl.State.normal)
|
|
|
|
registerButton.titleLabel!.font = .boldSystemFont(ofSize: Values.mediumFontSize)
|
2019-12-06 06:42:28 +01:00
|
|
|
registerButton.addTarget(self, action: #selector(register), for: UIControl.Event.touchUpInside)
|
2019-12-06 04:42:43 +01:00
|
|
|
// Set up restore button
|
|
|
|
let restoreButton = Button(style: .prominentOutline, size: .large)
|
|
|
|
restoreButton.setTitle(NSLocalizedString("Continue your Loki Messenger", comment: ""), for: UIControl.State.normal)
|
|
|
|
restoreButton.titleLabel!.font = .boldSystemFont(ofSize: Values.mediumFontSize)
|
|
|
|
// Set up button stack view
|
|
|
|
let buttonStackView = UIStackView(arrangedSubviews: [ registerButton, restoreButton ])
|
|
|
|
buttonStackView.axis = .vertical
|
|
|
|
buttonStackView.spacing = Values.mediumSpacing
|
|
|
|
buttonStackView.alignment = .fill
|
|
|
|
view.addSubview(buttonStackView)
|
|
|
|
buttonStackView.pin(.leading, to: .leading, of: view, withInset: Values.massiveSpacing)
|
|
|
|
view.pin(.trailing, to: .trailing, of: buttonStackView, withInset: Values.massiveSpacing)
|
2019-12-06 06:42:28 +01:00
|
|
|
view.pin(.bottom, to: .bottom, of: buttonStackView, withInset: Values.onboardingButtonBottomOffset)
|
|
|
|
}
|
|
|
|
|
|
|
|
// MARK: Interaction
|
|
|
|
@objc private func register() {
|
|
|
|
let publicKeyVC = PublicKeyVC()
|
|
|
|
navigationController!.pushViewController(publicKeyVC, animated: true)
|
2019-12-06 04:42:43 +01:00
|
|
|
}
|
|
|
|
}
|