Skip to content

Commit

Permalink
v4.2.0 Changing arrows for import screens
Browse files Browse the repository at this point in the history
  • Loading branch information
adocyn committed Apr 13, 2023
1 parent af3649f commit e80082f
Show file tree
Hide file tree
Showing 12 changed files with 167 additions and 47 deletions.
8 changes: 4 additions & 4 deletions TwoFAS/TwoFAS.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -779,7 +779,7 @@
C2CC0A4629D098CB00677A7B /* ExternalImportInstructionsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = C2CC0A4529D098CB00677A7B /* ExternalImportInstructionsView.swift */; };
C2CC0A4829D0C9FC00677A7B /* ExternalImportInstructionsViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = C2CC0A4729D0C9FC00677A7B /* ExternalImportInstructionsViewController.swift */; };
C2CC0A4A29D0CACC00677A7B /* ExternalImportInstructionsPresenter.swift in Sources */ = {isa = PBXBuildFile; fileRef = C2CC0A4929D0CACC00677A7B /* ExternalImportInstructionsPresenter.swift */; };
C2CC0A4C29D0D4FC00677A7B /* ExternalImportInstructionsService.swift in Sources */ = {isa = PBXBuildFile; fileRef = C2CC0A4B29D0D4FC00677A7B /* ExternalImportInstructionsService.swift */; };
C2CC0A4C29D0D4FC00677A7B /* ExternalImportService.swift in Sources */ = {isa = PBXBuildFile; fileRef = C2CC0A4B29D0D4FC00677A7B /* ExternalImportService.swift */; };
C2CC0A4E29D0D62600677A7B /* ExternalImportInstructionsFlowController.swift in Sources */ = {isa = PBXBuildFile; fileRef = C2CC0A4D29D0D62600677A7B /* ExternalImportInstructionsFlowController.swift */; };
C2CC80D627B99AF700294CF2 /* ComposeServicePresenter+Menu.swift in Sources */ = {isa = PBXBuildFile; fileRef = C2CC80D527B99AF700294CF2 /* ComposeServicePresenter+Menu.swift */; };
C2CC80D827B99B0600294CF2 /* ComposeServicePresenter.swift in Sources */ = {isa = PBXBuildFile; fileRef = C2CC80D727B99B0600294CF2 /* ComposeServicePresenter.swift */; };
Expand Down Expand Up @@ -2019,7 +2019,7 @@
C2CC0A4529D098CB00677A7B /* ExternalImportInstructionsView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ExternalImportInstructionsView.swift; sourceTree = "<group>"; };
C2CC0A4729D0C9FC00677A7B /* ExternalImportInstructionsViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ExternalImportInstructionsViewController.swift; sourceTree = "<group>"; };
C2CC0A4929D0CACC00677A7B /* ExternalImportInstructionsPresenter.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ExternalImportInstructionsPresenter.swift; sourceTree = "<group>"; };
C2CC0A4B29D0D4FC00677A7B /* ExternalImportInstructionsService.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ExternalImportInstructionsService.swift; sourceTree = "<group>"; };
C2CC0A4B29D0D4FC00677A7B /* ExternalImportService.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ExternalImportService.swift; sourceTree = "<group>"; };
C2CC0A4D29D0D62600677A7B /* ExternalImportInstructionsFlowController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ExternalImportInstructionsFlowController.swift; sourceTree = "<group>"; };
C2CC80D527B99AF700294CF2 /* ComposeServicePresenter+Menu.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "ComposeServicePresenter+Menu.swift"; sourceTree = "<group>"; };
C2CC80D727B99B0600294CF2 /* ComposeServicePresenter.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ComposeServicePresenter.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -5584,6 +5584,7 @@
C2DFE5BC264C851700F828C0 /* CircleView.swift */,
C2633EFC265A7D090034B836 /* TokenLabel.swift */,
C266542A2725EF7B00DC3A3C /* ExportFileRules.swift */,
C2CC0A4B29D0D4FC00677A7B /* ExternalImportService.swift */,
C2698B712986F6E800EBC179 /* UITabBarController+addTab.swift */,
);
path = Common;
Expand Down Expand Up @@ -5894,7 +5895,6 @@
C2CC0A4129D08D7700677A7B /* ExternalImportInstructions */ = {
isa = PBXGroup;
children = (
C2CC0A4B29D0D4FC00677A7B /* ExternalImportInstructionsService.swift */,
C2CC0A4429D08DAD00677A7B /* Flow */,
C2CC0A4329D08DA500677A7B /* Presenter */,
C2CC0A4229D08DA000677A7B /* View */,
Expand Down Expand Up @@ -7461,7 +7461,7 @@
C240485E27654C5F0076376E /* ImporterEnterPasswordFlowController.swift in Sources */,
C2A7944D27F795E900E5C641 /* BrowserExtensionPairedService.swift in Sources */,
C287D4FB276A92460001B272 /* AppSecurityExtensions.swift in Sources */,
C2CC0A4C29D0D4FC00677A7B /* ExternalImportInstructionsService.swift in Sources */,
C2CC0A4C29D0D4FC00677A7B /* ExternalImportService.swift in Sources */,
C244718825F4F6900024B4C5 /* ComposeServiceFormRowTitleLabel.swift in Sources */,
C2D587362650549700D9C4BD /* IntroductionPage4View.swift in Sources */,
C21A9E8827CBF77100FE4CC4 /* ComposeServiceNumberOfDigitsPresenter+Menu.swift in Sources */,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,10 @@

import Foundation

enum ExternalImportInstructionsService {
enum ExternalImportService {
case aegis
case raivo
case lastPass
case googleAuth
case twofas
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,25 @@ import Common

protocol ImporterEnterPasswordFlowControllerParent: AnyObject {
func hidePasswordImport()
func showPreimportSummary(count: Int, sections: [CommonSectionData], services: [ServiceData])
func showPreimportSummary(
count: Int,
sections: [CommonSectionData],
services: [ServiceData],
externalImportService: ExternalImportService
)
func showFileError(error: ImporterOpenFileError)
func showFileIsEmpty()
func showWrongPassword()
}

protocol ImporterEnterPasswordFlowControlling: AnyObject {
func toClose()
func toPreimportSummary(count: Int, sections: [CommonSectionData], services: [ServiceData])
func toPreimportSummary(
count: Int,
sections: [CommonSectionData],
services: [ServiceData],
externalImportService: ExternalImportService
)
func toFileError(error: ImporterOpenFileError)
func toFileIsEmpty()
func toWrongPassword()
Expand All @@ -42,7 +52,8 @@ final class ImporterEnterPasswordFlowController: FlowController {
static func push(
in navigationController: UINavigationController,
parent: ImporterEnterPasswordFlowControllerParent,
data: ExchangeDataFormat
data: ExchangeDataFormat,
externalImportService: ExternalImportService
) {
let view = ImporterEnterPasswordViewController()
let flowController = ImporterEnterPasswordFlowController(viewController: view)
Expand All @@ -52,7 +63,8 @@ final class ImporterEnterPasswordFlowController: FlowController {
)
let presenter = ImporterEnterPasswordPresenter(
flowController: flowController,
interactor: interactor
interactor: interactor,
externalImportService: externalImportService
)
presenter.view = view
view.presenter = presenter
Expand All @@ -66,8 +78,18 @@ extension ImporterEnterPasswordFlowController: ImporterEnterPasswordFlowControll
parent?.hidePasswordImport()
}

func toPreimportSummary(count: Int, sections: [CommonSectionData], services: [ServiceData]) {
parent?.showPreimportSummary(count: count, sections: sections, services: services)
func toPreimportSummary(
count: Int,
sections: [CommonSectionData],
services: [ServiceData],
externalImportService: ExternalImportService
) {
parent?.showPreimportSummary(
count: count,
sections: sections,
services: services,
externalImportService: externalImportService
)
}

func toFileError(error: ImporterOpenFileError) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,16 @@ final class ImporterEnterPasswordPresenter {

private let flowController: ImporterEnterPasswordFlowControlling
private let interactor: ImporterEnterPasswordModuleInteracting
private let externalImportService: ExternalImportService

init(flowController: ImporterEnterPasswordFlowControlling, interactor: ImporterEnterPasswordModuleInteracting) {
init(
flowController: ImporterEnterPasswordFlowControlling,
interactor: ImporterEnterPasswordModuleInteracting,
externalImportService: ExternalImportService
) {
self.flowController = flowController
self.interactor = interactor
self.externalImportService = externalImportService
}
}

Expand All @@ -59,7 +65,7 @@ extension ImporterEnterPasswordPresenter {
return
}
switch interactor.openFile(with: password) {
case .success(let data): parseData(data)
case .success(let data): parseData(data, externalImportService: externalImportService)
case .cantReadFile: flowController.toFileError(error: .cantReadFile(reason: nil))
case .wrongPassword: flowController.toWrongPassword()
}
Expand Down Expand Up @@ -91,11 +97,16 @@ extension ImporterEnterPasswordPresenter {
}

private extension ImporterEnterPasswordPresenter {
func parseData(_ data: ExchangeDataServices) {
func parseData(_ data: ExchangeDataServices, externalImportService: ExternalImportService) {
let result = interactor.parseFile(with: data)

if result.count > 0 {
flowController.toPreimportSummary(count: result.count, sections: result.sections, services: result.services)
flowController.toPreimportSummary(
count: result.count,
sections: result.sections,
services: result.services,
externalImportService: externalImportService
)
} else {
flowController.toFileIsEmpty()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,15 @@ protocol ImporterOpenFileFlowControllerParent: AnyObject {

protocol ImporterOpenFileFlowControlling: AnyObject {
func toClose()
func toPreimportSummary(count: Int, sections: [CommonSectionData], services: [ServiceData])
func toPreimportSummary(
count: Int,
sections: [CommonSectionData],
services: [ServiceData],
externalImportService: ExternalImportService
)
func toFileError(error: ImporterOpenFileError)
func toFileIsEmpty()
func toEnterPassword(for data: ExchangeDataFormat)
func toEnterPassword(for data: ExchangeDataFormat, externalImportService: ExternalImportService)
}

final class ImporterOpenFileFlowController: FlowController {
Expand Down Expand Up @@ -67,13 +72,19 @@ extension ImporterOpenFileFlowController: ImporterOpenFileFlowControlling {
parent?.closeImporter()
}

func toPreimportSummary(count: Int, sections: [CommonSectionData], services: [ServiceData]) {
func toPreimportSummary(
count: Int,
sections: [CommonSectionData],
services: [ServiceData],
externalImportService: ExternalImportService
) {
ImporterPreimportSummaryFlowController.push(
in: navigationController,
parent: self,
count: count,
sections: sections,
services: services
services: services,
externalImportService: externalImportService
)
}

Expand All @@ -85,8 +96,13 @@ extension ImporterOpenFileFlowController: ImporterOpenFileFlowControlling {
ImporterFileErrorFlowController.push(in: navigationController, parent: self, fileError: .noNewServices)
}

func toEnterPassword(for data: ExchangeDataFormat) {
ImporterEnterPasswordFlowController.push(in: navigationController, parent: self, data: data)
func toEnterPassword(for data: ExchangeDataFormat, externalImportService: ExternalImportService) {
ImporterEnterPasswordFlowController.push(
in: navigationController,
parent: self,
data: data,
externalImportService: externalImportService
)
}
}

Expand All @@ -95,8 +111,18 @@ extension ImporterOpenFileFlowController: ImporterEnterPasswordFlowControllerPar
parent?.closeImporter()
}

func showPreimportSummary(count: Int, sections: [CommonSectionData], services: [ServiceData]) {
toPreimportSummary(count: count, sections: sections, services: services)
func showPreimportSummary(
count: Int,
sections: [CommonSectionData],
services: [ServiceData],
externalImportService: ExternalImportService
) {
toPreimportSummary(
count: count,
sections: sections,
services: services,
externalImportService: externalImportService
)
}

func showFileError(error: ImporterOpenFileError) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,8 @@ private extension ImporterOpenFilePresenter {
flowController.toPreimportSummary(
count: parseResult.count,
sections: [],
services: parseResult
services: parseResult,
externalImportService: .lastPass
)
}
}
Expand All @@ -94,7 +95,8 @@ private extension ImporterOpenFilePresenter {
flowController.toPreimportSummary(
count: parseResult.count,
sections: [],
services: parseResult
services: parseResult,
externalImportService: .raivo
)
}
case .aegis(let result):
Expand All @@ -109,7 +111,8 @@ private extension ImporterOpenFilePresenter {
flowController.toPreimportSummary(
count: parseResult.count,
sections: [],
services: parseResult
services: parseResult,
externalImportService: .aegis
)
}
}
Expand All @@ -121,7 +124,7 @@ private extension ImporterOpenFilePresenter {
func checkTwoFAS(_ data: ExchangeDataFormat) {
switch interactor.checkTwoFAS(data) {
case .unencrypted: twoFASSummary(for: data)
case .encrypted: flowController.toEnterPassword(for: data)
case .encrypted: flowController.toEnterPassword(for: data, externalImportService: .twofas)
case .newerSchema: flowController.toFileError(error: .newerSchema)
}
}
Expand All @@ -131,7 +134,12 @@ private extension ImporterOpenFilePresenter {
let services = interactor.parseTwoFASServices(with: data.services, sections: sections)
let count = interactor.countNewServices(services)
if count > 0 {
flowController.toPreimportSummary(count: count, sections: sections, services: services)
flowController.toPreimportSummary(
count: count,
sections: sections,
services: services,
externalImportService: .twofas
)
} else {
flowController.toFileIsEmpty()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ final class ImporterPreimportSummaryFlowController: FlowController {
parent: ImporterPreimportSummaryFlowControllerParent,
count: Int,
sections: [CommonSectionData],
services: [ServiceData]
services: [ServiceData],
externalImportService: ExternalImportService
) {
let view = ImporterPreimportSummaryViewController()
let flowController = ImporterPreimportSummaryFlowController(viewController: view)
Expand All @@ -52,7 +53,8 @@ final class ImporterPreimportSummaryFlowController: FlowController {
)
let presenter = ImporterPreimportSummaryPresenter(
flowController: flowController,
interactor: interactor
interactor: interactor,
externalImportService: externalImportService
)
view.presenter = presenter

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,24 +17,36 @@
// along with this program. If not, see <https://www.gnu.org/licenses/>
//

import Foundation
import UIKit

final class ImporterPreimportSummaryPresenter {
weak var view: ImporterPreimportSummaryViewControlling?

private let flowController: ImporterPreimportSummaryFlowControlling
private let interactor: ImporterPreimportSummaryModuleInteracting
private let externalImportService: ExternalImportService

var count: Int {
interactor.count
}

var additionalIcon: UIImage? {
switch externalImportService {
case .aegis: return Asset.externalImportAegis.image
case .raivo: return Asset.externalImportRavio.image
case .lastPass: return Asset.externalImportLastPass.image
case .googleAuth, .twofas: return nil
}
}

init(
flowController: ImporterPreimportSummaryFlowControlling,
interactor: ImporterPreimportSummaryModuleInteracting
interactor: ImporterPreimportSummaryModuleInteracting,
externalImportService: ExternalImportService
) {
self.flowController = flowController
self.interactor = interactor
self.externalImportService = externalImportService
}
}

Expand Down
Loading

0 comments on commit e80082f

Please sign in to comment.