Skip to content

Commit

Permalink
chore: PR Feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
adrien-coye committed Oct 23, 2024
1 parent e41d291 commit 4061345
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 46 deletions.
2 changes: 1 addition & 1 deletion kDrive/SceneDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ final class SceneDelegate: UIResponder, UIWindowSceneDelegate, AccountManagerDel
guard userActivity.activityType == NSUserActivityTypeBrowsingWeb,
let incomingURL = userActivity.webpageURL,
let components = URLComponents(url: incomingURL, resolvingAgainstBaseURL: true) else {
Log.sceneDelegate("scene continue userActivity - unable", level: .error)
Log.sceneDelegate("scene continue userActivity - invalid activity", level: .error)
return
}

Expand Down
55 changes: 10 additions & 45 deletions kDrive/UI/Controller/Files/File List/FileListViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,14 @@ class FileListViewController: UICollectionViewController, SwipeActionCollectionV
viewModel.driveFileManager
}

lazy var addToKDriveButton: IKLargeButton = {
let button = IKLargeButton(frame: .zero)
button.setTitle(KDriveCoreStrings.Localizable.buttonAddToKDrive, for: .normal)
button.translatesAutoresizingMaskIntoConstraints = false
button.addTarget(self, action: #selector(addToMyDriveButtonTapped(_:)), for: .touchUpInside)
return button
}()

// MARK: - View controller lifecycle

deinit {
Expand Down Expand Up @@ -257,14 +265,6 @@ class FileListViewController: UICollectionViewController, SwipeActionCollectionV
return
}

let addToKDriveButton = IKButton(type: .custom)
addToKDriveButton.setTitle("Add to My kDrive", for: .normal)
addToKDriveButton.addTarget(self, action: #selector(addToMyDriveButtonTapped(_:)), for: .touchUpInside)
addToKDriveButton.setBackgroundColors(normal: .systemBlue, highlighted: .darkGray)
addToKDriveButton.translatesAutoresizingMaskIntoConstraints = false
addToKDriveButton.cornerRadius = 8.0
addToKDriveButton.clipsToBounds = true

view.addSubview(addToKDriveButton)
view.bringSubviewToFront(addToKDriveButton)

Expand Down Expand Up @@ -390,7 +390,7 @@ class FileListViewController: UICollectionViewController, SwipeActionCollectionV
}
}

private func fileLayout(files: [File]) -> FloatingPanelLayout {
private func fileFloatingPanelLayout(files: [File]) -> FloatingPanelLayout {
guard driveFileManager.isPublicShare else {
return FileFloatingPanelLayout(
initialState: .half,
Expand Down Expand Up @@ -425,7 +425,7 @@ class FileListViewController: UICollectionViewController, SwipeActionCollectionV
fileInformationsViewController.presentingParent = self
fileInformationsViewController.normalFolderHierarchy = viewModel.configuration.normalFolderHierarchy

floatingPanelViewController.layout = fileLayout(files: files)
floatingPanelViewController.layout = fileFloatingPanelLayout(files: files)

if let file = files.first {
fileInformationsViewController.setFile(file, driveFileManager: driveFileManager)
Expand Down Expand Up @@ -958,38 +958,3 @@ extension FileListViewController: UICollectionViewDropDelegate {
}
}
}

// Move to CoreUIKit or use something else ?
extension UIImage {
convenience init?(color: UIColor) {
let size = CGSize(width: 1, height: 1)
UIGraphicsBeginImageContext(size)
guard let context = UIGraphicsGetCurrentContext() else {
return nil
}

context.setFillColor(color.cgColor)
context.fill(CGRect(origin: .zero, size: size))

let image = UIGraphicsGetImageFromCurrentImageContext()!
UIGraphicsEndImageContext()
guard let cgImage = image.cgImage else {
return nil
}

self.init(cgImage: cgImage)
}
}

// Move to CoreUIKit or use something else ?
extension IKButton {
func setBackgroundColors(normal normalColor: UIColor, highlighted highlightedColor: UIColor) {
if let normalImage = UIImage(color: normalColor) {
setBackgroundImage(normalImage, for: .normal)
}

if let highlightedImage = UIImage(color: highlightedColor) {
setBackgroundImage(highlightedImage, for: .highlighted)
}
}
}

0 comments on commit 4061345

Please sign in to comment.