Add first-class Actions management (#63)
This commit is contained in:
@@ -29,25 +29,29 @@ final class SettingsViewController: UITableViewController {
|
||||
override func viewWillAppear(_ animated: Bool) {
|
||||
super.viewWillAppear(animated)
|
||||
notificationSwitch.isOn = context.core.settings().notificationsEnabled
|
||||
tableView.reloadSections(IndexSet(integer: 1), with: .none)
|
||||
Task {
|
||||
notificationStatus = await context.notifications.authorizationDescription()
|
||||
updateNotificationSettingsCell()
|
||||
}
|
||||
}
|
||||
|
||||
override func numberOfSections(in tableView: UITableView) -> Int { 2 }
|
||||
override func numberOfSections(in tableView: UITableView) -> Int { 3 }
|
||||
override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
|
||||
section == 0 ? 1 : 2
|
||||
section == 2 ? 2 : 1
|
||||
}
|
||||
|
||||
override func tableView(_ tableView: UITableView, titleForHeaderInSection section: Int) -> String? {
|
||||
section == 0 ? "Appearance" : "Notifications"
|
||||
["Appearance", "Navigation", "Notifications"][section]
|
||||
}
|
||||
|
||||
override func tableView(_ tableView: UITableView, titleForFooterInSection section: Int) -> String? {
|
||||
if section == 0 {
|
||||
return "Follow iOS automatically or choose a fixed appearance."
|
||||
}
|
||||
if section == 1 {
|
||||
return "Home is always present. Choose and order up to four additional destinations."
|
||||
}
|
||||
return "Gotcha checks periodically for server notifications. iOS decides when background refresh runs; delivery style, sounds, Focus, and summaries remain under your control in iOS Settings."
|
||||
}
|
||||
|
||||
@@ -55,6 +59,15 @@ final class SettingsViewController: UITableViewController {
|
||||
_ tableView: UITableView,
|
||||
cellForRowAt indexPath: IndexPath
|
||||
) -> UITableViewCell {
|
||||
if indexPath.section == 1 {
|
||||
let cell = UITableViewCell(style: .value1, reuseIdentifier: nil)
|
||||
var content = cell.defaultContentConfiguration()
|
||||
content.text = "Primary Destinations"
|
||||
content.secondaryText = "\(context.primaryDestinations.count) selected"
|
||||
cell.contentConfiguration = content
|
||||
cell.accessoryType = .disclosureIndicator
|
||||
return cell
|
||||
}
|
||||
guard indexPath.section == 0 else {
|
||||
if indexPath.row == 0 {
|
||||
let cell = UITableViewCell(style: .default, reuseIdentifier: nil)
|
||||
@@ -87,8 +100,14 @@ final class SettingsViewController: UITableViewController {
|
||||
|
||||
override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
|
||||
tableView.deselectRow(at: indexPath, animated: true)
|
||||
guard indexPath.section == 1, indexPath.row == 1 else { return }
|
||||
context.notifications.openSystemSettings()
|
||||
if indexPath.section == 1 {
|
||||
navigationController?.pushViewController(
|
||||
NavigationSettingsViewController(context: context),
|
||||
animated: true
|
||||
)
|
||||
} else if indexPath.section == 2, indexPath.row == 1 {
|
||||
context.notifications.openSystemSettings()
|
||||
}
|
||||
}
|
||||
|
||||
@objc private func appearanceChanged() {
|
||||
@@ -119,7 +138,7 @@ final class SettingsViewController: UITableViewController {
|
||||
}
|
||||
|
||||
private func updateNotificationSettingsCell() {
|
||||
guard let cell = tableView.cellForRow(at: IndexPath(row: 1, section: 1)) else { return }
|
||||
guard let cell = tableView.cellForRow(at: IndexPath(row: 1, section: 2)) else { return }
|
||||
var content = cell.defaultContentConfiguration()
|
||||
content.text = "Notification Settings"
|
||||
content.secondaryText = notificationStatus
|
||||
|
||||
Reference in New Issue
Block a user