From b37eb9922d6cd2d9506779fd1e7c3cd68441bed3 Mon Sep 17 00:00:00 2001 From: Stephenie Harris Date: Wed, 29 May 2019 14:34:04 -0600 Subject: [PATCH 1/3] TopTotalsCell: adjust rowsStackViewTopConstraint depending on subtitle visibility. --- .../Stats/Shared Views/TopTotalsCell.swift | 14 ++++---------- .../Stats/Shared Views/TopTotalsCell.xib | 16 +++++----------- 2 files changed, 9 insertions(+), 21 deletions(-) diff --git a/WordPress/Classes/ViewRelated/Stats/Shared Views/TopTotalsCell.swift b/WordPress/Classes/ViewRelated/Stats/Shared Views/TopTotalsCell.swift index 7bf3fb4a1bd8..c6394dfeb88f 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 + 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 @@ - + From 39c9f67f5339b6dad4437be19ba84903e84cc31d Mon Sep 17 00:00:00 2001 From: Stephenie Harris Date: Wed, 29 May 2019 14:44:12 -0600 Subject: [PATCH 2/3] CountriesCell: adjust rowsStackViewTopConstraint depending on subtitle visibility. --- .../Period Stats/Countries/CountriesCell.swift | 14 ++++---------- .../Stats/Period Stats/Countries/CountriesCell.xib | 8 +++----- 2 files changed, 7 insertions(+), 15 deletions(-) diff --git a/WordPress/Classes/ViewRelated/Stats/Period Stats/Countries/CountriesCell.swift b/WordPress/Classes/ViewRelated/Stats/Period Stats/Countries/CountriesCell.swift index 87a11ddc5765..08a59e1136ed 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.count > 0 ? 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 @@ - + From 56af0a2df56f30160dafb2e73c3c678efb937715 Mon Sep 17 00:00:00 2001 From: Stephenie Harris Date: Thu, 30 May 2019 11:17:34 -0600 Subject: [PATCH 3/3] Using isEmpty instead of count. --- .../Stats/Period Stats/Countries/CountriesCell.swift | 2 +- .../Classes/ViewRelated/Stats/Shared Views/TopTotalsCell.swift | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/WordPress/Classes/ViewRelated/Stats/Period Stats/Countries/CountriesCell.swift b/WordPress/Classes/ViewRelated/Stats/Period Stats/Countries/CountriesCell.swift index 08a59e1136ed..2c6bb34a4fba 100644 --- a/WordPress/Classes/ViewRelated/Stats/Period Stats/Countries/CountriesCell.swift +++ b/WordPress/Classes/ViewRelated/Stats/Period Stats/Countries/CountriesCell.swift @@ -74,7 +74,7 @@ private extension CountriesCell { return } - rowsStackViewTopConstraint.constant = dataRows.count > 0 ? subtitleHeight : 0 + rowsStackViewTopConstraint.constant = !dataRows.isEmpty ? subtitleHeight : 0 } } diff --git a/WordPress/Classes/ViewRelated/Stats/Shared Views/TopTotalsCell.swift b/WordPress/Classes/ViewRelated/Stats/Shared Views/TopTotalsCell.swift index c6394dfeb88f..aaba7c368af7 100644 --- a/WordPress/Classes/ViewRelated/Stats/Shared Views/TopTotalsCell.swift +++ b/WordPress/Classes/ViewRelated/Stats/Shared Views/TopTotalsCell.swift @@ -115,7 +115,7 @@ private extension TopTotalsCell { return } - let showSubtitles = dataRows.count > 0 && subtitlesProvided + let showSubtitles = !dataRows.isEmpty && subtitlesProvided rowsStackViewTopConstraint.constant = showSubtitles ? subtitleHeight : 0 }