Skip to content

Commit 572107e

Browse files
authored
Merge pull request #5469 from woocommerce/issue/4294-tags-loading-indicator
Continuous Improvements: Tags loading indicator
2 parents 2c092c8 + 2a997bb commit 572107e

File tree

5 files changed

+50
-35
lines changed

5 files changed

+50
-35
lines changed

WooCommerce/Classes/ViewRelated/Dashboard/Settings/Plugins/PluginListViewController.xib

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="17701" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
2+
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="19455" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
33
<device id="retina6_1" orientation="portrait" appearance="light"/>
44
<dependencies>
55
<deployment identifier="iOS"/>
6-
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="17703"/>
6+
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="19454"/>
77
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
88
<capability name="System colors in document resources" minToolsVersion="11.0"/>
99
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>

WooCommerce/Classes/ViewRelated/Products/Edit Product/Edit Categories/Add Category/AddProductCategoryViewController.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,10 @@ private extension AddProductCategoryViewController {
6868
title = Strings.titleView
6969

7070
addCloseNavigationBarButton(title: Strings.cancelButton)
71-
configureRightBarButtomitemAsSave()
71+
configureRightBarButtonItemAsSave()
7272
}
7373

74-
func configureRightBarButtomitemAsSave() {
74+
func configureRightBarButtonItemAsSave() {
7575
navigationItem.setRightBarButton(UIBarButtonItem(title: Strings.saveButton,
7676
style: .done,
7777
target: self,
@@ -129,7 +129,7 @@ extension AddProductCategoryViewController {
129129
let action = ProductCategoryAction.addProductCategory(siteID: siteID,
130130
name: categoryName,
131131
parentID: selectedParentCategory?.categoryID) { [weak self] (result) in
132-
self?.configureRightBarButtomitemAsSave()
132+
self?.configureRightBarButtonItemAsSave()
133133
switch result {
134134
case .success(let category):
135135
self?.onCompletion(category)

WooCommerce/Classes/ViewRelated/Products/Edit Product/Edit Tags/ProductTagsDataSource.swift

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -6,27 +6,6 @@ import UIKit
66
protocol ProductTagsDataSource: UITableViewDataSource {
77
}
88

9-
final class LoadingDataSource: NSObject, ProductTagsDataSource {
10-
11-
private static let cellIdentifier = BasicTableViewCell.reuseIdentifier
12-
13-
func numberOfSections(in tableView: UITableView) -> Int {
14-
return 1
15-
}
16-
17-
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
18-
return 1
19-
}
20-
21-
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
22-
let cell = tableView.dequeueReusableCell(withIdentifier: LoadingDataSource.cellIdentifier, for: indexPath)
23-
24-
cell.textLabel?.text = NSLocalizedString("Loading...", comment: "Loading tags in Product Tags screen")
25-
cell.selectionStyle = .none
26-
return cell
27-
}
28-
}
29-
309
final class FailureDataSource: NSObject, ProductTagsDataSource {
3110

3211
private static let cellIdentifier = BasicTableViewCell.reuseIdentifier

WooCommerce/Classes/ViewRelated/Products/Edit Product/Edit Tags/ProductTagsViewController.swift

Lines changed: 33 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
import UIKit
22
import Yosemite
3-
3+
import WordPressUI
44

55
/// ProductTagsViewController: Displays the list of ProductTag associated to the active Site and to the specific product.
66
///
77
final class ProductTagsViewController: UIViewController {
88

99
@IBOutlet private weak var tableView: UITableView!
10+
@IBOutlet private weak var ghostTableView: UITableView!
1011
@IBOutlet private weak var textView: UITextView!
1112
@IBOutlet private var separatorView: UIView!
1213

@@ -19,7 +20,7 @@ final class ProductTagsViewController: UIViewController {
1920
return resultController.fetchedObjects
2021
}
2122

22-
private var dataSource: ProductTagsDataSource = LoadingDataSource() {
23+
private var dataSource: ProductTagsDataSource? = nil {
2324
didSet {
2425
tableView.dataSource = dataSource
2526
tableView.reloadData()
@@ -63,7 +64,9 @@ final class ProductTagsViewController: UIViewController {
6364
configureMainView()
6465
configureTextView()
6566
configureSeparator()
67+
registerTableViewCells()
6668
configureTableView()
69+
configureGhostTableView()
6770
startListeningToNotifications()
6871

6972
textView.text = normalizeInitialTags(tags: originalTagNames)
@@ -141,18 +144,26 @@ private extension ProductTagsViewController {
141144
}
142145

143146
func configureTableView() {
144-
registerTableViewCells()
145147
// The datasource will be dynamically assigned on variable `dataSource`
146148
tableView.delegate = self
147149

148150
tableView.backgroundColor = .listBackground
149151
tableView.removeLastCellSeparator()
150152
}
151153

154+
func configureGhostTableView() {
155+
ghostTableView.translatesAutoresizingMaskIntoConstraints = false
156+
ghostTableView.backgroundColor = .listBackground
157+
ghostTableView.isScrollEnabled = false
158+
ghostTableView.isHidden = true
159+
ghostTableView.removeLastCellSeparator()
160+
}
161+
152162
/// Registers all of the available TableViewCells
153163
///
154164
func registerTableViewCells() {
155165
tableView.registerNib(for: BasicTableViewCell.self)
166+
ghostTableView.registerNib(for: WooBasicTableViewCell.self)
156167
}
157168
}
158169

@@ -203,7 +214,7 @@ extension ProductTagsViewController: KeyboardScrollable {
203214
//
204215
private extension ProductTagsViewController {
205216
func loadTags() {
206-
dataSource = LoadingDataSource()
217+
displayLoading()
207218

208219
let action = ProductTagAction.synchronizeAllProductTags(siteID: product.siteID) { [weak self] error in
209220
if let error = error {
@@ -222,6 +233,7 @@ private extension ProductTagsViewController {
222233
}
223234

224235
func tagsLoaded(tags: [String]) {
236+
hideLoading()
225237
dataSource = SuggestionsDataSource(suggestions: tags,
226238
selectedTags: completeTags,
227239
searchQuery: partialTag)
@@ -253,6 +265,23 @@ private extension ProductTagsViewController {
253265

254266
}
255267

268+
// MARK: Loading handling
269+
//
270+
private extension ProductTagsViewController {
271+
func displayLoading() {
272+
let options = GhostOptions(displaysSectionHeader: false,
273+
reuseIdentifier: WooBasicTableViewCell.reuseIdentifier,
274+
rowsPerSection: [3])
275+
ghostTableView.displayGhostContent(options: options, style: .wooDefaultGhostStyle)
276+
ghostTableView.isHidden = false
277+
}
278+
279+
func hideLoading() {
280+
ghostTableView.removeGhostContent()
281+
ghostTableView.isHidden = true
282+
}
283+
}
284+
256285
// MARK: Error handling
257286
//
258287
private extension ProductTagsViewController {
@@ -421,8 +450,6 @@ extension ProductTagsViewController: UITableViewDelegate {
421450
switch tableView.dataSource {
422451
case is FailureDataSource:
423452
loadTags()
424-
case is LoadingDataSource:
425-
return
426453
case is SuggestionsDataSource:
427454
suggestionTapped(cell: tableView.cellForRow(at: indexPath))
428455
default:

WooCommerce/Classes/ViewRelated/Products/Edit Product/Edit Tags/ProductTagsViewController.xib

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="17701" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
2+
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="19455" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
33
<device id="retina6_1" orientation="portrait" appearance="light"/>
44
<dependencies>
55
<deployment identifier="iOS"/>
6-
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="17703"/>
6+
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="19454"/>
77
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
88
<capability name="System colors in document resources" minToolsVersion="11.0"/>
99
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
1010
</dependencies>
1111
<objects>
1212
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner" customClass="ProductTagsViewController" customModule="WooCommerce" customModuleProvider="target">
1313
<connections>
14+
<outlet property="ghostTableView" destination="iGf-7j-RA7" id="8bf-Qd-2gU"/>
1415
<outlet property="separatorView" destination="Yju-A0-WgT" id="Xfk-TL-To5"/>
1516
<outlet property="tableView" destination="zVJ-8z-2vs" id="KHA-P7-8J7"/>
1617
<outlet property="textView" destination="6Wz-Zl-b7p" id="3gD-hq-Ybw"/>
@@ -58,19 +59,27 @@
5859
<tableView clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" style="plain" separatorStyle="default" rowHeight="-1" estimatedRowHeight="-1" sectionHeaderHeight="28" sectionFooterHeight="28" translatesAutoresizingMaskIntoConstraints="NO" id="zVJ-8z-2vs">
5960
<rect key="frame" x="0.0" y="113" width="414" height="749"/>
6061
</tableView>
62+
<tableView clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" style="plain" separatorStyle="default" rowHeight="-1" estimatedRowHeight="-1" sectionHeaderHeight="28" estimatedSectionHeaderHeight="-1" sectionFooterHeight="28" estimatedSectionFooterHeight="-1" translatesAutoresizingMaskIntoConstraints="NO" id="iGf-7j-RA7" userLabel="Ghost Table View">
63+
<rect key="frame" x="0.0" y="113" width="414" height="783"/>
64+
<color key="backgroundColor" systemColor="systemBackgroundColor"/>
65+
</tableView>
6166
</subviews>
6267
<viewLayoutGuide key="safeArea" id="fnl-2z-Ty3"/>
6368
<color key="backgroundColor" systemColor="systemBackgroundColor"/>
6469
<constraints>
6570
<constraint firstItem="zVJ-8z-2vs" firstAttribute="top" secondItem="Ip2-5h-wvk" secondAttribute="bottom" id="51P-yI-3FR"/>
6671
<constraint firstAttribute="trailing" secondItem="Ip2-5h-wvk" secondAttribute="trailing" id="5AZ-8i-UZP"/>
72+
<constraint firstItem="iGf-7j-RA7" firstAttribute="trailing" secondItem="i5M-Pr-FkT" secondAttribute="trailing" id="9at-iB-L88"/>
73+
<constraint firstItem="iGf-7j-RA7" firstAttribute="leading" secondItem="i5M-Pr-FkT" secondAttribute="leading" id="A0R-gI-Qdc"/>
6774
<constraint firstItem="zVJ-8z-2vs" firstAttribute="trailing" secondItem="i5M-Pr-FkT" secondAttribute="trailing" id="Chb-li-7pc"/>
6875
<constraint firstItem="zVJ-8z-2vs" firstAttribute="bottom" secondItem="fnl-2z-Ty3" secondAttribute="bottom" id="ECp-36-O08"/>
76+
<constraint firstItem="iGf-7j-RA7" firstAttribute="bottom" secondItem="i5M-Pr-FkT" secondAttribute="bottom" id="Q1i-f0-IsN"/>
6977
<constraint firstItem="Ip2-5h-wvk" firstAttribute="top" secondItem="fnl-2z-Ty3" secondAttribute="top" constant="24" id="REa-GU-ALk"/>
78+
<constraint firstItem="iGf-7j-RA7" firstAttribute="top" secondItem="Ip2-5h-wvk" secondAttribute="bottom" id="RF7-tb-0sL"/>
7079
<constraint firstItem="zVJ-8z-2vs" firstAttribute="leading" secondItem="i5M-Pr-FkT" secondAttribute="leading" id="eeY-QK-my7"/>
7180
<constraint firstItem="Ip2-5h-wvk" firstAttribute="leading" secondItem="i5M-Pr-FkT" secondAttribute="leading" id="oUV-Mg-GkZ"/>
7281
</constraints>
73-
<point key="canvasLocation" x="131.8840579710145" y="135.9375"/>
82+
<point key="canvasLocation" x="128.98550724637681" y="98.4375"/>
7483
</view>
7584
</objects>
7685
<resources>

0 commit comments

Comments
 (0)