mirror of
https://github.com/Ranchero-Software/NetNewsWire
synced 2025-08-12 06:26:36 +00:00
Adds account-wide to notifications manager
This commit is contained in:
@@ -185,6 +185,10 @@ struct AppAssets {
|
||||
return UIImage(systemName: "ellipsis.circle")!
|
||||
}()
|
||||
|
||||
static var moreImageFill: UIImage = {
|
||||
return UIImage(systemName: "ellipsis.circle.fill")!
|
||||
}()
|
||||
|
||||
static var nextArticleImage: UIImage = {
|
||||
return UIImage(systemName: "chevron.down")!
|
||||
}()
|
||||
|
||||
@@ -43,7 +43,7 @@ class NotificationsViewController: UIViewController {
|
||||
|
||||
filterButton = UIBarButtonItem(
|
||||
title: nil,
|
||||
image: AppAssets.filterInactiveImage,
|
||||
image: AppAssets.moreImage,
|
||||
primaryAction: nil,
|
||||
menu: notificationFilterMenu())
|
||||
|
||||
@@ -70,22 +70,23 @@ class NotificationsViewController: UIViewController {
|
||||
|
||||
private func notificationFilterMenu() -> UIMenu {
|
||||
|
||||
if let filterButton = filterButton {
|
||||
if newArticleNotificationFilter == true {
|
||||
filterButton.image = AppAssets.filterActiveImage
|
||||
if filterButton != nil {
|
||||
if newArticleNotificationFilter {
|
||||
filterButton.image = AppAssets.moreImageFill
|
||||
} else {
|
||||
filterButton.image = AppAssets.filterInactiveImage
|
||||
filterButton.image = AppAssets.moreImage
|
||||
}
|
||||
}
|
||||
|
||||
let menu = UIMenu(title: "",
|
||||
|
||||
let filterMenu = UIMenu(title: "",
|
||||
image: nil,
|
||||
identifier: nil,
|
||||
options: [.displayInline],
|
||||
children: [
|
||||
UIAction(
|
||||
title: NSLocalizedString("Show Feeds with Notifications Enabled", comment: "Feeds with Notifications"),
|
||||
image: AppAssets.appBadgeImage,
|
||||
image: nil,
|
||||
identifier: nil,
|
||||
discoverabilityTitle: nil,
|
||||
attributes: [],
|
||||
@@ -94,7 +95,55 @@ class NotificationsViewController: UIViewController {
|
||||
self?.newArticleNotificationFilter.toggle()
|
||||
self?.notificationsTableView.reloadData()
|
||||
})])
|
||||
return menu
|
||||
|
||||
|
||||
var menus = [UIMenuElement]()
|
||||
menus.append(filterMenu)
|
||||
|
||||
for account in AccountManager.shared.sortedActiveAccounts {
|
||||
let accountMenu = UIMenu(title: account.nameForDisplay, image: nil, identifier: nil, options: .singleSelection, children: [enableAllAction(for: account), disableAllAction(for: account)])
|
||||
menus.append(accountMenu)
|
||||
}
|
||||
|
||||
let combinedMenu = UIMenu(title: "",
|
||||
image: nil,
|
||||
identifier: nil,
|
||||
options: .displayInline,
|
||||
children: menus)
|
||||
|
||||
return combinedMenu
|
||||
}
|
||||
|
||||
private func enableAllAction(for account: Account) -> UIAction {
|
||||
let action = UIAction(title: NSLocalizedString("Enable All Notifications", comment: "Enable All"),
|
||||
image: nil,
|
||||
identifier: nil,
|
||||
discoverabilityTitle: nil,
|
||||
attributes: [],
|
||||
state: .off) { [weak self] _ in
|
||||
for feed in account.flattenedWebFeeds() {
|
||||
feed.isNotifyAboutNewArticles = true
|
||||
}
|
||||
self?.notificationsTableView.reloadData()
|
||||
self?.filterButton.menu = self?.notificationFilterMenu()
|
||||
}
|
||||
return action
|
||||
}
|
||||
|
||||
private func disableAllAction(for account: Account) -> UIAction {
|
||||
let action = UIAction(title: NSLocalizedString("Disable All Notifications", comment: "Disable All"),
|
||||
image: nil,
|
||||
identifier: nil,
|
||||
discoverabilityTitle: nil,
|
||||
attributes: [],
|
||||
state: .off) { [weak self] _ in
|
||||
for feed in account.flattenedWebFeeds() {
|
||||
feed.isNotifyAboutNewArticles = false
|
||||
}
|
||||
self?.notificationsTableView.reloadData()
|
||||
self?.filterButton.menu = self?.notificationFilterMenu()
|
||||
}
|
||||
return action
|
||||
}
|
||||
|
||||
// MARK: - Feed Filtering
|
||||
|
||||
@@ -43,7 +43,7 @@
|
||||
<rect key="frame" x="0.0" y="0.0" width="345.5" height="43.5"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<subviews>
|
||||
<label opaque="NO" multipleTouchEnabled="YES" contentMode="left" insetsLayoutMarginsFromSafeArea="NO" text="Notifications" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontForContentSizeCategory="YES" adjustsFontSizeToFit="NO" id="l7X-8L-61m">
|
||||
<label opaque="NO" multipleTouchEnabled="YES" contentMode="left" insetsLayoutMarginsFromSafeArea="NO" text="New Article Notifications" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontForContentSizeCategory="YES" adjustsFontSizeToFit="NO" id="l7X-8L-61m">
|
||||
<rect key="frame" x="20" y="0.0" width="317.5" height="43.5"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<fontDescription key="fontDescription" style="UICTFontTextStyleBody"/>
|
||||
|
||||
Reference in New Issue
Block a user