Skip to content

Commit

Permalink
improved images
Browse files Browse the repository at this point in the history
Signed-off-by: Marino Faggiana <[email protected]>
  • Loading branch information
marinofaggiana committed May 20, 2024
1 parent 7555f14 commit e458015
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 14 deletions.
2 changes: 1 addition & 1 deletion iOSClient/Activity/NCActivityCommentView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class NCActivityCommentView: UIView, UITextFieldDelegate {
if let image = UIImage(contentsOfFile: fileNameLocalPath) {
imageItem.image = image
} else {
imageItem.image = UIImage(named: "avatar")
imageItem.image = NCUtility().loadImage(named: "person.crop.circle", colors: [NCBrandColor.shared.iconImageColor])
}

if account.displayName.isEmpty {
Expand Down
6 changes: 4 additions & 2 deletions iOSClient/Activity/NCActivityTableViewCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ extension NCActivityTableViewCell: UICollectionViewDataSource {

let source = activityPreview.source

utility.convertSVGtoPNGWriteToUserData(svgUrlString: source, width: 100, rewrite: false, account: appDelegate.account, id: idActivity) { imageNamePath, id in
utility.convertSVGtoPNGWriteToUserData(svgUrlString: source, width: 150, rewrite: false, account: appDelegate.account, id: idActivity) { imageNamePath, id in
if let imageNamePath = imageNamePath, id == self.idActivity, let image = UIImage(contentsOfFile: imageNamePath) {
cell.imageView.image = image
} else {
Expand All @@ -192,8 +192,10 @@ extension NCActivityTableViewCell: UICollectionViewDataSource {

if FileManager.default.fileExists(atPath: fileNamePath), let image = UIImage(contentsOfFile: fileNamePath) {
cell.imageView.image = image
cell.imageView?.contentMode = .scaleAspectFill
} else {
cell.imageView?.image = UIImage(named: "file_photo")
cell.imageView?.image = utility.loadImage(named: "doc", colors: [NCBrandColor.shared.iconImageColor])
cell.imageView?.contentMode = .scaleAspectFit
cell.fileId = fileId
if !FileManager.default.fileExists(atPath: fileNamePath) {
if NCNetworking.shared.downloadThumbnailActivityQueue.operations.filter({ ($0 as? NCOperationDownloadThumbnailActivity)?.fileId == fileId }).isEmpty {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1215,7 +1215,6 @@ extension NCCollectionViewCommon: UICollectionViewDataSource {
}
if metadata.name == NCGlobal.shared.appName {
if let image = utility.createFilePreviewImage(ocId: metadata.ocId, etag: metadata.etag, fileNameView: metadata.fileNameView, classFile: metadata.classFile, status: metadata.status, createPreviewMedia: !metadata.hasPreview) {

cell.filePreviewImageView?.image = image
} else {
if metadata.iconName.isEmpty {
Expand Down
12 changes: 2 additions & 10 deletions iOSClient/Utility/NCUtility+Image.swift
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ extension NCUtility {
}

@objc func loadUserImage(for user: String, displayName: String?, userBaseUrl: NCUserBaseUrl) -> UIImage {

let fileName = userBaseUrl.userBaseUrl + "-" + user + ".png"
let localFilePath = utilityFileSystem.directoryUserData + "/" + fileName

Expand All @@ -101,12 +100,11 @@ extension NCUtility {
} else if let displayName = displayName, !displayName.isEmpty, let avatarImg = createAvatar(displayName: displayName, size: 30) {
return avatarImg
} else {
return UIImage(systemName: "person.crop.circle", withConfiguration: UIImage.SymbolConfiguration(pointSize: 30))!
return loadImage(named: "person.crop.circle", colors: [NCBrandColor.shared.iconImageColor])
}
}

func imageFromVideo(url: URL, at time: TimeInterval) -> UIImage? {

let asset = AVURLAsset(url: url)
let assetIG = AVAssetImageGenerator(asset: asset)

Expand All @@ -126,9 +124,7 @@ extension NCUtility {
}

func createImageFrom(fileNameView: String, ocId: String, etag: String, classFile: String) {

var originalImage, scaleImagePreview, scaleImageIcon: UIImage?

let fileNamePath = utilityFileSystem.getDirectoryProviderStorageOcId(ocId, fileNameView: fileNameView)
let fileNamePathPreview = utilityFileSystem.getDirectoryProviderStoragePreviewOcId(ocId, etag: etag)
let fileNamePathIcon = utilityFileSystem.getDirectoryProviderStorageIconOcId(ocId, etag: etag)
Expand Down Expand Up @@ -159,10 +155,7 @@ extension NCUtility {
}

func getImageMetadata(_ metadata: tableMetadata, for size: CGFloat) -> UIImage? {

if let image = getImage(metadata: metadata) {
return image
}
if let image = getImage(metadata: metadata) { return image }

if metadata.isVideo && !metadata.hasPreview {
createImageFrom(fileNameView: metadata.fileNameView, ocId: metadata.ocId, etag: metadata.etag, classFile: metadata.classFile)
Expand All @@ -182,7 +175,6 @@ extension NCUtility {
}

func getImage(metadata: tableMetadata) -> UIImage? {

let ext = (metadata.fileNameView as NSString).pathExtension.uppercased()
var image: UIImage?

Expand Down

0 comments on commit e458015

Please sign in to comment.