Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Public share locked and expired UI #1328

Merged
merged 17 commits into from
Nov 19, 2024
Merged
Show file tree
Hide file tree
Changes from 11 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions kDrive/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -107,11 +107,12 @@ final class AppDelegate: UIResponder, UIApplicationDelegate {
Task {
try! await Task.sleep(nanoseconds:5_000_000_000)
print("coucou")
let somePublicShare = URL(string: "https://kdrive.infomaniak.com/app/share/140946/01953831-16d3-4df6-8b48-33c8001c7981")
//await UIApplication.shared.open(somePublicShare!) // opens safari
// a public share expired
let somePublicShare = URL(string: "https://kdrive.infomaniak.com/app/share/140946/81de098a-3156-4ae6-93df-be7f9ae78ddd")
PhilippeWeidmann marked this conversation as resolved.
Show resolved Hide resolved
// a public share password protected
// let somePublicShare = URL(string: "https://kdrive.infomaniak.com/app/share/140946/34844cea-db8d-4d87-b66f-e944e9759a2e")

let components = URLComponents(url: somePublicShare!, resolvingAgainstBaseURL: true)
await UniversalLinksHelper.handlePath(components!.path)
await UniversalLinksHelper.handleURL(somePublicShare!)
}

return true
Expand Down
55 changes: 49 additions & 6 deletions kDrive/AppRouter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -585,19 +585,62 @@ public struct AppRouter: AppNavigable {

// MARK: RouterFileNavigable

@MainActor public func presentPublicShareLocked(_ destinationURL: URL) {
guard let window,
adrien-coye marked this conversation as resolved.
Show resolved Hide resolved
let rootViewController = window.rootViewController as? MainTabViewController else {
fatalError("TODO: fix offline routing - presentPublicShareLocked")
return
}

rootViewController.dismiss(animated: false) {
let viewController = LockedFolderViewController()
viewController.destinationURL = destinationURL
let publicShareNavigationController = UINavigationController(rootViewController: viewController)
publicShareNavigationController.modalPresentationStyle = .fullScreen
publicShareNavigationController.modalTransitionStyle = .coverVertical

rootViewController.selectedIndex = MainTabBarIndex.files.rawValue

guard let navigationController = rootViewController.selectedViewController as? UINavigationController else {
return
}

navigationController.present(publicShareNavigationController, animated: true, completion: nil)
}
}

@MainActor public func presentPublicShareExpired() {
guard let window,
adrien-coye marked this conversation as resolved.
Show resolved Hide resolved
let rootViewController = window.rootViewController as? MainTabViewController else {
fatalError("TODO: fix offline routing - presentPublicShareExpired")
return
}

rootViewController.dismiss(animated: false) {
let viewController = UnavaillableFolderViewController()
let publicShareNavigationController = UINavigationController(rootViewController: viewController)
publicShareNavigationController.modalPresentationStyle = .fullScreen
publicShareNavigationController.modalTransitionStyle = .coverVertical

rootViewController.selectedIndex = MainTabBarIndex.files.rawValue

guard let navigationController = rootViewController.selectedViewController as? UINavigationController else {
return
}

navigationController.present(publicShareNavigationController, animated: true, completion: nil)
}
}

@MainActor public func presentPublicShare(
frozenRootFolder: File,
publicShareProxy: PublicShareProxy,
driveFileManager: DriveFileManager,
apiFetcher: PublicShareApiFetcher
) {
guard let window,
let rootViewController = window.rootViewController else {
fatalError("TODO: lazy load a rootViewController")
}

guard let rootViewController = window.rootViewController as? MainTabViewController else {
fatalError("Root is not a MainTabViewController")
let rootViewController = window.rootViewController as? MainTabViewController else {
fatalError("TODO: fix offline routing - presentPublicShare")
return
}

Expand Down
24 changes: 24 additions & 0 deletions kDrive/Resources/Assets.xcassets/UFO.imageset/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"images" : [
{
"filename" : "abducted_files.svg",
"idiom" : "universal"
},
{
"appearances" : [
{
"appearance" : "luminosity",
"value" : "dark"
}
],
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
},
"properties" : {
"preserves-vector-representation" : true
}
}
39 changes: 39 additions & 0 deletions kDrive/Resources/Assets.xcassets/UFO.imageset/abducted_files.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"images" : [
{
"filename" : "lock-clear.svg",
"idiom" : "universal"
},
{
"appearances" : [
{
"appearance" : "luminosity",
"value" : "dark"
}
],
"filename" : "lock-dark.svg",
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
},
"properties" : {
"preserves-vector-representation" : true
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 2 additions & 3 deletions kDrive/SceneDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -232,13 +232,12 @@ final class SceneDelegate: UIResponder, UIWindowSceneDelegate, AccountManagerDel
Log.sceneDelegate("scene continue userActivity")
Task {
guard userActivity.activityType == NSUserActivityTypeBrowsingWeb,
let incomingURL = userActivity.webpageURL,
let components = URLComponents(url: incomingURL, resolvingAgainstBaseURL: true) else {
let incomingURL = userActivity.webpageURL else {
Log.sceneDelegate("scene continue userActivity - invalid activity", level: .error)
return
}

await UniversalLinksHelper.handlePath(components.path)
await UniversalLinksHelper.handleURL(incomingURL)
}
}

Expand Down
116 changes: 116 additions & 0 deletions kDrive/UI/Controller/Files/External/BaseInfoViewController.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
/*
Infomaniak kDrive - iOS App
Copyright (C) 2024 Infomaniak Network SA

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

import kDriveCore
import kDriveResources
import UIKit

class BaseInfoViewController: UIViewController {
adrien-coye marked this conversation as resolved.
Show resolved Hide resolved
let titleLabel: UILabel = {
let label = UILabel()
label.font = .preferredFont(forTextStyle: .headline)
label.textColor = KDriveResourcesAsset.primaryTextColor.color
label.numberOfLines = 1
label.textAlignment = .center
return label
}()

let descriptionLabel: UILabel = {
let label = UILabel()
label.font = .preferredFont(forTextStyle: .body)
label.textColor = KDriveResourcesAsset.secondaryTextColor.color
label.numberOfLines = 0
label.textAlignment = .center
return label
}()

let centerImageView: UIImageView = {
let imageView = UIImageView()
imageView.contentMode = .scaleAspectFit
return imageView
}()

let closeButton: IKButton = {
let button = IKButton()
button.setImage(UIImage(named: "close"), for: .normal)
return button
}()

let containerView = UIView()

override func viewDidLoad() {
super.viewDidLoad()

view.backgroundColor = KDriveResourcesAsset.backgroundColor.color
setupCloseButton()
setupBody()
}

private func setupCloseButton() {
closeButton.translatesAutoresizingMaskIntoConstraints = false
view.addSubview(closeButton)

closeButton.addTarget(self, action: #selector(closeButtonPressed), for: .touchUpInside)
NSLayoutConstraint.activate([
closeButton.topAnchor.constraint(equalTo: view.safeAreaLayoutGuide.topAnchor, constant: 0),
closeButton.leftAnchor.constraint(equalTo: view.safeAreaLayoutGuide.leftAnchor, constant: 25)
])
}

private func setupBody() {
containerView.translatesAutoresizingMaskIntoConstraints = false
view.addSubview(containerView)
NSLayoutConstraint.activate([
containerView.centerXAnchor.constraint(equalTo: view.centerXAnchor),
containerView.centerYAnchor.constraint(equalTo: view.centerYAnchor)
])

centerImageView.translatesAutoresizingMaskIntoConstraints = false
titleLabel.translatesAutoresizingMaskIntoConstraints = false
descriptionLabel.translatesAutoresizingMaskIntoConstraints = false

containerView.addSubview(centerImageView)
containerView.addSubview(titleLabel)
containerView.addSubview(descriptionLabel)

let views = ["titleLabel": titleLabel,
"descriptionLabel": descriptionLabel,
"centerImageView": centerImageView]

let verticalConstraints = NSLayoutConstraint
.constraints(withVisualFormat: "V:|[centerImageView]-[titleLabel]-[descriptionLabel]|",
metrics: nil,
views: views)
adrien-coye marked this conversation as resolved.
Show resolved Hide resolved

let horizontalConstraints = [
titleLabel.centerXAnchor.constraint(equalTo: view.centerXAnchor),
titleLabel.widthAnchor.constraint(equalTo: view.widthAnchor, multiplier: 1, constant: -20),
descriptionLabel.centerXAnchor.constraint(equalTo: view.centerXAnchor),
descriptionLabel.widthAnchor.constraint(equalTo: view.widthAnchor, multiplier: 1, constant: -20),
centerImageView.centerXAnchor.constraint(equalTo: view.centerXAnchor),
centerImageView.widthAnchor.constraint(equalTo: view.widthAnchor, multiplier: 1)
]

NSLayoutConstraint.activate(verticalConstraints)
NSLayoutConstraint.activate(horizontalConstraints)
}

@objc open func closeButtonPressed() {
dismiss(animated: true)
}
}
Loading
Loading