From 98999c0cc15f3a8885680ec21d3a6522bc11a3c4 Mon Sep 17 00:00:00 2001 From: Maurice Parker Date: Sun, 12 Sep 2021 16:18:55 -0500 Subject: [PATCH] Add Theme selector to iOS --- NetNewsWire.xcodeproj/project.pbxproj | 4 + .../ArticleThemesTableViewController.swift | 51 ++++++++ iOS/Settings/Settings.storyboard | 110 +++++++++++++++--- iOS/Settings/SettingsViewController.swift | 17 ++- 4 files changed, 158 insertions(+), 24 deletions(-) create mode 100644 iOS/Settings/ArticleThemesTableViewController.swift diff --git a/NetNewsWire.xcodeproj/project.pbxproj b/NetNewsWire.xcodeproj/project.pbxproj index d4c281256..8576f7e57 100644 --- a/NetNewsWire.xcodeproj/project.pbxproj +++ b/NetNewsWire.xcodeproj/project.pbxproj @@ -186,6 +186,7 @@ 510C418624E5D1B4008226FD /* ExtensionFeedAddRequest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 51B5C87A23F2317700032075 /* ExtensionFeedAddRequest.swift */; }; 510C43F7243D035C009F70C3 /* ExtensionPoint.swift in Sources */ = {isa = PBXBuildFile; fileRef = 510C43F6243D035C009F70C3 /* ExtensionPoint.swift */; }; 510C43F8243D035C009F70C3 /* ExtensionPoint.swift in Sources */ = {isa = PBXBuildFile; fileRef = 510C43F6243D035C009F70C3 /* ExtensionPoint.swift */; }; + 510FFAB326EEA22C00F32265 /* ArticleThemesTableViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 510FFAB226EEA22C00F32265 /* ArticleThemesTableViewController.swift */; }; 51102165233A7D6C0007A5F7 /* ArticleExtractorButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = 51102164233A7D6C0007A5F7 /* ArticleExtractorButton.swift */; }; 51107746243BEE2500D97C8C /* ExtensionPointPreferencesViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 51107745243BEE2500D97C8C /* ExtensionPointPreferencesViewController.swift */; }; 51107747243BEE2500D97C8C /* ExtensionPointPreferencesViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 51107745243BEE2500D97C8C /* ExtensionPointPreferencesViewController.swift */; }; @@ -1624,6 +1625,7 @@ 510C416624E5CDE3008226FD /* ShareExtension.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = ShareExtension.entitlements; sourceTree = ""; }; 510C418724E5D2E3008226FD /* NetNewsWire_shareextension_target.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = NetNewsWire_shareextension_target.xcconfig; sourceTree = ""; }; 510C43F6243D035C009F70C3 /* ExtensionPoint.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ExtensionPoint.swift; sourceTree = ""; }; + 510FFAB226EEA22C00F32265 /* ArticleThemesTableViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ArticleThemesTableViewController.swift; sourceTree = ""; }; 51102164233A7D6C0007A5F7 /* ArticleExtractorButton.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ArticleExtractorButton.swift; sourceTree = ""; }; 51107745243BEE2500D97C8C /* ExtensionPointPreferencesViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ExtensionPointPreferencesViewController.swift; sourceTree = ""; }; 5110C37C2373A8D100A9C04F /* InspectorIconHeaderView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = InspectorIconHeaderView.swift; sourceTree = ""; }; @@ -2797,6 +2799,7 @@ 51A16992235E10D600EB091F /* AddAccountViewController.swift */, 519ED47924482AEB007F8E94 /* EnableExtensionPointViewController.swift */, 519ED455244828C3007F8E94 /* AddExtensionPointViewController.swift */, + 510FFAB226EEA22C00F32265 /* ArticleThemesTableViewController.swift */, 516244E2241E19F000B61C47 /* ColorPaletteTableViewController.swift */, 516A09382360A2AE00EAE89B /* SettingsComboTableViewCell.swift */, 516A091D23609A3600EAE89B /* SettingsComboTableViewCell.xib */, @@ -5625,6 +5628,7 @@ 51627A6723861DA3007B3B4B /* MasterFeedViewController+Drag.swift in Sources */, 51FFF0C4235EE8E5002762AA /* VibrantButton.swift in Sources */, 51C45259226508D300C03939 /* AppDefaults.swift in Sources */, + 510FFAB326EEA22C00F32265 /* ArticleThemesTableViewController.swift in Sources */, 51CE1C0B23622007005548FC /* RefreshProgressView.swift in Sources */, 511D4419231FC02D00FB1562 /* KeyboardManager.swift in Sources */, 51A1699D235E10D700EB091F /* SettingsViewController.swift in Sources */, diff --git a/iOS/Settings/ArticleThemesTableViewController.swift b/iOS/Settings/ArticleThemesTableViewController.swift new file mode 100644 index 000000000..e49d2da92 --- /dev/null +++ b/iOS/Settings/ArticleThemesTableViewController.swift @@ -0,0 +1,51 @@ +// +// ArticleThemesTableViewController.swift +// NetNewsWire-iOS +// +// Created by Maurice Parker on 9/12/21. +// Copyright © 2021 Ranchero Software. All rights reserved. +// + +import Foundation + +import UIKit + +class ArticleThemesTableViewController: UITableViewController { + + // MARK: - Table view data source + + override func numberOfSections(in tableView: UITableView) -> Int { + return 1 + } + + override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { + return ArticleThemesManager.shared.themeNames.count + 1 + } + + override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { + let cell = tableView.dequeueReusableCell(withIdentifier: "Cell", for: indexPath) + + let themeName: String + if indexPath.row == 0 { + themeName = ArticleTheme.defaultTheme.name + } else { + themeName = ArticleThemesManager.shared.themeNames[indexPath.row - 1] + } + + cell.textLabel?.text = themeName + if themeName == ArticleThemesManager.shared.currentTheme.name { + cell.accessoryType = .checkmark + } else { + cell.accessoryType = .none + } + + return cell + } + + override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { + guard let cell = tableView.cellForRow(at: indexPath), let themeName = cell.textLabel?.text else { return } + ArticleThemesManager.shared.currentThemeName = themeName + navigationController?.popViewController(animated: true) + } + +} diff --git a/iOS/Settings/Settings.storyboard b/iOS/Settings/Settings.storyboard index c15ab7f81..9cb9246b5 100644 --- a/iOS/Settings/Settings.storyboard +++ b/iOS/Settings/Settings.storyboard @@ -264,9 +264,41 @@ - + + + + + + + + + + + + + + + + + + + + + + + @@ -298,7 +330,7 @@ - + @@ -332,7 +364,7 @@ - + @@ -377,20 +409,20 @@ - + - +