Skip to content
This repository was archived by the owner on Sep 20, 2023. It is now read-only.

Commit facd09d

Browse files
Huddiernystrom
authored andcommitted
Added activity indicator (#2157)
1 parent 9191380 commit facd09d

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

Classes/Issues/IssueTextActionsView.swift

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,14 +94,30 @@ final class IssueTextActionsView: UIView, UICollectionViewDataSource, UICollecti
9494
private let gradientWidth = Styles.Sizes.gutter
9595
private let sendButtonGradientLayer = CAGradientLayer()
9696
private let sendButton = UIButton()
97-
97+
private let activityIndicator = UIActivityIndicatorView(
98+
activityIndicatorStyle: UIActivityIndicatorViewStyle.gray
99+
)
100+
98101
public var sendButtonEnabled: Bool {
99102
get { return sendButton.isEnabled }
100103
set {
101104
sendButton.isEnabled = newValue
102105
sendButton.alpha = newValue ? 1 : 0.25
103106
}
104107
}
108+
109+
public var isProcessing: Bool = false {
110+
didSet {
111+
sendButton.isEnabled = !isProcessing
112+
if isProcessing {
113+
activityIndicator.startAnimating()
114+
sendButton.isHidden = true
115+
} else {
116+
activityIndicator.stopAnimating()
117+
sendButton.isHidden = false
118+
}
119+
}
120+
}
105121

106122
init(operations: [IssueTextActionOperation], showSendButton: Bool) {
107123
self.operations = operations
@@ -130,6 +146,9 @@ final class IssueTextActionsView: UIView, UICollectionViewDataSource, UICollecti
130146
sendButton.setImage(UIImage(named: "send")?.withRenderingMode(.alwaysTemplate), for: .normal)
131147
sendButton.addTarget(self, action: #selector(onSend), for: .touchUpInside)
132148
addSubview(sendButton)
149+
150+
activityIndicator.hidesWhenStopped = true
151+
addSubview(activityIndicator)
133152
}
134153
}
135154

@@ -155,6 +174,7 @@ final class IssueTextActionsView: UIView, UICollectionViewDataSource, UICollecti
155174
width: gradientWidth,
156175
height: height
157176
)
177+
activityIndicator.center = sendButton.center
158178
// put collection view beneath the gradient layer
159179
collectionView.frame = CGRect(x: 0, y: 0, width: sendButton.frame.minX, height: height)
160180
} else {
@@ -163,6 +183,7 @@ final class IssueTextActionsView: UIView, UICollectionViewDataSource, UICollecti
163183
}
164184

165185
@objc private func onSend() {
186+
isProcessing = true
166187
sendDelegate?.didSend(for: self)
167188
}
168189

Classes/Issues/IssuesViewController.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -521,6 +521,7 @@ final class IssuesViewController:
521521
viewerCanUpdate: Bool,
522522
viewerCanDelete: Bool
523523
) {
524+
self.actions?.isProcessing = false
524525
guard let previous = result,
525526
let comment = createCommentModel(
526527
id: id,
@@ -546,6 +547,7 @@ final class IssuesViewController:
546547
}
547548

548549
func didFailSendingComment(client: AddCommentClient, subjectId: String, body: String) {
550+
self.actions?.isProcessing = false
549551
messageView.text = body
550552
}
551553

0 commit comments

Comments
 (0)