Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stats Insights tweaks – default cards, modal presentation #13131

Merged
merged 4 commits into from Dec 20, 2019
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 2 additions & 1 deletion RELEASE-NOTES.txt
@@ -1,6 +1,7 @@
14.0
-----

* Stats: Updated default cards for the Insights view.

13.9
-----
* Stats: added a Today widget to display All-Time stats.
Expand Down
@@ -1,4 +1,5 @@
import UIKit
import Gridicons

class AddInsightTableViewController: UITableViewController {

Expand Down Expand Up @@ -39,6 +40,8 @@ class AddInsightTableViewController: UITableViewController {
WPStyleGuide.configureColors(view: view, tableView: tableView)
WPStyleGuide.configureAutomaticHeightRows(for: tableView)
tableView.accessibilityIdentifier = "Add Insight Table"

navigationItem.leftBarButtonItem = UIBarButtonItem(image: Gridicon.iconOfType(.cross), style: .plain, target: self, action: #selector(doneTapped))
}

override func viewWillDisappear(_ animated: Bool) {
Expand All @@ -57,6 +60,9 @@ class AddInsightTableViewController: UITableViewController {
return 0
}

@objc private func doneTapped() {
dismiss(animated: true, completion: nil)
}
}

private extension AddInsightTableViewController {
Expand Down Expand Up @@ -91,7 +97,7 @@ private extension AddInsightTableViewController {
return { [unowned self] row in
self.selectedStat = statSection
self.insightsDelegate?.addInsightSelected?(statSection)
self.navigationController?.popViewController(animated: true)
self.dismiss(animated: true, completion: nil)
}
}

Expand Down
Expand Up @@ -21,11 +21,10 @@ enum InsightType: Int {
case allAnnual

// These Insights will be displayed in this order if a site's Insights have not been customized.
static let defaultInsights = [InsightType.postingActivity,
static let defaultInsights = [InsightType.latestPostSummary,
.todaysStats,
.allTimeStats,
.mostPopularTime,
.comments
.followersTotals
]

static let defaultInsightsValues = InsightType.defaultInsights.map { $0.rawValue }
Expand Down Expand Up @@ -324,7 +323,8 @@ private extension SiteStatsInsightsTableViewController {

let controller = AddInsightTableViewController(insightsDelegate: self,
insightsShown: insightsToShow.compactMap { $0.statSection })
navigationController?.pushViewController(controller, animated: true)
let navigationController = UINavigationController(rootViewController: controller)
present(navigationController, animated: true, completion: nil)
}

func moveInsightUp(_ insight: InsightType) {
Expand Down