|
@@ -39,9 +39,9 @@ class NCHostingUploadAssetsView: NSObject {
|
|
|
// MARK: - Class
|
|
|
|
|
|
struct PreviewStore {
|
|
|
- var originalImage: UIImage
|
|
|
- var cropImage: UIImage?
|
|
|
+ var image: UIImage
|
|
|
var localIdentifier: String
|
|
|
+ var hasChanges: Bool
|
|
|
}
|
|
|
|
|
|
class NCUploadAssets: NSObject, ObservableObject, NCCreateFormUploadConflictDelegate {
|
|
@@ -66,7 +66,7 @@ class NCUploadAssets: NSObject, ObservableObject, NCCreateFormUploadConflictDele
|
|
|
DispatchQueue.global().async {
|
|
|
for asset in self.assets {
|
|
|
guard asset.type == .photo, let image = asset.fullResolutionImage, let localIdentifier = asset.phAsset?.localIdentifier else { continue }
|
|
|
- self.previewStore.append(PreviewStore(originalImage: image, localIdentifier: localIdentifier))
|
|
|
+ self.previewStore.append(PreviewStore(image: image, localIdentifier: localIdentifier, hasChanges: false))
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -209,7 +209,7 @@ struct UploadAssetsView: View {
|
|
|
metadata.status = NCGlobal.shared.metadataStatusWaitUpload
|
|
|
|
|
|
// Modified
|
|
|
- if let previewStore = uploadAssets.previewStore.first(where: { $0.localIdentifier == asset.localIdentifier }), let image = previewStore.cropImage, let data = image.jpegData(compressionQuality: 1) {
|
|
|
+ if let previewStore = uploadAssets.previewStore.first(where: { $0.localIdentifier == asset.localIdentifier }), previewStore.hasChanges, let data = previewStore.image.jpegData(compressionQuality: 1) {
|
|
|
if metadata.contentType == "image/heic" {
|
|
|
let fileNameNoExtension = (fileName as NSString).deletingPathExtension
|
|
|
metadata.contentType = "image/jpeg"
|
|
@@ -244,7 +244,7 @@ struct UploadAssetsView: View {
|
|
|
}
|
|
|
|
|
|
func copyImageforQL() {
|
|
|
- let image = uploadAssets.previewStore[index].originalImage
|
|
|
+ let image = uploadAssets.previewStore[index].image
|
|
|
if let data = image.jpegData(compressionQuality: 1) {
|
|
|
try? data.write(to: URL(fileURLWithPath: fileNamePath))
|
|
|
}
|
|
@@ -260,7 +260,7 @@ struct UploadAssetsView: View {
|
|
|
LazyHGrid(rows: gridItems, alignment: .center, spacing: 10) {
|
|
|
ForEach(0..<uploadAssets.previewStore.count, id: \.self) { index in
|
|
|
VStack {
|
|
|
- Image(uiImage: uploadAssets.previewStore[index].cropImage ?? uploadAssets.previewStore[index].originalImage)
|
|
|
+ Image(uiImage: uploadAssets.previewStore[index].image)
|
|
|
.resizable()
|
|
|
.frame(width: 100, height: 100, alignment: .center)
|
|
|
.cornerRadius(10)
|
|
@@ -270,7 +270,7 @@ struct UploadAssetsView: View {
|
|
|
isPresentedCrop = true
|
|
|
copyImageforQL()
|
|
|
}.fullScreenCover(isPresented: $isPresentedCrop) {
|
|
|
- ViewerQuickLook(url: URL(fileURLWithPath: fileNamePath), isPresented: $isPresentedCrop)
|
|
|
+ ViewerQuickLook(url: URL(fileURLWithPath: fileNamePath), isPresented: $isPresentedCrop, previewStore: $uploadAssets.previewStore[index])
|
|
|
.ignoresSafeArea()
|
|
|
}
|
|
|
}
|