✨ Notification manager for iOS

This commit is contained in:
Stuart Breckenridge committed 2026-02-07 16:39:03 +08:00
1 parent 3aea87bad1
commit a35c20f7ff
3 files changed
+67

No files matched your search

@@ -0,0 +1,50 @@
//
// AccountNotificationInspectorView.swift
// NetNewsWire-iOS
//
// Created by Stuart Breckenridge on 07/02/2026.
// Copyright © 2026 Ranchero Software. All rights reserved.
//
import SwiftUI
import UserNotifications
import Account
struct AccountNotificationInspectorView: View {
@Environment(\.dismiss) private var dismiss
var account: Account!
var body: some View {
NavigationStack {
List(account.flattenedFeeds().sorted(by: { a, b in
a.nameForDisplay < b.nameForDisplay
}), id: \.feedID) { feed in
Toggle(isOn: Binding(get: { feed.isNotifyAboutNewArticles ?? false }, set: { feed.isNotifyAboutNewArticles = $0 })) {
HStack {
if feed.smallIcon != nil {
Image(uiImage: feed.smallIcon!.image)
.resizable()
.frame(width: 24, height: 24)
.clipShape(RoundedRectangle(cornerRadius: 4.0, style: .continuous))
}
Text(verbatim: feed.nameForDisplay)
Spacer()
}
}
.tint(.accentColor)
}
.navigationTitle(Text("New Article Notifications", comment: "New Article Notifications"))
.navigationBarTitleDisplayMode(.inline)
.toolbar {
ToolbarItem(placement: .topBarTrailing) {
Button(role: .close) {
dismiss()
}
}
}
}
}
}
@@ -856,6 +856,8 @@ extension MainFeedCollectionViewController: UIContextMenuInteractionDelegate {
var menuElements = [UIMenuElement]()
menuElements.append(UIMenu(title: "", options: .displayInline, children: [self.getAccountInfoAction(account: account)]))
menuElements.append(UIMenu(title: "", options: .displayInline, children: [self.getAccountNotificationsAction(account: account)]))
if let markAllAction = self.markAllAsReadAction(account: account, contentView: interaction.view) {
menuElements.append(UIMenu(title: "", options: .displayInline, children: [markAllAction]))
}
@@ -1101,6 +1103,14 @@ extension MainFeedCollectionViewController {
}
return action
}
func getAccountNotificationsAction(account: Account) -> UIAction {
let title = NSLocalizedString("Notifications", comment: "Notifications")
let action = UIAction(title: title, image: UIImage(systemName: "bell.badge")) { [weak self] _ in
self?.coordinator.showNotificationInspector(for: account)
}
return action
}
func deactivateAccountAction(account: Account) -> UIAction {
let title = NSLocalizedString("Deactivate", comment: "Deactivate")
+7
View File
@@ -14,6 +14,7 @@ import Articles
import RSCore
import RSTree
import SafariServices
import SwiftUI
enum SearchScope: Int {
case timeline = 0
@@ -1347,6 +1348,12 @@ struct SidebarItemNode: Hashable, Sendable {
accountInspectorController.account = account
rootSplitViewController.present(accountInspectorNavController, animated: true)
}
func showNotificationInspector(for account: Account) {
let hostingController = UIHostingController(rootView: AccountNotificationInspectorView(account: account))
hostingController.modalPresentationStyle = .formSheet
rootSplitViewController.present(hostingController, animated: true)
}
func showFeedInspector() {
guard let feed = timelineFeed as? Feed ?? currentArticle?.feed else {