Skip to content

Commit ad78d19

Browse files
committed
Add Share Vault Button in Vault Detail
1 parent 9f0e435 commit ad78d19

File tree

16 files changed

+567
-1
lines changed

16 files changed

+567
-1
lines changed

Cryptomator.xcodeproj/project.pbxproj

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -445,6 +445,9 @@
445445
B34C532A2D142BA700F30FE9 /* SharePointAuthenticating.swift in Sources */ = {isa = PBXBuildFile; fileRef = B34C53292D142B9200F30FE9 /* SharePointAuthenticating.swift */; };
446446
B379DBBF2D27F595003B5849 /* SharePointDriveListViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = B379DBBE2D27F58C003B5849 /* SharePointDriveListViewController.swift */; };
447447
B379DBC12D27F5B5003B5849 /* SharePointDriveListViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = B379DBC02D27F5A4003B5849 /* SharePointDriveListViewModel.swift */; };
448+
B3C397FE2EB10FC0001280AC /* ShareVaultViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = B3C397FC2EB10FC0001280AC /* ShareVaultViewController.swift */; };
449+
B3C398002EB110F9001280AC /* ShareVaultViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = B3C397FF2EB110F9001280AC /* ShareVaultViewModel.swift */; };
450+
988E23D6223540118B002237 /* ShareVaultCoordinator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 988E23D6223540118B002238 /* ShareVaultCoordinator.swift */; };
448451
B3D19A442CB937C700CD18A5 /* FileProviderCoordinatorError.swift in Sources */ = {isa = PBXBuildFile; fileRef = B3D19A432CB937BF00CD18A5 /* FileProviderCoordinatorError.swift */; };
449452
/* End PBXBuildFile section */
450453

@@ -1064,6 +1067,9 @@
10641067
B34C53292D142B9200F30FE9 /* SharePointAuthenticating.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SharePointAuthenticating.swift; sourceTree = "<group>"; };
10651068
B379DBBE2D27F58C003B5849 /* SharePointDriveListViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SharePointDriveListViewController.swift; sourceTree = "<group>"; };
10661069
B379DBC02D27F5A4003B5849 /* SharePointDriveListViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SharePointDriveListViewModel.swift; sourceTree = "<group>"; };
1070+
B3C397FC2EB10FC0001280AC /* ShareVaultViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ShareVaultViewController.swift; sourceTree = "<group>"; };
1071+
B3C397FF2EB110F9001280AC /* ShareVaultViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ShareVaultViewModel.swift; sourceTree = "<group>"; };
1072+
988E23D6223540118B002238 /* ShareVaultCoordinator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ShareVaultCoordinator.swift; sourceTree = "<group>"; };
10671073
B3D19A432CB937BF00CD18A5 /* FileProviderCoordinatorError.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FileProviderCoordinatorError.swift; sourceTree = "<group>"; };
10681074
/* End PBXFileReference section */
10691075

@@ -1282,6 +1288,7 @@
12821288
4A4B7E3E26B2ABC0009BFDB1 /* VaultDetailViewController.swift */,
12831289
4A4B7E4126B2AD6F009BFDB1 /* VaultDetailViewModel.swift */,
12841290
4AB8539B26BA8A8200555F00 /* VaultPasswordVerifying.swift */,
1291+
B3C397FD2EB10FC0001280AC /* ShareVault */,
12851292
4AF45357271F2A8B00CF1919 /* RenameVault */,
12861293
4A0337C82726FBEC001753B7 /* MoveVault */,
12871294
4A91D8CF272ADC7E003F8BD8 /* ChangePassword */,
@@ -2114,6 +2121,16 @@
21142121
path = Purchase;
21152122
sourceTree = "<group>";
21162123
};
2124+
B3C397FD2EB10FC0001280AC /* ShareVault */ = {
2125+
isa = PBXGroup;
2126+
children = (
2127+
988E23D6223540118B002238 /* ShareVaultCoordinator.swift */,
2128+
B3C397FF2EB110F9001280AC /* ShareVaultViewModel.swift */,
2129+
B3C397FC2EB10FC0001280AC /* ShareVaultViewController.swift */,
2130+
);
2131+
path = ShareVault;
2132+
sourceTree = "<group>";
2133+
};
21172134
/* End PBXGroup section */
21182135

