Reader and CloudKit Account Views

This commit is contained in:
Stuart Breckenridge
2022-12-16 16:38:06 +08:00
parent b3208bf269
commit 4ff0bc8f98
20 changed files with 554 additions and 149 deletions

View File

@@ -11,7 +11,6 @@
"ACTIVE" = "Active";
"CLOUDKIT_LIMITATIONS_TITLE" = "[iCloud Syncing Limitations & Solutions](https://netnewswire.com/help/iCloud)";
"REMOVE_ACCOUNT_TITLE" = "Remove Account";
"REMOVE_ACCOUNT_BUTTON_TITLE" = "Remove Account";
"REMOVE_FEEDLY_MESSAGE" = "Are you sure you want to remove this account? NetNewsWire will no longer be able to access articles and feeds unless the account is added again.";
"REMOVE_ACCOUNT_MESSAGE" = "Are you sure you want to remove this account? This cannot be undone.";
"REMOVE_ACCOUNT_TITLE" = "Remove Account";

View File

@@ -14,12 +14,56 @@ struct AccountInspectorView: View {
@Environment(\.dismiss) var dismiss
@State private var showRemoveAccountAlert: Bool = false
@State private var showAccountCredentialsSheet: Bool = false
var account: Account
var body: some View {
Form {
Section(header: accountHeaderView){}
accountNameAndActiveSection
if account.type != .onMyMac &&
account.type != .cloudKit &&
account.type != .feedly {
credentialsSection
}
if account != AccountManager.shared.defaultAccount {
removeAccountSection
}
if account.type == .cloudKit {
Section(footer: cloudKitLimitations){}
}
}
.navigationBarTitleDisplayMode(.inline)
.navigationTitle(account.nameForDisplay)
.tint(Color(uiColor: AppAssets.primaryAccentColor))
.edgesIgnoringSafeArea(.bottom)
.sheet(isPresented: $showAccountCredentialsSheet) {
switch account.type {
case .theOldReader, .bazQux, .inoreader, .freshRSS:
ReaderAPIAccountView(accountType: account.type, account: account)
default:
EmptyView()
}
}
}
var accountHeaderView: some View {
HStack {
Spacer()
Image(uiImage: account.smallIcon!.image)
.resizable()
.aspectRatio(contentMode: .fit)
.frame(width: 48, height: 48)
Spacer()
}
}
var accountNameAndActiveSection: some View {
Section {
TextField(text: Binding(
get: { account.name ?? account.defaultName },
set: { account.name = $0 }),
@@ -32,60 +76,55 @@ struct AccountInspectorView: View {
}, set: { account.isActive = $0 })) {
Text("ACTIVE", tableName: "Inspector")
}
if account != AccountManager.shared.defaultAccount {
Section {
Button(role: .destructive) {
showRemoveAccountAlert = true
} label: {
HStack {
Spacer()
Text("REMOVE_ACCOUNT_BUTTON_TITLE", tableName: "Inspector")
Spacer()
}
}
.confirmationDialog(Text("REMOVE_ACCOUNT_TITLE", tableName: "Inspector"), isPresented: $showRemoveAccountAlert, titleVisibility: .visible) {
Button(role: .destructive) {
AccountManager.shared.deleteAccount(account)
dismiss()
} label: {
Text("REMOVE_ACCOUNT_BUTTON_TITLE", tableName: "Inspector")
}
Button(role: .cancel) {
//
} label: {
Text("CANCEL_BUTTON_TITLE", tableName: "Buttons")
}
} message: {
if account.type == .feedly {
Text("REMOVE_FEEDLY_MESSAGE", tableName: "Inspector")
} else {
Text("REMOVE_ACCOUNT_MESSAGE", tableName: "Inspector")
}
}
}
}
var credentialsSection: some View {
Section {
Button {
showAccountCredentialsSheet = true
} label: {
HStack {
Spacer()
Text("CREDENTIALS_BUTTON_TITLE", tableName: "Buttons")
Spacer()
}
}
if account.type == .cloudKit {
Section(footer: cloudKitLimitations){}
}
}
.navigationBarTitleDisplayMode(.inline)
.navigationTitle(account.nameForDisplay)
.tint(Color(uiColor: AppAssets.primaryAccentColor))
.edgesIgnoringSafeArea(.bottom) // Fix to make sure view is not offset from the top when presented
}
}
var accountHeaderView: some View {
HStack {
Spacer()
Image(uiImage: account.smallIcon!.image)
.resizable()
.aspectRatio(contentMode: .fit)
.frame(width: 30, height: 30)
Spacer()
var removeAccountSection: some View {
Section {
Button(role: .destructive) {
showRemoveAccountAlert = true
} label: {
HStack {
Spacer()
Text("REMOVE_ACCOUNT_BUTTON_TITLE", tableName: "Buttons")
Spacer()
}
}
.confirmationDialog(Text("REMOVE_ACCOUNT_TITLE", tableName: "Inspector"), isPresented: $showRemoveAccountAlert, titleVisibility: .visible) {
Button(role: .destructive) {
AccountManager.shared.deleteAccount(account)
dismiss()
} label: {
Text("REMOVE_ACCOUNT_BUTTON_TITLE", tableName: "Buttons")
}
Button(role: .cancel) {
//
} label: {
Text("CANCEL_BUTTON_TITLE", tableName: "Buttons")
}
} message: {
if account.type == .feedly {
Text("REMOVE_FEEDLY_MESSAGE", tableName: "Inspector")
} else {
Text("REMOVE_ACCOUNT_MESSAGE", tableName: "Inspector")
}
}
}
}

View File

@@ -32,7 +32,7 @@ struct ExtensionInspectorView: View {
Button(role: .destructive) {
ExtensionPointManager.shared.deactivateExtensionPoint(extensionPoint!.extensionPointID)
} label: {
Text("DEACTIVATE", tableName: "Settings")
Text("DEACTIVATE_BUTTON_TITLE", tableName: "Buttons")
}
Button(role: .cancel) {
@@ -59,7 +59,7 @@ struct ExtensionInspectorView: View {
Image(uiImage: extensionPoint!.image)
.resizable()
.aspectRatio(contentMode: .fit)
.frame(width: 30, height: 30)
.frame(width: 48, height: 48)
Spacer()
}
}

View File

@@ -71,7 +71,7 @@ struct WebFeedInspectorView: View {
Image(uiImage: webFeed.smallIcon!.image)
.resizable()
.aspectRatio(contentMode: .fit)
.frame(width: 30, height: 30)
.frame(width: 48, height: 48)
Spacer()
}
}