Skip to content

Commit

Permalink
Cleaned up code and renamed class
Browse files Browse the repository at this point in the history
  • Loading branch information
iammajid committed Oct 11, 2024
1 parent 58e8dc1 commit 99a4534
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 23 deletions.
12 changes: 8 additions & 4 deletions Cryptomator.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,8 @@
74F5DC1C26DCD2FB00AFE989 /* StoreObserver.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74F5DC1B26DCD2FB00AFE989 /* StoreObserver.swift */; };
74F5DC1F26DD036D00AFE989 /* StoreManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74F5DC1E26DD036D00AFE989 /* StoreManager.swift */; };
74FC576125ADED030003ED27 /* VaultCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74FC576025ADED030003ED27 /* VaultCell.swift */; };
B330CB452CB5735300C21E03 /* ReauthenticationViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = B330CB442CB5735000C21E03 /* ReauthenticationViewController.swift */; };
B330CB452CB5735300C21E03 /* UnauthorizedErrorViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = B330CB442CB5735000C21E03 /* UnauthorizedErrorViewController.swift */; };
B3D19A442CB937C700CD18A5 /* FileProviderCoordinatorError.swift in Sources */ = {isa = PBXBuildFile; fileRef = B3D19A432CB937BF00CD18A5 /* FileProviderCoordinatorError.swift */; };
/* End PBXBuildFile section */

/* Begin PBXContainerItemProxy section */
Expand Down Expand Up @@ -1042,7 +1043,8 @@
74F5DC1B26DCD2FB00AFE989 /* StoreObserver.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StoreObserver.swift; sourceTree = "<group>"; };
74F5DC1E26DD036D00AFE989 /* StoreManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StoreManager.swift; sourceTree = "<group>"; };
74FC576025ADED030003ED27 /* VaultCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = VaultCell.swift; sourceTree = "<group>"; };
B330CB442CB5735000C21E03 /* ReauthenticationViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ReauthenticationViewController.swift; sourceTree = "<group>"; };
B330CB442CB5735000C21E03 /* UnauthorizedErrorViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UnauthorizedErrorViewController.swift; sourceTree = "<group>"; };
B3D19A432CB937BF00CD18A5 /* FileProviderCoordinatorError.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FileProviderCoordinatorError.swift; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
Expand Down Expand Up @@ -1665,8 +1667,9 @@
4A9FCB0B251A02A3002A8B41 /* FileProviderExtensionUI.entitlements */,
4AA621EB249A6A8400A0BCBD /* Info.plist */,
4A6A521A268B7147006F7368 /* FileProviderCoordinator.swift */,
B3D19A432CB937BF00CD18A5 /* FileProviderCoordinatorError.swift */,
4A6A5218268B6D31006F7368 /* OnboardingViewController.swift */,
B330CB442CB5735000C21E03 /* ReauthenticationViewController.swift */,
B330CB442CB5735000C21E03 /* UnauthorizedErrorViewController.swift */,
4A6A520C268B5EF7006F7368 /* RootViewController.swift */,
4A9BED65268F2D9C00721BAA /* UnlockVaultViewController.swift */,
4AFD8C0E269304A700F77BA6 /* UnlockVaultViewModel.swift */,
Expand Down Expand Up @@ -2673,7 +2676,8 @@
4A804082276952C300D7D999 /* FileProviderCoordinatorSnapshotMock.swift in Sources */,
4A9BED66268F2D9D00721BAA /* UnlockVaultViewController.swift in Sources */,
4A6A521B268B7147006F7368 /* FileProviderCoordinator.swift in Sources */,
B330CB452CB5735300C21E03 /* ReauthenticationViewController.swift in Sources */,
B330CB452CB5735300C21E03 /* UnauthorizedErrorViewController.swift in Sources */,
B3D19A442CB937C700CD18A5 /* FileProviderCoordinatorError.swift in Sources */,
4A6A5219268B6D32006F7368 /* OnboardingViewController.swift in Sources */,
4AFD8C0F269304A700F77BA6 /* UnlockVaultViewModel.swift in Sources */,
);
Expand Down
18 changes: 6 additions & 12 deletions FileProviderExtensionUI/FileProviderCoordinator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import LocalAuthentication
import UIKit

