Skip to content

Commit

Permalink
Stats: Open People -> Subscribers from Subscribers List card (#23077
Browse files Browse the repository at this point in the history
)
  • Loading branch information
guarani authored Apr 26, 2024
2 parents 26a669d + 83df7d6 commit 7d360c3
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 17 deletions.
39 changes: 30 additions & 9 deletions WordPress/Classes/ViewRelated/People/PeopleViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ class PeopleViewController: UITableViewController {
}
}

/// Default Filter value when People loads
///
fileprivate var defaultFilter = Filter.users

/// NoResults Helper
///
private let noResultsViewController = NoResultsViewController.controller()
Expand Down Expand Up @@ -240,12 +244,9 @@ extension PeopleViewController: NetworkStatusDelegate {
}
}

// MARK: - Private behavior

private extension PeopleViewController {

// MARK: Enums
// MARK: - Enum

extension PeopleViewController {
enum Filter: String, CaseIterable, FilterTabBarItem {

case users = "users"
Expand All @@ -262,11 +263,11 @@ private extension PeopleViewController {
case .users:
return NSLocalizedString("Users", comment: "Blog Users")
case .followers:
return NSLocalizedString("Followers", comment: "Blog Followers")
return NSLocalizedString("users.list.title.subscribers", value: "Subscribers", comment: "Site Subscribers")
case .viewers:
return NSLocalizedString("Viewers", comment: "Blog Viewers")
case .email:
return NSLocalizedString("Email Followers", comment: "Blog Email Followers")
return NSLocalizedString("users.list.title.subscribers", value: "Email Subscribers", comment: "Site Email Subscribers")
}
}

Expand Down Expand Up @@ -296,6 +297,11 @@ private extension PeopleViewController {
}
}
}
}

// MARK: - Private behavior

private extension PeopleViewController {

enum Storyboard {
static let inviteSegueIdentifier = "invite"
Expand Down Expand Up @@ -497,8 +503,9 @@ private extension PeopleViewController {
filterBar.items = filtersAvailableForBlog(blog)
filterBar.addTarget(self, action: #selector(selectedFilterDidChange(_:)), for: .valueChanged)

// By default, let's display the Blog's Users
filter = .users
let indexToSet = Filter.allCases.firstIndex(where: { $0 == defaultFilter }) ?? 0
filterBar.setSelectedIndex(indexToSet)
filter = defaultFilter
}

func setupTableView() {
Expand Down Expand Up @@ -555,3 +562,17 @@ extension PeopleViewController {
WPAnalytics.track(.peopleFilterChanged, properties: [:], blog: blog)
}
}

extension PeopleViewController {
class func controllerWithBlog(_ blog: Blog, selectedFilter: Filter) -> PeopleViewController? {
let storyboard = UIStoryboard(name: "People", bundle: nil)
guard let viewController = storyboard.instantiateInitialViewController() as? PeopleViewController else {
return nil
}

viewController.defaultFilter = selectedFilter
viewController.blog = blog

return viewController
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,13 @@ final class PersonViewController: UITableViewController {
var title: String {
switch self {
case .User:
return NSLocalizedString("Blog's User", comment: "Blog's User Profile. Displayed when the name is empty!")
return NSLocalizedString("user.details.title.user", value: "Site's User", comment: "Sites's User Profile. Displayed when the name is empty!")
case .Follower:
return NSLocalizedString("Blog's Follower", comment: "Blog's Follower Profile. Displayed when the name is empty!")
return NSLocalizedString("user.details.title.subscriber", value: "Site's Subscriber", comment: "Site's Subscriber Profile. Displayed when the name is empty!")
case .Viewer:
return NSLocalizedString("Blog's Viewer", comment: "Blog's Viewer Profile. Displayed when the name is empty!")
return NSLocalizedString("user.details.title.viewer", value: "Site's Viewer", comment: "Site's Viewers Profile. Displayed when the name is empty!")
case .Email:
return NSLocalizedString("Blog's Email Follower", comment: "Blog's Email Follower Profile. Displayed when the name is empty!")
return NSLocalizedString("user.details.title.emailSubscriber", value: "Site's Email Subscriber", comment: "Site's Email Subscriber Profile. Displayed when the name is empty!")
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,10 @@ private extension ViewMoreRow {
backgroundColor = .listForeground
viewMoreLabel.text = NSLocalizedString("View more", comment: "Label for viewing more stats.")
viewMoreLabel.textColor = WPStyleGuide.Stats.actionTextColor
if statSection == .insightsFollowersWordPress || statSection == .insightsFollowersEmail {
if statSection == .insightsFollowersWordPress ||
statSection == .insightsFollowersEmail ||
statSection == .subscribersList ||
statSection == .subscribersEmailsSummary {
disclosureImageView.isHidden = true
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,18 @@ final class StatsSubscribersViewController: SiteStatsBaseTableViewController {

extension StatsSubscribersViewController: SiteStatsPeriodDelegate {
func viewMoreSelectedForStatSection(_ statSection: StatSection) {
let detailTableViewController = SiteStatsDetailTableViewController.loadFromStoryboard()
detailTableViewController.configure(statSection: statSection)
navigationController?.pushViewController(detailTableViewController, animated: true)
switch statSection {
case .subscribersList:
guard let blog = RootViewCoordinator.sharedPresenter.mySitesCoordinator.currentBlog,
let peopleViewController = PeopleViewController.controllerWithBlog(blog, selectedFilter: .followers) else { return }
navigationController?.pushViewController(peopleViewController, animated: true)
case .subscribersEmailsSummary:
let detailTableViewController = SiteStatsDetailTableViewController.loadFromStoryboard()
detailTableViewController.configure(statSection: statSection)
navigationController?.pushViewController(detailTableViewController, animated: true)
default:
// TODO
DDLogInfo("\(statSection) selected")
}
}
}

0 comments on commit 7d360c3

Please sign in to comment.