Skip to content

Commit d0dc00b

Browse files
committed
Add activity indicator view
1 parent 205f29a commit d0dc00b

File tree

1 file changed

+29
-20
lines changed

1 file changed

+29
-20
lines changed

WooCommerce/Classes/ViewRelated/Dashboard/Settings/CardReadersV2/CardReaderSettingsConnectedViewController.swift

Lines changed: 29 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -92,13 +92,15 @@ private extension CardReaderSettingsConnectedViewController {
9292

9393
/// This section displays whether or not there is update for the reader software
9494
///
95-
sections.append(
96-
Section(title: nil,
97-
rows: [
98-
.updatePrompt
99-
]
100-
)
101-
)
95+
let checkForReaderUpdateInProgress = viewModel?.checkForReaderUpdateInProgress ?? false
96+
var rows = [Row]()
97+
if checkForReaderUpdateInProgress {
98+
rows = [.checkingForUpdate]
99+
} else {
100+
rows = [.updatePrompt]
101+
}
102+
103+
sections.append(Section(title: nil, rows: rows))
102104

103105
/// This section displays details about the connected reader
104106
///
@@ -165,6 +167,8 @@ private extension CardReaderSettingsConnectedViewController {
165167
///
166168
func configure(_ cell: UITableViewCell, for row: Row, at indexPath: IndexPath) {
167169
switch cell {
170+
case let cell as ActivitySpinnerAndLabelTableViewCell where row == .checkingForUpdate:
171+
configureCheckingForUpdate(cell: cell)
168172
case let cell as LeftImageTableViewCell where row == .updatePrompt:
169173
configureUpdatePrompt(cell: cell)
170174
case let cell as ConnectedReaderTableViewCell where row == .connectedReader:
@@ -178,24 +182,26 @@ private extension CardReaderSettingsConnectedViewController {
178182
}
179183
}
180184

185+
private func configureCheckingForUpdate(cell: ActivitySpinnerAndLabelTableViewCell) {
186+
cell.configure(labelText: Localization.updateChecking)
187+
cell.selectionStyle = .none
188+
}
189+
181190
private func configureUpdatePrompt(cell: LeftImageTableViewCell) {
182191
guard let readerUpdateAvailable = viewModel?.readerUpdateAvailable else {
183192
return
184193
}
185194

186-
switch readerUpdateAvailable {
187-
case .isUnknown:
188-
cell.configure(image: .infoOutlineImage, text: Localization.updateChecking)
189-
cell.backgroundColor = .none
190-
cell.imageView?.tintColor = .warning
191-
case .isFalse:
192-
cell.configure(image: .infoOutlineImage, text: Localization.updateNotNeeded)
193-
cell.backgroundColor = .none
194-
cell.imageView?.tintColor = .info
195-
case .isTrue:
196-
cell.configure(image: .infoOutlineImage, text: Localization.updateAvailable)
197-
cell.backgroundColor = .warningBackground
198-
cell.imageView?.tintColor = .warning
195+
if readerUpdateAvailable == .isFalse {
196+
cell.configure(image: .infoOutlineImage, text: Localization.updateNotNeeded)
197+
cell.backgroundColor = .none
198+
cell.imageView?.tintColor = .info
199+
}
200+
201+
if readerUpdateAvailable == .isTrue {
202+
cell.configure(image: .infoOutlineImage, text: Localization.updateAvailable)
203+
cell.backgroundColor = .warningBackground
204+
cell.imageView?.tintColor = .warning
199205
}
200206

201207
cell.selectionStyle = .none
@@ -327,13 +333,16 @@ private struct Section {
327333
}
328334

329335
private enum Row: CaseIterable {
336+
case checkingForUpdate
330337
case updatePrompt
331338
case connectedReader
332339
case updateButton
333340
case disconnectButton
334341

335342
var type: UITableViewCell.Type {
336343
switch self {
344+
case .checkingForUpdate:
345+
return ActivitySpinnerAndLabelTableViewCell.self
337346
case .updatePrompt:
338347
return LeftImageTableViewCell.self
339348
case .connectedReader:

0 commit comments

Comments
 (0)