Merge pull request #2535 from stuartbreckenridge/add-account-cleanup

Add account cleanup
This commit is contained in:
Maurice Parker 2020-10-30 04:00:12 -05:00 committed by GitHub
commit f9361fbb72
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 53 additions and 37 deletions

View File

@ -11,7 +11,12 @@ import Account
import SwiftUI
import RSCore
// MARK: - AccountsPreferencesAddAccountDelegate
protocol AccountsPreferencesAddAccountDelegate {
func presentSheetForAccount(_ accountType: AccountType)
}
// MARK: - AccountsPreferencesViewController
final class AccountsPreferencesViewController: NSViewController {
@IBOutlet weak var tableView: NSTableView!
@ -39,6 +44,11 @@ final class AccountsPreferencesViewController: NSViewController {
var rTable = tableView.frame
rTable.size.width = tableView.superview!.frame.size.width
tableView.frame = rTable
// Set initial row selection
if sortedAccounts.count > 0 {
tableView.selectRow(0)
}
}
@IBAction func addAccount(_ sender: Any) {
@ -119,7 +129,7 @@ extension AccountsPreferencesViewController: NSTableViewDelegate {
let selectedRow = tableView.selectedRow
if tableView.selectedRow == -1 {
deleteButton.isEnabled = false
showController(AccountsAddViewController())
hideController()
return
} else {
deleteButton.isEnabled = true
@ -137,11 +147,6 @@ extension AccountsPreferencesViewController: NSTableViewDelegate {
}
// MARK: - AccountsPreferencesAddAccountDelegate
protocol AccountsPreferencesAddAccountDelegate {
func presentSheetForAccount(_ accountType: AccountType)
}
extension AccountsPreferencesViewController: AccountsPreferencesAddAccountDelegate {
func presentSheetForAccount(_ accountType: 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 {

View File

@ -31,7 +31,7 @@ private enum AddAccountSections: Int, CaseIterable {
var sectionFooter: String {
switch self {
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:
return NSLocalizedString("Use your iCloud account to sync your subscriptions across your iOS and macOS devices.", comment: "iCloud Account")
case .web:
@ -117,7 +117,9 @@ struct AddAccountsView: View {
.frame(width: 80)
})
}
}.padding(.vertical, 8)
}
.padding(.top, 12)
.padding(.bottom, 4)
}
.pickerStyle(RadioGroupPickerStyle())
.fixedSize(horizontal: false, vertical: true)
@ -130,28 +132,29 @@ struct AddAccountsView: View {
Text("Local")
.font(.headline)
.padding(.horizontal)
Picker(selection: $selectedAccount, label: Text(""), content: {
ForEach(AddAccountSections.local.sectionContent, id: \.self, content: { account in
HStack(alignment: .top) {
HStack(alignment: .center) {
account.image()
.resizable()
.aspectRatio(contentMode: .fit)
.frame(width: 25, height: 25, alignment: .center)
.offset(CGSize(width: 0, height: -2.5))
.padding(.leading, 4)
VStack(alignment: .leading, spacing: 4) {
Text(account.localizedAccountName())
Text(AddAccountSections.local.sectionFooter).foregroundColor(.gray)
.font(.caption)
}
}
.tag(account)
})
})
.pickerStyle(RadioGroupPickerStyle())
.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")
.font(.headline)
.padding(.horizontal)
.padding(.top, 8)
Picker(selection: $selectedAccount, label: Text(""), content: {
ForEach(AddAccountSections.icloud.sectionContent, id: \.self, content: { account in
HStack(alignment: .top) {
HStack(alignment: .center) {
account.image()
.resizable()
.aspectRatio(contentMode: .fit)
.frame(width: 25, height: 25, alignment: .center)
.offset(CGSize(width: 0, height: -5))
.padding(.leading, 4)
VStack(alignment: .leading, spacing: 4) {
Text(account.localizedAccountName())
Text(AddAccountSections.icloud.sectionFooter).foregroundColor(.gray)
.font(.caption)
}
}
.tag(account)
})
})
.offset(x: 7.5, y: 0)
.disabled(isCloudInUse())
Text(AddAccountSections.icloud.sectionFooter).foregroundColor(.gray)
.font(.caption)
.padding(.horizontal)
}
}
@ -190,6 +194,8 @@ struct AddAccountsView: View {
Text("Web")
.font(.headline)
.padding(.horizontal)
.padding(.top, 8)
Picker(selection: $selectedAccount, label: Text(""), content: {
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)
.padding(.leading, 4)
VStack(alignment: .leading) {
Text(account.localizedAccountName())
}
}
.tag(account)
})
})
.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)
.padding(.horizontal)
.padding(.top, 8)
Picker(selection: $selectedAccount, label: Text(""), content: {
ForEach(AddAccountSections.selfhosted.sectionContent, id: \.self, content: { account in
HStack(alignment: .top) {
HStack(alignment: .center) {
account.image()
.resizable()
.aspectRatio(contentMode: .fit)
.frame(width: 25, height: 25, alignment: .center)
.offset(CGSize(width: 0, height: -4))
.padding(.leading, 4)
VStack(alignment: .leading, spacing: 4) {
Text(account.localizedAccountName())
Text("Web and self-hosted accounts sync across all signed-in devices.")
.font(.caption)
.foregroundColor(.gray)
}
}.tag(account)
})
})
.offset(x: 7.5, y: 0)
Text(AddAccountSections.selfhosted.sectionFooter).foregroundColor(.gray)
.font(.caption)
.padding(.horizontal)
}
}

View File

@ -1,7 +1,7 @@
{
"images" : [
{
"filename" : "freshrss-any.pdf",
"filename" : "FreshRSS.pdf",
"idiom" : "universal"
}
],