Skip to content
This repository has been archived by the owner on Jun 7, 2020. It is now read-only.

Commit

Permalink
Merge pull request #719 from RocketChat/chore/show_loader_connecting.713
Browse files Browse the repository at this point in the history
[NEW] Show activity indicator when connecting to the server in the status banner
  • Loading branch information
rafaelks authored Sep 25, 2017
2 parents f4400d2 + bc5131d commit 7779655
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
21 changes: 21 additions & 0 deletions Rocket.Chat/Controllers/Chat/ChatControllerHeaderStatus.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ extension ChatViewController {
chatHeaderViewStatus?.removeFromSuperview()

if let headerView = ChatHeaderViewStatus.instantiateFromNib() {
headerView.delegate = self
headerView.translatesAutoresizingMaskIntoConstraints = false
headerView.frame = CGRect(x: 0, y: 0, width: view.frame.width, height: 44)
view.addSubview(headerView)
Expand Down Expand Up @@ -47,3 +48,23 @@ extension ChatViewController {
}

}

// MARK: ChatHeaderViewStatusDelegate

extension ChatViewController: ChatHeaderViewStatusDelegate {

func viewStatusButtonRefreshDidPressed(_ view: ChatHeaderViewStatus) {
view.activityIndicator.startAnimating()
view.buttonRefresh.isHidden = true

SocketManager.reconnect()

DispatchQueue.main.asyncAfter(deadline: .now() + 5.0) {
if !SocketManager.isConnected() {
view.activityIndicator.stopAnimating()
view.buttonRefresh.isHidden = false
}
}
}

}
8 changes: 7 additions & 1 deletion Rocket.Chat/Views/Chat/ChatHeaderViewStatus.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,16 @@

import UIKit

protocol ChatHeaderViewStatusDelegate: class {
func viewStatusButtonRefreshDidPressed(_ view: ChatHeaderViewStatus)
}

final class ChatHeaderViewStatus: UIView {

static let defaultHeight = CGFloat(44)

weak var delegate: ChatHeaderViewStatusDelegate?

@IBOutlet weak var labelTitle: UILabel! {
didSet {
labelTitle.lineBreakMode = .byTruncatingMiddle
Expand All @@ -32,7 +38,7 @@ final class ChatHeaderViewStatus: UIView {
// MARK: IBAction

@IBAction func buttonRefreshDidPressed(_ sender: Any) {
SocketManager.reconnect()
delegate?.viewStatusButtonRefreshDidPressed(self)
}

}

0 comments on commit 7779655

Please # to comment.