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.
111 lines
Swift
111 lines
Swift
7 years ago
|
//
|
||
6 years ago
|
// Copyright (c) 2019 Open Whisper Systems. All rights reserved.
|
||
7 years ago
|
//
|
||
|
|
||
|
import UIKit
|
||
|
import PureLayout
|
||
|
|
||
|
class SAELoadViewController: UIViewController {
|
||
|
|
||
7 years ago
|
weak var delegate: ShareViewDelegate?
|
||
7 years ago
|
|
||
7 years ago
|
var activityIndicator: UIActivityIndicatorView!
|
||
|
var progressView: UIProgressView!
|
||
|
|
||
|
var progress: Progress? {
|
||
|
didSet {
|
||
|
guard progressView != nil else {
|
||
|
return
|
||
|
}
|
||
|
|
||
|
updateProgressViewVisability()
|
||
|
progressView.observedProgress = progress
|
||
|
}
|
||
|
}
|
||
|
|
||
|
func updateProgressViewVisability() {
|
||
|
guard progressView != nil, activityIndicator != nil else {
|
||
|
return
|
||
|
}
|
||
|
|
||
|
// Prefer to show progress view when progress is present
|
||
|
if self.progress == nil {
|
||
|
activityIndicator.startAnimating()
|
||
|
self.progressView.isHidden = true
|
||
|
self.activityIndicator.isHidden = false
|
||
|
} else {
|
||
|
activityIndicator.stopAnimating()
|
||
|
self.progressView.isHidden = false
|
||
|
self.activityIndicator.isHidden = true
|
||
|
}
|
||
|
}
|
||
7 years ago
|
|
||
|
// MARK: Initializers and Factory Methods
|
||
|
|
||
7 years ago
|
init(delegate: ShareViewDelegate) {
|
||
7 years ago
|
self.delegate = delegate
|
||
|
super.init(nibName: nil, bundle: nil)
|
||
|
}
|
||
|
|
||
7 years ago
|
@available(*, unavailable, message:"use other constructor instead.")
|
||
7 years ago
|
required init?(coder aDecoder: NSCoder) {
|
||
6 years ago
|
notImplemented()
|
||
7 years ago
|
}
|
||
|
|
||
|
override func loadView() {
|
||
|
super.loadView()
|
||
|
|
||
|
self.navigationItem.leftBarButtonItem = UIBarButtonItem(barButtonSystemItem: .cancel,
|
||
|
target: self,
|
||
|
action: #selector(cancelPressed))
|
||
5 years ago
|
self.navigationItem.title = "Session"
|
||
7 years ago
|
|
||
7 years ago
|
self.view.backgroundColor = UIColor.ows_signalBrandBlue
|
||
7 years ago
|
|
||
6 years ago
|
let activityIndicator = UIActivityIndicatorView(style: .whiteLarge)
|
||
7 years ago
|
self.activityIndicator = activityIndicator
|
||
|
self.view.addSubview(activityIndicator)
|
||
|
activityIndicator.autoCenterInSuperview()
|
||
|
|
||
7 years ago
|
progressView = UIProgressView(progressViewStyle: .default)
|
||
|
progressView.observedProgress = progress
|
||
|
|
||
|
self.view.addSubview(progressView)
|
||
|
progressView.autoVCenterInSuperview()
|
||
|
progressView.autoPinWidthToSuperview(withMargin: ScaleFromIPhone5(30))
|
||
|
progressView.progressTintColor = UIColor.white
|
||
|
|
||
|
updateProgressViewVisability()
|
||
|
|
||
7 years ago
|
let label = UILabel()
|
||
|
label.textColor = UIColor.white
|
||
|
label.font = UIFont.ows_mediumFont(withSize: 18)
|
||
|
label.text = NSLocalizedString("SHARE_EXTENSION_LOADING",
|
||
|
comment: "Indicates that the share extension is still loading.")
|
||
|
self.view.addSubview(label)
|
||
|
label.autoHCenterInSuperview()
|
||
|
label.autoPinEdge(.top, to: .bottom, of: activityIndicator, withOffset: 25)
|
||
|
}
|
||
|
|
||
|
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 {
|
||
6 years ago
|
owsFailDebug("missing delegate")
|
||
7 years ago
|
return
|
||
|
}
|
||
7 years ago
|
delegate.shareViewWasCancelled()
|
||
7 years ago
|
}
|
||
|
}
|