@@ -94,14 +94,30 @@ final class IssueTextActionsView: UIView, UICollectionViewDataSource, UICollecti
94
94
private let gradientWidth = Styles . Sizes. gutter
95
95
private let sendButtonGradientLayer = CAGradientLayer ( )
96
96
private let sendButton = UIButton ( )
97
-
97
+ private let activityIndicator = UIActivityIndicatorView (
98
+ activityIndicatorStyle: UIActivityIndicatorViewStyle . gray
99
+ )
100
+
98
101
public var sendButtonEnabled : Bool {
99
102
get { return sendButton. isEnabled }
100
103
set {
101
104
sendButton. isEnabled = newValue
102
105
sendButton. alpha = newValue ? 1 : 0.25
103
106
}
104
107
}
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
+ }
105
121
106
122
init ( operations: [ IssueTextActionOperation ] , showSendButton: Bool ) {
107
123
self . operations = operations
@@ -130,6 +146,9 @@ final class IssueTextActionsView: UIView, UICollectionViewDataSource, UICollecti
130
146
sendButton. setImage ( UIImage ( named: " send " ) ? . withRenderingMode ( . alwaysTemplate) , for: . normal)
131
147
sendButton. addTarget ( self , action: #selector( onSend) , for: . touchUpInside)
132
148
addSubview ( sendButton)
149
+
150
+ activityIndicator. hidesWhenStopped = true
151
+ addSubview ( activityIndicator)
133
152
}
134
153
}
135
154
@@ -155,6 +174,7 @@ final class IssueTextActionsView: UIView, UICollectionViewDataSource, UICollecti
155
174
width: gradientWidth,
156
175
height: height
157
176
)
177
+ activityIndicator. center = sendButton. center
158
178
// put collection view beneath the gradient layer
159
179
collectionView. frame = CGRect ( x: 0 , y: 0 , width: sendButton. frame. minX, height: height)
160
180
} else {
@@ -163,6 +183,7 @@ final class IssueTextActionsView: UIView, UICollectionViewDataSource, UICollecti
163
183
}
164
184
165
185
@objc private func onSend( ) {
186
+ isProcessing = true
166
187
sendDelegate? . didSend ( for: self )
167
188
}
168
189
0 commit comments