Skip to content

Commit 2ec2444

Browse files
committed
StorePickerViewController: Wiring AccountHeaderView
1 parent 52bbc4c commit 2ec2444

File tree

2 files changed

+56
-88
lines changed

2 files changed

+56
-88
lines changed

WooCommerce/Classes/Authentication/Epilogue/StorePickerViewController.swift

Lines changed: 27 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -8,53 +8,47 @@ import WordPressUI
88
///
99
class StorePickerViewController: UIViewController {
1010

11-
/// White-Background View, to be placed surrounding the bottom area.
11+
/// No Results Placeholder Image
1212
///
13-
@IBOutlet private var buttonBackgroundView: UIView! {
14-
didSet {
15-
buttonBackgroundView.layer.masksToBounds = false
16-
buttonBackgroundView.layer.shadowOpacity = Constants.backgroundShadowOpacity
17-
}
18-
}
13+
@IBOutlet private var noResultsImageView: UIImageView!
1914

20-
/// Account's Gravatar.
15+
/// No Results Placeholder Text
2116
///
22-
@IBOutlet private var gravatarImageView: UIImageView! {
17+
@IBOutlet private var noResultsLabel: UILabel! {
2318
didSet {
24-
gravatarImageView.image = .gravatarPlaceholderImage
19+
noResultsLabel.font = UIFont.font(forStyle: .subheadline, weight: .regular)
20+
noResultsLabel.textColor = StyleManager.wooGreyTextMin
2521
}
2622
}
2723

28-
/// Account's Full Name.
24+
/// Header View: Displays all of the Account Details
2925
///
30-
@IBOutlet private var fullnameLabel: UILabel!
26+
private let accountHeaderView: AccountHeaderView = {
27+
return AccountHeaderView.loadFromNib()
28+
}()
3129

32-
/// Account's Username.
30+
/// Main tableView
3331
///
34-
@IBOutlet private var usernameLabel: UILabel! {
32+
@IBOutlet private var tableView: UITableView! {
3533
didSet {
36-
usernameLabel.textColor = StyleManager.wooGreyTextMin
34+
tableView.tableHeaderView = accountHeaderView
3735
}
3836
}
3937

40-
/// No Results Placeholder Image
41-
///
42-
@IBOutlet private var noResultsImageView: UIImageView!
43-
44-
/// No Results Placeholder Text
38+
/// White-Background View, to be placed surrounding the bottom area.
4539
///
46-
@IBOutlet private var noResultsLabel: UILabel! {
40+
@IBOutlet private var actionBackgroundView: UIView! {
4741
didSet {
48-
noResultsLabel.font = UIFont.font(forStyle: .subheadline, weight: .regular)
49-
noResultsLabel.textColor = StyleManager.wooGreyTextMin
42+
actionBackgroundView.layer.masksToBounds = false
43+
actionBackgroundView.layer.shadowOpacity = Constants.backgroundShadowOpacity
5044
}
5145
}
5246

5347
/// Default Action Button.
5448
///
55-
@IBOutlet private var continueButton: UIButton! {
49+
@IBOutlet private var actionButton: UIButton! {
5650
didSet {
57-
continueButton.backgroundColor = .clear
51+
actionButton.backgroundColor = .clear
5852
}
5953
}
6054

@@ -69,9 +63,8 @@ class StorePickerViewController: UIViewController {
6963
override func viewDidLoad() {
7064
super.viewDidLoad()
7165

72-
setupMainView()
73-
setupAccountDetails()
74-
downloadGravatarImage()
66+
setup(mainView: view)
67+
setup(headerView: accountHeaderView)
7568
}
7669

7770
override func viewWillAppear(_ animated: Bool) {
@@ -90,25 +83,18 @@ class StorePickerViewController: UIViewController {
9083
//
9184
private extension StorePickerViewController {
9285

93-
func setupMainView() {
94-
view.backgroundColor = StyleManager.tableViewBackgroundColor
95-
}
96-
97-
func downloadGravatarImage() {
98-
guard let targetURL = StoresManager.shared.sessionManager.defaultAccount?.gravatarUrl, let gravatarURL = URL(string: targetURL) else {
99-
return
100-
}
101-
102-
gravatarImageView.downloadImage(from: gravatarURL, placeholderImage: .gravatarPlaceholderImage)
86+
func setup(mainView: UIView) {
87+
mainView.backgroundColor = StyleManager.tableViewBackgroundColor
10388
}
10489

105-
func setupAccountDetails() {
90+
func setup(headerView: AccountHeaderView) {
10691
guard let defaultAccount = StoresManager.shared.sessionManager.defaultAccount else {
10792
return
10893
}
10994

110-
fullnameLabel.text = defaultAccount.displayName
111-
usernameLabel.text = "@" + defaultAccount.username
95+
headerView.username = "@" + defaultAccount.username
96+
headerView.fullname = defaultAccount.displayName
97+
headerView.downloadGravatar(with: defaultAccount.email)
11298
}
11399
}
114100

WooCommerce/Classes/Authentication/Epilogue/StorePickerViewController.xib

Lines changed: 29 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,11 @@
1212
<objects>
1313
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner" customClass="StorePickerViewController" customModule="WooCommerce" customModuleProvider="target">
1414
<connections>
15-
<outlet property="buttonBackgroundView" destination="H5J-Qa-DXp" id="AbM-SK-Wdu"/>
16-
<outlet property="continueButton" destination="0KD-hY-YaS" id="k8d-re-dNi"/>
17-
<outlet property="fullnameLabel" destination="8YX-3n-gWf" id="3nf-1k-mDc"/>
18-
<outlet property="gravatarImageView" destination="Whj-W0-IDm" id="XmU-mA-kJE"/>
15+
<outlet property="actionBackgroundView" destination="H5J-Qa-DXp" id="aj6-RY-z7g"/>
16+
<outlet property="actionButton" destination="0KD-hY-YaS" id="mJR-Pi-S0z"/>
1917
<outlet property="noResultsImageView" destination="Bm8-4s-4Cg" id="5TG-sO-2h6"/>
2018
<outlet property="noResultsLabel" destination="1qT-mX-0SF" id="L6b-My-936"/>
21-
<outlet property="usernameLabel" destination="Xml-DM-3k0" id="XLT-g0-U2L"/>
19+
<outlet property="tableView" destination="oVs-XS-592" id="tgt-K5-nCu"/>
2220
<outlet property="view" destination="jLk-oK-hVZ" id="tZZ-hi-Qto"/>
2321
</connections>
2422
</placeholder>
@@ -27,10 +25,29 @@
2725
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
2826
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
2927
<subviews>
30-
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="H5J-Qa-DXp" userLabel="Button Background View">
28+
<imageView hidden="YES" userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="woo-no-store" translatesAutoresizingMaskIntoConstraints="NO" id="Bm8-4s-4Cg">
29+
<rect key="frame" x="0.0" y="195" width="375" height="187.5"/>
30+
<constraints>
31+
<constraint firstAttribute="width" secondItem="Bm8-4s-4Cg" secondAttribute="height" multiplier="2:1" id="0tK-4I-r0m"/>
32+
</constraints>
33+
</imageView>
34+
<label hidden="YES" opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Unable to find WooCommerce stores connected to this account" textAlignment="center" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="1qT-mX-0SF">
35+
<rect key="frame" x="10" y="404.5" width="355" height="41"/>
36+
<fontDescription key="fontDescription" type="system" pointSize="17"/>
37+
<nil key="textColor"/>
38+
<nil key="highlightedColor"/>
39+
</label>
40+
<tableView clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" contentInsetAdjustmentBehavior="never" style="grouped" separatorStyle="default" rowHeight="-1" estimatedRowHeight="-1" sectionHeaderHeight="18" sectionFooterHeight="18" translatesAutoresizingMaskIntoConstraints="NO" id="oVs-XS-592" userLabel="Sites Table View">
41+
<rect key="frame" x="0.0" y="20" width="375" height="557"/>
42+
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
43+
<connections>
44+
<outlet property="dataSource" destination="-1" id="m9y-Av-zfJ"/>
45+
</connections>
46+
</tableView>
47+
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="H5J-Qa-DXp" userLabel="Action Background View">
3148
<rect key="frame" x="0.0" y="577" width="375" height="90"/>
3249
<subviews>
33-
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="0KD-hY-YaS" customClass="FancyButton" customModule="WordPressUI">
50+
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="0KD-hY-YaS" userLabel="Action Button" customClass="FancyButton" customModule="WordPressUI">
3451
<rect key="frame" x="20" y="20" width="335" height="50"/>
3552
<color key="backgroundColor" red="0.58823529409999997" green="0.34509803919999998" blue="0.54117647059999996" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
3653
<constraints>
@@ -53,56 +70,21 @@
5370
<constraint firstAttribute="bottom" secondItem="0KD-hY-YaS" secondAttribute="bottom" constant="20" id="OdM-Ig-UUD"/>
5471
</constraints>
5572
</view>
56-
<imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="Whj-W0-IDm" customClass="CircularImageView" customModule="WooCommerce" customModuleProvider="target">
57-
<rect key="frame" x="157" y="50" width="60" height="60"/>
58-
<constraints>
59-
<constraint firstAttribute="height" constant="60" id="lDx-hp-adw"/>
60-
<constraint firstAttribute="width" constant="60" id="y8j-p5-W7W"/>
61-
</constraints>
62-
</imageView>
63-
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Full Name" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontForContentSizeCategory="YES" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="8YX-3n-gWf">
64-
<rect key="frame" x="20" y="118" width="335" height="21"/>
65-
<fontDescription key="fontDescription" style="UICTFontTextStyleHeadline"/>
66-
<nil key="textColor"/>
67-
<nil key="highlightedColor"/>
68-
</label>
69-
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="@username" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Xml-DM-3k0">
70-
<rect key="frame" x="20" y="147" width="335" height="18"/>
71-
<fontDescription key="fontDescription" style="UICTFontTextStyleSubhead"/>
72-
<color key="textColor" cocoaTouchSystemColor="scrollViewTexturedBackgroundColor"/>
73-
<nil key="highlightedColor"/>
74-
</label>
75-
<imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="woo-no-store" translatesAutoresizingMaskIntoConstraints="NO" id="Bm8-4s-4Cg">
76-
<rect key="frame" x="0.0" y="195" width="375" height="187.5"/>
77-
<constraints>
78-
<constraint firstAttribute="width" secondItem="Bm8-4s-4Cg" secondAttribute="height" multiplier="2:1" id="0tK-4I-r0m"/>
79-
</constraints>
80-
</imageView>
81-
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Unable to find WooCommerce stores connected to this account" textAlignment="center" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="1qT-mX-0SF">
82-
<rect key="frame" x="10" y="404.5" width="355" height="41"/>
83-
<fontDescription key="fontDescription" type="system" pointSize="17"/>
84-
<nil key="textColor"/>
85-
<nil key="highlightedColor"/>
86-
</label>
8773
</subviews>
8874
<color key="backgroundColor" red="0.96862745098039216" green="0.96862745098039216" blue="0.96862745098039216" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
8975
<constraints>
9076
<constraint firstAttribute="trailing" secondItem="1qT-mX-0SF" secondAttribute="trailing" constant="10" id="28r-Y1-luC"/>
91-
<constraint firstItem="Bm8-4s-4Cg" firstAttribute="top" secondItem="Xml-DM-3k0" secondAttribute="bottom" constant="30" id="6rj-YX-w5y"/>
92-
<constraint firstItem="8YX-3n-gWf" firstAttribute="leading" secondItem="t7O-Ph-IKW" secondAttribute="leading" constant="20" id="GeD-nc-jMq"/>
93-
<constraint firstItem="t7O-Ph-IKW" firstAttribute="trailing" secondItem="Xml-DM-3k0" secondAttribute="trailing" constant="20" id="IXP-ZG-HXb"/>
94-
<constraint firstItem="Whj-W0-IDm" firstAttribute="top" secondItem="t7O-Ph-IKW" secondAttribute="top" constant="30" id="KkS-GG-Ocz"/>
95-
<constraint firstItem="t7O-Ph-IKW" firstAttribute="trailing" secondItem="8YX-3n-gWf" secondAttribute="trailing" constant="20" id="MiD-v1-5ll"/>
77+
<constraint firstItem="oVs-XS-592" firstAttribute="top" secondItem="t7O-Ph-IKW" secondAttribute="top" id="B6Y-er-Fc6"/>
78+
<constraint firstItem="t7O-Ph-IKW" firstAttribute="trailing" secondItem="oVs-XS-592" secondAttribute="trailing" id="Mr3-k9-GG9"/>
9679
<constraint firstItem="1qT-mX-0SF" firstAttribute="leading" secondItem="t7O-Ph-IKW" secondAttribute="leading" constant="10" id="OAu-kM-52v"/>
97-
<constraint firstItem="8YX-3n-gWf" firstAttribute="top" secondItem="Whj-W0-IDm" secondAttribute="bottom" constant="8" id="aAx-Nq-PA5"/>
80+
<constraint firstItem="Bm8-4s-4Cg" firstAttribute="top" secondItem="t7O-Ph-IKW" secondAttribute="top" constant="175" id="Wt5-9Y-bb1"/>
9881
<constraint firstItem="Bm8-4s-4Cg" firstAttribute="leading" secondItem="t7O-Ph-IKW" secondAttribute="leading" id="exG-7x-7xe"/>
9982
<constraint firstItem="Bm8-4s-4Cg" firstAttribute="trailing" secondItem="t7O-Ph-IKW" secondAttribute="trailing" id="fvk-bR-p20"/>
10083
<constraint firstItem="H5J-Qa-DXp" firstAttribute="leading" secondItem="t7O-Ph-IKW" secondAttribute="leading" id="hj7-UB-iIW"/>
84+
<constraint firstItem="oVs-XS-592" firstAttribute="leading" secondItem="t7O-Ph-IKW" secondAttribute="leading" id="hu9-s1-iSg"/>
10185
<constraint firstItem="t7O-Ph-IKW" firstAttribute="trailing" secondItem="H5J-Qa-DXp" secondAttribute="trailing" id="iDf-P9-Du1"/>
102-
<constraint firstItem="Xml-DM-3k0" firstAttribute="top" secondItem="8YX-3n-gWf" secondAttribute="bottom" constant="8" id="jqP-Pt-Gr6"/>
103-
<constraint firstItem="Xml-DM-3k0" firstAttribute="leading" secondItem="t7O-Ph-IKW" secondAttribute="leading" constant="20" id="nJP-Gp-Soq"/>
86+
<constraint firstItem="H5J-Qa-DXp" firstAttribute="top" secondItem="oVs-XS-592" secondAttribute="bottom" id="qDG-7s-1jf"/>
10487
<constraint firstItem="1qT-mX-0SF" firstAttribute="top" secondItem="Bm8-4s-4Cg" secondAttribute="bottom" constant="22" id="qa1-Pc-Opa"/>
105-
<constraint firstItem="Whj-W0-IDm" firstAttribute="centerX" secondItem="jLk-oK-hVZ" secondAttribute="centerX" id="skA-xW-Bw5"/>
10688
<constraint firstItem="H5J-Qa-DXp" firstAttribute="bottom" secondItem="t7O-Ph-IKW" secondAttribute="bottom" id="udx-Gd-qCx"/>
10789
</constraints>
10890
<viewLayoutGuide key="safeArea" id="t7O-Ph-IKW"/>

0 commit comments

Comments
 (0)