minor tweaks

This commit is contained in:
Stuart Breckenridge
2022-11-14 19:36:58 +08:00
parent ccd8fa4ca7
commit 08d46f877b
4 changed files with 117 additions and 2 deletions

View File

@@ -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 = "<group>"; };
DDF9E1D628EDF2FC000BC355 /* notificationSoundBlip.mp3 */ = {isa = PBXFileReference; lastKnownFileType = audio.mp3; path = notificationSoundBlip.mp3; sourceTree = "<group>"; };
DF59F071292085B800ACD33D /* ColorPaletteSelectorView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ColorPaletteSelectorView.swift; sourceTree = "<group>"; };
DF59F0732920DB5100ACD33D /* AccountsManagementView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AccountsManagementView.swift; sourceTree = "<group>"; };
DF790D6128E990A900455FC7 /* AboutData.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AboutData.swift; sourceTree = "<group>"; };
DFC14F0E28EA55BD00F6EE86 /* AboutWindowController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AboutWindowController.swift; sourceTree = "<group>"; };
DFC14F1428EB177000F6EE86 /* AboutNetNewsWireView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AboutNetNewsWireView.swift; sourceTree = "<group>"; };
@@ -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 = "<group>";
};
DF59F0752920E42000ACD33D /* Account Management View */ = {
isa = PBXGroup;
children = (
DF59F0732920DB5100ACD33D /* AccountsManagementView.swift */,
);
path = "Account Management View";
sourceTree = "<group>";
};
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 */,

View File

@@ -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<AnyCancellable>()
@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..<AccountManager.shared.sortedAccounts.filter({ $0.isActive == false }).count, id: \.self) { i in
accountRow(AccountManager.shared.sortedAccounts.filter({ $0.isActive == false })[i])
}
}
}
.navigationTitle(Text("Accounts"))
.navigationBarTitleDisplayMode(.inline)
.tint(Color(uiColor: AppAssets.primaryAccentColor))
.toolbar {
ToolbarItem(placement: .navigationBarTrailing) {
Button {
//
} label: {
Image(systemName: "plus")
}
}
}
.onReceive(NotificationCenter.default.publisher(for: .AccountStateDidChange)) { _ in
updated.toggle()
}
}
var addAccountButton: some View {
HStack {
Spacer()
Text("Add Account")
.padding(8)
.overlay(NavigationLink { AddAccountViewControllerRepresentable() } label: { EmptyView() }.opacity(0.0))
.background(Color(uiColor: AppAssets.primaryAccentColor))
.clipShape(RoundedRectangle(cornerRadius: 6))
Spacer()
}
}
func accountFooterText(_ account: Account) -> 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<Bool>(
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()
}
}

View File

@@ -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: {

View File

@@ -41,7 +41,6 @@ struct SettingsView: View {
SettingsViewRows.ShowHelpSheet(sheet: HelpSheet.allCases[i], selectedSheet: $helpSheet, $showHelpSheet)
}
SettingsViewRows.AboutNetNewsWire
}
}
.tint(Color(uiColor: AppAssets.primaryAccentColor))