Skip to content

Commit 5d39ee5

Browse files
committed
Extract separate view for the site visit empty view
1 parent 7784b12 commit 5d39ee5

File tree

3 files changed

+50
-31
lines changed

3 files changed

+50
-31
lines changed
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
import UIKit
2+
3+
final class StoreStatsSiteVisitEmptyView: UIView {
4+
convenience init() {
5+
self.init(frame: .zero)
6+
}
7+
8+
override init(frame: CGRect) {
9+
super.init(frame: frame)
10+
setupSubviews()
11+
}
12+
13+
required init?(coder: NSCoder) {
14+
fatalError("init(coder:) has not been implemented")
15+
}
16+
17+
private func setupSubviews() {
18+
translatesAutoresizingMaskIntoConstraints = false
19+
20+
let emptyView = UIView(frame: .zero)
21+
emptyView.backgroundColor = .systemColor(.systemGroupedBackground)
22+
emptyView.layer.cornerRadius = 2.0
23+
emptyView.translatesAutoresizingMaskIntoConstraints = false
24+
25+
let jetpackImageView = UIImageView(image: .jetpackLogoImage.withRenderingMode(.alwaysTemplate))
26+
jetpackImageView.contentMode = .scaleAspectFit
27+
jetpackImageView.tintColor = .jetpackGreen
28+
jetpackImageView.translatesAutoresizingMaskIntoConstraints = false
29+
30+
addSubview(emptyView)
31+
addSubview(jetpackImageView)
32+
33+
NSLayoutConstraint.activate([
34+
self.widthAnchor.constraint(equalToConstant: 48),
35+
emptyView.widthAnchor.constraint(equalToConstant: 32),
36+
emptyView.heightAnchor.constraint(equalToConstant: 10),
37+
emptyView.centerXAnchor.constraint(equalTo: self.centerXAnchor),
38+
emptyView.topAnchor.constraint(equalTo: jetpackImageView.bottomAnchor),
39+
jetpackImageView.widthAnchor.constraint(equalToConstant: 14),
40+
jetpackImageView.heightAnchor.constraint(equalToConstant: 14),
41+
jetpackImageView.leadingAnchor.constraint(equalTo: emptyView.trailingAnchor),
42+
jetpackImageView.topAnchor.constraint(equalTo: self.topAnchor, constant: 4)
43+
])
44+
}
45+
}

WooCommerce/Classes/ViewRelated/Dashboard/Stats v4/StoreStatsV4PeriodViewController.swift

Lines changed: 1 addition & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -153,37 +153,7 @@ final class StoreStatsV4PeriodViewController: UIViewController {
153153
roundSmallNumbers: false) ?? String()
154154
}
155155

156-
private lazy var visitorsEmptyView: UIView = {
157-
let containerView = UIView(frame: .zero)
158-
containerView.translatesAutoresizingMaskIntoConstraints = false
159-
160-
let emptyView = UIView(frame: .zero)
161-
emptyView.backgroundColor = .systemColor(.systemGroupedBackground)
162-
emptyView.layer.cornerRadius = 2.0
163-
emptyView.translatesAutoresizingMaskIntoConstraints = false
164-
165-
let jetpackImageView = UIImageView(image: .jetpackLogoImage.withRenderingMode(.alwaysTemplate))
166-
jetpackImageView.contentMode = .scaleAspectFit
167-
jetpackImageView.tintColor = .jetpackGreen
168-
jetpackImageView.translatesAutoresizingMaskIntoConstraints = false
169-
170-
containerView.addSubview(emptyView)
171-
containerView.addSubview(jetpackImageView)
172-
173-
NSLayoutConstraint.activate([
174-
containerView.widthAnchor.constraint(equalToConstant: 48),
175-
emptyView.widthAnchor.constraint(equalToConstant: 32),
176-
emptyView.heightAnchor.constraint(equalToConstant: 10),
177-
emptyView.centerXAnchor.constraint(equalTo: containerView.centerXAnchor),
178-
emptyView.topAnchor.constraint(equalTo: jetpackImageView.bottomAnchor),
179-
jetpackImageView.widthAnchor.constraint(equalToConstant: 14),
180-
jetpackImageView.heightAnchor.constraint(equalToConstant: 14),
181-
jetpackImageView.leadingAnchor.constraint(equalTo: emptyView.trailingAnchor),
182-
jetpackImageView.topAnchor.constraint(equalTo: containerView.topAnchor, constant: 4)
183-
])
184-
185-
return containerView
186-
}()
156+
private lazy var visitorsEmptyView = StoreStatsSiteVisitEmptyView()
187157
// MARK: - Initialization
188158

