From c7302f6a2016454857c796e9890aef595f7c93b4 Mon Sep 17 00:00:00 2001 From: Anton Kharchevskyi Date: Thu, 1 Jul 2021 11:16:06 +0300 Subject: [PATCH] Rename EmailProviderViewController to SetupImapViewController --- FlowCrypt.xcodeproj/project.pbxproj | 26 ++++++-------- .../SetupImapViewController.swift} | 24 ++++++------- .../SetupImapViewDecorator.swift} | 31 +++++------------ .../SignIn Other/UserObject+Empty.swift | 34 ------------------- .../SignIn/SignInViewController.swift | 4 +-- .../Models/Realm Models/SessionObject.swift | 14 ++++++++ .../Models/Realm Models/UserObject.swift | 11 ++++++ 7 files changed, 58 insertions(+), 86 deletions(-) rename FlowCrypt/Controllers/{SignIn Other/EmailProviderViewController.swift => SetupImap/SetupImapViewController.swift} (96%) rename FlowCrypt/Controllers/{SignIn Other/EmailProviderViewDecorator.swift => SetupImap/SetupImapViewDecorator.swift} (82%) delete mode 100644 FlowCrypt/Controllers/SignIn Other/UserObject+Empty.swift diff --git a/FlowCrypt.xcodeproj/project.pbxproj b/FlowCrypt.xcodeproj/project.pbxproj index 786d34444..31d0e04f0 100644 --- a/FlowCrypt.xcodeproj/project.pbxproj +++ b/FlowCrypt.xcodeproj/project.pbxproj @@ -250,7 +250,6 @@ D2891AC224C59EFA008918E3 /* KeyService.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2891AC124C59EFA008918E3 /* KeyService.swift */; }; D2891AC424C62446008918E3 /* ErrorHandler.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2891AC324C62446008918E3 /* ErrorHandler.swift */; }; D28A1CBD2525C141003B760B /* CheckBoxTextNode.swift in Sources */ = {isa = PBXBuildFile; fileRef = D28A1CBC2525C141003B760B /* CheckBoxTextNode.swift */; }; - D297990D2444A76D004A3E31 /* UserObject+Empty.swift in Sources */ = {isa = PBXBuildFile; fileRef = D297990C2444A76D004A3E31 /* UserObject+Empty.swift */; }; D29AFFF6240939AE00C1387D /* Then.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9FD22A1B230FE7D0005067A6 /* Then.swift */; }; D29AFFF92409767F00C1387D /* GoogleContactsResponse.swift in Sources */ = {isa = PBXBuildFile; fileRef = D29AFFF82409767F00C1387D /* GoogleContactsResponse.swift */; }; D29AFFFE240990BE00C1387D /* Throttler.swift in Sources */ = {isa = PBXBuildFile; fileRef = D29AFFFD240990BE00C1387D /* Throttler.swift */; }; @@ -300,8 +299,8 @@ D2F6D147243506DA00DB4065 /* MailSettingsCredentials.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2F6D146243506DA00DB4065 /* MailSettingsCredentials.swift */; }; D2FC1C0624D82C9F003B949D /* ContactsService.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2FC1C0524D82C9F003B949D /* ContactsService.swift */; }; D2FD0F692453245E00259FF0 /* Either.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2FD0F682453245E00259FF0 /* Either.swift */; }; - D2FF6966243115EC007182F0 /* EmailProviderViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2FF6965243115EC007182F0 /* EmailProviderViewController.swift */; }; - D2FF6968243115F9007182F0 /* EmailProviderViewDecorator.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2FF6967243115F9007182F0 /* EmailProviderViewDecorator.swift */; }; + D2FF6966243115EC007182F0 /* SetupImapViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2FF6965243115EC007182F0 /* SetupImapViewController.swift */; }; + D2FF6968243115F9007182F0 /* SetupImapViewDecorator.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2FF6967243115F9007182F0 /* SetupImapViewDecorator.swift */; }; D952B71D1ED0CB2500E5C02B /* MessageViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = D952B71C1ED0CB2500E5C02B /* MessageViewController.swift */; }; E29491346F23FA1463A07459 /* Pods_FlowCryptAppTests.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 990E5AB8A4A7F69E1C113365 /* Pods_FlowCryptAppTests.framework */; }; /* End PBXBuildFile section */ @@ -641,7 +640,6 @@ D2891AC124C59EFA008918E3 /* KeyService.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = KeyService.swift; sourceTree = ""; }; D2891AC324C62446008918E3 /* ErrorHandler.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ErrorHandler.swift; sourceTree = ""; }; D28A1CBC2525C141003B760B /* CheckBoxTextNode.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CheckBoxTextNode.swift; sourceTree = ""; }; - D297990C2444A76D004A3E31 /* UserObject+Empty.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UserObject+Empty.swift"; sourceTree = ""; }; D29AFFF82409767F00C1387D /* GoogleContactsResponse.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GoogleContactsResponse.swift; sourceTree = ""; }; D29AFFFD240990BE00C1387D /* Throttler.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Throttler.swift; sourceTree = ""; }; D2A1D3B723FD64AB00D626D6 /* FlowCryptUIApplication.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = FlowCryptUIApplication.app; sourceTree = BUILT_PRODUCTS_DIR; }; @@ -676,8 +674,8 @@ D2F6D146243506DA00DB4065 /* MailSettingsCredentials.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MailSettingsCredentials.swift; sourceTree = ""; }; D2FC1C0524D82C9F003B949D /* ContactsService.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContactsService.swift; sourceTree = ""; }; D2FD0F682453245E00259FF0 /* Either.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Either.swift; sourceTree = ""; }; - D2FF6965243115EC007182F0 /* EmailProviderViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EmailProviderViewController.swift; sourceTree = ""; }; - D2FF6967243115F9007182F0 /* EmailProviderViewDecorator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EmailProviderViewDecorator.swift; sourceTree = ""; }; + D2FF6965243115EC007182F0 /* SetupImapViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SetupImapViewController.swift; sourceTree = ""; }; + D2FF6967243115F9007182F0 /* SetupImapViewDecorator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SetupImapViewDecorator.swift; sourceTree = ""; }; D952B71C1ED0CB2500E5C02B /* MessageViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MessageViewController.swift; sourceTree = ""; }; DFA70003EC75596718303F14 /* Pods-FlowCryptUITests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-FlowCryptUITests.debug.xcconfig"; path = "Target Support Files/Pods-FlowCryptUITests/Pods-FlowCryptUITests.debug.xcconfig"; sourceTree = ""; }; /* End PBXFileReference section */ @@ -1457,7 +1455,7 @@ isa = PBXGroup; children = ( 04B472911ECE29F600B8266F /* SideMenu */, - D2FF6969243115FE007182F0 /* SignIn Other */, + D2FF6969243115FE007182F0 /* SetupImap */, 32DCA8D5AF0A43354CC7F58B /* SignIn */, C192421D1EC48B5600C3D251 /* Setup */, D29AFFF12409301300C1387D /* Bootstrap */, @@ -1796,14 +1794,13 @@ path = "Mail Sessions Providers"; sourceTree = ""; }; - D2FF6969243115FE007182F0 /* SignIn Other */ = { + D2FF6969243115FE007182F0 /* SetupImap */ = { isa = PBXGroup; children = ( - D2FF6965243115EC007182F0 /* EmailProviderViewController.swift */, - D2FF6967243115F9007182F0 /* EmailProviderViewDecorator.swift */, - D297990C2444A76D004A3E31 /* UserObject+Empty.swift */, + D2FF6965243115EC007182F0 /* SetupImapViewController.swift */, + D2FF6967243115F9007182F0 /* SetupImapViewDecorator.swift */, ); - path = "SignIn Other"; + path = SetupImap; sourceTree = ""; }; D952B71B1ED0CB0100E5C02B /* Msg */ = { @@ -2463,7 +2460,7 @@ 9F53CB7B2555E1E300C0157A /* GmailService+folders.swift in Sources */, 9F79228826696B0200DA3D80 /* PassPhraseService.swift in Sources */, D2E26F6624F169B400612AF1 /* ContactsListDecorator.swift in Sources */, - D2FF6968243115F9007182F0 /* EmailProviderViewDecorator.swift in Sources */, + D2FF6968243115F9007182F0 /* SetupImapViewDecorator.swift in Sources */, 9F589F0D238C7A9B007FD759 /* LocalStorage.swift in Sources */, D2FC1C0624D82C9F003B949D /* ContactsService.swift in Sources */, 9FD364862381EFCB00657302 /* SetupManuallyEnterPassPhraseViewController.swift in Sources */, @@ -2510,9 +2507,8 @@ D211CE7623FC36BC00D1CE38 /* UIColorExtension.swift in Sources */, 9FC7EBAA266EBD3700F3BF5D /* InMemoryPassPhraseStorage.swift in Sources */, 9FA9C83C264C2D75005A9670 /* MessageService.swift in Sources */, - D2FF6966243115EC007182F0 /* EmailProviderViewController.swift in Sources */, + D2FF6966243115EC007182F0 /* SetupImapViewController.swift in Sources */, D2CDC3D22402D4DA002B045F /* UIViewControllerExtensions.swift in Sources */, - D297990D2444A76D004A3E31 /* UserObject+Empty.swift in Sources */, 21C7DF0B266C0E3600C44800 /* Configuration.swift in Sources */, D2D27B79248A8694007346FA /* BigIntExtension.swift in Sources */, 9F003D6D25EA8F3200EB38C0 /* UserAccountService.swift in Sources */, diff --git a/FlowCrypt/Controllers/SignIn Other/EmailProviderViewController.swift b/FlowCrypt/Controllers/SetupImap/SetupImapViewController.swift similarity index 96% rename from FlowCrypt/Controllers/SignIn Other/EmailProviderViewController.swift rename to FlowCrypt/Controllers/SetupImap/SetupImapViewController.swift index 8eb52faf5..dccf288e7 100644 --- a/FlowCrypt/Controllers/SignIn Other/EmailProviderViewController.swift +++ b/FlowCrypt/Controllers/SetupImap/SetupImapViewController.swift @@ -1,5 +1,5 @@ // -// EmailProviderViewController.swift +// SetupImapViewController.swift // FlowCrypt // // Created by Anton Kharchevskyi on 29/03/2020. @@ -15,7 +15,7 @@ import Promises * - User redirects here from SignInViewController * - After successful connection user will be redirected to *setup flow* which would typically means *SetupInitialViewController* */ -final class EmailProviderViewController: TableNodeViewController { +final class SetupImapViewController: TableNodeViewController { private enum UserError: Error { case password case empty @@ -28,7 +28,7 @@ final class EmailProviderViewController: TableNodeViewController { private let dataService: DataServiceType private let globalRouter: GlobalRouterType - private let decorator: EmailProviderViewDecoratorType + private let decorator: SetupImapViewDecorator private let sessionCredentials: SessionCredentialsProvider private let imap: Imap private var user = UserObject.empty @@ -36,7 +36,7 @@ final class EmailProviderViewController: TableNodeViewController { init( globalRouter: GlobalRouterType = GlobalRouter(), dataService: DataServiceType = DataService.shared, - decorator: EmailProviderViewDecoratorType = EmailProviderViewDecorator(), + decorator: SetupImapViewDecorator = SetupImapViewDecorator(), sessionCredentials: SessionCredentialsProvider = SessionCredentialsService(), imap: Imap = Imap.shared ) { @@ -67,7 +67,7 @@ final class EmailProviderViewController: TableNodeViewController { } // MARK: - Parts -extension EmailProviderViewController { +extension SetupImapViewController { enum Section { case account(AccountPart) case imap(ServerPart) @@ -156,7 +156,7 @@ extension EmailProviderViewController { } // MARK: - Setup -extension EmailProviderViewController { +extension SetupImapViewController { private func setupUI() { title = "Email Provider" observeKeyboardNotifications() @@ -202,7 +202,7 @@ extension EmailProviderViewController { } // MARK: - ASTableDelegate, ASTableDataSource -extension EmailProviderViewController: ASTableDelegate, ASTableDataSource { +extension SetupImapViewController: ASTableDelegate, ASTableDataSource { func numberOfSections(in tableNode: ASTableNode) -> Int { Section.numberOfSections } @@ -227,7 +227,7 @@ extension EmailProviderViewController: ASTableDelegate, ASTableDataSource { } // MARK: - Nodes -extension EmailProviderViewController { +extension SetupImapViewController { private func titleNode(for indexPath: IndexPath) -> ASCellNode { guard let section = Section(indexPath: indexPath) else { assertionFailure() @@ -277,7 +277,7 @@ extension EmailProviderViewController { } // MARK: - Helpers -extension EmailProviderViewController { +extension SetupImapViewController { private var connections: [ConnectionType] { ConnectionType.allCases } @@ -310,7 +310,7 @@ extension EmailProviderViewController { } // MARK: - Actions -extension EmailProviderViewController { +extension SetupImapViewController { private func handleTextField(_ action: TextFieldActionType, for indexPath: IndexPath) { guard let section = Section(indexPath: indexPath) else { return } selectedSection = section @@ -461,7 +461,7 @@ extension EmailProviderViewController { } // MARK: - Connect -extension EmailProviderViewController { +extension SetupImapViewController { private func connect() { let result = checkCurrentUser() switch result { @@ -523,7 +523,7 @@ extension EmailProviderViewController { } // MARK: - Picker -extension EmailProviderViewController: UIPickerViewDelegate, UIPickerViewDataSource { +extension SetupImapViewController: UIPickerViewDelegate, UIPickerViewDataSource { func numberOfComponents(in pickerView: UIPickerView) -> Int { 1 } diff --git a/FlowCrypt/Controllers/SignIn Other/EmailProviderViewDecorator.swift b/FlowCrypt/Controllers/SetupImap/SetupImapViewDecorator.swift similarity index 82% rename from FlowCrypt/Controllers/SignIn Other/EmailProviderViewDecorator.swift rename to FlowCrypt/Controllers/SetupImap/SetupImapViewDecorator.swift index 613a0a104..846055879 100644 --- a/FlowCrypt/Controllers/SignIn Other/EmailProviderViewDecorator.swift +++ b/FlowCrypt/Controllers/SetupImap/SetupImapViewDecorator.swift @@ -1,5 +1,5 @@ // -// EmailProviderViewDecorator.swift +// SetupImapViewDecorator.swift // FlowCrypt // // Created by Anton Kharchevskyi on 29/03/2020. @@ -9,22 +9,7 @@ import FlowCryptUI import UIKit -protocol EmailProviderViewDecoratorType { - var connectButtonTitle: NSAttributedString { get } - var connectButtonInsets: UIEdgeInsets { get } - func title(for section: EmailProviderViewController.Section) -> InfoCellNode.Input - func textFieldInput(for section: EmailProviderViewController.Section) -> TextFieldCellNode.Input? - func stringFor(user: UserObject, for section: EmailProviderViewController.Section) -> NSAttributedString? - func switchInput(isOn: Bool) -> SwitchCellNode.Input - func shouldAddToolBar(for section: EmailProviderViewController.Section) -> Bool - func pickerView( - for: EmailProviderViewController.Section, - delegate: UIPickerViewDelegate, - dataSource: UIPickerViewDataSource - ) -> UIPickerView? -} - -struct EmailProviderViewDecorator: EmailProviderViewDecoratorType { +struct SetupImapViewDecorator { var connectButtonTitle: NSAttributedString { "other_provider_connect" .localized @@ -47,7 +32,7 @@ struct EmailProviderViewDecorator: EmailProviderViewDecoratorType { ) } - func title(for section: EmailProviderViewController.Section) -> InfoCellNode.Input { + func title(for section: SetupImapViewController.Section) -> InfoCellNode.Input { let title: String = { switch section { case .account(.title): return "other_provider_account_title" @@ -78,8 +63,8 @@ struct EmailProviderViewDecorator: EmailProviderViewDecoratorType { ) } - // swiftlint:disable cyclomatic_complexity - func textFieldInput(for section: EmailProviderViewController.Section) -> TextFieldCellNode.Input? { + // swiftlint:disable cyclomatic_complexity function_body_length + func textFieldInput(for section: SetupImapViewController.Section) -> TextFieldCellNode.Input? { let placeholder: String? var isSecure = false var keyboardType: UIKeyboardType = .default @@ -150,7 +135,7 @@ struct EmailProviderViewDecorator: EmailProviderViewDecoratorType { ) } - func stringFor(user: UserObject, for section: EmailProviderViewController.Section) -> NSAttributedString? { + func stringFor(user: UserObject, for section: SetupImapViewController.Section) -> NSAttributedString? { switch section { case let .account(part): switch part { @@ -209,7 +194,7 @@ struct EmailProviderViewDecorator: EmailProviderViewDecoratorType { } func pickerView( - for section: EmailProviderViewController.Section, + for section: SetupImapViewController.Section, delegate: UIPickerViewDelegate, dataSource: UIPickerViewDataSource ) -> UIPickerView? { @@ -224,7 +209,7 @@ struct EmailProviderViewDecorator: EmailProviderViewDecoratorType { } } - func shouldAddToolBar(for section: EmailProviderViewController.Section) -> Bool { + func shouldAddToolBar(for section: SetupImapViewController.Section) -> Bool { switch section { case .imap(.security), .smtp(.security), diff --git a/FlowCrypt/Controllers/SignIn Other/UserObject+Empty.swift b/FlowCrypt/Controllers/SignIn Other/UserObject+Empty.swift deleted file mode 100644 index 9fdaa2ba1..000000000 --- a/FlowCrypt/Controllers/SignIn Other/UserObject+Empty.swift +++ /dev/null @@ -1,34 +0,0 @@ -// -// UserObject+Empty.swift -// FlowCrypt -// -// Created by Anton Kharchevskyi on 13/04/2020. -// Copyright © 2020 FlowCrypt Limited. All rights reserved. -// - -import Foundation - -extension UserObject { - static var empty: UserObject { - UserObject( - name: "", - email: "", - imap: .empty, - smtp: .empty - ) - } -} - -extension SessionObject { - static var empty: SessionObject { - SessionObject( - hostname: "", - port: 0, - username: "", - password: nil, - oAuth2Token: nil, - connectionType: "", - email: "" - ) - } -} diff --git a/FlowCrypt/Controllers/SignIn/SignInViewController.swift b/FlowCrypt/Controllers/SignIn/SignInViewController.swift index c0a367fb2..d0c5e5f24 100644 --- a/FlowCrypt/Controllers/SignIn/SignInViewController.swift +++ b/FlowCrypt/Controllers/SignIn/SignInViewController.swift @@ -11,7 +11,7 @@ import FlowCryptUI * - User can sign in with: * - Gmail * - Outlook (not implemented yet) - * - Other email provider (*EmailProviderViewController*) + * - Other email provider (*SetupImapViewController*) * - User can also check privacy, terms and security links via *WebViewController* */ final class SignInViewController: TableNodeViewController { @@ -154,7 +154,7 @@ extension SignInViewController { } private func proceedToOtherProvider() { - let setupViewController = EmailProviderViewController() + let setupViewController = SetupImapViewController() navigationController?.pushViewController(setupViewController, animated: true) } diff --git a/FlowCrypt/Models/Realm Models/SessionObject.swift b/FlowCrypt/Models/Realm Models/SessionObject.swift index 2d45386d9..7b89d4e29 100644 --- a/FlowCrypt/Models/Realm Models/SessionObject.swift +++ b/FlowCrypt/Models/Realm Models/SessionObject.swift @@ -63,3 +63,17 @@ extension SessionObject { ) } } + +extension SessionObject { + static var empty: SessionObject { + SessionObject( + hostname: "", + port: 0, + username: "", + password: nil, + oAuth2Token: nil, + connectionType: "", + email: "" + ) + } +} diff --git a/FlowCrypt/Models/Realm Models/UserObject.swift b/FlowCrypt/Models/Realm Models/UserObject.swift index f4f0c5708..1912d74fa 100644 --- a/FlowCrypt/Models/Realm Models/UserObject.swift +++ b/FlowCrypt/Models/Realm Models/UserObject.swift @@ -77,3 +77,14 @@ extension User { self.isActive = userObject.isActive } } + +extension UserObject { + static var empty: UserObject { + UserObject( + name: "", + email: "", + imap: .empty, + smtp: .empty + ) + } +}