From 08d46f877beb2e5320de3c980ce2891d83490079 Mon Sep 17 00:00:00 2001 From: Stuart Breckenridge Date: Mon, 14 Nov 2022 19:36:58 +0800 Subject: [PATCH] minor tweaks --- NetNewsWire.xcodeproj/project.pbxproj | 12 ++ .../AccountsManagementView.swift | 104 ++++++++++++++++++ iOS/Settings/Settings View/SettingsRows.swift | 2 +- iOS/Settings/Settings View/SettingsView.swift | 1 - 4 files changed, 117 insertions(+), 2 deletions(-) create mode 100644 iOS/Settings/Account Management View/AccountsManagementView.swift diff --git a/NetNewsWire.xcodeproj/project.pbxproj b/NetNewsWire.xcodeproj/project.pbxproj index 7bca6344f..6053df0c3 100644 --- a/NetNewsWire.xcodeproj/project.pbxproj +++ b/NetNewsWire.xcodeproj/project.pbxproj @@ -850,6 +850,7 @@ DDF9E1D828EDF2FC000BC355 /* notificationSoundBlip.mp3 in Resources */ = {isa = PBXBuildFile; fileRef = DDF9E1D628EDF2FC000BC355 /* notificationSoundBlip.mp3 */; }; DDF9E1D928EDF2FC000BC355 /* notificationSoundBlip.mp3 in Resources */ = {isa = PBXBuildFile; fileRef = DDF9E1D628EDF2FC000BC355 /* notificationSoundBlip.mp3 */; }; DF59F072292085B800ACD33D /* ColorPaletteSelectorView.swift in Sources */ = {isa = PBXBuildFile; fileRef = DF59F071292085B800ACD33D /* ColorPaletteSelectorView.swift */; }; + DF59F0742920DB5100ACD33D /* AccountsManagementView.swift in Sources */ = {isa = PBXBuildFile; fileRef = DF59F0732920DB5100ACD33D /* AccountsManagementView.swift */; }; DF5AD10128D6922200CA3BF7 /* SmartFeedSummaryWidget.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1768144D2564BCE000D98635 /* SmartFeedSummaryWidget.swift */; }; DF790D6228E990A900455FC7 /* AboutData.swift in Sources */ = {isa = PBXBuildFile; fileRef = DF790D6128E990A900455FC7 /* AboutData.swift */; }; DFC14F0F28EA55BD00F6EE86 /* AboutWindowController.swift in Sources */ = {isa = PBXBuildFile; fileRef = DFC14F0E28EA55BD00F6EE86 /* AboutWindowController.swift */; }; @@ -1602,6 +1603,7 @@ DD82AB09231003F6002269DF /* SharingTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SharingTests.swift; sourceTree = ""; }; DDF9E1D628EDF2FC000BC355 /* notificationSoundBlip.mp3 */ = {isa = PBXFileReference; lastKnownFileType = audio.mp3; path = notificationSoundBlip.mp3; sourceTree = ""; }; DF59F071292085B800ACD33D /* ColorPaletteSelectorView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ColorPaletteSelectorView.swift; sourceTree = ""; }; + DF59F0732920DB5100ACD33D /* AccountsManagementView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AccountsManagementView.swift; sourceTree = ""; }; DF790D6128E990A900455FC7 /* AboutData.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AboutData.swift; sourceTree = ""; }; DFC14F0E28EA55BD00F6EE86 /* AboutWindowController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AboutWindowController.swift; sourceTree = ""; }; DFC14F1428EB177000F6EE86 /* AboutNetNewsWireView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AboutNetNewsWireView.swift; sourceTree = ""; }; @@ -2014,6 +2016,7 @@ 51A16990235E10D600EB091F /* Settings.storyboard */, DFD406F8291FB5D500C02962 /* Settings View */, DFD406FD291FDBD900C02962 /* Appearance View */, + DF59F0752920E42000ACD33D /* Account Management View */, 516A09382360A2AE00EAE89B /* SettingsComboTableViewCell.swift */, 516A091D23609A3600EAE89B /* SettingsComboTableViewCell.xib */, 516A093A2360A4A000EAE89B /* SettingsTableViewCell.xib */, @@ -2887,6 +2890,14 @@ path = Scriptability; sourceTree = ""; }; + DF59F0752920E42000ACD33D /* Account Management View */ = { + isa = PBXGroup; + children = ( + DF59F0732920DB5100ACD33D /* AccountsManagementView.swift */, + ); + path = "Account Management View"; + sourceTree = ""; + }; DFC14F0928EA51AB00F6EE86 /* About */ = { isa = PBXGroup; children = ( @@ -4206,6 +4217,7 @@ 51A169A0235E10D700EB091F /* FeedbinAccountViewController.swift in Sources */, 51934CCE2310792F006127BE /* ActivityManager.swift in Sources */, 5108F6B72375E612001ABC45 /* CacheCleaner.swift in Sources */, + DF59F0742920DB5100ACD33D /* AccountsManagementView.swift in Sources */, 518651DA235621840078E021 /* ImageTransition.swift in Sources */, 51C266EA238C334800F53014 /* ContextMenuPreviewViewController.swift in Sources */, 173A642C2547BE9600267F6E /* AccountType+Helpers.swift in Sources */, diff --git a/iOS/Settings/Account Management View/AccountsManagementView.swift b/iOS/Settings/Account Management View/AccountsManagementView.swift new file mode 100644 index 000000000..ea19c7d0a --- /dev/null +++ b/iOS/Settings/Account Management View/AccountsManagementView.swift @@ -0,0 +1,104 @@ +// +// AccountsManagementView.swift +// NetNewsWire-iOS +// +// Created by Stuart Breckenridge on 13/11/2022. +// Copyright © 2022 Ranchero Software. All rights reserved. +// + +import SwiftUI +import Account +import Combine + +struct AccountsManagementView: View { + + @State private var showAddAccountSheet: Bool = false + var cancellables = Set() + @State private var updated: Bool = false + + + var body: some View { + List { + ForEach(AccountManager.shared.sortedActiveAccounts, id: \.accountID) { account in + Section(footer: accountFooterText(account)) { + accountRow(account) + } + } + + Section(header: Text("Inactive Accounts"), footer: inactiveFooterText) { + ForEach(0.. some View { + if account.type == .cloudKit { + return Text("iCloud Syncing Limitations & Solutions") + } else { + return Text("") + } + } + + func accountRow(_ account: Account) -> some View { + Group { + HStack { + Image(uiImage: account.smallIcon!.image) + .resizable() + .frame(width: 25, height: 25) + TextField(text: Binding(get: { account.nameForDisplay }, set: { account.name = $0 })) { + Text(account.nameForDisplay) + }.foregroundColor(.secondary) + } + Toggle(isOn: Binding( + get: { account.isActive }, + set: { account.isActive = $0 } + )) { + Text("Active") + } + } + } + + var inactiveFooterText: some View { + if AccountManager.shared.sortedAccounts.filter({ $0.isActive == false }).count == 0 { + return Text("There are no inactive accounts.") + } else { + return Text("") + } + } + +} + +struct AddAccountView_Previews: PreviewProvider { + static var previews: some View { + AccountsManagementView() + } +} diff --git a/iOS/Settings/Settings View/SettingsRows.swift b/iOS/Settings/Settings View/SettingsRows.swift index 0be579199..b26597be5 100644 --- a/iOS/Settings/Settings View/SettingsRows.swift +++ b/iOS/Settings/Settings View/SettingsRows.swift @@ -72,7 +72,7 @@ struct SettingsViewRows { /// This row, when tapped, will push the the Add Account screen /// in to view. static var AddAccount: some View { - NavigationLink(destination: AddAccountViewControllerRepresentable().edgesIgnoringSafeArea(.all)) { + NavigationLink(destination: AccountsManagementView()) { Label { Text("Manage Accounts") } icon: { diff --git a/iOS/Settings/Settings View/SettingsView.swift b/iOS/Settings/Settings View/SettingsView.swift index b53249b3f..97e1a0c4a 100644 --- a/iOS/Settings/Settings View/SettingsView.swift +++ b/iOS/Settings/Settings View/SettingsView.swift @@ -41,7 +41,6 @@ struct SettingsView: View { SettingsViewRows.ShowHelpSheet(sheet: HelpSheet.allCases[i], selectedSheet: $helpSheet, $showHelpSheet) } SettingsViewRows.AboutNetNewsWire - } } .tint(Color(uiColor: AppAssets.primaryAccentColor))