mirror of https://github.com/oxen-io/session-ios
				
				
				
			
			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.
		
		
		
		
		
			
		
			
	
	
		
			97 lines
		
	
	
		
			3.3 KiB
		
	
	
	
		
			Swift
		
	
		
		
			
		
	
	
			97 lines
		
	
	
		
			3.3 KiB
		
	
	
	
		
			Swift
		
	
| 
								 
											8 years ago
										 
									 | 
							
								//
							 | 
						||
| 
								 
											7 years ago
										 
									 | 
							
								//  Copyright (c) 2018 Open Whisper Systems. All rights reserved.
							 | 
						||
| 
								 
											8 years ago
										 
									 | 
							
								//
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								import UIKit
							 | 
						||
| 
								 | 
							
								import PureLayout
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								// All Observer methods will be invoked from the main thread.
							 | 
						||
| 
								 | 
							
								protocol SAEFailedViewDelegate: class {
							 | 
						||
| 
								 
											8 years ago
										 
									 | 
							
								    func shareViewWasCancelled()
							 | 
						||
| 
								 
											8 years ago
										 
									 | 
							
								}
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								class SAEFailedViewController: UIViewController {
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								    weak var delegate: SAEFailedViewDelegate?
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								    let failureTitle: String
							 | 
						||
| 
								 | 
							
								    let failureMessage: String
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								    // MARK: Initializers and Factory Methods
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								    init(delegate: SAEFailedViewDelegate, title: String, message: String) {
							 | 
						||
| 
								 | 
							
								        self.delegate = delegate
							 | 
						||
| 
								 | 
							
								        self.failureTitle = title
							 | 
						||
| 
								 | 
							
								        self.failureMessage = message
							 | 
						||
| 
								 | 
							
								        super.init(nibName: nil, bundle: nil)
							 | 
						||
| 
								 | 
							
								    }
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 
											8 years ago
										 
									 | 
							
								    @available(*, unavailable, message:"use other constructor instead.")
							 | 
						||
| 
								 
											8 years ago
										 
									 | 
							
								    required init?(coder aDecoder: NSCoder) {
							 | 
						||
| 
								 
											7 years ago
										 
									 | 
							
								        notImplemented()
							 | 
						||
| 
								 
											8 years ago
										 
									 | 
							
								    }
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								    override func loadView() {
							 | 
						||
| 
								 | 
							
								        super.loadView()
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								        self.navigationItem.leftBarButtonItem = UIBarButtonItem(barButtonSystemItem: .cancel,
							 | 
						||
| 
								 | 
							
								                                                                target: self,
							 | 
						||
| 
								 | 
							
								                                                                action: #selector(cancelPressed))
							 | 
						||
| 
								 
											6 years ago
										 
									 | 
							
								        self.navigationItem.title = "Session"
							 | 
						||
| 
								 
											8 years ago
										 
									 | 
							
								
							 | 
						||
| 
								 
											8 years ago
										 
									 | 
							
								        self.view.backgroundColor = UIColor.ows_signalBrandBlue
							 | 
						||
| 
								 
											8 years ago
										 
									 | 
							
								
							 | 
						||
| 
								 | 
							
								        let logoImage = UIImage(named: "logoSignal")
							 | 
						||
| 
								 | 
							
								        let logoImageView = UIImageView(image: logoImage)
							 | 
						||
| 
								 | 
							
								        self.view.addSubview(logoImageView)
							 | 
						||
| 
								 | 
							
								        logoImageView.autoCenterInSuperview()
							 | 
						||
| 
								 | 
							
								        let logoSize = CGFloat(120)
							 | 
						||
| 
								 | 
							
								        logoImageView.autoSetDimension(.width, toSize: logoSize)
							 | 
						||
| 
								 | 
							
								        logoImageView.autoSetDimension(.height, toSize: logoSize)
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								        let titleLabel = UILabel()
							 | 
						||
| 
								 | 
							
								        titleLabel.textColor = UIColor.white
							 | 
						||
| 
								 | 
							
								        titleLabel.font = UIFont.ows_mediumFont(withSize: 18)
							 | 
						||
| 
								 | 
							
								        titleLabel.text = failureTitle
							 | 
						||
| 
								 | 
							
								        titleLabel.textAlignment = .center
							 | 
						||
| 
								 | 
							
								        titleLabel.numberOfLines = 0
							 | 
						||
| 
								 | 
							
								        titleLabel.lineBreakMode = .byWordWrapping
							 | 
						||
| 
								 | 
							
								        self.view.addSubview(titleLabel)
							 | 
						||
| 
								 | 
							
								        titleLabel.autoPinEdge(toSuperviewEdge: .leading, withInset: 20)
							 | 
						||
| 
								 | 
							
								        titleLabel.autoPinEdge(toSuperviewEdge: .trailing, withInset: 20)
							 | 
						||
| 
								 | 
							
								        titleLabel.autoPinEdge(.top, to: .bottom, of: logoImageView, withOffset: 25)
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								        let messageLabel = UILabel()
							 | 
						||
| 
								 | 
							
								        messageLabel.textColor = UIColor.white
							 | 
						||
| 
								 | 
							
								        messageLabel.font = UIFont.ows_regularFont(withSize: 14)
							 | 
						||
| 
								 | 
							
								        messageLabel.text = failureMessage
							 | 
						||
| 
								 | 
							
								        messageLabel.textAlignment = .center
							 | 
						||
| 
								 | 
							
								        messageLabel.numberOfLines = 0
							 | 
						||
| 
								 | 
							
								        messageLabel.lineBreakMode = .byWordWrapping
							 | 
						||
| 
								 | 
							
								        self.view.addSubview(messageLabel)
							 | 
						||
| 
								 | 
							
								        messageLabel.autoPinEdge(toSuperviewEdge: .leading, withInset: 20)
							 | 
						||
| 
								 | 
							
								        messageLabel.autoPinEdge(toSuperviewEdge: .trailing, withInset: 20)
							 | 
						||
| 
								 | 
							
								        messageLabel.autoPinEdge(.top, to: .bottom, of: titleLabel, withOffset: 10)
							 | 
						||
| 
								 | 
							
								    }
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								    override func viewWillAppear(_ animated: Bool) {
							 | 
						||
| 
								 | 
							
								        super.viewWillAppear(animated)
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								        self.navigationController?.isNavigationBarHidden = false
							 | 
						||
| 
								 | 
							
								    }
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								    override func viewDidDisappear(_ animated: Bool) {
							 | 
						||
| 
								 | 
							
								        super.viewDidDisappear(animated)
							 | 
						||
| 
								 | 
							
								    }
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								    // MARK: - Event Handlers
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								    @objc func cancelPressed(sender: UIButton) {
							 | 
						||
| 
								 | 
							
								        guard let delegate = delegate else {
							 | 
						||
| 
								 
											7 years ago
										 
									 | 
							
								            owsFailDebug("missing delegate")
							 | 
						||
| 
								 
											8 years ago
										 
									 | 
							
								            return
							 | 
						||
| 
								 | 
							
								        }
							 | 
						||
| 
								 
											8 years ago
										 
									 | 
							
								        delegate.shareViewWasCancelled()
							 | 
						||
| 
								 
											8 years ago
										 
									 | 
							
								    }
							 | 
						||
| 
								 | 
							
								}
							 |