Merge pull request #2535 from stuartbreckenridge/add-account-cleanup
Add account cleanup
This commit is contained in:
commit
f9361fbb72
|
@ -11,7 +11,12 @@ import Account
|
||||||
import SwiftUI
|
import SwiftUI
|
||||||
import RSCore
|
import RSCore
|
||||||
|
|
||||||
|
// MARK: - AccountsPreferencesAddAccountDelegate
|
||||||
|
protocol AccountsPreferencesAddAccountDelegate {
|
||||||
|
func presentSheetForAccount(_ accountType: AccountType)
|
||||||
|
}
|
||||||
|
|
||||||
|
// MARK: - AccountsPreferencesViewController
|
||||||
final class AccountsPreferencesViewController: NSViewController {
|
final class AccountsPreferencesViewController: NSViewController {
|
||||||
|
|
||||||
@IBOutlet weak var tableView: NSTableView!
|
@IBOutlet weak var tableView: NSTableView!
|
||||||
|
@ -39,6 +44,11 @@ final class AccountsPreferencesViewController: NSViewController {
|
||||||
var rTable = tableView.frame
|
var rTable = tableView.frame
|
||||||
rTable.size.width = tableView.superview!.frame.size.width
|
rTable.size.width = tableView.superview!.frame.size.width
|
||||||
tableView.frame = rTable
|
tableView.frame = rTable
|
||||||
|
|
||||||
|
// Set initial row selection
|
||||||
|
if sortedAccounts.count > 0 {
|
||||||
|
tableView.selectRow(0)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@IBAction func addAccount(_ sender: Any) {
|
@IBAction func addAccount(_ sender: Any) {
|
||||||
|
@ -119,7 +129,7 @@ extension AccountsPreferencesViewController: NSTableViewDelegate {
|
||||||
let selectedRow = tableView.selectedRow
|
let selectedRow = tableView.selectedRow
|
||||||
if tableView.selectedRow == -1 {
|
if tableView.selectedRow == -1 {
|
||||||
deleteButton.isEnabled = false
|
deleteButton.isEnabled = false
|
||||||
showController(AccountsAddViewController())
|
hideController()
|
||||||
return
|
return
|
||||||
} else {
|
} else {
|
||||||
deleteButton.isEnabled = true
|
deleteButton.isEnabled = true
|
||||||
|
@ -137,11 +147,6 @@ extension AccountsPreferencesViewController: NSTableViewDelegate {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// MARK: - AccountsPreferencesAddAccountDelegate
|
|
||||||
protocol AccountsPreferencesAddAccountDelegate {
|
|
||||||
func presentSheetForAccount(_ accountType: AccountType)
|
|
||||||
}
|
|
||||||
|
|
||||||
extension AccountsPreferencesViewController: AccountsPreferencesAddAccountDelegate {
|
extension AccountsPreferencesViewController: AccountsPreferencesAddAccountDelegate {
|
||||||
func presentSheetForAccount(_ accountType: AccountType) {
|
func presentSheetForAccount(_ accountType: AccountType) {
|
||||||
switch accountType {
|
switch accountType {
|
||||||
|
@ -241,6 +246,13 @@ private extension AccountsPreferencesViewController {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func hideController() {
|
||||||
|
if let controller = children.first {
|
||||||
|
children.removeAll()
|
||||||
|
controller.view.removeFromSuperview()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
extension AccountsPreferencesViewController: OAuthAccountAuthorizationOperationDelegate {
|
extension AccountsPreferencesViewController: OAuthAccountAuthorizationOperationDelegate {
|
||||||
|
|
|
@ -31,7 +31,7 @@ private enum AddAccountSections: Int, CaseIterable {
|
||||||
var sectionFooter: String {
|
var sectionFooter: String {
|
||||||
switch self {
|
switch self {
|
||||||
case .local:
|
case .local:
|
||||||
return NSLocalizedString("This account does not sync subscriptions across devices.", comment: "Local Account")
|
return NSLocalizedString("Local accounts do not sync subscriptions across devices.", comment: "Local Account")
|
||||||
case .icloud:
|
case .icloud:
|
||||||
return NSLocalizedString("Use your iCloud account to sync your subscriptions across your iOS and macOS devices.", comment: "iCloud Account")
|
return NSLocalizedString("Use your iCloud account to sync your subscriptions across your iOS and macOS devices.", comment: "iCloud Account")
|
||||||
case .web:
|
case .web:
|
||||||
|
@ -117,7 +117,9 @@ struct AddAccountsView: View {
|
||||||
.frame(width: 80)
|
.frame(width: 80)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}.padding(.vertical, 8)
|
}
|
||||||
|
.padding(.top, 12)
|
||||||
|
.padding(.bottom, 4)
|
||||||
}
|
}
|
||||||
.pickerStyle(RadioGroupPickerStyle())
|
.pickerStyle(RadioGroupPickerStyle())
|
||||||
.fixedSize(horizontal: false, vertical: true)
|
.fixedSize(horizontal: false, vertical: true)
|
||||||
|
@ -130,28 +132,29 @@ struct AddAccountsView: View {
|
||||||
Text("Local")
|
Text("Local")
|
||||||
.font(.headline)
|
.font(.headline)
|
||||||
.padding(.horizontal)
|
.padding(.horizontal)
|
||||||
|
|
||||||
Picker(selection: $selectedAccount, label: Text(""), content: {
|
Picker(selection: $selectedAccount, label: Text(""), content: {
|
||||||
ForEach(AddAccountSections.local.sectionContent, id: \.self, content: { account in
|
ForEach(AddAccountSections.local.sectionContent, id: \.self, content: { account in
|
||||||
HStack(alignment: .top) {
|
HStack(alignment: .center) {
|
||||||
account.image()
|
account.image()
|
||||||
.resizable()
|
.resizable()
|
||||||
.aspectRatio(contentMode: .fit)
|
.aspectRatio(contentMode: .fit)
|
||||||
.frame(width: 25, height: 25, alignment: .center)
|
.frame(width: 25, height: 25, alignment: .center)
|
||||||
.offset(CGSize(width: 0, height: -2.5))
|
|
||||||
.padding(.leading, 4)
|
.padding(.leading, 4)
|
||||||
|
|
||||||
|
|
||||||
VStack(alignment: .leading, spacing: 4) {
|
|
||||||
Text(account.localizedAccountName())
|
Text(account.localizedAccountName())
|
||||||
Text(AddAccountSections.local.sectionFooter).foregroundColor(.gray)
|
|
||||||
.font(.caption)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
.tag(account)
|
.tag(account)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
.pickerStyle(RadioGroupPickerStyle())
|
.pickerStyle(RadioGroupPickerStyle())
|
||||||
.offset(x: 7.5, y: 0)
|
.offset(x: 7.5, y: 0)
|
||||||
|
|
||||||
|
Text(AddAccountSections.local.sectionFooter).foregroundColor(.gray)
|
||||||
|
.font(.caption)
|
||||||
|
.padding(.horizontal)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -161,27 +164,28 @@ struct AddAccountsView: View {
|
||||||
Text("iCloud")
|
Text("iCloud")
|
||||||
.font(.headline)
|
.font(.headline)
|
||||||
.padding(.horizontal)
|
.padding(.horizontal)
|
||||||
|
.padding(.top, 8)
|
||||||
|
|
||||||
Picker(selection: $selectedAccount, label: Text(""), content: {
|
Picker(selection: $selectedAccount, label: Text(""), content: {
|
||||||
ForEach(AddAccountSections.icloud.sectionContent, id: \.self, content: { account in
|
ForEach(AddAccountSections.icloud.sectionContent, id: \.self, content: { account in
|
||||||
HStack(alignment: .top) {
|
HStack(alignment: .center) {
|
||||||
account.image()
|
account.image()
|
||||||
.resizable()
|
.resizable()
|
||||||
.aspectRatio(contentMode: .fit)
|
.aspectRatio(contentMode: .fit)
|
||||||
.frame(width: 25, height: 25, alignment: .center)
|
.frame(width: 25, height: 25, alignment: .center)
|
||||||
.offset(CGSize(width: 0, height: -5))
|
|
||||||
.padding(.leading, 4)
|
.padding(.leading, 4)
|
||||||
|
|
||||||
VStack(alignment: .leading, spacing: 4) {
|
|
||||||
Text(account.localizedAccountName())
|
Text(account.localizedAccountName())
|
||||||
Text(AddAccountSections.icloud.sectionFooter).foregroundColor(.gray)
|
|
||||||
.font(.caption)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
.tag(account)
|
.tag(account)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
.offset(x: 7.5, y: 0)
|
.offset(x: 7.5, y: 0)
|
||||||
.disabled(isCloudInUse())
|
.disabled(isCloudInUse())
|
||||||
|
|
||||||
|
Text(AddAccountSections.icloud.sectionFooter).foregroundColor(.gray)
|
||||||
|
.font(.caption)
|
||||||
|
.padding(.horizontal)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -190,6 +194,8 @@ struct AddAccountsView: View {
|
||||||
Text("Web")
|
Text("Web")
|
||||||
.font(.headline)
|
.font(.headline)
|
||||||
.padding(.horizontal)
|
.padding(.horizontal)
|
||||||
|
.padding(.top, 8)
|
||||||
|
|
||||||
Picker(selection: $selectedAccount, label: Text(""), content: {
|
Picker(selection: $selectedAccount, label: Text(""), content: {
|
||||||
ForEach(AddAccountSections.web.sectionContent.filter({ isRestricted($0) != true }), id: \.self, content: { account in
|
ForEach(AddAccountSections.web.sectionContent.filter({ isRestricted($0) != true }), id: \.self, content: { account in
|
||||||
|
|
||||||
|
@ -200,15 +206,17 @@ struct AddAccountsView: View {
|
||||||
.frame(width: 25, height: 25, alignment: .center)
|
.frame(width: 25, height: 25, alignment: .center)
|
||||||
.padding(.leading, 4)
|
.padding(.leading, 4)
|
||||||
|
|
||||||
VStack(alignment: .leading) {
|
|
||||||
Text(account.localizedAccountName())
|
Text(account.localizedAccountName())
|
||||||
}
|
}
|
||||||
}
|
|
||||||
.tag(account)
|
.tag(account)
|
||||||
|
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
.offset(x: 7.5, y: 0)
|
.offset(x: 7.5, y: 0)
|
||||||
|
|
||||||
|
Text(AddAccountSections.web.sectionFooter).foregroundColor(.gray)
|
||||||
|
.font(.caption)
|
||||||
|
.padding(.horizontal)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -218,29 +226,25 @@ struct AddAccountsView: View {
|
||||||
.font(.headline)
|
.font(.headline)
|
||||||
.padding(.horizontal)
|
.padding(.horizontal)
|
||||||
.padding(.top, 8)
|
.padding(.top, 8)
|
||||||
|
|
||||||
Picker(selection: $selectedAccount, label: Text(""), content: {
|
Picker(selection: $selectedAccount, label: Text(""), content: {
|
||||||
ForEach(AddAccountSections.selfhosted.sectionContent, id: \.self, content: { account in
|
ForEach(AddAccountSections.selfhosted.sectionContent, id: \.self, content: { account in
|
||||||
HStack(alignment: .top) {
|
HStack(alignment: .center) {
|
||||||
account.image()
|
account.image()
|
||||||
.resizable()
|
.resizable()
|
||||||
.aspectRatio(contentMode: .fit)
|
.aspectRatio(contentMode: .fit)
|
||||||
.frame(width: 25, height: 25, alignment: .center)
|
.frame(width: 25, height: 25, alignment: .center)
|
||||||
.offset(CGSize(width: 0, height: -4))
|
|
||||||
.padding(.leading, 4)
|
.padding(.leading, 4)
|
||||||
|
|
||||||
|
|
||||||
VStack(alignment: .leading, spacing: 4) {
|
|
||||||
Text(account.localizedAccountName())
|
Text(account.localizedAccountName())
|
||||||
Text("Web and self-hosted accounts sync across all signed-in devices.")
|
|
||||||
.font(.caption)
|
|
||||||
.foregroundColor(.gray)
|
|
||||||
}
|
|
||||||
}.tag(account)
|
}.tag(account)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
.offset(x: 7.5, y: 0)
|
.offset(x: 7.5, y: 0)
|
||||||
|
|
||||||
|
Text(AddAccountSections.selfhosted.sectionFooter).foregroundColor(.gray)
|
||||||
|
.font(.caption)
|
||||||
|
.padding(.horizontal)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Binary file not shown.
Binary file not shown.
|
@ -1,7 +1,7 @@
|
||||||
{
|
{
|
||||||
"images" : [
|
"images" : [
|
||||||
{
|
{
|
||||||
"filename" : "freshrss-any.pdf",
|
"filename" : "FreshRSS.pdf",
|
||||||
"idiom" : "universal"
|
"idiom" : "universal"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
|
Loading…
Reference in New Issue