Skip to content

Commit 7d644ed

Browse files
committed
Implements AccountHeaderView
1 parent c2160da commit 7d644ed

File tree

2 files changed

+124
-0
lines changed

2 files changed

+124
-0
lines changed
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
import Foundation
2+
import UIKit
3+
4+
5+
/// AccountHeaderView: Displays an Account's Details: [Gravatar + Name + Username]
6+
///
7+
class AccountHeaderView: UIView {
8+
9+
/// Account's Gravatar.
10+
///
11+
@IBOutlet private var gravatarImageView: UIImageView! {
12+
didSet {
13+
gravatarImageView.image = .gravatarPlaceholderImage
14+
}
15+
}
16+
17+
/// Account's Full Name.
18+
///
19+
@IBOutlet private var fullnameLabel: UILabel!
20+
21+
/// Account's Username.
22+
///
23+
@IBOutlet private var usernameLabel: UILabel! {
24+
didSet {
25+
usernameLabel.textColor = StyleManager.wooGreyTextMin
26+
}
27+
}
28+
}
29+
30+
31+
// MARK: - Public Methods
32+
//
33+
extension AccountHeaderView {
34+
35+
/// Account's Username.
36+
///
37+
var username: String? {
38+
set {
39+
usernameLabel.text = newValue
40+
}
41+
get {
42+
return usernameLabel.text
43+
}
44+
}
45+
46+
/// Account's Full Name
47+
///
48+
var fullname: String? {
49+
set {
50+
fullnameLabel.text = newValue
51+
}
52+
get {
53+
return fullnameLabel.text
54+
}
55+
}
56+
57+
/// Downloads (and displays) the Gravatar associated with the specified Email.
58+
///
59+
func downloadGravatar(with email: String) {
60+
gravatarImageView.downloadGravatarWithEmail(email)
61+
}
62+
}
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
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">
3+
<device id="retina4_7" orientation="portrait">
4+
<adaptation id="fullscreen"/>
5+
</device>
6+
<dependencies>
7+
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14088"/>
8+
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
9+
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
10+
</dependencies>
11+
<objects>
12+
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner"/>
13+
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
14+
<view contentMode="scaleToFill" id="wsJ-iY-FyE" customClass="AccountHeaderView" customModule="WooCommerce" customModuleProvider="target">
15+
<rect key="frame" x="0.0" y="0.0" width="375" height="174"/>
16+
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
17+
<subviews>
18+
<imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" horizontalCompressionResistancePriority="1000" verticalCompressionResistancePriority="1000" translatesAutoresizingMaskIntoConstraints="NO" id="vOQ-CP-fZ1" customClass="CircularImageView" customModule="WooCommerce" customModuleProvider="target">
19+
<rect key="frame" x="157.5" y="29" width="60" height="60"/>
20+
<constraints>
21+
<constraint firstAttribute="height" constant="60" id="IcJ-wJ-Tra"/>
22+
<constraint firstAttribute="width" constant="60" id="cwR-2d-T4e"/>
23+
</constraints>
24+
</imageView>
25+
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="252" verticalHuggingPriority="252" horizontalCompressionResistancePriority="1000" verticalCompressionResistancePriority="1000" text="Full Name" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontForContentSizeCategory="YES" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="xHF-gJ-reo">
26+
<rect key="frame" x="10" y="97" width="355" height="20.5"/>
27+
<fontDescription key="fontDescription" style="UICTFontTextStyleHeadline"/>
28+
<nil key="textColor"/>
29+
<nil key="highlightedColor"/>
30+
</label>
31+
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="252" verticalHuggingPriority="253" verticalCompressionResistancePriority="1000" text="@username" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="LiJ-G2-nZS">
32+
<rect key="frame" x="10" y="125.5" width="355" height="18"/>
33+
<fontDescription key="fontDescription" style="UICTFontTextStyleSubhead"/>
34+
<color key="textColor" cocoaTouchSystemColor="scrollViewTexturedBackgroundColor"/>
35+
<nil key="highlightedColor"/>
36+
</label>
37+
</subviews>
38+
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
39+
<constraints>
40+
<constraint firstItem="LiJ-G2-nZS" firstAttribute="leading" secondItem="DAy-rN-ump" secondAttribute="leading" constant="10" id="4a0-8q-Z34"/>
41+
<constraint firstItem="xHF-gJ-reo" firstAttribute="top" secondItem="vOQ-CP-fZ1" secondAttribute="bottom" constant="8" id="BTx-oz-REg"/>
42+
<constraint firstItem="DAy-rN-ump" firstAttribute="trailing" secondItem="xHF-gJ-reo" secondAttribute="trailing" constant="10" id="JKO-gN-oNe"/>
43+
<constraint firstItem="vOQ-CP-fZ1" firstAttribute="centerX" secondItem="wsJ-iY-FyE" secondAttribute="centerX" id="NgM-Yn-gMx"/>
44+
<constraint firstItem="DAy-rN-ump" firstAttribute="bottom" relation="greaterThanOrEqual" secondItem="LiJ-G2-nZS" secondAttribute="bottom" constant="29" id="Ved-ir-LoS"/>
45+
<constraint firstItem="xHF-gJ-reo" firstAttribute="leading" secondItem="DAy-rN-ump" secondAttribute="leading" constant="10" id="bvI-bc-8La"/>
46+
<constraint firstItem="LiJ-G2-nZS" firstAttribute="top" secondItem="xHF-gJ-reo" secondAttribute="bottom" constant="8" id="gOl-k9-naS"/>
47+
<constraint firstItem="DAy-rN-ump" firstAttribute="trailing" secondItem="LiJ-G2-nZS" secondAttribute="trailing" constant="10" id="je2-Uv-FAR"/>
48+
<constraint firstItem="vOQ-CP-fZ1" firstAttribute="top" secondItem="DAy-rN-ump" secondAttribute="top" constant="29" id="yHD-B7-H48"/>
49+
</constraints>
50+
<nil key="simulatedTopBarMetrics"/>
51+
<nil key="simulatedBottomBarMetrics"/>
52+
<freeformSimulatedSizeMetrics key="simulatedDestinationMetrics"/>
53+
<viewLayoutGuide key="safeArea" id="DAy-rN-ump"/>
54+
<connections>
55+
<outlet property="fullnameLabel" destination="xHF-gJ-reo" id="ba9-Sw-RJO"/>
56+
<outlet property="gravatarImageView" destination="vOQ-CP-fZ1" id="K0E-fC-gY9"/>
57+
<outlet property="usernameLabel" destination="LiJ-G2-nZS" id="SiG-bv-eTM"/>
58+
</connections>
59+
<point key="canvasLocation" x="-6.5" y="-323"/>
60+
</view>
61+
</objects>
62+
</document>

0 commit comments

Comments
 (0)