Skip to content

Commit

Permalink
Merge branch 'release/2.0.0-beta1'
Browse files Browse the repository at this point in the history
  • Loading branch information
tobihagemann committed Jun 29, 2021
2 parents 75f1b31 + 7339b8c commit 30307f6
Show file tree
Hide file tree
Showing 211 changed files with 1,864 additions and 495 deletions.
174 changes: 154 additions & 20 deletions Cryptomator.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
"repositoryURL": "https://github.com/cryptomator/cloud-access-swift.git",
"state": {
"branch": null,
"revision": "fb5090d76f1f8861f57d2186d9109449c7867918",
"version": "0.12.2"
"revision": "785aba8f7d8b0c4762667b5b12c70870ca56b224",
"version": "0.12.4"
}
},
{
Expand Down
17 changes: 1 addition & 16 deletions Cryptomator/AddVault/AddVaultSuccessCoordinator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -43,22 +43,7 @@ class AddVaultSuccessCoordinator: AddVaultSuccesing, Coordinator {
}

func showFilesApp(forVaultUID vaultUID: String) {
guard let containerURL = FileManager.default.containerURL(forSecurityApplicationGroupIdentifier: CryptomatorConstants.appGroupName) else {
DDLogDebug("containerURL is nil")
return
}
let url = containerURL.appendingPathComponent("File Provider Storage").appendingPathComponent(vaultUID)
guard let sharedDocumentsURL = changeSchemeToSharedDocuments(for: url) else {
DDLogDebug("Conversion to shared documents url failed")
return
}
UIApplication.shared.open(sharedDocumentsURL)
FilesAppUtil.showFilesApp(forVaultUID: vaultUID)
done()
}

private func changeSchemeToSharedDocuments(for url: URL) -> URL? {
var comps = URLComponents(url: url, resolvingAgainstBaseURL: false)
comps?.scheme = "shareddocuments"
return comps?.url
}
}
8 changes: 4 additions & 4 deletions Cryptomator/AddVault/AddVaultSuccessViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,10 @@ private class VaultSuccessHeaderView: UIView {
addSubview(stack)

NSLayoutConstraint.activate([
stack.leadingAnchor.constraint(equalTo: layoutMarginsGuide.leadingAnchor),
stack.trailingAnchor.constraint(equalTo: layoutMarginsGuide.trailingAnchor),
stack.topAnchor.constraint(equalTo: layoutMarginsGuide.topAnchor, constant: 12),
stack.bottomAnchor.constraint(equalTo: layoutMarginsGuide.bottomAnchor, constant: -12)
stack.leadingAnchor.constraint(equalTo: readableContentGuide.leadingAnchor),
stack.trailingAnchor.constraint(equalTo: readableContentGuide.trailingAnchor),
stack.topAnchor.constraint(equalTo: topAnchor, constant: 20),
stack.bottomAnchor.constraint(equalTo: bottomAnchor, constant: -20)
])
}
}
Expand Down
1 change: 1 addition & 0 deletions Cryptomator/AddVault/AddVaultSuccessViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
//

import Foundation

