From a35c20f7ff5752c332a1d021df13d827d01969c8 Mon Sep 17 00:00:00 2001 From: Stuart Breckenridge Date: Sat, 7 Feb 2026 16:39:03 +0800 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20Notification=20manager=20for=20iOS?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../AccountNotificationInspectorView.swift | 50 +++++++++++++++++++ .../MainFeedCollectionViewController.swift | 10 ++++ iOS/SceneCoordinator.swift | 7 +++ 3 files changed, 67 insertions(+) create mode 100644 iOS/Account/AccountNotificationInspectorView.swift diff --git a/iOS/Account/AccountNotificationInspectorView.swift b/iOS/Account/AccountNotificationInspectorView.swift new file mode 100644 index 000000000..e81fd4480 --- /dev/null +++ b/iOS/Account/AccountNotificationInspectorView.swift @@ -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() + } + } + } + } + } +} + diff --git a/iOS/MainFeed/MainFeedCollectionViewController.swift b/iOS/MainFeed/MainFeedCollectionViewController.swift index ce9a18212..6e3a75642 100644 --- a/iOS/MainFeed/MainFeedCollectionViewController.swift +++ b/iOS/MainFeed/MainFeedCollectionViewController.swift @@ -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") diff --git a/iOS/SceneCoordinator.swift b/iOS/SceneCoordinator.swift index 5021a0c3e..185de0356 100644 --- a/iOS/SceneCoordinator.swift +++ b/iOS/SceneCoordinator.swift @@ -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 {