189159
/// Designated Initializer

WooCommerce/WooCommerce.xcodeproj/project.pbxproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1367,6 +1367,7 @@
13671367
DEC2962526C122DF005A056B /* ShippingLabelCustomsFormInputViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = DEC2962426C122DF005A056B /* ShippingLabelCustomsFormInputViewModel.swift */; };
13681368
DEC2962726C17AD8005A056B /* ShippingLabelCustomsForm+Localization.swift in Sources */ = {isa = PBXBuildFile; fileRef = DEC2962626C17AD8005A056B /* ShippingLabelCustomsForm+Localization.swift */; };
13691369
DEC2962926C20ECB005A056B /* CollapsibleView.swift in Sources */ = {isa = PBXBuildFile; fileRef = DEC2962826C20ECB005A056B /* CollapsibleView.swift */; };
1370+
DEC6C51827466B59006832D3 /* StoreStatsSiteVisitEmptyView.swift in Sources */ = {isa = PBXBuildFile; fileRef = DEC6C51727466B59006832D3 /* StoreStatsSiteVisitEmptyView.swift */; };
13701371
DEDB886B26E8531E00981595 /* ShippingLabelPackageAttributes.swift in Sources */ = {isa = PBXBuildFile; fileRef = DEDB886A26E8531E00981595 /* ShippingLabelPackageAttributes.swift */; };
13711372
DEE6437626D87C4100888A75 /* PrintCustomsFormsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = DEE6437526D87C4100888A75 /* PrintCustomsFormsView.swift */; };
13721373
DEE6437826D8DAD900888A75 /* InProgressView.swift in Sources */ = {isa = PBXBuildFile; fileRef = DEE6437726D8DAD900888A75 /* InProgressView.swift */; };
@@ -2852,6 +2853,7 @@
28522853
DEC2962426C122DF005A056B /* ShippingLabelCustomsFormInputViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ShippingLabelCustomsFormInputViewModel.swift; sourceTree = "<group>"; };
28532854
DEC2962626C17AD8005A056B /* ShippingLabelCustomsForm+Localization.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "ShippingLabelCustomsForm+Localization.swift"; sourceTree = "<group>"; };
28542855
DEC2962826C20ECB005A056B /* CollapsibleView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CollapsibleView.swift; sourceTree = "<group>"; };
2856+
DEC6C51727466B59006832D3 /* StoreStatsSiteVisitEmptyView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StoreStatsSiteVisitEmptyView.swift; sourceTree = "<group>"; };
28552857
DEDB886A26E8531E00981595 /* ShippingLabelPackageAttributes.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ShippingLabelPackageAttributes.swift; sourceTree = "<group>"; };
28562858
DEE6437526D87C4100888A75 /* PrintCustomsFormsView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PrintCustomsFormsView.swift; sourceTree = "<group>"; };
28572859
DEE6437726D8DAD900888A75 /* InProgressView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = InProgressView.swift; sourceTree = "<group>"; };
@@ -3644,6 +3646,7 @@
36443646
02E4FD7D2306A8180049610C /* StatsTimeRangeBarViewModel.swift */,
36453647
0240B3AB230A910C000A866C /* StoreStatsV4ChartAxisHelper.swift */,
36463648
5778E00524DB0C3900B65CBF /* StoreStatsAndTopPerformersPeriodViewModel.swift */,
3649+
DEC6C51727466B59006832D3 /* StoreStatsSiteVisitEmptyView.swift */,
36473650
);
36483651
path = "Stats v4";
36493652
sourceTree = "<group>";
@@ -7536,6 +7539,7 @@
75367539
0260F40123224E8100EDA10A /* ProductsViewController.swift in Sources */,
75377540
7E6A019F2725CD76001668D5 /* FilterProductCategoryListViewModel.swift in Sources */,
75387541
4569D3C325DC008700CDC3E2 /* SiteAddress.swift in Sources */,
7542+
DEC6C51827466B59006832D3 /* StoreStatsSiteVisitEmptyView.swift in Sources */,
75397543
31FE28C225E6D338003519F2 /* LearnMoreTableViewCell.swift in Sources */,
75407544
02D45647231CB1FB008CF0A9 /* UIImage+Dot.swift in Sources */,
75417545
E11228BE2707267F004E9F2D /* CardPresentModalUpdateFailedNonRetryable.swift in Sources */,

0 commit comments

Comments
 (0)