Add account sheets are now showing
This commit is contained in:
parent
0dac343748
commit
6bc0728fdb
|
@ -10,12 +10,22 @@ import Foundation
|
||||||
import Account
|
import Account
|
||||||
import Combine
|
import Combine
|
||||||
|
|
||||||
class AccountsPreferencesModel: ObservableObject {
|
public enum AccountConfigurationSheets: Equatable {
|
||||||
|
case addAccountPicker, addSelectedAccount(AccountType), credentials, none
|
||||||
|
|
||||||
enum AccountConfigurationSheets {
|
public static func == (lhs: AccountConfigurationSheets, rhs: AccountConfigurationSheets) -> Bool {
|
||||||
case addAccountPicker, credentials, none
|
switch (lhs, rhs) {
|
||||||
|
case (let .addSelectedAccount(lhsType), let .addSelectedAccount(rhsType)):
|
||||||
|
return lhsType == rhsType
|
||||||
|
default:
|
||||||
|
return false
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public class AccountsPreferencesModel: ObservableObject {
|
||||||
|
|
||||||
// Selected Account
|
// Selected Account
|
||||||
public private(set) var account: Account?
|
public private(set) var account: Account?
|
||||||
|
|
||||||
|
@ -57,7 +67,7 @@ class AccountsPreferencesModel: ObservableObject {
|
||||||
@Published var showSheet: Bool = false
|
@Published var showSheet: Bool = false
|
||||||
@Published var sheetToShow: AccountConfigurationSheets = .none {
|
@Published var sheetToShow: AccountConfigurationSheets = .none {
|
||||||
didSet {
|
didSet {
|
||||||
showSheet = sheetToShow != .none
|
if sheetToShow == .none { showSheet = false } else { showSheet = true }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@Published var showDeleteConfirmation: Bool = false
|
@Published var showDeleteConfirmation: Bool = false
|
||||||
|
|
|
@ -30,11 +30,26 @@ struct AccountsPreferencesView: View {
|
||||||
content: {
|
content: {
|
||||||
switch viewModel.sheetToShow {
|
switch viewModel.sheetToShow {
|
||||||
case .addAccountPicker:
|
case .addAccountPicker:
|
||||||
AddAccountView()
|
AddAccountView(accountToAdd: $viewModel.sheetToShow)
|
||||||
case .credentials:
|
case .credentials:
|
||||||
EditAccountCredentialsView(viewModel: viewModel)
|
EditAccountCredentialsView(viewModel: viewModel)
|
||||||
case .none:
|
case .none:
|
||||||
EmptyView()
|
EmptyView()
|
||||||
|
case .addSelectedAccount(let type):
|
||||||
|
switch type {
|
||||||
|
case .onMyMac:
|
||||||
|
AddLocalAccountView()
|
||||||
|
case .feedbin:
|
||||||
|
AddFeedbinAccountView()
|
||||||
|
case .cloudKit:
|
||||||
|
AddCloudKitAccountView()
|
||||||
|
case .feedWrangler:
|
||||||
|
AddFeedWranglerAccountView()
|
||||||
|
case .newsBlur:
|
||||||
|
AddNewsBlurAccountView()
|
||||||
|
default:
|
||||||
|
AddReaderAPIAccountView(accountType: type)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.alert(isPresented: $viewModel.showDeleteConfirmation, content: {
|
.alert(isPresented: $viewModel.showDeleteConfirmation, content: {
|
||||||
|
|
|
@ -72,6 +72,7 @@ enum AddAccountSections: Int, CaseIterable {
|
||||||
struct AddAccountView: View {
|
struct AddAccountView: View {
|
||||||
|
|
||||||
@State private var selectedAccount: AccountType = .onMyMac
|
@State private var selectedAccount: AccountType = .onMyMac
|
||||||
|
@Binding public var accountToAdd: AccountConfigurationSheets
|
||||||
@Environment(\.presentationMode) var presentationMode
|
@Environment(\.presentationMode) var presentationMode
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
|
@ -108,8 +109,10 @@ struct AddAccountView: View {
|
||||||
}
|
}
|
||||||
if #available(OSX 11.0, *) {
|
if #available(OSX 11.0, *) {
|
||||||
Button(action: {
|
Button(action: {
|
||||||
//
|
|
||||||
presentationMode.wrappedValue.dismiss()
|
presentationMode.wrappedValue.dismiss()
|
||||||
|
DispatchQueue.main.asyncAfter(deadline: .now() + 0.5, execute: {
|
||||||
|
accountToAdd = AccountConfigurationSheets.addSelectedAccount(selectedAccount)
|
||||||
|
})
|
||||||
}, label: {
|
}, label: {
|
||||||
Text("Continue")
|
Text("Continue")
|
||||||
.frame(width: 80)
|
.frame(width: 80)
|
||||||
|
@ -120,6 +123,9 @@ struct AddAccountView: View {
|
||||||
} else {
|
} else {
|
||||||
Button(action: {
|
Button(action: {
|
||||||
presentationMode.wrappedValue.dismiss()
|
presentationMode.wrappedValue.dismiss()
|
||||||
|
DispatchQueue.main.asyncAfter(deadline: .now() + 0.5, execute: {
|
||||||
|
accountToAdd = AccountConfigurationSheets.addSelectedAccount(selectedAccount)
|
||||||
|
})
|
||||||
}, label: {
|
}, label: {
|
||||||
Text("Continue")
|
Text("Continue")
|
||||||
.frame(width: 80)
|
.frame(width: 80)
|
||||||
|
|
|
@ -0,0 +1,115 @@
|
||||||
|
//
|
||||||
|
// AddReaderAPIAccountView.swift
|
||||||
|
// Multiplatform macOS
|
||||||
|
//
|
||||||
|
// Created by Stuart Breckenridge on 03/12/2020.
|
||||||
|
// Copyright © 2020 Ranchero Software. All rights reserved.
|
||||||
|
//
|
||||||
|
|
||||||
|
import SwiftUI
|
||||||
|
import Account
|
||||||
|
|
||||||
|
struct AddReaderAPIAccountView: View {
|
||||||
|
|
||||||
|
@Environment (\.presentationMode) var presentationMode
|
||||||
|
@State private var username: String = ""
|
||||||
|
@State private var password: String = ""
|
||||||
|
public var accountType: AccountType
|
||||||
|
|
||||||
|
var body: some View {
|
||||||
|
VStack {
|
||||||
|
HStack(spacing: 16) {
|
||||||
|
VStack(alignment: .leading) {
|
||||||
|
accountType.image()
|
||||||
|
.resizable()
|
||||||
|
.frame(width: 50, height: 50)
|
||||||
|
Spacer()
|
||||||
|
}
|
||||||
|
VStack(alignment: .leading, spacing: 8) {
|
||||||
|
Text("Sign in to your \(accountType.localizedAccountName()) account.")
|
||||||
|
.font(.headline)
|
||||||
|
HStack {
|
||||||
|
if accountType == .freshRSS {
|
||||||
|
Text("Don't have a \(accountType.localizedAccountName()) instance?")
|
||||||
|
.font(.callout)
|
||||||
|
} else {
|
||||||
|
Text("Don't have an \(accountType.localizedAccountName()) account?")
|
||||||
|
.font(.callout)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Button(action: {
|
||||||
|
signUp()
|
||||||
|
}, label: {
|
||||||
|
Text(accountType == .freshRSS ? "Find out more." : "Sign up here.").font(.callout)
|
||||||
|
}).buttonStyle(LinkButtonStyle())
|
||||||
|
}
|
||||||
|
|
||||||
|
HStack {
|
||||||
|
VStack(alignment: .trailing, spacing: 14) {
|
||||||
|
Text("Email")
|
||||||
|
Text("Password")
|
||||||
|
}
|
||||||
|
VStack(spacing: 8) {
|
||||||
|
TextField("me@email.com", text: $username)
|
||||||
|
SecureField("•••••••••••", text: $password)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Text("Your username and password will be encrypted and stored in Keychain.")
|
||||||
|
.foregroundColor(.secondary)
|
||||||
|
.font(.callout)
|
||||||
|
.lineLimit(2)
|
||||||
|
.padding(.top, 4)
|
||||||
|
|
||||||
|
Spacer()
|
||||||
|
HStack(spacing: 8) {
|
||||||
|
Spacer()
|
||||||
|
ProgressView().scaleEffect(CGSize(width: 0.5, height: 0.5))
|
||||||
|
Button(action: {
|
||||||
|
presentationMode.wrappedValue.dismiss()
|
||||||
|
}, label: {
|
||||||
|
Text("Cancel")
|
||||||
|
.frame(width: 60)
|
||||||
|
}).keyboardShortcut(.cancelAction)
|
||||||
|
|
||||||
|
Button(action: {
|
||||||
|
presentationMode.wrappedValue.dismiss()
|
||||||
|
}, label: {
|
||||||
|
Text("Create")
|
||||||
|
.frame(width: 60)
|
||||||
|
})
|
||||||
|
.keyboardShortcut(.defaultAction)
|
||||||
|
.disabled(username.isEmpty && password.isEmpty)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.padding()
|
||||||
|
.frame(width: 400, height: 230)
|
||||||
|
.textFieldStyle(RoundedBorderTextFieldStyle())
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private func signUp() {
|
||||||
|
switch accountType {
|
||||||
|
case .freshRSS:
|
||||||
|
NSWorkspace.shared.open(URL(string: "https://freshrss.org")!)
|
||||||
|
case .inoreader:
|
||||||
|
NSWorkspace.shared.open(URL(string: "https://www.inoreader.com")!)
|
||||||
|
case .bazQux:
|
||||||
|
NSWorkspace.shared.open(URL(string: "https://bazqux.com")!)
|
||||||
|
case .theOldReader:
|
||||||
|
NSWorkspace.shared.open(URL(string: "https://theoldreader.com")!)
|
||||||
|
default:
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
struct AddReaderAPIAccountView_Previews: PreviewProvider {
|
||||||
|
static var previews: some View {
|
||||||
|
AddReaderAPIAccountView(accountType: .freshRSS)
|
||||||
|
}
|
||||||
|
}
|
|
@ -1101,6 +1101,7 @@
|
||||||
DF98E29A2578A73A00F18944 /* AddCloudKitAccountView.swift in Sources */ = {isa = PBXBuildFile; fileRef = DF98E2992578A73A00F18944 /* AddCloudKitAccountView.swift */; };
|
DF98E29A2578A73A00F18944 /* AddCloudKitAccountView.swift in Sources */ = {isa = PBXBuildFile; fileRef = DF98E2992578A73A00F18944 /* AddCloudKitAccountView.swift */; };
|
||||||
DF98E2B02578AA5C00F18944 /* AddFeedWranglerAccountView.swift in Sources */ = {isa = PBXBuildFile; fileRef = DF98E2AF2578AA5C00F18944 /* AddFeedWranglerAccountView.swift */; };
|
DF98E2B02578AA5C00F18944 /* AddFeedWranglerAccountView.swift in Sources */ = {isa = PBXBuildFile; fileRef = DF98E2AF2578AA5C00F18944 /* AddFeedWranglerAccountView.swift */; };
|
||||||
DF98E2BE2578AC0000F18944 /* AddNewsBlurAccountView.swift in Sources */ = {isa = PBXBuildFile; fileRef = DF98E2BD2578AC0000F18944 /* AddNewsBlurAccountView.swift */; };
|
DF98E2BE2578AC0000F18944 /* AddNewsBlurAccountView.swift in Sources */ = {isa = PBXBuildFile; fileRef = DF98E2BD2578AC0000F18944 /* AddNewsBlurAccountView.swift */; };
|
||||||
|
DF98E2C62578AD1B00F18944 /* AddReaderAPIAccountView.swift in Sources */ = {isa = PBXBuildFile; fileRef = DF98E2C52578AD1B00F18944 /* AddReaderAPIAccountView.swift */; };
|
||||||
FA80C11724B0728000974098 /* AddFolderView.swift in Sources */ = {isa = PBXBuildFile; fileRef = FA80C11624B0728000974098 /* AddFolderView.swift */; };
|
FA80C11724B0728000974098 /* AddFolderView.swift in Sources */ = {isa = PBXBuildFile; fileRef = FA80C11624B0728000974098 /* AddFolderView.swift */; };
|
||||||
FA80C11824B0728000974098 /* AddFolderView.swift in Sources */ = {isa = PBXBuildFile; fileRef = FA80C11624B0728000974098 /* AddFolderView.swift */; };
|
FA80C11824B0728000974098 /* AddFolderView.swift in Sources */ = {isa = PBXBuildFile; fileRef = FA80C11624B0728000974098 /* AddFolderView.swift */; };
|
||||||
FA80C13E24B072AA00974098 /* AddFolderModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = FA80C13D24B072AA00974098 /* AddFolderModel.swift */; };
|
FA80C13E24B072AA00974098 /* AddFolderModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = FA80C13D24B072AA00974098 /* AddFolderModel.swift */; };
|
||||||
|
@ -1938,6 +1939,7 @@
|
||||||
DF98E2992578A73A00F18944 /* AddCloudKitAccountView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AddCloudKitAccountView.swift; sourceTree = "<group>"; };
|
DF98E2992578A73A00F18944 /* AddCloudKitAccountView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AddCloudKitAccountView.swift; sourceTree = "<group>"; };
|
||||||
DF98E2AF2578AA5C00F18944 /* AddFeedWranglerAccountView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AddFeedWranglerAccountView.swift; sourceTree = "<group>"; };
|
DF98E2AF2578AA5C00F18944 /* AddFeedWranglerAccountView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AddFeedWranglerAccountView.swift; sourceTree = "<group>"; };
|
||||||
DF98E2BD2578AC0000F18944 /* AddNewsBlurAccountView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AddNewsBlurAccountView.swift; sourceTree = "<group>"; };
|
DF98E2BD2578AC0000F18944 /* AddNewsBlurAccountView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AddNewsBlurAccountView.swift; sourceTree = "<group>"; };
|
||||||
|
DF98E2C52578AD1B00F18944 /* AddReaderAPIAccountView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AddReaderAPIAccountView.swift; sourceTree = "<group>"; };
|
||||||
FA80C11624B0728000974098 /* AddFolderView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AddFolderView.swift; sourceTree = "<group>"; };
|
FA80C11624B0728000974098 /* AddFolderView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AddFolderView.swift; sourceTree = "<group>"; };
|
||||||
FA80C13D24B072AA00974098 /* AddFolderModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AddFolderModel.swift; sourceTree = "<group>"; };
|
FA80C13D24B072AA00974098 /* AddFolderModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AddFolderModel.swift; sourceTree = "<group>"; };
|
||||||
FF3ABF09232599450074C542 /* ArticleSorterTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ArticleSorterTests.swift; sourceTree = "<group>"; };
|
FF3ABF09232599450074C542 /* ArticleSorterTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ArticleSorterTests.swift; sourceTree = "<group>"; };
|
||||||
|
@ -2144,6 +2146,7 @@
|
||||||
17386BC32577CC600014C8B2 /* AddFeedbinAccountView.swift */,
|
17386BC32577CC600014C8B2 /* AddFeedbinAccountView.swift */,
|
||||||
DF98E2AF2578AA5C00F18944 /* AddFeedWranglerAccountView.swift */,
|
DF98E2AF2578AA5C00F18944 /* AddFeedWranglerAccountView.swift */,
|
||||||
DF98E2BD2578AC0000F18944 /* AddNewsBlurAccountView.swift */,
|
DF98E2BD2578AC0000F18944 /* AddNewsBlurAccountView.swift */,
|
||||||
|
DF98E2C52578AD1B00F18944 /* AddReaderAPIAccountView.swift */,
|
||||||
);
|
);
|
||||||
path = Views;
|
path = Views;
|
||||||
sourceTree = "<group>";
|
sourceTree = "<group>";
|
||||||
|
@ -4675,6 +4678,7 @@
|
||||||
51E498FC24A808BA00B667CB /* FaviconURLFinder.swift in Sources */,
|
51E498FC24A808BA00B667CB /* FaviconURLFinder.swift in Sources */,
|
||||||
51E4991C24A8092000B667CB /* NSAttributedString+NetNewsWire.swift in Sources */,
|
51E4991C24A8092000B667CB /* NSAttributedString+NetNewsWire.swift in Sources */,
|
||||||
1769E32B24BCB030000E1E8E /* ConfiguredAccountRow.swift in Sources */,
|
1769E32B24BCB030000E1E8E /* ConfiguredAccountRow.swift in Sources */,
|
||||||
|
DF98E2C62578AD1B00F18944 /* AddReaderAPIAccountView.swift in Sources */,
|
||||||
FF64D0E824AF53EE0084080A /* RefreshProgressModel.swift in Sources */,
|
FF64D0E824AF53EE0084080A /* RefreshProgressModel.swift in Sources */,
|
||||||
51E499D924A912C200B667CB /* SceneModel.swift in Sources */,
|
51E499D924A912C200B667CB /* SceneModel.swift in Sources */,
|
||||||
51919FB424AAB97900541E64 /* FeedIconImageLoader.swift in Sources */,
|
51919FB424AAB97900541E64 /* FeedIconImageLoader.swift in Sources */,
|
||||||
|
|
Loading…
Reference in New Issue