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: External links #1236

Closed
wants to merge 31 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
9b1f099
WIP endpoints
adrien-coye Jul 26, 2024
b91e02f
chore: Merge branch 'master' into externalLinks
adrien-coye Aug 15, 2024
00271f3
feat: In memory realm for external share context
adrien-coye Aug 16, 2024
729fd5e
fix: Project builds
adrien-coye Aug 16, 2024
9c21f67
chore: Merge branch 'master' into externalLinks
adrien-coye Aug 16, 2024
2d38281
feat: Public share metadata WIP
adrien-coye Aug 19, 2024
e821a54
feat(Rights): Updated to be compatible with public share
adrien-coye Aug 20, 2024
254255e
feat(PublicShareMetadata): Parsing pass
adrien-coye Aug 20, 2024
72fe9cf
chore: Merge branch 'master' into externalLinks
adrien-coye Aug 22, 2024
30389e1
refactor(Endpoint): Split files into dedicated extensiions
adrien-coye Aug 22, 2024
4db1410
chore: Merge branch 'master' into externalLinks
adrien-coye Aug 28, 2024
4dfc177
feat: Fetch root folder for a public share
adrien-coye Aug 29, 2024
638b423
feat: Cursored public share children query
adrien-coye Sep 2, 2024
fd7dfab
feat: Can natively show a public share within the app
adrien-coye Sep 3, 2024
fb9442b
chore: Merge branch 'master' into externalLinks
adrien-coye Sep 16, 2024
d9bc2d3
fix(FilePresenter): Present public share in context
adrien-coye Sep 16, 2024
7c8c2c7
fix: Capabilities for Public Share
adrien-coye Sep 16, 2024
70d65a0
feat: Thumbnails on public share
adrien-coye Sep 17, 2024
d352554
feat: Can navigate hierarchy of public share folders
adrien-coye Sep 18, 2024
07e1c48
feat: Preview for public share
adrien-coye Sep 19, 2024
c26647f
feat: Download file from public share
adrien-coye Sep 19, 2024
76bf4e0
feat: Actions match spec on public share
adrien-coye Sep 20, 2024
c6a78e7
chore: Merge branch 'master' into externalLinks
adrien-coye Sep 23, 2024
14c2ca0
fix: Tuist config update to build
adrien-coye Sep 23, 2024
7224695
feat: Add to my drive button
adrien-coye Sep 23, 2024
98822b8
chore: Merge branch 'master' into externalLinks
adrien-coye Sep 24, 2024
a1bf2c4
WIP
adrien-coye Sep 24, 2024
31e6119
chore: Matomo for public share tasks
adrien-coye Sep 25, 2024
a4b8d70
chore: Align Matomo with android on what exists
adrien-coye Sep 26, 2024
e7d49dc
feat: Download all files from current folder as a ZIP within a public…
adrien-coye Sep 26, 2024
126df8e
chore: Merge branch 'master' into externalLinks
adrien-coye Sep 26, 2024
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
1 change: 1 addition & 0 deletions Tuist/ProjectDescriptionHelpers/ExtensionTarget.swift
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ public extension Target {
"kDrive/UI/Controller/DriveUpdateRequiredViewController.swift",
"kDrive/UI/Controller/FloatingPanelSelectOptionViewController.swift",
"kDrive/UI/Controller/Create File/FloatingPanelUtils.swift",
"kDrive/UI/Controller/Create File/FloatingPanelLayouts.swift",
"kDrive/UI/Controller/Files/Categories/**",
"kDrive/UI/Controller/Files/Rights and Share/**",
"kDrive/UI/Controller/Files/Save File/**",
Expand Down
11 changes: 11 additions & 0 deletions kDrive/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,17 @@ final class AppDelegate: UIResponder, UIApplicationDelegate {
}
application.registerForRemoteNotifications()

// swiftlint:disable force_try
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TODO remove

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

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

return true
}