struct AddVaultSuccessViewModel {
let vaultName: String
let vaultUID: String
Expand Down
7 changes: 3 additions & 4 deletions Cryptomator/AddVault/AddVaultViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,10 @@ class AddVaultViewController: UITableViewController {
imageView.contentMode = .scaleAspectFit
imageView.translatesAutoresizingMaskIntoConstraints = false
NSLayoutConstraint.activate([
imageView.leadingAnchor.constraint(equalTo: headerView.layoutMarginsGuide.leadingAnchor),
imageView.bottomAnchor.constraint(equalTo: headerView.bottomAnchor, constant: -20),
imageView.leadingAnchor.constraint(equalTo: headerView.readableContentGuide.leadingAnchor),
imageView.trailingAnchor.constraint(equalTo: headerView.readableContentGuide.trailingAnchor),
imageView.topAnchor.constraint(equalTo: headerView.topAnchor, constant: 20),
imageView.trailingAnchor.constraint(equalTo: headerView.layoutMarginsGuide.trailingAnchor)
imageView.bottomAnchor.constraint(equalTo: headerView.bottomAnchor, constant: -20)
])

return headerView
Expand All @@ -93,7 +93,6 @@ class AddVaultViewController: UITableViewController {
}

#if DEBUG
import CryptomatorCloudAccess
import SwiftUI

struct VaultAddVCPreview: PreviewProvider {
Expand Down
1 change: 0 additions & 1 deletion Cryptomator/AddVault/ChooseCloudViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ class ChooseCloudViewController: SingleSectionHeaderTableViewController {
}

#if DEBUG
import CryptomatorCloudAccess
import SwiftUI

struct ChooseCloudVCPreview: PreviewProvider {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,8 @@
//

import UIKit
class CreateNewVaultChooseFolderViewController: ChooseFolderViewController {
init(viewModel: CreateNewVaultChooseFolderViewModelProtocol) {
super.init(with: viewModel)
}

class CreateNewVaultChooseFolderViewController: ChooseFolderViewController {
override func viewDidLoad() {
super.viewDidLoad()
title = NSLocalizedString("addVault.createNewVault.title", comment: "")
Expand All @@ -25,16 +22,16 @@ class CreateNewVaultChooseFolderViewController: ChooseFolderViewController {
toolbarItems?.append(createFolderButton)
}

override func showDetectedVault(_ vault: Item) {
let failureView = FailureView()
override func showDetectedVault(_ vault: VaultDetailItem) {
let failureView = DetectedVaultFailureView()
let containerView = UIView()
failureView.translatesAutoresizingMaskIntoConstraints = false
containerView.addSubview(failureView)
NSLayoutConstraint.activate([
failureView.centerYAnchor.constraint(equalTo: containerView.centerYAnchor),
failureView.centerXAnchor.constraint(equalTo: containerView.centerXAnchor),
failureView.leadingAnchor.constraint(equalTo: containerView.readableContentGuide.leadingAnchor),
failureView.trailingAnchor.constraint(equalTo: containerView.readableContentGuide.trailingAnchor)
failureView.centerYAnchor.constraint(equalTo: containerView.centerYAnchor),
failureView.leadingAnchor.constraint(equalTo: containerView.leadingAnchor),
failureView.trailingAnchor.constraint(equalTo: containerView.trailingAnchor)
])

// Prevents the view from being placed under the navigation bar
Expand All @@ -58,23 +55,36 @@ class CreateNewVaultChooseFolderViewController: ChooseFolderViewController {
}
}

private class FailureView: DetectedVaultView {
init() {
let configuration = UIImage.SymbolConfiguration(pointSize: 120)
let warningSymbol = UIImage(systemName: "exclamationmark.triangle.fill", withConfiguration: configuration)
let imageView = UIImageView(image: warningSymbol)
imageView.tintColor = UIColor(named: "yellow")
super.init(imageView: imageView, text: NSLocalizedString("addVault.createNewVault.detectedMasterkey.text", comment: ""))
}
}

#if DEBUG
import CryptomatorCloudAccessCore
import SwiftUI
struct FailureView_Preview: PreviewProvider {
static var previews: some View {
FailureView().toPreview()

private class CreateNewVaultChooseFolderViewModelMock: ChooseFolderViewModelProtocol {
var headerTitle: String = "/Vault"

let foundMasterkey = true
let canCreateFolder: Bool
let cloudPath: CloudPath
let items: [CloudItemMetadata] = []

init(cloudPath: CloudPath, canCreateFolder: Bool) {
self.canCreateFolder = canCreateFolder
self.cloudPath = cloudPath
}

func startListenForChanges(onError: @escaping (Error) -> Void, onChange: @escaping () -> Void, onVaultDetection: @escaping (VaultDetailItem) -> Void) {
onChange()
}

func refreshItems() {}
}

struct CreateNewVaultChooseFolderVCPreview: PreviewProvider {
static var previews: some View {
let viewController = CreateNewVaultChooseFolderViewController(with: CreateNewVaultChooseFolderViewModelMock(cloudPath: CloudPath("/Vault"), canCreateFolder: false))
let item = VaultDetailItem(name: "Vault", vaultPath: CloudPath("/Vault/masterkey.cryptomator"), isLegacyVault: false)
viewController.showDetectedVault(item)
return viewController.toPreview()
}
}
#endif
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@

import CryptomatorCloudAccessCore
import Foundation

protocol CreateNewVaultChooseFolderViewModelProtocol: ChooseFolderViewModelProtocol {
var vaultName: String { get }
func chooseCurrentFolder() throws -> Item
func chooseCurrentFolder() throws -> Folder
}

class CreateNewVaultChooseFolderViewModel: ChooseFolderViewModel, CreateNewVaultChooseFolderViewModelProtocol {
Expand All @@ -21,12 +22,12 @@ class CreateNewVaultChooseFolderViewModel: ChooseFolderViewModel, CreateNewVault
super.init(canCreateFolder: true, cloudPath: cloudPath, provider: provider)
}

func chooseCurrentFolder() throws -> Item {
func chooseCurrentFolder() throws -> Folder {
guard !items.contains(where: { $0.name == vaultName }) else {
throw CreateNewVaultChooseFolderViewModelError.vaultNameCollision
}
let vaultPath = cloudPath.appendingPathComponent(vaultName)
return Item(type: .folder, path: vaultPath)
return Folder(path: vaultPath)
}
}

Expand Down
57 changes: 39 additions & 18 deletions Cryptomator/AddVault/CreateNewVault/CreateNewVaultCoordinator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
// Copyright © 2021 Skymatic GmbH. All rights reserved.
//

import CocoaLumberjackSwift
import CryptomatorCloudAccessCore
import CryptomatorCommonCore
import UIKit
Expand All @@ -32,16 +33,13 @@ class CreateNewVaultCoordinator: AccountListing, CloudChoosing, Coordinator {

func showAccountList(for cloudProviderType: CloudProviderType) {
if cloudProviderType == .localFileSystem {
let alertController = UIAlertController(title: "Info", message: NSLocalizedString("testFlight.otherFileProviders.alert.text", comment: ""), preferredStyle: .alert)
let okAction = UIAlertAction(title: NSLocalizedString("common.button.ok", comment: ""), style: .default)
alertController.addAction(okAction)
navigationController.present(alertController, animated: true, completion: nil)
return
startLocalFileSystemAuthenticationFlow()
} else {
let viewModel = AccountListViewModel(with: cloudProviderType)
let accountListVC = AccountListViewController(with: viewModel)
accountListVC.coordinator = self
navigationController.pushViewController(accountListVC, animated: true)
}
let viewModel = AccountListViewModel(with: cloudProviderType)
let accountListVC = AccountListViewController(with: viewModel)
accountListVC.coordinator = self
navigationController.pushViewController(accountListVC, animated: true)
}

func showAddAccount(for cloudProviderType: CloudProviderType, from viewController: UIViewController) {
Expand Down Expand Up @@ -70,6 +68,23 @@ class CreateNewVaultCoordinator: AccountListing, CloudChoosing, Coordinator {
navigationController.dismiss(animated: true)
parentCoordinator?.childDidFinish(self)
}

// MARK: - LocalFileSystemProvider Flow

private func startLocalFileSystemAuthenticationFlow() {
let child = CreateNewLocalVaultCoordinator(vaultName: vaultName, navigationController: navigationController)
childCoordinators.append(child)
child.parentCoordinator = self
child.start()
}

func startAuthenticatedLocalFileSystemCreateNewVaultFlow(credential: LocalFileSystemCredential, account: CloudProviderAccount, item: Item) {
let provider = LocalFileSystemProvider(rootURL: credential.rootURL)
let child = AuthenticatedCreateNewVaultCoordinator(navigationController: navigationController, provider: provider, account: account, vaultName: vaultName)
childCoordinators.append(child)
child.parentCoordinator = self
child.chooseItem(item)
}
}

private class AuthenticatedCreateNewVaultCoordinator: FolderChoosing, VaultInstalling, Coordinator {
Expand All @@ -96,7 +111,7 @@ private class AuthenticatedCreateNewVaultCoordinator: FolderChoosing, VaultInsta

func showItems(for path: CloudPath) {
let viewModel = CreateNewVaultChooseFolderViewModel(vaultName: vaultName, cloudPath: path, provider: provider)
let chooseFolderVC = CreateNewVaultChooseFolderViewController(viewModel: viewModel)
let chooseFolderVC = CreateNewVaultChooseFolderViewController(with: viewModel)
chooseFolderVC.coordinator = self
navigationController.pushViewController(chooseFolderVC, animated: true)
}
Expand All @@ -106,26 +121,32 @@ private class AuthenticatedCreateNewVaultCoordinator: FolderChoosing, VaultInsta
}

func chooseItem(_ item: Item) {
switch item.type {
case .folder:
let viewModel = CreateNewVaultPasswordViewModel(vaultPath: item.path, account: account, vaultUID: UUID().uuidString)
let passwordVC = CreateNewVaultPasswordViewController(viewModel: viewModel)
passwordVC.coordinator = self
navigationController.pushViewController(passwordVC, animated: true)
default:
guard let vaultFolder = item as? Folder else {
handleError(VaultCoordinatorError.wrongItemType, for: navigationController)
return
}
let viewModel = CreateNewVaultPasswordViewModel(vaultPath: vaultFolder.path, account: account, vaultUID: UUID().uuidString)
let passwordVC = CreateNewVaultPasswordViewController(viewModel: viewModel)
passwordVC.coordinator = self
navigationController.pushViewController(passwordVC, animated: true)
}

func showCreateNewFolder(parentPath: CloudPath) {
let modalNavigationController = UINavigationController()
let modalNavigationController = BaseNavigationController()
let child = AuthenticatedFolderCreationCoordinator(navigationController: modalNavigationController, provider: provider, parentPath: parentPath)
child.parentCoordinator = self
childCoordinators.append(child)
navigationController.topViewController?.present(modalNavigationController, animated: true)
child.start()
}

func handleError(error: Error) {
navigationController.popViewController(animated: true)
if let topViewController = navigationController.topViewController {
handleError(error, for: topViewController)
}
}

// MARK: - VaultInstalling

func showSuccessfullyAddedVault(withName name: String, vaultUID: String) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
//

import UIKit

class CreateNewVaultPasswordViewController: UITableViewController {
weak var coordinator: (Coordinator & VaultInstalling)?
private var viewModel: CreateNewVaultPasswordViewModelProtocol
Expand Down Expand Up @@ -121,6 +122,7 @@ class CreateNewVaultPasswordViewController: UITableViewController {
#if DEBUG
import Promises
import SwiftUI

private class CreateNewVaultPasswordViewModelMock: CreateNewVaultPasswordViewModelProtocol {
let vaultUID = ""
let vaultName = ""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import CryptomatorCloudAccessCore
import CryptomatorCommonCore
import Foundation
import Promises

protocol CreateNewVaultPasswordViewModelProtocol {
var headerTitles: [String] { get }
var vaultUID: String { get }
Expand All @@ -26,7 +27,10 @@ class CreateNewVaultPasswordViewModel: CreateNewVaultPasswordViewModelProtocol {
}

let vaultUID: String
let headerTitles = ["Enter a new password.", "Confirm the new password."]
let headerTitles = [
NSLocalizedString("addVault.createNewVault.enterPassword.header", comment: ""),
NSLocalizedString("addVault.createNewVault.confirmPassword.header", comment: "")
]
var password: String?
var confirmingPassword: String?

Expand Down
19 changes: 19 additions & 0 deletions Cryptomator/AddVault/CreateNewVault/DetectedVaultFailureView.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
//
// DetectedVaultFailureView.swift
// Cryptomator
//
// Created by Philipp Schmid on 28.06.21.
// Copyright © 2021 Skymatic GmbH. All rights reserved.
//

import UIKit

class DetectedVaultFailureView: DetectedVaultView {
init() {
let configuration = UIImage.SymbolConfiguration(pointSize: 120)
let warningSymbol = UIImage(systemName: "exclamationmark.triangle.fill", withConfiguration: configuration)
let imageView = UIImageView(image: warningSymbol)
imageView.tintColor = UIColor(named: "yellow")
super.init(imageView: imageView, text: NSLocalizedString("addVault.createNewVault.detectedMasterkey.text", comment: ""))
}
}
Loading

0 comments on commit 30307f6

Please sign in to comment.