diff --git a/Mac/AppDelegate.swift b/Mac/AppDelegate.swift index 203b7d9f1..7ea878eba 100644 --- a/Mac/AppDelegate.swift +++ b/Mac/AppDelegate.swift @@ -179,7 +179,6 @@ let appName = "NetNewsWire" Self.logger.debug("Is first run.") } let localAccount = AccountManager.shared.defaultAccount - if isFirstRun && !AccountManager.shared.anyAccountHasAtLeastOneFeed() { // Import default feeds. DefaultFeedsImporter.importDefaultFeeds(account: localAccount) diff --git a/Mac/Base.lproj/Preferences.storyboard b/Mac/Base.lproj/Preferences.storyboard index 35d4ad895..4ce945c4e 100644 --- a/Mac/Base.lproj/Preferences.storyboard +++ b/Mac/Base.lproj/Preferences.storyboard @@ -532,7 +532,7 @@ - + diff --git a/Mac/MainWindow/NNW3/NNW3OpenPanelAccessoryViewController.swift b/Mac/MainWindow/NNW3/NNW3OpenPanelAccessoryViewController.swift index b7cd973c0..c62c6f1b4 100644 --- a/Mac/MainWindow/NNW3/NNW3OpenPanelAccessoryViewController.swift +++ b/Mac/MainWindow/NNW3/NNW3OpenPanelAccessoryViewController.swift @@ -17,7 +17,8 @@ final class NNW3OpenPanelAccessoryViewController: NSViewController { guard let item: NSMenuItem = accountPopUpButton.selectedItem else { return nil } - return item.representedObject as? Account + let account: Account? = item.representedObject as? Account + return account } init() { diff --git a/Mac/MainWindow/OPML/ExportOPMLWindowController.swift b/Mac/MainWindow/OPML/ExportOPMLWindowController.swift index 0e888094d..909848676 100644 --- a/Mac/MainWindow/OPML/ExportOPMLWindowController.swift +++ b/Mac/MainWindow/OPML/ExportOPMLWindowController.swift @@ -29,14 +29,18 @@ final class ExportOPMLWindowController: NSWindowController { let savedAccountID: String? = AppDefaults.shared.exportOPMLAccountID for oneAccount in accounts { - let oneMenuItem = NSMenuItem() - oneMenuItem.title = oneAccount.nameForDisplay - oneMenuItem.representedObject = oneAccount - menu.addItem(oneMenuItem) + addMenuItem(to: menu, for: oneAccount, savedAccountID: savedAccountID) + } + } - if oneAccount.accountID == savedAccountID { - accountPopUpButton.select(oneMenuItem) - } + private func addMenuItem(to menu: NSMenu, for account: Account, savedAccountID: String?) { + let menuItem = NSMenuItem() + menuItem.title = account.nameForDisplay + menuItem.representedObject = account + menu.addItem(menuItem) + + if account.accountID == savedAccountID { + accountPopUpButton.select(menuItem) } } diff --git a/Mac/MainWindow/OPML/ImportOPMLWindowController.swift b/Mac/MainWindow/OPML/ImportOPMLWindowController.swift index 79c48c2ad..7f68d6ab3 100644 --- a/Mac/MainWindow/OPML/ImportOPMLWindowController.swift +++ b/Mac/MainWindow/OPML/ImportOPMLWindowController.swift @@ -32,15 +32,18 @@ final class ImportOPMLWindowController: NSWindowController { if oneAccount.behaviors.contains(.disallowOPMLImports) { continue } + addMenuItem(to: menu, for: oneAccount, savedAccountID: savedAccountID) + } + } - let oneMenuItem = NSMenuItem() - oneMenuItem.title = oneAccount.nameForDisplay - oneMenuItem.representedObject = oneAccount - menu.addItem(oneMenuItem) + private func addMenuItem(to menu: NSMenu, for account: Account, savedAccountID: String?) { + let menuItem = NSMenuItem() + menuItem.title = account.nameForDisplay + menuItem.representedObject = account + menu.addItem(menuItem) - if oneAccount.accountID == savedAccountID { - accountPopUpButton.select(oneMenuItem) - } + if account.accountID == savedAccountID { + accountPopUpButton.select(menuItem) } } diff --git a/Mac/Preferences/Accounts/AccountsAddCloudKit.xib b/Mac/Preferences/Accounts/AccountsAddCloudKit.xib index ce029a13e..61ff5ac40 100644 --- a/Mac/Preferences/Accounts/AccountsAddCloudKit.xib +++ b/Mac/Preferences/Accounts/AccountsAddCloudKit.xib @@ -1,8 +1,7 @@ - + - - + @@ -18,29 +17,29 @@ - + - + - - + + - - + + @@ -48,7 +47,7 @@ - + @@ -75,16 +74,16 @@ Gw - - + + - - + + @@ -94,7 +93,7 @@ Gw - + diff --git a/Mac/Preferences/Accounts/AccountsDetail.xib b/Mac/Preferences/Accounts/AccountsDetail.xib deleted file mode 100644 index 0fc570b52..000000000 --- a/Mac/Preferences/Accounts/AccountsDetail.xib +++ /dev/null @@ -1,135 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - The name appears in the sidebar. It can be anything you want. You can even use emoji. 🎸 - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/Mac/Preferences/Accounts/AccountsDetailView.swift b/Mac/Preferences/Accounts/AccountsDetailView.swift new file mode 100644 index 000000000..41fcdd4ef --- /dev/null +++ b/Mac/Preferences/Accounts/AccountsDetailView.swift @@ -0,0 +1,115 @@ +// +// AccountsDetailView.swift +// NetNewsWire +// +// Created by Brent Simmons on 3/19/26. +// + +import SwiftUI +import Account + +struct AccountsDetailView: View { + + let account: Account + var onCredentials: (() -> Void)? + + @State private var accountName: String + @State private var isActive: Bool + @State private var syncUnreadContent: Bool + + init(account: Account, onCredentials: (() -> Void)? = nil) { + self.account = account + self.onCredentials = onCredentials + _accountName = State(initialValue: account.name ?? "") + _isActive = State(initialValue: account.isActive) + _syncUnreadContent = State(initialValue: UserDefaults.standard.bool(forKey: Account.iCloudSyncArticleContentForUnreadArticlesKey)) + } + + private var showCredentialsButton: Bool { + switch account.type { + case .onMyMac, .cloudKit, .feedly: + return false + default: + return true + } + } + + var body: some View { + VStack(alignment: .leading, spacing: 0) { + Grid(alignment: .leading, verticalSpacing: 0) { + GridRow(alignment: .firstTextBaseline) { + Text("Type:") + .gridColumnAlignment(.trailing) + Text(account.defaultName) + } + + GridRow { + Color.clear + .gridCellUnsizedAxes([.horizontal, .vertical]) + Toggle("Active", isOn: $isActive) + .onChange(of: isActive) { + account.isActive = isActive + } + .padding(.top, 9) + } + + GridRow(alignment: .firstTextBaseline) { + Text("Name:") + TextField("", text: $accountName) + .frame(width: 150) + .onSubmit { + commitName() + } + .onChange(of: accountName) { + commitName() + } + } + .padding(.top, 14) + + GridRow { + Color.clear + .gridCellUnsizedAxes([.horizontal, .vertical]) + Text("The name can be anything you want. You can even use emoji. 🎸") + .foregroundStyle(.secondary) + .fixedSize(horizontal: false, vertical: true) + .padding(.top, 1) + } + + if showCredentialsButton { + GridRow { + Color.clear + .gridCellUnsizedAxes([.horizontal, .vertical]) + Button("Credentials") { + onCredentials?() + } + .padding(.top, 12) + } + } + } + + if account.type == .cloudKit { + Toggle("Sync content of unread articles", isOn: $syncUnreadContent) + .onChange(of: syncUnreadContent) { + UserDefaults.standard.set(syncUnreadContent, forKey: Account.iCloudSyncArticleContentForUnreadArticlesKey) + } + .padding(.top, 12) + + Text("Syncing article content increases iCloud storage use, sync time, and battery use.\n\nArticle status and the content of starred articles are always synced.") + .foregroundStyle(.secondary) + .fixedSize(horizontal: false, vertical: true) + .padding(.top, 4) + .padding(.leading, 21) + } + } + .padding(20) + .frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .topLeading) + } + + private func commitName() { + if accountName.isEmpty { + account.name = nil + } else { + account.name = accountName + } + } +} diff --git a/Mac/Preferences/Accounts/AccountsDetailViewController.swift b/Mac/Preferences/Accounts/AccountsDetailViewController.swift index 98a20da6e..2c3b4a6ee 100644 --- a/Mac/Preferences/Accounts/AccountsDetailViewController.swift +++ b/Mac/Preferences/Accounts/AccountsDetailViewController.swift @@ -7,64 +7,32 @@ // import AppKit +import SwiftUI import Account -final class AccountsDetailViewController: NSViewController, NSTextFieldDelegate { - @IBOutlet var typeLabel: NSTextField! - @IBOutlet var nameTextField: NSTextField! - @IBOutlet var activeButton: NSButtonCell! - @IBOutlet var credentialsButton: NSButton! +final class AccountsDetailViewController: NSViewController { + private let account: Account private var accountsWindowController: NSWindowController? - private var account: Account? init(account: Account) { - super.init(nibName: "AccountsDetail", bundle: nil) self.account = account + super.init(nibName: nil, bundle: nil) } public required init?(coder: NSCoder) { - super.init(coder: coder) + fatalError("AccountsDetailViewController does not support init(coder:)") } - private var hidesCredentialsButton: Bool { - guard let account = account else { - return true - } - switch account.type { - case .onMyMac, .cloudKit, .feedly: - return true - default: - return false + override func loadView() { + let detailView = AccountsDetailView(account: account) { [weak self] in + self?.showCredentials() } + let hostingView = NSHostingView(rootView: detailView) + self.view = hostingView } - override func viewDidLoad() { - super.viewDidLoad() - - nameTextField.delegate = self - typeLabel.stringValue = account?.defaultName ?? "" - nameTextField.stringValue = account?.name ?? "" - activeButton.state = account?.isActive ?? false ? .on : .off - credentialsButton.isHidden = hidesCredentialsButton - } - - func controlTextDidEndEditing(_ obj: Notification) { - if !nameTextField.stringValue.isEmpty { - account?.name = nameTextField.stringValue - } else { - account?.name = nil - } - } - - @IBAction func active(_ sender: NSButtonCell) { - account?.isActive = sender.state == .on ? true : false - } - - @IBAction func credentials(_ sender: Any) { - guard let account else { - return - } + private func showCredentials() { guard let window = view.window else { return } diff --git a/Modules/Account/Sources/Account/Account.swift b/Modules/Account/Sources/Account/Account.swift index ed9de5368..ba99e706c 100644 --- a/Modules/Account/Sources/Account/Account.swift +++ b/Modules/Account/Sources/Account/Account.swift @@ -101,6 +101,8 @@ public enum FetchType { public static let syncErrors = "syncErrors" // AccountsDidFailToSyncWithErrors } + public static let iCloudSyncArticleContentForUnreadArticlesKey = "iCloudSyncArticleContentForUnreadArticles" + public var isDeleted = false public var containerID: ContainerIdentifier? { diff --git a/Modules/Account/Sources/Account/AccountManager.swift b/Modules/Account/Sources/Account/AccountManager.swift index 0f8eb79d7..ac153c044 100644 --- a/Modules/Account/Sources/Account/AccountManager.swift +++ b/Modules/Account/Sources/Account/AccountManager.swift @@ -123,6 +123,8 @@ import ErrorLog accountsDictionary[defaultAccount.accountID] = defaultAccount readAccountsFromDisk() + + CloudKitAccountDelegate.migrateiCloudSyncArticleContentForUnreadArticlesSetting(hasiCloudAccount: hasiCloudAccount) } public func start() { diff --git a/Modules/Account/Sources/Account/CloudKit/CloudKitAccountDelegate.swift b/Modules/Account/Sources/Account/CloudKit/CloudKitAccountDelegate.swift index 99aafd673..b61566404 100644 --- a/Modules/Account/Sources/Account/CloudKit/CloudKitAccountDelegate.swift +++ b/Modules/Account/Sources/Account/CloudKit/CloudKitAccountDelegate.swift @@ -76,6 +76,15 @@ enum CloudKitAccountDelegateError: LocalizedError, Sendable { } } + static var syncArticleContentForUnreadArticles: Bool { + get { + UserDefaults.standard.bool(forKey: Account.iCloudSyncArticleContentForUnreadArticlesKey) + } + set { + UserDefaults.standard.set(newValue, forKey: Account.iCloudSyncArticleContentForUnreadArticlesKey) + } + } + init(dataFolder: String) { Self.logger.debug("CloudKitAccountDelegate: \(#function, privacy: .public)") self.accountZone = CloudKitAccountZone(container: container) @@ -86,12 +95,22 @@ enum CloudKitAccountDelegateError: LocalizedError, Sendable { self.refresher = LocalAccountRefresher() self.refresher.delegate = self + self.articlesZone.settings = self NotificationCenter.default.addObserver(self, selector: #selector(refreshProgressDidChange(_:)), name: .progressInfoDidChange, object: refresher) NotificationCenter.default.addObserver(self, selector: #selector(syncProgressDidChange(_:)), name: .progressInfoDidChange, object: syncProgress) Self.logger.debug("CloudKitAccountDelegate: \(#function, privacy: .public) did complete") } + static func migrateiCloudSyncArticleContentForUnreadArticlesSetting(hasiCloudAccount: Bool) { + // iCloudSyncArticleContentForUnreadArticles should be set to false unless + // the user already has an iCloud account. + guard UserDefaults.standard.object(forKey: Account.iCloudSyncArticleContentForUnreadArticlesKey) == nil else { + return + } + syncArticleContentForUnreadArticles = hasiCloudAccount + } + func receiveRemoteNotification(for account: Account, userInfo: [AnyHashable: Any]) async { Self.logger.debug("CloudKitAccountDelegate: \(#function, privacy: .public)") await withCheckedContinuation { continuation in @@ -766,7 +785,8 @@ private extension CloudKitAccountDelegate { try await withCheckedThrowingContinuation { (continuation: CheckedContinuation) in let op = CloudKitSendStatusOperation(account: account, articlesZone: articlesZone, - database: syncDatabase) + database: syncDatabase, + settings: self) op.completionBlock = { mainThreadOperation in Self.logger.debug("CloudKitAccountDelegate: \(#function, privacy: .public) did complete") if mainThreadOperation.isCanceled { diff --git a/Modules/Account/Sources/Account/CloudKit/CloudKitArticleStatusUpdate.swift b/Modules/Account/Sources/Account/CloudKit/CloudKitArticleStatusUpdate.swift index 7cd1a2aec..f70852982 100644 --- a/Modules/Account/Sources/Account/CloudKit/CloudKitArticleStatusUpdate.swift +++ b/Modules/Account/Sources/Account/CloudKit/CloudKitArticleStatusUpdate.swift @@ -22,11 +22,13 @@ struct CloudKitArticleStatusUpdate { var articleID: String var statuses: [SyncStatus] var article: Article? + var settings: any CloudKitSettings - init?(articleID: String, statuses: [SyncStatus], article: Article?) { + init?(articleID: String, statuses: [SyncStatus], article: Article?, settings: any CloudKitSettings) { self.articleID = articleID self.statuses = statuses self.article = article + self.settings = settings let rec = record // This is an invalid status update. The article is required for new and all @@ -44,8 +46,11 @@ struct CloudKitArticleStatusUpdate { return .new } - if let article = article { - if article.status.read == false || article.status.starred == true { + if let article { + if article.status.starred { + return .all + } + if !article.status.read && settings.syncArticleContentForUnreadArticles { return .all } } diff --git a/Modules/Account/Sources/Account/CloudKit/CloudKitArticlesZone.swift b/Modules/Account/Sources/Account/CloudKit/CloudKitArticlesZone.swift index 4055ca48f..bc33678a6 100644 --- a/Modules/Account/Sources/Account/CloudKit/CloudKitArticlesZone.swift +++ b/Modules/Account/Sources/Account/CloudKit/CloudKitArticlesZone.swift @@ -17,6 +17,8 @@ import SyncDatabase import CloudKitSync final class CloudKitArticlesZone: CloudKitZone { + + private static let logger = cloudKitLogger var zoneID: CKRecordZone.ID weak var container: CKContainer? @@ -55,6 +57,8 @@ final class CloudKitArticlesZone: CloudKitZone { } } + var settings: (any CloudKitSettings)! + init(container: CKContainer) { self.container = container self.database = container.privateCloudDatabase @@ -82,10 +86,21 @@ final class CloudKitArticlesZone: CloudKitZone { var records = [CKRecord]() - let saveArticles = articles.filter { $0.status.read == false || $0.status.starred == true } - for saveArticle in saveArticles { - records.append(makeStatusRecord(saveArticle)) - records.append(makeArticleRecord(saveArticle)) + let syncUnreadContent = settings.syncArticleContentForUnreadArticles + Self.logger.info("CloudKitArticlesZone: saveNewArticles syncUnreadContent: \(syncUnreadContent, privacy: .public)") + + for article in articles { + if article.status.starred { + records.append(makeStatusRecord(article)) + records.append(makeArticleRecord(article)) + } else if !article.status.read { + records.append(makeStatusRecord(article)) + if syncUnreadContent { + records.append(makeArticleRecord(article)) + } else { + Self.logger.debug("CloudKitArticlesZone: saveNewArticles skipping content for unread article \(article.articleID, privacy: .public)") + } + } } let compressedRecords = await Task.detached(priority: .userInitiated) { @@ -109,6 +124,9 @@ final class CloudKitArticlesZone: CloudKitZone { var newRecords = [CKRecord]() var deleteRecordIDs = [CKRecord.ID]() + let syncUnreadContent = settings.syncArticleContentForUnreadArticles + Self.logger.info("CloudKitArticlesZone: modifyArticles syncUnreadContent: \(syncUnreadContent, privacy: .public)") + for statusUpdate in statusUpdates { switch statusUpdate.record { case .all: @@ -116,7 +134,11 @@ final class CloudKitArticlesZone: CloudKitZone { modifyRecords.append(self.makeArticleRecord(statusUpdate.article!)) case .new: newRecords.append(self.makeStatusRecord(statusUpdate)) - newRecords.append(self.makeArticleRecord(statusUpdate.article!)) + if statusUpdate.article!.status.starred || syncUnreadContent { + newRecords.append(self.makeArticleRecord(statusUpdate.article!)) + } else { + Self.logger.debug("CloudKitArticlesZone: modifyArticles skipping content for unread article \(statusUpdate.articleID, privacy: .public)") + } case .delete: deleteRecordIDs.append(CKRecord.ID(recordName: self.statusID(statusUpdate.articleID), zoneID: zoneID)) case .statusOnly: diff --git a/Modules/Account/Sources/Account/CloudKit/CloudKitSendStatusOperation.swift b/Modules/Account/Sources/Account/CloudKit/CloudKitSendStatusOperation.swift index 086213b08..7f3cd9bd1 100644 --- a/Modules/Account/Sources/Account/CloudKit/CloudKitSendStatusOperation.swift +++ b/Modules/Account/Sources/Account/CloudKit/CloudKitSendStatusOperation.swift @@ -19,12 +19,14 @@ final class CloudKitSendStatusOperation: MainThreadOperation, @unchecked Sendabl private weak var account: Account? private weak var articlesZone: CloudKitArticlesZone? private var syncDatabase: SyncDatabase + private let settings: any CloudKitSettings private static let logger = cloudKitLogger - init(account: Account, articlesZone: CloudKitArticlesZone, database: SyncDatabase) { + init(account: Account, articlesZone: CloudKitArticlesZone, database: SyncDatabase, settings: any CloudKitSettings) { self.account = account self.articlesZone = articlesZone self.syncDatabase = database + self.settings = settings super.init(name: "CloudKitSendStatusOperation") } @@ -81,7 +83,7 @@ final class CloudKitSendStatusOperation: MainThreadOperation, @unchecked Sendabl result[article.articleID] = article } let statusUpdates = syncStatusesDict.compactMap { (key, value) in - CloudKitArticleStatusUpdate(articleID: key, statuses: value, article: articlesDict[key]) + CloudKitArticleStatusUpdate(articleID: key, statuses: value, article: articlesDict[key], settings: self.settings) } // If this happens, we have somehow gotten into a state where we have new status records diff --git a/Modules/Account/Sources/Account/CloudKit/CloudKitSettings.swift b/Modules/Account/Sources/Account/CloudKit/CloudKitSettings.swift new file mode 100644 index 000000000..90e5bace5 --- /dev/null +++ b/Modules/Account/Sources/Account/CloudKit/CloudKitSettings.swift @@ -0,0 +1,19 @@ +// +// CloudKitSettings.swift +// Account +// +// Created by Brent Simmons on 3/18/26. +// + +import Foundation + +protocol CloudKitSettings { + var syncArticleContentForUnreadArticles: Bool { get } +} + +extension CloudKitAccountDelegate: CloudKitSettings { + + var syncArticleContentForUnreadArticles: Bool { + CloudKitAccountDelegate.syncArticleContentForUnreadArticles + } +} diff --git a/iOS/Inspector/AccountInspectorViewController.swift b/iOS/Inspector/AccountInspectorViewController.swift index 8ac64b9f2..57639c02a 100644 --- a/iOS/Inspector/AccountInspectorViewController.swift +++ b/iOS/Inspector/AccountInspectorViewController.swift @@ -17,6 +17,7 @@ final class AccountInspectorViewController: UITableViewController { @IBOutlet var nameTextField: UITextField! @IBOutlet var activeSwitch: UISwitch! @IBOutlet var deleteAccountButton: VibrantButton! + @IBOutlet var syncContentSwitch: UISwitch! @IBOutlet var limitationsAndSolutionsButton: UIButton! var isModal = false @@ -31,6 +32,7 @@ final class AccountInspectorViewController: UITableViewController { nameTextField.text = account.name nameTextField.delegate = self activeSwitch.isOn = account.isActive + syncContentSwitch.isOn = UserDefaults.standard.bool(forKey: Account.iCloudSyncArticleContentForUnreadArticlesKey) navigationItem.title = account.nameForDisplay @@ -56,6 +58,10 @@ final class AccountInspectorViewController: UITableViewController { account?.isActive = activeSwitch.isOn } + @IBAction func syncContentSwitchDidChange(_ sender: UISwitch) { + UserDefaults.standard.set(sender.isOn, forKey: Account.iCloudSyncArticleContentForUnreadArticlesKey) + } + @objc func done() { dismiss(animated: true) } @@ -131,12 +137,24 @@ final class AccountInspectorViewController: UITableViewController { } } -// MARK: Table View +// MARK: - Table View extension AccountInspectorViewController { + /// Sections as laid out in the storyboard. + enum StoryboardSection: Int { + case nameAndActive = 0 + case credentials = 1 + case deleteAccount = 2 + case syncContent = 3 + } + + var isCloudKitAccount: Bool { + account?.type == .cloudKit + } + var hidesCredentialsSection: Bool { - guard let account = account else { + guard let account else { return true } switch account.type { @@ -147,44 +165,69 @@ extension AccountInspectorViewController { } } - override func numberOfSections(in tableView: UITableView) -> Int { - guard let account = account else { return 0 } - - if account == AccountManager.shared.defaultAccount { - return 1 - } else if hidesCredentialsSection { - return 2 - } else { - return super.numberOfSections(in: tableView) + /// The storyboard sections to display, in order, for the current account type. + /// + /// - Default account: name/active only + /// - cloudKit: name/active, sync content, delete + /// - Other hidden-credentials: name/active, delete + /// - All others: name/active, credentials, delete + var displayedSections: [StoryboardSection] { + guard let account else { + return [] } + if account == AccountManager.shared.defaultAccount { + return [.nameAndActive] + } + if isCloudKitAccount { + return [.nameAndActive, .syncContent, .deleteAccount] + } + if hidesCredentialsSection { + return [.nameAndActive, .deleteAccount] + } + return [.nameAndActive, .credentials, .deleteAccount] + } + + override func numberOfSections(in tableView: UITableView) -> Int { + displayedSections.count + } + + override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { + let storyboardIndex = displayedSections[section].rawValue + return super.tableView(tableView, numberOfRowsInSection: storyboardIndex) } override func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat { - return section == 0 ? ImageHeaderView.rowHeight : super.tableView(tableView, heightForHeaderInSection: section) + if displayedSections[section] == .nameAndActive { + return ImageHeaderView.rowHeight + } + let storyboardIndex = displayedSections[section].rawValue + return super.tableView(tableView, heightForHeaderInSection: storyboardIndex) } override func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? { - guard let account = account else { return nil } - - if section == 0 { + guard let account else { + return nil + } + if displayedSections[section] == .nameAndActive { let headerView = tableView.dequeueReusableHeaderFooterView(withIdentifier: "SectionHeader") as! ImageHeaderView headerView.imageView.image = Assets.accountImage(account.type) return headerView - } else { - return super.tableView(tableView, viewForHeaderInSection: section) } + let storyboardIndex = displayedSections[section].rawValue + return super.tableView(tableView, viewForHeaderInSection: storyboardIndex) } override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { - let cell: UITableViewCell + let storyboardIndex = displayedSections[indexPath.section].rawValue + return super.tableView(tableView, cellForRowAt: IndexPath(row: indexPath.row, section: storyboardIndex)) + } - if indexPath.section == 1, hidesCredentialsSection { - cell = super.tableView(tableView, cellForRowAt: IndexPath(row: 0, section: 2)) - } else { - cell = super.tableView(tableView, cellForRowAt: indexPath) + override func tableView(_ tableView: UITableView, titleForFooterInSection section: Int) -> String? { + if displayedSections[section] == .syncContent { + return "Syncing article content increases iCloud storage use, sync time, and battery use.\n\nArticle status and the content of starred articles are always synced." } - - return cell + let storyboardIndex = displayedSections[section].rawValue + return super.tableView(tableView, titleForFooterInSection: storyboardIndex) } override func tableView(_ tableView: UITableView, shouldHighlightRowAt indexPath: IndexPath) -> Bool { diff --git a/iOS/Inspector/Inspector.storyboard b/iOS/Inspector/Inspector.storyboard index c22eeda00..e88729b20 100644 --- a/iOS/Inspector/Inspector.storyboard +++ b/iOS/Inspector/Inspector.storyboard @@ -1,8 +1,8 @@ - + - + @@ -16,7 +16,7 @@ - +