Fixes #2534
• Minor tweaks to the iCloud icon • Consistent footers on add account sheet • Old functionality removed when the accounts tableview has no selection
This commit is contained in:
parent
7bc3153dfd
commit
24dbe7c310
|
@ -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:
|
||||||
|
@ -130,6 +130,7 @@ 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: .top) {
|
||||||
|
@ -137,21 +138,22 @@ struct AddAccountsView: View {
|
||||||
.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))
|
.offset(CGSize(width: 0, height: -3.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,6 +163,8 @@ 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: .top) {
|
||||||
|
@ -168,20 +172,20 @@ struct AddAccountsView: View {
|
||||||
.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))
|
.offset(CGSize(width: 0, height: -3.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,6 +226,7 @@ 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: .top) {
|
||||||
|
@ -228,19 +237,15 @@ struct AddAccountsView: View {
|
||||||
.offset(CGSize(width: 0, height: -4))
|
.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.
Loading…
Reference in New Issue