From f5365a9d6eff55c6a65d67986a8f47d8a17de94f Mon Sep 17 00:00:00 2001 From: Nathan Mattes Date: Tue, 26 Sep 2023 15:49:58 +0200 Subject: [PATCH] Toggle alerts on tap (IOS-14) This feels kind of good :D --- .../NotificationSettingsViewController.swift | 16 ++++++++++++---- .../Settings/Shared/ToggleTableViewCell.swift | 1 - 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/Mastodon/Scene/Settings/Notification Settings/NotificationSettingsViewController.swift b/Mastodon/Scene/Settings/Notification Settings/NotificationSettingsViewController.swift index c56c23e4c..50eaeb9be 100644 --- a/Mastodon/Scene/Settings/Notification Settings/NotificationSettingsViewController.swift +++ b/Mastodon/Scene/Settings/Notification Settings/NotificationSettingsViewController.swift @@ -110,11 +110,19 @@ extension NotificationSettingsViewController: UITableViewDelegate { let entry = sections[indexPath.section].entries[indexPath.row] + switch entry { - case .alert(_): - break - case .policy: - delegate?.showPolicyList(self, viewModel: viewModel) + case .alert(let alert): + + guard let cell = tableView.cellForRow(at: indexPath) as? NotificationSettingTableViewToggleCell else { return } + + let newValue = (cell.toggle.isOn == false) + cell.toggle.setOn(newValue, animated: true) + + toggleValueChanged(cell, alert: alert, newValue: newValue) + + case .policy: + delegate?.showPolicyList(self, viewModel: viewModel) } tableView.deselectRow(at: indexPath, animated: true) diff --git a/Mastodon/Scene/Settings/Shared/ToggleTableViewCell.swift b/Mastodon/Scene/Settings/Shared/ToggleTableViewCell.swift index 47e595d66..11454d9e6 100644 --- a/Mastodon/Scene/Settings/Shared/ToggleTableViewCell.swift +++ b/Mastodon/Scene/Settings/Shared/ToggleTableViewCell.swift @@ -23,7 +23,6 @@ class ToggleTableViewCell: UITableViewCell { toggle.onTintColor = Asset.Colors.Brand.blurple.color super.init(style: style, reuseIdentifier: reuseIdentifier) - contentView.addSubview(label) contentView.addSubview(toggle)