diff --git a/Multiplatform/Shared/Add/Add Account Models/AddFeedlyViewModel.swift b/Multiplatform/Shared/Add/Add Account Models/AddFeedlyViewModel.swift index 2c96c6856..c5445b524 100644 --- a/Multiplatform/Shared/Add/Add Account Models/AddFeedlyViewModel.swift +++ b/Multiplatform/Shared/Add/Add Account Models/AddFeedlyViewModel.swift @@ -19,6 +19,16 @@ class AddFeedlyViewModel: ObservableObject, OAuthAccountAuthorizationOperationDe @Published var username: String = "" @Published var password: String = "" + func authenticateFeedly() { + isAuthenticating = true + let addAccount = OAuthAccountAuthorizationOperation(accountType: .feedly) + addAccount.delegate = self + #if os(macOS) + addAccount.presentationAnchor = NSApplication.shared.windows.last + #endif + MainThreadOperationQueue.shared.add(addAccount) + } + func oauthAccountAuthorizationOperation(_ operation: OAuthAccountAuthorizationOperation, didCreate account: Account) { isAuthenticating = false diff --git a/Multiplatform/Shared/Add/Add Account Sheets/AddFeedWranglerAccountView.swift b/Multiplatform/Shared/Add/Add Account Sheets/AddFeedWranglerAccountView.swift index 8e28df5a7..9d2f3e8aa 100644 --- a/Multiplatform/Shared/Add/Add Account Sheets/AddFeedWranglerAccountView.swift +++ b/Multiplatform/Shared/Add/Add Account Sheets/AddFeedWranglerAccountView.swift @@ -19,6 +19,41 @@ struct AddFeedWranglerAccountView: View { @StateObject private var model = AddFeedWranglerViewModel() var body: some View { + #if os(macOS) + macBody + #else + iosBody + #endif + } + + + #if os(iOS) + var iosBody: some View { + List { + Section(header: formHeader, footer: ProgressView() + .scaleEffect(CGSize(width: 0.5, height: 0.5)) + .hidden(!model.isAuthenticating) , content: { + TextField("me@email.com", text: $model.username) + SecureField("•••••••••••", text: $model.password) + }) + }.navigationBarItems(leading: + Button(action: { + presentationMode.wrappedValue.dismiss() + }, label: { + Text("Dismiss") + }) + , trailing: + Button(action: { + model.authenticateFeedWrangler() + }, label: { + Text("Add") + }).disabled(model.username.isEmpty || model.password.isEmpty) + ) + } + #endif + + #if os(macOS) + var macBody: some View { VStack { HStack(spacing: 16) { VStack(alignment: .leading) { @@ -93,9 +128,26 @@ struct AddFeedWranglerAccountView: View { presentationMode.wrappedValue.dismiss() } }) - } - - + } + #endif + + var formHeader: some View { + HStack { + VStack(alignment: .center) { + AccountType.newsBlur.image() + .resizable() + .frame(width: 50, height: 50) + Text("Sign in to your NewsBlur account.") + .font(.headline) + + Text("This account syncs across your subscriptions across devices.") + .foregroundColor(.secondary) + .font(.callout) + .lineLimit(2) + .padding(.top, 4) + } + } + } } diff --git a/Multiplatform/Shared/Add/Add Account Sheets/AddFeedbinAccountView.swift b/Multiplatform/Shared/Add/Add Account Sheets/AddFeedbinAccountView.swift index e0f2b2884..0d61cd738 100644 --- a/Multiplatform/Shared/Add/Add Account Sheets/AddFeedbinAccountView.swift +++ b/Multiplatform/Shared/Add/Add Account Sheets/AddFeedbinAccountView.swift @@ -21,7 +21,9 @@ struct AddFeedbinAccountView: View { #if os(macOS) macBody #else + NavigationView { iosBody + } #endif } @@ -29,24 +31,37 @@ struct AddFeedbinAccountView: View { var iosBody: some View { List { Section(header: formHeader, footer: ProgressView() - .scaleEffect(CGSize(width: 0.5, height: 0.5)) .hidden(!model.isAuthenticating) , content: { - TextField("me@email.com", text: $model.username) - SecureField("•••••••••••", text: $model.password) + TextField("Email", text: $model.username) + SecureField("Password", text: $model.password) }) - }.navigationBarItems(leading: + + Section(footer: formFooter, content: { + Button(action: { + model.authenticateFeedbin() + }, label: { + Text("Sign In") + }).disabled(model.username.isEmpty || model.password.isEmpty) + }) + + } + .navigationBarItems(leading: Button(action: { presentationMode.wrappedValue.dismiss() }, label: { Text("Dismiss") - }) - , trailing: - Button(action: { - model.authenticateFeedbin() - }, label: { - Text("Add") - }).disabled(model.username.isEmpty || model.password.isEmpty) - ) + })) + .listStyle(InsetGroupedListStyle()) + .navigationBarTitleDisplayMode(.inline) + .navigationTitle(Text("Feedbin")) + .alert(isPresented: $model.showError, content: { + Alert(title: Text("Sign In Error"), message: Text(model.accountUpdateError.description), dismissButton: .cancel(Text("Dismiss"))) + }) + .onReceive(model.$canDismiss, perform: { value in + if value == true { + presentationMode.wrappedValue.dismiss() + } + }) } #endif @@ -130,14 +145,31 @@ struct AddFeedbinAccountView: View { var formHeader: some View { HStack { + Spacer() VStack(alignment: .center) { AccountType.feedbin.image() .resizable() .frame(width: 50, height: 50) - Text("Sign in to your Feedbin account.") - .font(.headline) } - } + Spacer() + }.padding(.vertical) + } + + var formFooter: some View { + HStack { + Spacer() + VStack(spacing: 8) { + Text("Sign in to your Feedbin account and sync your subscriptions across your devices. Your username and password and password will be encrypted and stored in Keychain.") + Text("Don't have a Feedbin account?") + Button(action: {}, label: { + Text("Sign Up Here").foregroundColor(.blue).multilineTextAlignment(.center) + }).disabled(model.username.isEmpty || model.password.isEmpty) + } + .multilineTextAlignment(.center) + .font(.caption2) + Spacer() + + }.padding(.vertical) } diff --git a/Multiplatform/Shared/Add/Add Account Sheets/AddFeedlyAccountView.swift b/Multiplatform/Shared/Add/Add Account Sheets/AddFeedlyAccountView.swift index fb5941d6e..69551cce0 100644 --- a/Multiplatform/Shared/Add/Add Account Sheets/AddFeedlyAccountView.swift +++ b/Multiplatform/Shared/Add/Add Account Sheets/AddFeedlyAccountView.swift @@ -18,6 +18,26 @@ struct AddFeedlyAccountView: View { @StateObject private var model = AddFeedlyViewModel() var body: some View { + #if os(macOS) + macBody + #else + NavigationView { + iosBody + } + + + #endif + } + + + #if os(iOS) + var iosBody: some View { + Text("TBC") + } + #endif + + #if os(macOS) + var macBody: some View { VStack { HStack(spacing: 16) { VStack(alignment: .leading) { @@ -67,17 +87,10 @@ struct AddFeedlyAccountView: View { .alert(isPresented: $model.showError, content: { Alert(title: Text("Sign In Error"), message: Text(model.accountUpdateError.description), dismissButton: .cancel()) }) - } - - private func authenticateFeedly() { - model.isAuthenticating = true - let addAccount = OAuthAccountAuthorizationOperation(accountType: .feedly) - addAccount.delegate = model - #if os(macOS) - addAccount.presentationAnchor = NSApplication.shared.windows.last - #endif - MainThreadOperationQueue.shared.add(addAccount) } + #endif + + } struct AddFeedlyAccountView_Previews: PreviewProvider { diff --git a/Multiplatform/Shared/Add/Add Account Sheets/AddNewsBlurAccountView.swift b/Multiplatform/Shared/Add/Add Account Sheets/AddNewsBlurAccountView.swift index 51ddccf90..df8f67ca8 100644 --- a/Multiplatform/Shared/Add/Add Account Sheets/AddNewsBlurAccountView.swift +++ b/Multiplatform/Shared/Add/Add Account Sheets/AddNewsBlurAccountView.swift @@ -42,7 +42,7 @@ struct AddNewsBlurAccountView: View { }) , trailing: Button(action: { - authenticateNewsBlur() + model.authenticateNewsBlur() }, label: { Text("Add") }).disabled(model.username.isEmpty || model.password.isEmpty) diff --git a/Multiplatform/Shared/Add/Add Account Sheets/AddReaderAPIAccountView.swift b/Multiplatform/Shared/Add/Add Account Sheets/AddReaderAPIAccountView.swift index 6fa144609..9255615ba 100644 --- a/Multiplatform/Shared/Add/Add Account Sheets/AddReaderAPIAccountView.swift +++ b/Multiplatform/Shared/Add/Add Account Sheets/AddReaderAPIAccountView.swift @@ -19,6 +19,21 @@ struct AddReaderAPIAccountView: View { public var accountType: AccountType var body: some View { + #if os(macOS) + macBody + #else + iosBody + #endif + } + + #if os(iOS) + var iosBody: some View { + Text("TBC") + } + #endif + + #if os(macOS) + var macBody: some View { VStack { HStack(spacing: 16) { VStack(alignment: .leading) { @@ -107,6 +122,10 @@ struct AddReaderAPIAccountView: View { } }) } + #endif + + + func createDisabled() -> Bool { if accountType == .freshRSS { @@ -122,6 +141,9 @@ struct AddReaderAPIAccountView: View { return 230 } + + + private func signUp() { switch accountType { case .freshRSS: diff --git a/Multiplatform/iOS/Settings/Accounts/SettingsAddAccountView.swift b/Multiplatform/iOS/Settings/Accounts/SettingsAddAccountView.swift index aa7b52bc9..c8855409e 100644 --- a/Multiplatform/iOS/Settings/Accounts/SettingsAddAccountView.swift +++ b/Multiplatform/iOS/Settings/Accounts/SettingsAddAccountView.swift @@ -27,15 +27,21 @@ struct SettingsAddAccountView: View { } .listStyle(InsetGroupedListStyle()) .sheet(isPresented: $model.isAddPresented) { - switch model.selectedAccountType { + switch model.selectedAccountType! { case .onMyMac: AddLocalAccountView() - case .feedbin, .feedWrangler, .newsBlur, .freshRSS: - SettingsCredentialsAccountView(accountType: model.selectedAccountType!) + case .feedbin: + AddFeedbinAccountView() case .cloudKit: - SettingsCloudKitAccountView() + AddCloudKitAccountView() + case .feedWrangler: + AddFeedWranglerAccountView() + case .newsBlur: + AddNewsBlurAccountView() + case .feedly: + AddFeedlyAccountView() default: - EmptyView() + AddReaderAPIAccountView(accountType: model.selectedAccountType!) } } .navigationBarTitle(Text("Add Account"), displayMode: .inline) diff --git a/iOS/Add/Add.storyboard b/iOS/Add/Add.storyboard index 3e86949aa..ca335bf36 100644 --- a/iOS/Add/Add.storyboard +++ b/iOS/Add/Add.storyboard @@ -1,9 +1,9 @@ - + - +