class FileProviderCoordinator: Coordinator {
private var isReauthenticationInProgress = false
lazy var childCoordinators = [Coordinator]()
lazy var navigationController: UINavigationController = {
let appearance = UINavigationBarAppearance()
Expand Down Expand Up @@ -81,12 +80,12 @@ class FileProviderCoordinator: Coordinator {
navigationController.pushViewController(onboardingVC, animated: false)
}

func showReauthentication(vaultName: String) {
let reauthenticationVC = ReauthenticationViewController(vaultName: vaultName)
reauthenticationVC.coordinator = self
navigationController.pushViewController(reauthenticationVC, animated: true)
func showUnauthorizedError(vaultName: String) {
let unauthorizedErrorVC = UnauthorizedErrorViewController(vaultName: vaultName)
unauthorizedErrorVC.coordinator = self
navigationController.pushViewController(unauthorizedErrorVC, animated: true)
}

func openCryptomatorApp() {
let url = URL(string: "cryptomator:")!
extensionContext.open(url) { success in
Expand Down Expand Up @@ -142,16 +141,11 @@ class FileProviderCoordinator: Coordinator {
case CloudProviderError.noInternetConnection, LocalizedCloudProviderError.itemNotFound:
break
case LocalizedCloudProviderError.unauthorized:
self.showReauthentication(vaultName: domain.displayName)
self.isReauthenticationInProgress = true
return
throw FileProviderCoordinatorError.unauthorized(vaultName: domain.displayName)
default:
throw error
}
}.then {
guard !self.isReauthenticationInProgress else {
return
}
let cachedVault = try vaultCache.getCachedVault(withVaultUID: vaultUID)
if let vaultConfigToken = cachedVault.vaultConfigToken {
let unverifiedVaultConfig = try UnverifiedVaultConfig(token: vaultConfigToken)
Expand Down
13 changes: 13 additions & 0 deletions FileProviderExtensionUI/FileProviderCoordinatorError.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
//
// FileProviderCoordinatorError.swift
// Cryptomator
//
// Created by Majid Achhoud on 11.10.24.
// Copyright © 2024 Skymatic GmbH. All rights reserved.
//

import Foundation

public enum FileProviderCoordinatorError: Error {
case unauthorized(vaultName: String)
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// ReauthenticationViewController.swift
// UnauthorizedErrorViewController.swift
// Cryptomator
//
// Created by Majid Achhoud on 08.10.24.
Expand All @@ -9,7 +9,7 @@
import CryptomatorCommonCore
import UIKit

class ReauthenticationViewController: UITableViewController {
class UnauthorizedErrorViewController: UITableViewController {
weak var coordinator: FileProviderCoordinator?
private var vaultName: String

Expand Down Expand Up @@ -60,7 +60,7 @@ class ReauthenticationViewController: UITableViewController {
// MARK: - UITableViewDelegate

override func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
return ReauthenticationHeaderView(vaultName: vaultName)
return UnauthorizedErrorHeaderView(vaultName: vaultName)
}

override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
Expand All @@ -69,7 +69,7 @@ class ReauthenticationViewController: UITableViewController {
}
}

private class ReauthenticationHeaderView: LargeHeaderFooterView {
private class UnauthorizedErrorHeaderView: LargeHeaderFooterView {
init(vaultName: String) {
let config = UIImage.SymbolConfiguration(pointSize: 100)
let symbolImage = UIImage(systemName: "exclamationmark.triangle.fill", withConfiguration: config)?.withTintColor(.systemYellow, renderingMode: .alwaysOriginal)
Expand All @@ -79,4 +79,3 @@ private class ReauthenticationHeaderView: LargeHeaderFooterView {
super.init(image: symbolImage, infoText: infoText)
}
}

1 change: 0 additions & 1 deletion SharedResources/de.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,6 @@
"fileProvider.error.biometricalAuthWrongPassword.message" = "Das für %@ gespeicherte Passwort ist falsch. Bitte versuche es erneut und gib dein Passwort ein, um %@ wieder zu aktivieren.";
"fileProvider.error.defaultLock.title" = "Entsperren erforderlich";
"fileProvider.error.defaultLock.message" = "Um auf den Inhalt deines Tresors zuzugreifen und ihn anzuzeigen, muss dieser entsperrt werden.";
"fileprovider.error.reauthentication" = "Der Cloud-Zugriff auf Ihren Tresor \"%@\" muss neu authentifiziert werden. Öffnen Sie die Haupt-App, um dies zu tun.";
"fileProvider.error.unlockButton" = "Entsperren";
"fileProvider.clearFileFromCache.title" = "Datei aus Cache löschen";
"fileProvider.clearFileFromCache.message" = "Dies entfernt nur die lokale Datei von deinem Gerät und löscht nicht die Datei in der Cloud.";
Expand Down
2 changes: 1 addition & 1 deletion SharedResources/en.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@
"fileProvider.error.biometricalAuthWrongPassword.message" = "The password that has been saved for %@ is wrong. Please try again and enter your password to re-enable %@.";
"fileProvider.error.defaultLock.title" = "Unlock Required";
"fileProvider.error.defaultLock.message" = "To access and show the contents of your vault, it has to be unlocked.";
"fileprovider.error.reauthentication" = "The cloud access of your vault \"%@\" needs to be re-authenticated. Open the main app to do so.";
"fileprovider.error.reauthentication" = "Access to your vault \"%@\" was denied. Open the main app to check your connection and re-authenticate if needed.";
"fileProvider.error.unlockButton" = "Unlock";
"fileProvider.clearFileFromCache.title" = "Clear File from Cache";
"fileProvider.clearFileFromCache.message" = "This only removes the local file from your device and does not delete the file in the cloud.";
Expand Down

0 comments on commit 99a4534

Please sign in to comment.