Skip to content

Commit 3f2b8a7

Browse files
committed
StorePickerViewController: Adding Placeholder
1 parent 15cd443 commit 3f2b8a7

File tree

2 files changed

+70
-30
lines changed

2 files changed

+70
-30
lines changed

WooCommerce/Classes/Authentication/Epilogue/StorePickerViewController.swift

Lines changed: 42 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import Foundation
22
import UIKit
33
import WordPressAuthenticator
4+
import WordPressUI
45

56

67
/// Allows the user to pick which WordPress.com (OR) Jetpack-Connected-Store we should set up as the Main Store.
@@ -9,17 +10,13 @@ class StorePickerViewController: UIViewController {
910

1011
/// White-Background View, to be placed surrounding the bottom area.
1112
///
12-
@IBOutlet private var backgroundView: UIView! {
13+
@IBOutlet private var buttonBackgroundView: UIView! {
1314
didSet {
14-
backgroundView.layer.masksToBounds = false
15-
backgroundView.layer.shadowOpacity = Constants.backgroundShadowOpacity
15+
buttonBackgroundView.layer.masksToBounds = false
16+
buttonBackgroundView.layer.shadowOpacity = Constants.backgroundShadowOpacity
1617
}
1718
}
1819

19-
/// Spinner, to be displayed while the User Details are being retrieved.
20-
///
21-
@IBOutlet private var activityIndicator: UIActivityIndicatorView!
22-
2320
/// Account's Gravatar.
2421
///
2522
@IBOutlet private var gravatarImageView: UIImageView! {
@@ -34,7 +31,24 @@ class StorePickerViewController: UIViewController {
3431

3532
/// Account's Username.
3633
///
37-
@IBOutlet private var usernameLabel: UILabel!
34+
@IBOutlet private var usernameLabel: UILabel! {
35+
didSet {
36+
usernameLabel.textColor = StyleManager.wooGreyTextMin
37+
}
38+
}
39+
40+
/// No Results Placeholder Image
41+
///
42+
@IBOutlet private var noResultsImageView: UIImageView!
43+
44+
/// No Results Placeholder Text
45+
///
46+
@IBOutlet private var noResultsLabel: UILabel! {
47+
didSet {
48+
noResultsLabel.font = UIFont.font(forStyle: .subheadline, weight: .regular)
49+
noResultsLabel.textColor = StyleManager.wooGreyTextMin
50+
}
51+
}
3852

3953
/// Default Action Button.
4054
///
@@ -44,10 +58,6 @@ class StorePickerViewController: UIViewController {
4458
}
4559
}
4660

47-
///
48-
///
49-
var credentials: WordPressCredentials!
50-
5161
/// Closure to be executed upon dismissal.
5262
///
5363
var onDismiss: (() -> Void)?
@@ -58,7 +68,10 @@ class StorePickerViewController: UIViewController {
5868

5969
override func viewDidLoad() {
6070
super.viewDidLoad()
71+
6172
setupMainView()
73+
setupAccountDetails()
74+
downloadGravatarImage()
6275
}
6376

6477
override func viewWillAppear(_ animated: Bool) {
@@ -80,6 +93,23 @@ private extension StorePickerViewController {
8093
func setupMainView() {
8194
view.backgroundColor = StyleManager.tableViewBackgroundColor
8295
}
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)
103+
}
104+
105+
func setupAccountDetails() {
106+
guard let defaultAccount = StoresManager.shared.sessionManager.defaultAccount else {
107+
return
108+
}
109+
110+
fullnameLabel.text = defaultAccount.displayName
111+
usernameLabel.text = "@" + defaultAccount.username
112+
}
83113
}
84114

85115

WooCommerce/Classes/Authentication/Epilogue/StorePickerViewController.xib

Lines changed: 28 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,23 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="14109" 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="14113" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
33
<device id="retina4_7" orientation="portrait">
44
<adaptation id="fullscreen"/>
55
</device>
66
<dependencies>
77
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14088"/>
8+
<capability name="Aspect ratio constraints" minToolsVersion="5.1"/>
89
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
910
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
1011
</dependencies>
1112
<objects>
1213
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner" customClass="StorePickerViewController" customModule="WooCommerce" customModuleProvider="target">
1314
<connections>
14-
<outlet property="activityIndicator" destination="h18-yC-h2j" id="P5a-Xd-o3g"/>
15-
<outlet property="backgroundView" destination="6Ln-r5-ZV0" id="HoG-zv-DBP"/>
15+
<outlet property="buttonBackgroundView" destination="H5J-Qa-DXp" id="AbM-SK-Wdu"/>
1616
<outlet property="continueButton" destination="0KD-hY-YaS" id="k8d-re-dNi"/>
1717
<outlet property="fullnameLabel" destination="8YX-3n-gWf" id="3nf-1k-mDc"/>
1818
<outlet property="gravatarImageView" destination="Whj-W0-IDm" id="XmU-mA-kJE"/>
19+
<outlet property="noResultsImageView" destination="Bm8-4s-4Cg" id="5TG-sO-2h6"/>
20+
<outlet property="noResultsLabel" destination="1qT-mX-0SF" id="L6b-My-936"/>
1921
<outlet property="usernameLabel" destination="Xml-DM-3k0" id="XLT-g0-U2L"/>
2022
<outlet property="view" destination="jLk-oK-hVZ" id="tZZ-hi-Qto"/>
2123
</connections>
@@ -25,11 +27,7 @@
2527
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
2628
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
2729
<subviews>
28-
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="6Ln-r5-ZV0" userLabel="Background View">
29-
<rect key="frame" x="0.0" y="576.5" width="375" height="90.5"/>
30-
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
31-
</view>
32-
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="H5J-Qa-DXp" userLabel="Container View">
30+
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="H5J-Qa-DXp" userLabel="Button Background View">
3331
<rect key="frame" x="0.0" y="577" width="375" height="90"/>
3432
<subviews>
3533
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="0KD-hY-YaS" customClass="FancyButton" customModule="WordPressUI">
@@ -74,32 +72,44 @@
7472
<color key="textColor" cocoaTouchSystemColor="scrollViewTexturedBackgroundColor"/>
7573
<nil key="highlightedColor"/>
7674
</label>
77-
<activityIndicatorView hidden="YES" opaque="NO" contentMode="scaleToFill" horizontalHuggingPriority="750" verticalHuggingPriority="750" hidesWhenStopped="YES" style="gray" translatesAutoresizingMaskIntoConstraints="NO" id="h18-yC-h2j">
78-
<rect key="frame" x="177" y="135" width="20" height="20"/>
79-
</activityIndicatorView>
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>
8087
</subviews>
8188
<color key="backgroundColor" red="0.96862745098039216" green="0.96862745098039216" blue="0.96862745098039216" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
8289
<constraints>
83-
<constraint firstItem="H5J-Qa-DXp" firstAttribute="trailing" secondItem="6Ln-r5-ZV0" secondAttribute="trailing" id="1sC-fV-lRd"/>
84-
<constraint firstItem="h18-yC-h2j" firstAttribute="top" secondItem="Whj-W0-IDm" secondAttribute="bottom" constant="25" id="3di-vc-etI"/>
90+
<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"/>
8592
<constraint firstItem="8YX-3n-gWf" firstAttribute="leading" secondItem="t7O-Ph-IKW" secondAttribute="leading" constant="20" id="GeD-nc-jMq"/>
8693
<constraint firstItem="t7O-Ph-IKW" firstAttribute="trailing" secondItem="Xml-DM-3k0" secondAttribute="trailing" constant="20" id="IXP-ZG-HXb"/>
8794
<constraint firstItem="Whj-W0-IDm" firstAttribute="top" secondItem="t7O-Ph-IKW" secondAttribute="top" constant="30" id="KkS-GG-Ocz"/>
8895
<constraint firstItem="t7O-Ph-IKW" firstAttribute="trailing" secondItem="8YX-3n-gWf" secondAttribute="trailing" constant="20" id="MiD-v1-5ll"/>
89-
<constraint firstItem="6Ln-r5-ZV0" firstAttribute="bottom" secondItem="jLk-oK-hVZ" secondAttribute="bottom" id="PhU-pm-reU"/>
90-
<constraint firstItem="H5J-Qa-DXp" firstAttribute="leading" secondItem="6Ln-r5-ZV0" secondAttribute="leading" id="VAX-el-1jK"/>
96+
<constraint firstItem="1qT-mX-0SF" firstAttribute="leading" secondItem="t7O-Ph-IKW" secondAttribute="leading" constant="10" id="OAu-kM-52v"/>
9197
<constraint firstItem="8YX-3n-gWf" firstAttribute="top" secondItem="Whj-W0-IDm" secondAttribute="bottom" constant="8" id="aAx-Nq-PA5"/>
98+
<constraint firstItem="Bm8-4s-4Cg" firstAttribute="leading" secondItem="t7O-Ph-IKW" secondAttribute="leading" id="exG-7x-7xe"/>
99+
<constraint firstItem="Bm8-4s-4Cg" firstAttribute="trailing" secondItem="t7O-Ph-IKW" secondAttribute="trailing" id="fvk-bR-p20"/>
92100
<constraint firstItem="H5J-Qa-DXp" firstAttribute="leading" secondItem="t7O-Ph-IKW" secondAttribute="leading" id="hj7-UB-iIW"/>
93101
<constraint firstItem="t7O-Ph-IKW" firstAttribute="trailing" secondItem="H5J-Qa-DXp" secondAttribute="trailing" id="iDf-P9-Du1"/>
94102
<constraint firstItem="Xml-DM-3k0" firstAttribute="top" secondItem="8YX-3n-gWf" secondAttribute="bottom" constant="8" id="jqP-Pt-Gr6"/>
95103
<constraint firstItem="Xml-DM-3k0" firstAttribute="leading" secondItem="t7O-Ph-IKW" secondAttribute="leading" constant="20" id="nJP-Gp-Soq"/>
96-
<constraint firstItem="h18-yC-h2j" firstAttribute="centerX" secondItem="jLk-oK-hVZ" secondAttribute="centerX" id="q1V-Ll-8Ks"/>
97-
<constraint firstItem="H5J-Qa-DXp" firstAttribute="top" secondItem="6Ln-r5-ZV0" secondAttribute="top" id="qgu-Fc-gr4"/>
104+
<constraint firstItem="1qT-mX-0SF" firstAttribute="top" secondItem="Bm8-4s-4Cg" secondAttribute="bottom" constant="22" id="qa1-Pc-Opa"/>
98105
<constraint firstItem="Whj-W0-IDm" firstAttribute="centerX" secondItem="jLk-oK-hVZ" secondAttribute="centerX" id="skA-xW-Bw5"/>
99106
<constraint firstItem="H5J-Qa-DXp" firstAttribute="bottom" secondItem="t7O-Ph-IKW" secondAttribute="bottom" id="udx-Gd-qCx"/>
100107
</constraints>
101108
<viewLayoutGuide key="safeArea" id="t7O-Ph-IKW"/>
102-
<point key="canvasLocation" x="-474.5" y="20"/>
109+
<point key="canvasLocation" x="-474.5" y="19.5"/>
103110
</view>
104111
</objects>
112+
<resources>
113+
<image name="woo-no-store" width="320" height="180"/>
114+
</resources>
105115
</document>

0 commit comments

Comments
 (0)