diff --git a/WordPress/Classes/ViewRelated/Stats/Extensions/Double+Stats.swift b/WordPress/Classes/ViewRelated/Stats/Extensions/Double+Stats.swift index eecee0402efd..b66ab7fb9f83 100644 --- a/WordPress/Classes/ViewRelated/Stats/Extensions/Double+Stats.swift +++ b/WordPress/Classes/ViewRelated/Stats/Extensions/Double+Stats.swift @@ -143,12 +143,8 @@ extension Double { return formattedString } - func abbreviatedPercentageString(forHeroNumber: Bool = false) -> String { - guard let numberWithPercentage = NumberFormatter.statsPercentage.string(from: .init(value: self)) else { - return abbreviatedString(forHeroNumber: forHeroNumber) - } - - return numberWithPercentage.replacingOccurrences(of: "\(self)", with: self.abbreviatedString(forHeroNumber: forHeroNumber)) + func percentageString() -> String { + return NumberFormatter.statsPercentage.string(from: .init(value: self))! } private func formatWithCommas() -> String { @@ -166,8 +162,8 @@ extension NSNumber { return self.doubleValue.abbreviatedString(forHeroNumber: forHeroNumber) } - func abbreviatedPercentageString(forHeroNumber: Bool = false) -> String { - return self.doubleValue.abbreviatedPercentageString(forHeroNumber: forHeroNumber) + func percentageString() -> String { + return self.doubleValue.percentageString() } } @@ -176,8 +172,8 @@ extension Float { return Double(self).abbreviatedString(forHeroNumber: forHeroNumber) } - func abbreviatedPercentageString(forHeroNumber: Bool = false) -> String { - return Double(self).abbreviatedPercentageString(forHeroNumber: forHeroNumber) + func percentageString(forHeroNumber: Bool = false) -> String { + return Double(self).percentageString() } } @@ -186,7 +182,7 @@ extension Int { return Double(self).abbreviatedString(forHeroNumber: forHeroNumber) } - func abbreviatedPercentageString(forHeroNumber: Bool = false) -> String { - return Double(self).abbreviatedPercentageString(forHeroNumber: forHeroNumber) + func percentageString(forHeroNumber: Bool = false) -> String { + return Double(self).percentageString() } } diff --git a/WordPress/Classes/ViewRelated/Stats/Insights/SiteStatsInsightsViewModel.swift b/WordPress/Classes/ViewRelated/Stats/Insights/SiteStatsInsightsViewModel.swift index 477cefee503e..144dfdb4435d 100644 --- a/WordPress/Classes/ViewRelated/Stats/Insights/SiteStatsInsightsViewModel.swift +++ b/WordPress/Classes/ViewRelated/Stats/Insights/SiteStatsInsightsViewModel.swift @@ -523,8 +523,8 @@ private extension SiteStatsInsightsViewModel { return nil } - let dayPercentage = String(format: MostPopularStats.viewPercentage, mostPopularStats.mostPopularDayOfWeekPercentage.abbreviatedPercentageString()) - let hourPercentage = String(format: MostPopularStats.viewPercentage, mostPopularStats.mostPopularHourPercentage.abbreviatedPercentageString()) + let dayPercentage = String(format: MostPopularStats.viewPercentage, mostPopularStats.mostPopularDayOfWeekPercentage.percentageString()) + let hourPercentage = String(format: MostPopularStats.viewPercentage, mostPopularStats.mostPopularHourPercentage.percentageString()) return StatsMostPopularTimeData(mostPopularDayTitle: MostPopularStats.bestDay, mostPopularTimeTitle: MostPopularStats.bestHour, mostPopularDay: dayString, mostPopularTime: timeString.uppercased(), dayPercentage: dayPercentage, timePercentage: hourPercentage) } diff --git a/WordPress/Classes/ViewRelated/Stats/Insights/StatsTotalInsightsCell.swift b/WordPress/Classes/ViewRelated/Stats/Insights/StatsTotalInsightsCell.swift index 6ea0a5670973..299386b84797 100644 --- a/WordPress/Classes/ViewRelated/Stats/Insights/StatsTotalInsightsCell.swift +++ b/WordPress/Classes/ViewRelated/Stats/Insights/StatsTotalInsightsCell.swift @@ -304,9 +304,9 @@ class StatsTotalInsightsCell: StatsBaseCell { let differenceText: String = { if difference > 0 { - return String(format: TextContent.differenceHigher, differencePrefix, difference.abbreviatedString(), percentage.abbreviatedPercentageString()) + return String(format: TextContent.differenceHigher, differencePrefix, difference.abbreviatedString(), percentage.percentageString()) } else if difference < 0 { - return String(format: TextContent.differenceLower, differencePrefix, difference.abbreviatedString(), percentage.abbreviatedPercentageString()) + return String(format: TextContent.differenceLower, differencePrefix, difference.abbreviatedString(), percentage.percentageString()) } else { return TextContent.differenceSame } diff --git a/WordPress/Classes/ViewRelated/Stats/Insights/ViewsVisitors/ViewsVisitorsChartMarker.swift b/WordPress/Classes/ViewRelated/Stats/Insights/ViewsVisitors/ViewsVisitorsChartMarker.swift index 412aead1ec58..54f265c35786 100644 --- a/WordPress/Classes/ViewRelated/Stats/Insights/ViewsVisitors/ViewsVisitorsChartMarker.swift +++ b/WordPress/Classes/ViewRelated/Stats/Insights/ViewsVisitors/ViewsVisitorsChartMarker.swift @@ -265,7 +265,7 @@ final class ViewsVisitorsChartMarker: MarkerView { .paragraphStyle: paragraphStyle, .foregroundColor: UIColor.white] - let topRowStr = NSMutableAttributedString(string: "\(differenceStr) (\(roundedPercentage.abbreviatedPercentageString()))\n", attributes: topRowAttributes) + let topRowStr = NSMutableAttributedString(string: "\(differenceStr) (\(roundedPercentage.percentageString()))\n", attributes: topRowAttributes) let bottomRowStr = NSAttributedString(string: "\(yValue) \(name)", attributes: bottomRowAttributes) topRowStr.append(bottomRowStr) diff --git a/WordPress/Classes/ViewRelated/Stats/Insights/ViewsVisitors/ViewsVisitorsLineChartCell.swift b/WordPress/Classes/ViewRelated/Stats/Insights/ViewsVisitors/ViewsVisitorsLineChartCell.swift index 3ae03231eb51..a345b42db4fd 100644 --- a/WordPress/Classes/ViewRelated/Stats/Insights/ViewsVisitors/ViewsVisitorsLineChartCell.swift +++ b/WordPress/Classes/ViewRelated/Stats/Insights/ViewsVisitors/ViewsVisitorsLineChartCell.swift @@ -77,7 +77,7 @@ struct StatsSegmentedControlData { stringFormat, plusSign, difference.abbreviatedString(), - differencePercent.abbreviatedPercentageString() + differencePercent.percentageString() ) } else { let stringFormat = NSLocalizedString( diff --git a/WordPress/Classes/ViewRelated/Stats/Period Stats/Overview/OverviewCell.swift b/WordPress/Classes/ViewRelated/Stats/Period Stats/Overview/OverviewCell.swift index 67d34a3a61d5..6cea18a78e6a 100644 --- a/WordPress/Classes/ViewRelated/Stats/Period Stats/Overview/OverviewCell.swift +++ b/WordPress/Classes/ViewRelated/Stats/Period Stats/Overview/OverviewCell.swift @@ -65,7 +65,7 @@ struct OverviewTabData: FilterTabBarItem, Hashable { return String.localizedStringWithFormat(stringFormat, difference < 0 ? "" : "+", difference.abbreviatedString(), - differencePercent.abbreviatedPercentageString()) + differencePercent.percentageString()) } var differenceTextColor: UIColor {