Skip to content

Commit

Permalink
Varie bug fix (#3095)
Browse files Browse the repository at this point in the history
* rename fix

Signed-off-by: Marino Faggiana <marino@marinofaggiana.com>

* cleaning

Signed-off-by: Marino Faggiana <marino@marinofaggiana.com>

* cod

Signed-off-by: Marino Faggiana <marino@marinofaggiana.com>

* background color

Signed-off-by: Marino Faggiana <marino@marinofaggiana.com>

* code improved

Signed-off-by: Marino Faggiana <marino@marinofaggiana.com>

* cod

Signed-off-by: Marino Faggiana <marino@marinofaggiana.com>

* fix

Signed-off-by: Marino Faggiana <marino@marinofaggiana.com>

---------

Signed-off-by: Marino Faggiana <marino@marinofaggiana.com>
  • Loading branch information
marinofaggiana authored Oct 7, 2024
1 parent 228fa35 commit f972587
Show file tree
Hide file tree
Showing 8 changed files with 37 additions and 19 deletions.
14 changes: 3 additions & 11 deletions File Provider Extension/FileProviderExtension+Actions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -135,31 +135,23 @@ extension FileProviderExtension {
}

override func renameItem(withIdentifier itemIdentifier: NSFileProviderItemIdentifier, toName itemName: String, completionHandler: @escaping (NSFileProviderItem?, Error?) -> Void) {
guard let metadata = providerUtility.getTableMetadataFromItemIdentifier(itemIdentifier),
let directoryTable = self.database.getTableDirectory(predicate: NSPredicate(format: "account == %@ AND serverUrl == %@", metadata.account, metadata.serverUrl)) else {
guard let metadata = providerUtility.getTableMetadataFromItemIdentifier(itemIdentifier) else {
return completionHandler(nil, NSFileProviderError(.noSuchItem))
}
let fileNameFrom = metadata.fileNameView
let fileNamePathFrom = metadata.serverUrl + "/" + fileNameFrom
let fileNamePathTo = metadata.serverUrl + "/" + itemName
let ocId = metadata.ocId

NextcloudKit.shared.moveFileOrFolder(serverUrlFileNameSource: fileNamePathFrom, serverUrlFileNameDestination: fileNamePathTo, overwrite: false, account: metadata.account) { account, error in
NextcloudKit.shared.moveFileOrFolder(serverUrlFileNameSource: fileNamePathFrom, serverUrlFileNameDestination: fileNamePathTo, overwrite: false, account: metadata.account) { _, error in
if error == .success {
// Rename metadata

self.database.renameMetadata(fileNameNew: itemName, ocId: ocId)
self.database.setMetadataServeUrlFileNameStatusNormal(ocId: ocId)

guard let metadata = self.database.getMetadataFromOcId(ocId) else {
return completionHandler(nil, NSFileProviderError(.noSuchItem))
}
if metadata.directory {
self.database.setDirectory(serverUrl: fileNamePathFrom, serverUrlTo: fileNamePathTo, encrypted: directoryTable.e2eEncrypted, account: account)
} else {
let itemIdentifier = self.providerUtility.getItemIdentifier(metadata: metadata)
self.providerUtility.moveFile(self.utilityFileSystem.getDirectoryProviderStorageOcId(itemIdentifier.rawValue, fileNameView: fileNameFrom), toPath: self.utilityFileSystem.getDirectoryProviderStorageOcId(itemIdentifier.rawValue, fileNameView: itemName))
self.database.setLocalFile(ocId: ocId, fileName: itemName)
}

guard let parentItemIdentifier = self.providerUtility.getParentItemIdentifier(metadata: metadata) else {
return completionHandler(nil, NSFileProviderError(.noSuchItem))
Expand Down
4 changes: 4 additions & 0 deletions iOSClient/Main/Collection Common/Cell/NCPhotoCell.xib
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
</button>
</subviews>
</view>
<color key="backgroundColor" systemColor="secondarySystemBackgroundColor"/>
<constraints>
<constraint firstAttribute="bottom" secondItem="PfR-89-FqQ" secondAttribute="bottom" constant="8" id="0XY-5K-ZuW"/>
<constraint firstItem="DHy-Up-3Bh" firstAttribute="leading" secondItem="vf1-Kf-9uL" secondAttribute="leading" constant="5" id="1T3-8p-uIW"/>
Expand Down Expand Up @@ -87,6 +88,9 @@
</objects>
<resources>
<image name="ellipsis" catalog="system" width="128" height="37"/>
<systemColor name="secondarySystemBackgroundColor">
<color red="0.94901960784313721" green="0.94901960784313721" blue="0.96862745098039216" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</systemColor>
<systemColor name="systemGray2Color">
<color red="0.68235294117647061" green="0.68235294117647061" blue="0.69803921568627447" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</systemColor>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,22 @@ extension NCCollectionViewCommon: UICollectionViewDataSource {

cell.ocId = metadata.ocId
cell.ocIdTransfer = metadata.ocIdTransfer
cell.hideButtonMore(true)
cell.hideImageStatus(true)

/// Image
///
if let image = NCImageCache.shared.getImageCache(ocId: metadata.ocId, etag: metadata.etag, ext: ext) {

cell.filePreviewImageView?.image = image
cell.filePreviewImageView?.contentMode = .scaleAspectFill

} else {

if isPinchGestureActive || ext == global.previewExt512 || ext == global.previewExt1024 {
cell.filePreviewImageView?.image = self.utility.getImage(ocId: metadata.ocId, etag: metadata.etag, ext: ext)
}

DispatchQueue.global(qos: .userInteractive).async {
let image = self.utility.getImage(ocId: metadata.ocId, etag: metadata.etag, ext: ext)
if let image {
Expand All @@ -82,7 +91,7 @@ extension NCCollectionViewCommon: UICollectionViewDataSource {
cell.filePreviewImageView?.image = image
cell.filePreviewImageView?.contentMode = .scaleAspectFill
}
} else {
} else if !metadata.hasPreview {
DispatchQueue.main.async {
cell.filePreviewImageView?.contentMode = .scaleAspectFit
if metadata.iconName.isEmpty {
Expand Down Expand Up @@ -110,10 +119,7 @@ extension NCCollectionViewCommon: UICollectionViewDataSource {
cell.selected(false, isEditMode: isEditMode)
}

if width < 100 {
cell.hideButtonMore(true)
cell.hideImageStatus(true)
} else {
if width > 100 && cell.filePreviewImageView?.image != nil {
cell.hideButtonMore(false)
cell.hideImageStatus(false)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,10 @@ class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UIS
return totalItems == 0
}

var isPinchGestureActive: Bool {
return pinchGesture.state == .began || pinchGesture.state == .changed
}

// MARK: - View Life Cycle

override func viewDidLoad() {
Expand Down Expand Up @@ -236,6 +240,8 @@ class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UIS
collectionView?.collectionViewLayout = mediaLayout
self.layoutType = global.layoutPhotoSquare
}

collectionView.reloadData()
}

override func viewDidAppear(_ animated: Bool) {
Expand Down Expand Up @@ -379,7 +385,7 @@ class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UIS
layoutForView.layout = layoutForView.layout
self.layoutType = layoutForView.layout

self.reloadDataSource()
collectionView.reloadData()

switch layoutForView.layout {
case global.layoutList:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,12 @@ class NCCollectionViewDownloadThumbnail: ConcurrentOperation, @unchecked Sendabl
filePreviewImageView.layer.borderColor = UIColor.systemGray3.cgColor
}

if let photoCell = (cell as? NCPhotoCell),
photoCell.bounds.size.width > 100 {
cell.hideButtonMore(false)
cell.hideImageStatus(false)
}

UIView.transition(with: filePreviewImageView,
duration: 0.75,
options: .transitionCrossDissolve,
Expand Down
5 changes: 5 additions & 0 deletions iOSClient/Media/Cell/NCMediaCell.xib
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="23084"/>
<capability name="System colors in document resources" minToolsVersion="11.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<objects>
Expand Down Expand Up @@ -44,6 +45,7 @@
</imageView>
</subviews>
</view>
<color key="backgroundColor" systemColor="secondarySystemBackgroundColor"/>
<constraints>
<constraint firstAttribute="trailing" secondItem="r1K-4X-gNd" secondAttribute="trailing" id="1Hu-GT-dJv"/>
<constraint firstItem="DHy-Up-3Bh" firstAttribute="leading" secondItem="vf1-Kf-9uL" secondAttribute="leading" constant="5" id="1T3-8p-uIW"/>
Expand All @@ -70,5 +72,8 @@
</objects>
<resources>
<image name="checkmark.circle.fill" width="300" height="300"/>
<systemColor name="secondarySystemBackgroundColor">
<color red="0.94901960784313721" green="0.94901960784313721" blue="0.96862745098039216" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</systemColor>
</resources>
</document>
1 change: 0 additions & 1 deletion iOSClient/Media/NCMedia+CollectionViewDataSource.swift
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,6 @@ extension NCMedia: UICollectionViewDataSource {
let ext = global.getSizeExtension(column: self.numberOfColumns)
let imageCache = imageCache.getImageCache(ocId: metadata.ocId, etag: metadata.etag, ext: ext)

cell.backgroundColor = .secondarySystemBackground
cell.imageItem.image = imageCache
cell.date = metadata.date as Date
cell.ocId = metadata.ocId
Expand Down
2 changes: 1 addition & 1 deletion iOSClient/Media/NCMediaPinchGesture.swift
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ extension NCMedia {
self.collectionView.collectionViewLayout.invalidateLayout()

} completion: { _ in
self.setTitleDate()

if let layoutForView = self.database.getLayoutForView(account: self.session.account, key: self.global.layoutViewMedia, serverUrl: "") {
layoutForView.columnPhoto = self.numberOfColumns
Expand Down Expand Up @@ -86,6 +85,7 @@ extension NCMedia {
UIView.animate(withDuration: 0.30) {
self.currentScale = 1.0
self.collectionView.transform = .identity
self.setTitleDate()
}
default:
break
Expand Down

0 comments on commit f972587

Please sign in to comment.