Skip to content

Commit 5e24072

Browse files
committed
StorePickerViewController: Multiple Updates
1 parent 587bca9 commit 5e24072

File tree

2 files changed

+44
-8
lines changed

2 files changed

+44
-8
lines changed

WooCommerce/Classes/Authentication/Epilogue/AccountHeaderView.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import Foundation
22
import UIKit
33

44

5+
56
/// AccountHeaderView: Displays an Account's Details: [Gravatar + Name + Username]
67
///
78
class AccountHeaderView: UIView {

WooCommerce/Classes/Authentication/Epilogue/StorePickerViewController.swift

Lines changed: 43 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class StorePickerViewController: UIViewController {
2424
/// Header View: Displays all of the Account Details
2525
///
2626
private let accountHeaderView: AccountHeaderView = {
27-
return AccountHeaderView.loadFromNib()
27+
return AccountHeaderView.instantiateFromNib()
2828
}()
2929

3030
/// Main tableView
@@ -40,7 +40,7 @@ class StorePickerViewController: UIViewController {
4040
@IBOutlet private var actionBackgroundView: UIView! {
4141
didSet {
4242
actionBackgroundView.layer.masksToBounds = false
43-
actionBackgroundView.layer.shadowOpacity = Constants.backgroundShadowOpacity
43+
actionBackgroundView.layer.shadowOpacity = StorePickerConstants.backgroundShadowOpacity
4444
}
4545
}
4646

@@ -64,7 +64,8 @@ class StorePickerViewController: UIViewController {
6464
super.viewDidLoad()
6565

6666
setup(mainView: view)
67-
setup(headerView: accountHeaderView)
67+
registerTableViewCells()
68+
displayAccountDetails(in: accountHeaderView)
6869
}
6970

7071
override func viewWillAppear(_ animated: Bool) {
@@ -87,7 +88,17 @@ private extension StorePickerViewController {
8788
mainView.backgroundColor = StyleManager.tableViewBackgroundColor
8889
}
8990

90-
func setup(headerView: AccountHeaderView) {
91+
func registerTableViewCells() {
92+
let cells = [
93+
EmptyStoresTableViewCell.reuseIdentifier: EmptyStoresTableViewCell.loadNib()
94+
]
95+
96+
for (reuseIdentifier, nib) in cells {
97+
tableView.register(nib, forCellReuseIdentifier: reuseIdentifier)
98+
}
99+
}
100+
101+
func displayAccountDetails(in headerView: AccountHeaderView) {
91102
guard let defaultAccount = StoresManager.shared.sessionManager.defaultAccount else {
92103
return
93104
}
@@ -111,11 +122,35 @@ extension StorePickerViewController {
111122
}
112123

113124

114-
// MARK: - Nested Types
125+
// MARK: - Action Handlers
115126
//
116-
extension StorePickerViewController {
127+
extension StorePickerViewController: UITableViewDataSource {
128+
129+
func numberOfSections(in tableView: UITableView) -> Int {
130+
return 1
131+
}
132+
133+
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
134+
return 1
135+
}
117136

118-
struct Constants {
119-
static let backgroundShadowOpacity = Float(0.2)
137+
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
138+
return tableView.dequeueReusableCell(withIdentifier: EmptyStoresTableViewCell.reuseIdentifier, for: indexPath)
120139
}
121140
}
141+
142+
143+
// MARK: - StorePickerConstants: Contains all of the constants required by the Picker.
144+
//
145+
private enum StorePickerConstants {
146+
static let backgroundShadowOpacity = Float(0.2)
147+
}
148+
149+
150+
// MARK: - Represents the StorePickerViewController's Internal State.
151+
//
152+
private enum StorePickerState {
153+
case empty
154+
case single
155+
case multiple
156+
}

0 commit comments

Comments
 (0)