diff --git a/Mastodon/Scene/Notification/Notification Filtering/NotificationPolicyFilterTableViewCell.swift b/Mastodon/Scene/Notification/Notification Filtering/NotificationPolicyFilterTableViewCell.swift index 8359d95e9..f07f1b066 100644 --- a/Mastodon/Scene/Notification/Notification Filtering/NotificationPolicyFilterTableViewCell.swift +++ b/Mastodon/Scene/Notification/Notification Filtering/NotificationPolicyFilterTableViewCell.swift @@ -17,6 +17,9 @@ class NotificationPolicyFilterTableViewCell: ToggleTableViewCell { override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) { super.init(style: style, reuseIdentifier: reuseIdentifier) + label.font = UIFontMetrics(forTextStyle: .body).scaledFont(for: .systemFont(ofSize: 17, weight: .semibold)) + subtitleLabel.textColor = .secondaryLabel + toggle.addTarget(self, action: #selector(NotificationPolicyFilterTableViewCell.toggleValueChanged(_:)), for: .valueChanged) } diff --git a/Mastodon/Scene/Notification/Notification Filtering/NotificationPolicyViewController.swift b/Mastodon/Scene/Notification/Notification Filtering/NotificationPolicyViewController.swift index d9e2b8761..e1f09c3c5 100644 --- a/Mastodon/Scene/Notification/Notification Filtering/NotificationPolicyViewController.swift +++ b/Mastodon/Scene/Notification/Notification Filtering/NotificationPolicyViewController.swift @@ -2,6 +2,7 @@ import UIKit import MastodonLocalization +import MastodonAsset enum NotificationFilterSection: Hashable { case main @@ -14,6 +15,7 @@ enum NotificationFilterItem: Hashable, CaseIterable { case privateMentions var title: String { + // TODO: Localization switch self { case .notFollowing: return "People you don't follow" @@ -27,6 +29,7 @@ enum NotificationFilterItem: Hashable, CaseIterable { } var subtitle: String { + // TODO: Localization switch self { case .notFollowing: return "Until you manually approve them" @@ -56,7 +59,6 @@ struct NotificationFilterViewModel { class NotificationPolicyViewController: UIViewController { - //TODO: DataSource, Source, Items let tableView: UITableView var dataSource: UITableViewDiffableDataSource? let items: [NotificationFilterItem] @@ -77,8 +79,6 @@ class NotificationPolicyViewController: UIViewController { fatalError("No NotificationPolicyFilterTableViewCell") } - //TODO: Configuration - let item = items[indexPath.row] cell.configure(with: item, viewModel: self.viewModel) cell.delegate = self @@ -86,6 +86,9 @@ class NotificationPolicyViewController: UIViewController { return cell } + // TODO: Localization + title = "Filter Notifications from" + tableView.dataSource = dataSource tableView.delegate = self @@ -137,6 +140,22 @@ class NotificationPolicyViewController: UIViewController { extension NotificationPolicyViewController: UITableViewDelegate { func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { tableView.deselectRow(at: indexPath, animated: true) + + let filterItem = items[indexPath.row] + switch filterItem { + case .notFollowing: + viewModel.notFollowing.toggle() + case .noFollower: + viewModel.noFollower.toggle() + case .newAccount: + viewModel.newAccount.toggle() + case .privateMentions: + viewModel.privateMentions.toggle() + } + + if let snapshot = dataSource?.snapshot() { + dataSource?.applySnapshotUsingReloadData(snapshot) + } } } diff --git a/Mastodon/Scene/Settings/Shared/ToggleTableViewCell.swift b/Mastodon/Scene/Settings/Shared/ToggleTableViewCell.swift index 0b49875ea..db47a7f75 100644 --- a/Mastodon/Scene/Settings/Shared/ToggleTableViewCell.swift +++ b/Mastodon/Scene/Settings/Shared/ToggleTableViewCell.swift @@ -27,6 +27,7 @@ class ToggleTableViewCell: UITableViewCell { labelStackView.translatesAutoresizingMaskIntoConstraints = false labelStackView.alignment = .leading labelStackView.axis = .vertical + labelStackView.spacing = 4 toggle = UISwitch() toggle.translatesAutoresizingMaskIntoConstraints = false