2020-11-04 03:35:53 +01:00
|
|
|
//
|
|
|
|
// AddAccountHelpView.swift
|
|
|
|
// NetNewsWire
|
|
|
|
//
|
|
|
|
// Created by Stuart Breckenridge on 4/11/20.
|
|
|
|
// Copyright © 2020 Ranchero Software. All rights reserved.
|
|
|
|
//
|
|
|
|
|
|
|
|
import SwiftUI
|
|
|
|
import Account
|
|
|
|
|
|
|
|
struct AddAccountHelpView: View {
|
|
|
|
|
|
|
|
let accountTypes: [AccountType] = AddAccountSections.allOrdered.sectionContent
|
|
|
|
var delegate: AccountsPreferencesAddAccountDelegate?
|
|
|
|
var helpText: String
|
2020-11-06 12:07:28 +01:00
|
|
|
@State private var iCloudUnavailableError: Bool = false
|
2020-11-04 03:35:53 +01:00
|
|
|
|
|
|
|
var body: some View {
|
|
|
|
VStack {
|
|
|
|
HStack {
|
2020-12-10 21:21:22 +01:00
|
|
|
ForEach(accountTypes, id: \.self) { accountType in
|
|
|
|
if !(AppDefaults.shared.isDeveloperBuild && accountType.isDeveloperRestricted) {
|
|
|
|
Button(action: {
|
|
|
|
if accountType == .cloudKit && AccountManager.shared.accounts.contains(where: { $0.type == .cloudKit }) {
|
|
|
|
iCloudUnavailableError = true
|
|
|
|
} else {
|
|
|
|
delegate?.presentSheetForAccount(accountType)
|
|
|
|
}
|
|
|
|
}, label: {
|
|
|
|
accountType.image()
|
|
|
|
.resizable()
|
|
|
|
.frame(width: 20, height: 20, alignment: .center)
|
|
|
|
})
|
|
|
|
.buttonStyle(PlainButtonStyle())
|
|
|
|
}
|
2020-11-04 03:35:53 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Text(helpText)
|
|
|
|
.multilineTextAlignment(.center)
|
|
|
|
.padding(.top, 8)
|
2020-11-06 12:07:28 +01:00
|
|
|
|
2020-11-04 03:35:53 +01:00
|
|
|
}
|
2020-11-06 12:07:28 +01:00
|
|
|
.alert(isPresented: $iCloudUnavailableError, content: {
|
|
|
|
Alert(title: Text(NSLocalizedString("Error", comment: "Error")),
|
|
|
|
message: Text(NSLocalizedString("You've already set up an iCloud account.", comment: "Error")),
|
|
|
|
dismissButton: Alert.Button.cancel({
|
|
|
|
iCloudUnavailableError = false
|
|
|
|
}))
|
|
|
|
})
|
2020-11-04 03:35:53 +01:00
|
|
|
}
|
2020-12-10 21:21:22 +01:00
|
|
|
|
2020-11-04 03:35:53 +01:00
|
|
|
}
|