-
-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add UnauthorizedError screen for invalid cloud access in Files app (#384
- Loading branch information
Showing
5 changed files
with
118 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
FileProviderExtensionUI/FileProviderCoordinatorError.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
} |
81 changes: 81 additions & 0 deletions
81
FileProviderExtensionUI/UnauthorizedErrorViewController.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
// | ||
// UnauthorizedErrorViewController.swift | ||
// Cryptomator | ||
// | ||
// Created by Majid Achhoud on 08.10.24. | ||
// Copyright © 2024 Skymatic GmbH. All rights reserved. | ||
// | ||
|
||
import CryptomatorCommonCore | ||
import UIKit | ||
|
||
class UnauthorizedErrorViewController: UITableViewController { | ||
weak var coordinator: FileProviderCoordinator? | ||
private var vaultName: String | ||
|
||
private lazy var openCryptomatorCell: UITableViewCell = { | ||
let cell = UITableViewCell() | ||
cell.textLabel?.text = LocalizedString.getValue("fileProvider.onboarding.button.openCryptomator") | ||
cell.textLabel?.textColor = .cryptomatorPrimary | ||
return cell | ||
}() | ||
|
||
init(vaultName: String) { | ||
self.vaultName = vaultName | ||
super.init(style: .insetGrouped) | ||
} | ||
|
||
@available(*, unavailable) | ||
required init?(coder: NSCoder) { | ||
fatalError("init(coder:) has not been implemented") | ||
} | ||
|
||
override func viewDidLoad() { | ||
super.viewDidLoad() | ||
title = vaultName | ||
let doneButton = UIBarButtonItem(barButtonSystemItem: .cancel, target: self, action: #selector(done)) | ||
navigationItem.rightBarButtonItem = doneButton | ||
tableView.backgroundColor = .cryptomatorBackground | ||
tableView.cellLayoutMarginsFollowReadableWidth = true | ||
} | ||
|
||
@objc func done() { | ||
coordinator?.userCancelled() | ||
} | ||
|
||
override func numberOfSections(in tableView: UITableView) -> Int { | ||
return 1 | ||
} | ||
|
||
// MARK: - UITableViewDataSource | ||
|
||
override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { | ||
return 1 | ||
} | ||
|
||
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { | ||
return openCryptomatorCell | ||
} | ||
|
||
// MARK: - UITableViewDelegate | ||
|
||
override func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? { | ||
return UnauthorizedErrorHeaderView(vaultName: vaultName) | ||
} | ||
|
||
override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { | ||
tableView.deselectRow(at: indexPath, animated: true) | ||
coordinator?.openCryptomatorApp() | ||
} | ||
} | ||
|
||
private class UnauthorizedErrorHeaderView: LargeHeaderFooterView { | ||
init(vaultName: String) { | ||
let config = UIImage.SymbolConfiguration(pointSize: 120) | ||
let symbolImage = UIImage(systemName: "exclamationmark.triangle.fill", withConfiguration: config)?.withTintColor(.systemYellow, renderingMode: .alwaysOriginal) | ||
|
||
let infoText = String(format: LocalizedString.getValue("fileprovider.error.unauthorized.text"), vaultName) | ||
|
||
super.init(image: symbolImage, infoText: infoText) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters