Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Modules/Sources/JetpackStats/Constants.swift
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import SwiftUI
import ColorStudio

enum Constants {
public enum Constants {
enum Colors {
static let positiveChangeForeground = Color(UIColor(
light: UIColor(red: 0.2, green: 0.6, blue: 0.2, alpha: 1.0),
Expand Down Expand Up @@ -69,7 +69,7 @@ enum Constants {
static let cardHorizontalInsetCompact: CGFloat = step1

/// Returns the appropriate horizontal card inset for the given size class
static func cardHorizontalInset(for sizeClass: UserInterfaceSizeClass?) -> CGFloat {
public static func cardHorizontalInset(for sizeClass: UserInterfaceSizeClass?) -> CGFloat {
sizeClass == .regular ? cardHorizontalInsetRegular : cardHorizontalInsetCompact
}

Expand Down
2 changes: 1 addition & 1 deletion Modules/Sources/JetpackStats/Screens/TrafficTabView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ struct TrafficTabView: View {
buttonAddChart
timeZoneInfo
}
.padding(.vertical, Constants.step2 + (horizontalSizeClass == .regular ? Constants.step1 : 0))
.padding(.vertical, Constants.step2)
.padding(.horizontal, Constants.cardHorizontalInset(for: horizontalSizeClass))
.padding(.top, topPadding)
.onReceive(viewModel.scrollToCardSubject) { cardID in
Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,17 @@
import UIKit
import DesignSystem
import SwiftUI
import WordPressUI
import JetpackStats

/// Base class for site stats table view controllers
///

class SiteStatsBaseTableViewController: UIViewController {

let refreshControl = UIRefreshControl()

/// This property must be set before viewDidLoad is called - currently the classes that inherit are created from storyboards
/// When storyboard is removed it can be passed in as a parameter in an initializer
var tableStyle: UITableView.Style = .grouped
var tableStyle: UITableView.Style { .insetGrouped }

// MARK: - Properties
lazy var tableView: UITableView = {
UITableView(frame: .zero, style: tableStyle)
}()
private(set) lazy var tableView = UITableView(frame: .zero, style: tableStyle)

override func viewDidLoad() {
super.viewDidLoad()
Expand All @@ -28,16 +24,29 @@ class SiteStatsBaseTableViewController: UIViewController {
}

func initTableView() {
tableView.translatesAutoresizingMaskIntoConstraints = false
tableView.cellLayoutMarginsFollowReadableWidth = true

if #available(iOS 26, *) {
tableView.preservesSuperviewLayoutMargins = false
}

view.addSubview(tableView)
view.pinSubviewToAllEdges(tableView)
tableView.pinEdges()

tableView.refreshControl = refreshControl
}

override func traitCollectionDidChange(_ previousTraitCollection: UITraitCollection?) {
super.traitCollectionDidChange(previousTraitCollection)

if #available(iOS 26, *) {
let inset = JetpackStats.Constants.cardHorizontalInset(for: UserInterfaceSizeClass(traitCollection.horizontalSizeClass))
tableView.directionalLayoutMargins = .init(top: 0, leading: inset, bottom: 0, trailing: inset)
}
}
}

// MARK: - Tableview Datasource
// MARK: - UITableViewDataSource

// These methods aren't actually needed as the tableview is controlled by an instance of ImmuTableViewHandler.
// However, ImmuTableViewHandler requires that the owner of the tableview is a data source and delegate.
Expand All @@ -52,14 +61,14 @@ extension SiteStatsBaseTableViewController: TableViewContainer, UITableViewDataS
}

func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
return UITableViewCell()
UITableViewCell()
}

func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
return .DS.Padding.double
if #available(iOS 26, *) { 30 } else { 16 }
}

func tableView(_ tableView: UITableView, heightForFooterInSection section: Int) -> CGFloat {
return 0
0
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -52,17 +52,6 @@ class SiteStatsInsightsTableViewController: SiteStatsBaseTableViewController {
return ImmuTableDiffableViewHandler(takeOver: self, with: analyticsTracker)
}()

// MARK: - Initialization

init() {
super.init(nibName: nil, bundle: nil)
tableStyle = .insetGrouped
}

required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}

// MARK: - View

override func viewDidLoad() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ final class SiteStatsPeriodTableViewController: SiteStatsBaseTableViewController
datePickerViewModel = StatsTrafficDatePickerViewModel(period: period, date: date)
datePickerView = StatsTrafficDatePickerView(viewModel: datePickerViewModel)
super.init(nibName: nil, bundle: nil)
tableStyle = .insetGrouped
}

required init?(coder: NSCoder) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ class SiteStatsInsightsDetailsTableViewController: SiteStatsBaseTableViewControl
self.selectedDate = selectedDate ?? StatsDataHelper.currentDateForSite()
self.selectedPeriod = selectedPeriod
self.postID = postID
tableStyle = .insetGrouped
title = statSection.detailsTitle
initViewModel()
updateHeader()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ final class StatsSubscribersViewController: SiteStatsBaseTableViewController {
init(viewModel: StatsSubscribersViewModel) {
self.viewModel = viewModel
super.init(nibName: nil, bundle: nil)

tableStyle = .insetGrouped
}

required init?(coder: NSCoder) {
Expand Down