Expand Down
46 changes: 45 additions & 1 deletion kDrive/AppRouter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,8 @@ public struct AppRouter: AppNavigable {
let fileIds = sceneUserInfo[SceneRestorationValues.Carousel.filesIds.rawValue] as? [Int],
let currentIndex = sceneUserInfo[SceneRestorationValues.Carousel.currentIndex.rawValue] as? Int,
let normalFolderHierarchy = sceneUserInfo[SceneRestorationValues.Carousel.normalFolderHierarchy.rawValue] as? Bool,
let presentationOrigin = sceneUserInfo[SceneRestorationValues.Carousel.presentationOrigin.rawValue] as? PresentationOrigin else {
let presentationOrigin =
sceneUserInfo[SceneRestorationValues.Carousel.presentationOrigin.rawValue] as? PresentationOrigin else {
Log.sceneDelegate("metadata issue for PreviewController :\(sceneUserInfo)", level: .error)
return
}
Expand Down Expand Up @@ -584,6 +585,49 @@ public struct AppRouter: AppNavigable {

// MARK: RouterFileNavigable

@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")
return
}

// TODO: Fix access right
guard !frozenRootFolder.isDisabled else {
fatalError("isDisabled")
return
}

rootViewController.dismiss(animated: false) {
rootViewController.selectedIndex = MainTabBarIndex.files.rawValue

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

let viewModel = PublicShareViewModel(publicShareProxy: publicShareProxy,
sortType: .nameAZ,
driveFileManager: driveFileManager,
currentDirectory: frozenRootFolder,
apiFetcher: apiFetcher)
let viewController = FileListViewController(viewModel: viewModel)
let publicShareNavigationController = UINavigationController(rootViewController: viewController)
publicShareNavigationController.modalPresentationStyle = .fullScreen
publicShareNavigationController.modalTransitionStyle = .coverVertical

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

@MainActor public func present(file: File, driveFileManager: DriveFileManager) {
present(file: file, driveFileManager: driveFileManager, office: false)
}
Expand Down
15 changes: 9 additions & 6 deletions kDrive/SceneDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -230,13 +230,16 @@ final class SceneDelegate: UIResponder, UIWindowSceneDelegate, AccountManagerDel

func scene(_ scene: UIScene, continue userActivity: NSUserActivity) {
Log.sceneDelegate("scene continue userActivity")
guard userActivity.activityType == NSUserActivityTypeBrowsingWeb,
let incomingURL = userActivity.webpageURL,
let components = URLComponents(url: incomingURL, resolvingAgainstBaseURL: true) else {
return
}
Task {
guard userActivity.activityType == NSUserActivityTypeBrowsingWeb,
let incomingURL = userActivity.webpageURL,
let components = URLComponents(url: incomingURL, resolvingAgainstBaseURL: true) else {
Log.sceneDelegate("scene continue userActivity - unable", level: .error)
return
}

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

func scene(_ scene: UIScene, didFailToContinueUserActivityWithType userActivityType: String, error: Error) {
Expand Down
141 changes: 141 additions & 0 deletions kDrive/UI/Controller/Create File/FloatingPanelLayouts.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
/*
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 FloatingPanel
import kDriveCore
import kDriveResources
import UIKit

/// Layout used for a folder within a public share
class PublicShareFolderFloatingPanelLayout: FloatingPanelLayout {
var position: FloatingPanelPosition = .bottom
var initialState: FloatingPanelState = .tip
var anchors: [FloatingPanelState: FloatingPanelLayoutAnchoring]
private var backdropAlpha: CGFloat

init(initialState: FloatingPanelState = .tip, hideTip: Bool = false, safeAreaInset: CGFloat = 0, backdropAlpha: CGFloat = 0) {
self.initialState = initialState
self.backdropAlpha = backdropAlpha
let extendedAnchor = FloatingPanelLayoutAnchor(
absoluteInset: 140.0 + safeAreaInset,
edge: .bottom,
referenceGuide: .superview
)
anchors = [
.full: extendedAnchor,
.half: extendedAnchor,
.tip: FloatingPanelLayoutAnchor(absoluteInset: 86.0 + safeAreaInset, edge: .bottom, referenceGuide: .superview)
]
}

func backdropAlpha(for state: FloatingPanelState) -> CGFloat {
return backdropAlpha
}
}

/// Layout used for a file within a public share
class PublicShareFileFloatingPanelLayout: FloatingPanelLayout {
var position: FloatingPanelPosition = .bottom
var initialState: FloatingPanelState = .tip
var anchors: [FloatingPanelState: FloatingPanelLayoutAnchoring]
private var backdropAlpha: CGFloat

init(initialState: FloatingPanelState = .tip, hideTip: Bool = false, safeAreaInset: CGFloat = 0, backdropAlpha: CGFloat = 0) {
self.initialState = initialState
self.backdropAlpha = backdropAlpha
let extendedAnchor = FloatingPanelLayoutAnchor(
absoluteInset: 248.0 + safeAreaInset,
edge: .bottom,
referenceGuide: .superview
)
anchors = [
.full: extendedAnchor,
.half: extendedAnchor,
.tip: FloatingPanelLayoutAnchor(absoluteInset: 86.0 + safeAreaInset, edge: .bottom, referenceGuide: .superview)
]
}

func backdropAlpha(for state: FloatingPanelState) -> CGFloat {
return backdropAlpha
}
}

class FileFloatingPanelLayout: FloatingPanelLayout {
var position: FloatingPanelPosition = .bottom
var initialState: FloatingPanelState = .tip
var anchors: [FloatingPanelState: FloatingPanelLayoutAnchoring]
private var backdropAlpha: CGFloat

init(initialState: FloatingPanelState = .tip, hideTip: Bool = false, safeAreaInset: CGFloat = 0, backdropAlpha: CGFloat = 0) {
self.initialState = initialState
self.backdropAlpha = backdropAlpha
if hideTip {
anchors = [
.full: FloatingPanelLayoutAnchor(absoluteInset: 16.0, edge: .top, referenceGuide: .safeArea),
.half: FloatingPanelLayoutAnchor(fractionalInset: 0.5, edge: .bottom, referenceGuide: .safeArea)
]
} else {
anchors = [
.full: FloatingPanelLayoutAnchor(absoluteInset: 16.0, edge: .top, referenceGuide: .safeArea),
.half: FloatingPanelLayoutAnchor(fractionalInset: 0.5, edge: .bottom, referenceGuide: .safeArea),
.tip: FloatingPanelLayoutAnchor(absoluteInset: 86.0 + safeAreaInset, edge: .bottom, referenceGuide: .superview)
]
}
}

func backdropAlpha(for state: FloatingPanelState) -> CGFloat {
return backdropAlpha
}
}

class PlusButtonFloatingPanelLayout: FloatingPanelLayout {
var position: FloatingPanelPosition = .bottom
var height: CGFloat = 16

init(height: CGFloat) {
self.height = height
}

var anchors: [FloatingPanelState: FloatingPanelLayoutAnchoring] {
return [
.full: FloatingPanelLayoutAnchor(absoluteInset: height, edge: .bottom, referenceGuide: .safeArea)
]
}

var initialState: FloatingPanelState = .full

func backdropAlpha(for state: FloatingPanelState) -> CGFloat {
return 0.2
}
}

class InformationViewFloatingPanelLayout: FloatingPanelLayout {
var position: FloatingPanelPosition = .bottom

var initialState: FloatingPanelState = .full

var anchors: [FloatingPanelState: FloatingPanelLayoutAnchoring] {
return [
.full: FloatingPanelIntrinsicLayoutAnchor(absoluteOffset: 0, referenceGuide: .safeArea)
]
}

func backdropAlpha(for state: FloatingPanelState) -> CGFloat {
return 0.3
}
}
65 changes: 0 additions & 65 deletions kDrive/UI/Controller/Create File/FloatingPanelUtils.swift
Original file line number Diff line number Diff line change
Expand Up @@ -73,68 +73,3 @@ class AdaptiveDriveFloatingPanelController: DriveFloatingPanelController {
track(scrollView: scrollView)
}
}

class FileFloatingPanelLayout: FloatingPanelLayout {
var position: FloatingPanelPosition = .bottom
var initialState: FloatingPanelState = .tip
var anchors: [FloatingPanelState: FloatingPanelLayoutAnchoring]
private var backdropAlpha: CGFloat

init(initialState: FloatingPanelState = .tip, hideTip: Bool = false, safeAreaInset: CGFloat = 0, backdropAlpha: CGFloat = 0) {
self.initialState = initialState
self.backdropAlpha = backdropAlpha
if hideTip {
anchors = [
.full: FloatingPanelLayoutAnchor(absoluteInset: 16.0, edge: .top, referenceGuide: .safeArea),
.half: FloatingPanelLayoutAnchor(fractionalInset: 0.5, edge: .bottom, referenceGuide: .safeArea)
]
} else {
anchors = [
.full: FloatingPanelLayoutAnchor(absoluteInset: 16.0, edge: .top, referenceGuide: .safeArea),
.half: FloatingPanelLayoutAnchor(fractionalInset: 0.5, edge: .bottom, referenceGuide: .safeArea),
.tip: FloatingPanelLayoutAnchor(absoluteInset: 86.0 + safeAreaInset, edge: .bottom, referenceGuide: .superview)
]
}
}

func backdropAlpha(for state: FloatingPanelState) -> CGFloat {
return backdropAlpha
}
}

class PlusButtonFloatingPanelLayout: FloatingPanelLayout {
var position: FloatingPanelPosition = .bottom
var height: CGFloat = 16

init(height: CGFloat) {
self.height = height
}

var anchors: [FloatingPanelState: FloatingPanelLayoutAnchoring] {
return [
.full: FloatingPanelLayoutAnchor(absoluteInset: height, edge: .bottom, referenceGuide: .safeArea)
]
}

var initialState: FloatingPanelState = .full

func backdropAlpha(for state: FloatingPanelState) -> CGFloat {
return 0.2
}
}

class InformationViewFloatingPanelLayout: FloatingPanelLayout {
var position: FloatingPanelPosition = .bottom

var initialState: FloatingPanelState = .full

var anchors: [FloatingPanelState: FloatingPanelLayoutAnchoring] {
return [
.full: FloatingPanelIntrinsicLayoutAnchor(absoluteOffset: 0, referenceGuide: .safeArea)
]
}

func backdropAlpha(for state: FloatingPanelState) -> CGFloat {
return 0.3
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,13 @@ class ConcreteFileListViewModel: FileListViewModel {
try await loadFiles()
}

override func barButtonPressed(type: FileListBarButtonType) {
override func barButtonPressed(sender: Any?, type: FileListBarButtonType) {
if type == .search {
let viewModel = SearchFilesViewModel(driveFileManager: driveFileManager)
let searchViewController = SearchViewController.instantiateInNavigationController(viewModel: viewModel)
onPresentViewController?(.modal, searchViewController, true)
} else {
super.barButtonPressed(type: type)
super.barButtonPressed(sender: sender, type: type)
}
}
}
Loading
Loading