diff --git a/WordPress/Classes/ViewRelated/Stats/Period Stats/Countries/CountriesCell.swift b/WordPress/Classes/ViewRelated/Stats/Period Stats/Countries/CountriesCell.swift
index 87a11ddc5765..2c6bb34a4fba 100644
--- a/WordPress/Classes/ViewRelated/Stats/Period Stats/Countries/CountriesCell.swift
+++ b/WordPress/Classes/ViewRelated/Stats/Period Stats/Countries/CountriesCell.swift
@@ -10,11 +10,8 @@ class CountriesCell: UITableViewCell, NibLoadable {
@IBOutlet weak var itemSubtitleLabel: UILabel!
@IBOutlet weak var dataSubtitleLabel: UILabel!
@IBOutlet weak var bottomSeparatorLine: UIView!
-
- // If the subtitles are not shown, this is active.
+ @IBOutlet weak var subtitlesStackViewTopConstraint: NSLayoutConstraint!
@IBOutlet weak var rowsStackViewTopConstraint: NSLayoutConstraint!
- // If the subtitles are shown, this is active.
- @IBOutlet weak var rowsStackViewTopConstraintWithSubtitles: NSLayoutConstraint!
private weak var siteStatsPeriodDelegate: SiteStatsPeriodDelegate?
private var dataRows = [StatsTotalRowData]()
@@ -70,17 +67,14 @@ private extension CountriesCell {
}
func setSubtitleVisibility() {
+ let subtitleHeight = subtitlesStackViewTopConstraint.constant * 2 + subtitleStackView.frame.height
if forDetails {
- subtitleStackView.isHidden = false
- rowsStackView.isHidden = true
+ rowsStackViewTopConstraint.constant = subtitleHeight
return
}
- let showSubtitles = dataRows.count > 0
- subtitleStackView.isHidden = !showSubtitles
- rowsStackViewTopConstraint.isActive = !showSubtitles
- rowsStackViewTopConstraintWithSubtitles.isActive = showSubtitles
+ rowsStackViewTopConstraint.constant = !dataRows.isEmpty ? subtitleHeight : 0
}
}
diff --git a/WordPress/Classes/ViewRelated/Stats/Period Stats/Countries/CountriesCell.xib b/WordPress/Classes/ViewRelated/Stats/Period Stats/Countries/CountriesCell.xib
index da698783cc09..3432f2e9f346 100644
--- a/WordPress/Classes/ViewRelated/Stats/Period Stats/Countries/CountriesCell.xib
+++ b/WordPress/Classes/ViewRelated/Stats/Period Stats/Countries/CountriesCell.xib
@@ -61,7 +61,7 @@
-
+
@@ -84,9 +84,8 @@
-
-
+
@@ -101,7 +100,6 @@
-
@@ -112,8 +110,8 @@
-
+
diff --git a/WordPress/Classes/ViewRelated/Stats/Shared Views/TopTotalsCell.swift b/WordPress/Classes/ViewRelated/Stats/Shared Views/TopTotalsCell.swift
index 7bf3fb4a1bd8..aaba7c368af7 100644
--- a/WordPress/Classes/ViewRelated/Stats/Shared Views/TopTotalsCell.swift
+++ b/WordPress/Classes/ViewRelated/Stats/Shared Views/TopTotalsCell.swift
@@ -15,12 +15,8 @@ class TopTotalsCell: UITableViewCell, NibLoadable {
@IBOutlet weak var rowsStackView: UIStackView!
@IBOutlet weak var itemSubtitleLabel: UILabel!
@IBOutlet weak var dataSubtitleLabel: UILabel!
-
- // If the subtitles are not shown, this is active.
+ @IBOutlet weak var subtitlesStackViewTopConstraint: NSLayoutConstraint!
@IBOutlet weak var rowsStackViewTopConstraint: NSLayoutConstraint!
- // If the subtitles are shown, this is active.
- @IBOutlet weak var rowsStackViewTopConstraintWithSubtitles: NSLayoutConstraint!
-
@IBOutlet weak var topSeparatorLine: UIView!
@IBOutlet weak var bottomSeparatorLine: UIView!
@@ -111,18 +107,16 @@ private extension TopTotalsCell {
/// - Hide the stack view.
///
func setSubtitleVisibility() {
+ let subtitleHeight = subtitlesStackViewTopConstraint.constant * 2 + subtitleStackView.frame.height
if forDetails {
- subtitleStackView.isHidden = !subtitlesProvided
- rowsStackView.isHidden = true
bottomSeparatorLine.isHidden = true
+ rowsStackViewTopConstraint.constant = subtitlesProvided ? subtitleHeight : 0
return
}
- let showSubtitles = dataRows.count > 0 && subtitlesProvided
- subtitleStackView.isHidden = !showSubtitles
- rowsStackViewTopConstraint.isActive = !showSubtitles
- rowsStackViewTopConstraintWithSubtitles.isActive = showSubtitles
+ let showSubtitles = !dataRows.isEmpty && subtitlesProvided
+ rowsStackViewTopConstraint.constant = showSubtitles ? subtitleHeight : 0
}
// MARK: - Child Row Handling
diff --git a/WordPress/Classes/ViewRelated/Stats/Shared Views/TopTotalsCell.xib b/WordPress/Classes/ViewRelated/Stats/Shared Views/TopTotalsCell.xib
index 8ee82cd0e128..cb9c3c0dab13 100644
--- a/WordPress/Classes/ViewRelated/Stats/Shared Views/TopTotalsCell.xib
+++ b/WordPress/Classes/ViewRelated/Stats/Shared Views/TopTotalsCell.xib
@@ -1,11 +1,11 @@
-
+
-
+
@@ -40,7 +40,7 @@
-
+
@@ -62,7 +62,6 @@
-
@@ -71,13 +70,8 @@
-
+
-
-
-
-
-
@@ -86,8 +80,8 @@
-
+