mirror of
https://github.com/Ranchero-Software/NetNewsWire
synced 2025-08-12 06:26:36 +00:00
Reader and CloudKit Account Views
This commit is contained in:
@@ -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")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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()
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user