21192136
/* Begin PBXNativeTarget section */
@@ -2783,6 +2800,8 @@
27832800
4A644B57267C958F008CBB9A /* ChildCoordinator.swift in Sources */,
27842801
4A53CC15267CC33100853BB3 /* CreateNewVaultPasswordViewModel.swift in Sources */,
27852802
4AA22C1E261CA94700A17486 /* UsernameFieldCell.swift in Sources */,
2803+
B3C397FE2EB10FC0001280AC /* ShareVaultViewController.swift in Sources */,
2804+
988E23D6223540118B002237 /* ShareVaultCoordinator.swift in Sources */,
27862805
4A136132276770BB0077EB7F /* SnapshotVaultListViewModel.swift in Sources */,
27872806
4AED9A79286B4DF500352951 /* S3Authenticating.swift in Sources */,
27882807
747C35172762A3F500E4CA28 /* AttributedTextHeaderFooterViewModel.swift in Sources */,
@@ -2810,6 +2829,7 @@
28102829
4A644B55267C926A008CBB9A /* FolderCreating.swift in Sources */,
28112830
74A295EF2D80902800C54136 /* SharePointAuthenticator.swift in Sources */,
28122831
4A3D658626847B11000DA764 /* CreateNewLocalVaultViewModel.swift in Sources */,
2832+
B3C398002EB110F9001280AC /* ShareVaultViewModel.swift in Sources */,
28132833
4AE97DAB24572E4900452814 /* AppDelegate.swift in Sources */,
28142834
4AA22C16261CA8D800A17486 /* URLFieldCell.swift in Sources */,
28152835
4A2FD07925B5D98B008565C8 /* CloudCell.swift in Sources */,
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
//
2+
// ShareVaultCoordinator.swift
3+
// Cryptomator
4+
//
5+
// Created by Majid Achhoud on 30.10.25.
6+
// Copyright © 2025 Skymatic GmbH. All rights reserved.
7+
//
8+
9+
import CryptomatorCloudAccessCore
10+
import CryptomatorCommonCore
11+
import UIKit
12+
13+
class ShareVaultCoordinator: Coordinator {
14+
weak var parentCoordinator: Coordinator?
15+
lazy var childCoordinators = [Coordinator]()
16+
var navigationController: UINavigationController
17+
private let vaultInfo: VaultInfo
18+
19+
init(vaultInfo: VaultInfo, navigationController: UINavigationController) {
20+
self.vaultInfo = vaultInfo
21+
self.navigationController = navigationController
22+
}
23+
24+
func start() {
25+
let viewModel: ShareVaultViewModel
26+
if vaultInfo.vaultConfigType == .hub, let hubURL = extractHubVaultURL() {
27+
viewModel = ShareVaultViewModel(type: .hub(hubURL))
28+
} else {
29+
viewModel = ShareVaultViewModel(type: .normal)
30+
}
31+
let shareVaultViewController = ShareVaultViewController(viewModel: viewModel)
32+
shareVaultViewController.coordinator = self
33+
navigationController.pushViewController(shareVaultViewController, animated: true)
34+
}
35+
36+
private func extractHubVaultURL() -> URL? {
37+
guard let cachedVault = try? VaultDBCache().getCachedVault(withVaultUID: vaultInfo.vaultUID),
38+
let vaultConfigToken = cachedVault.vaultConfigToken,
39+
let vaultConfig = try? UnverifiedVaultConfig(token: vaultConfigToken),
40+
let hubConfig = vaultConfig.allegedHubConfig else {
41+
return nil
42+
}
43+
44+
// Extract base Hub URL
45+
let apiBaseURL: URL?
46+
if let apiBaseUrl = hubConfig.apiBaseUrl {
47+
apiBaseURL = URL(string: apiBaseUrl)
48+
} else if let deviceResourceURL = URL(string: hubConfig.devicesResourceUrl) {
49+
apiBaseURL = deviceResourceURL.deletingLastPathComponent()
50+
} else {
51+
apiBaseURL = nil
52+
}
53+
54+
return apiBaseURL?.deletingLastPathComponent()
55+
}
56+
}

0 commit comments

Comments
 (0)