mirror of
https://github.com/Ranchero-Software/NetNewsWire
synced 2025-08-12 06:26:36 +00:00
Merge pull request #2258 from rizwankce/add-cloudkit-settings
Add cloudkit view for settings accounts
This commit is contained in:
@@ -34,7 +34,11 @@ class SettingsAddAccountModel: ObservableObject {
|
||||
init() {
|
||||
self.accounts = [
|
||||
SettingsAddAccount(name: Account.defaultLocalAccountName, accountType: .onMyMac),
|
||||
SettingsAddAccount(name: "Feedbin", accountType: .feedbin)
|
||||
SettingsAddAccount(name: "Feedbin", accountType: .feedbin),
|
||||
SettingsAddAccount(name: "Feedly", accountType: .feedly),
|
||||
SettingsAddAccount(name: "Feed Wrangler", accountType: .feedWrangler),
|
||||
SettingsAddAccount(name: "iCloud", accountType: .cloudKit),
|
||||
SettingsAddAccount(name: "NewsBlur", accountType: .newsBlur)
|
||||
]
|
||||
}
|
||||
|
||||
|
||||
@@ -27,11 +27,19 @@ struct SettingsAddAccountView: View {
|
||||
}
|
||||
.listStyle(InsetGroupedListStyle())
|
||||
.sheet(isPresented: $model.isAddPresented) {
|
||||
if model.selectedAccountType == .onMyMac {
|
||||
|
||||
switch model.selectedAccountType {
|
||||
case .onMyMac:
|
||||
SettingsLocalAccountView()
|
||||
}
|
||||
if model.selectedAccountType == .feedbin {
|
||||
|
||||
case .feedbin:
|
||||
SettingsFeedbinAccountView()
|
||||
|
||||
case .cloudKit:
|
||||
SettingsCloudKitAccountView()
|
||||
|
||||
default:
|
||||
EmptyView()
|
||||
}
|
||||
}
|
||||
.navigationBarTitle(Text("Add Account"), displayMode: .inline)
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
//
|
||||
// SettingsCloudKitAccountView.swift
|
||||
// Multiplatform iOS
|
||||
//
|
||||
// Created by Rizwan on 13/07/20.
|
||||
// Copyright © 2020 Ranchero Software. All rights reserved.
|
||||
//
|
||||
|
||||
import SwiftUI
|
||||
import Account
|
||||
|
||||
struct SettingsCloudKitAccountView: View {
|
||||
@Environment(\.presentationMode) var presentationMode
|
||||
|
||||
var body: some View {
|
||||
NavigationView {
|
||||
List {
|
||||
Section(header: AccountHeaderImageView(image: AppAssets.image(for: .cloudKit)!)) { }
|
||||
Section {
|
||||
HStack {
|
||||
Spacer()
|
||||
Button(action: { self.addAccount() }) {
|
||||
Text("Add Account")
|
||||
}
|
||||
Spacer()
|
||||
}
|
||||
}
|
||||
}
|
||||
.listStyle(InsetGroupedListStyle())
|
||||
.navigationBarTitle(Text(verbatim: "iCloud"), displayMode: .inline)
|
||||
.navigationBarItems(leading: Button(action: { self.dismiss() }) { Text("Cancel") } )
|
||||
}
|
||||
}
|
||||
|
||||
private func addAccount() {
|
||||
_ = AccountManager.shared.createAccount(type: .cloudKit)
|
||||
dismiss()
|
||||
}
|
||||
|
||||
private func dismiss() {
|
||||
presentationMode.wrappedValue.dismiss()
|
||||
}
|
||||
}
|
||||
|
||||
struct SettingsCloudKitAccountView_Previews: PreviewProvider {
|
||||
static var previews: some View {
|
||||
SettingsCloudKitAccountView()
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user