Skip to content
Merged

svg-fix #3990

Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 2 additions & 2 deletions Nextcloud.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -5775,7 +5775,7 @@
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
COPY_PHASE_STRIP = NO;
CURRENT_PROJECT_VERSION = 5;
CURRENT_PROJECT_VERSION = 6;
DEBUG_INFORMATION_FORMAT = dwarf;
DEVELOPMENT_TEAM = NKUJUXUJ3B;
ENABLE_STRICT_OBJC_MSGSEND = YES;
Expand Down Expand Up @@ -5841,7 +5841,7 @@
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
COPY_PHASE_STRIP = NO;
CURRENT_PROJECT_VERSION = 5;
CURRENT_PROJECT_VERSION = 6;
DEVELOPMENT_TEAM = NKUJUXUJ3B;
ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_TESTABILITY = YES;
Expand Down
19 changes: 18 additions & 1 deletion iOSClient/Extensions/UIImage+Extension.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,24 @@ import UIKit
import Accelerate

extension UIImage {
/// Returns a raster-resized copy of the image at the specified size,
/// preserving the original scale and renderingMode.
///
/// - Parameter size: Target size in points.
/// - Returns: A resized UIImage.
func rasterResized(to size: CGSize) -> UIImage {
let format = UIGraphicsImageRendererFormat.default()
format.scale = self.scale
format.opaque = false

let renderer = UIGraphicsImageRenderer(size: size, format: format)

return renderer.image { _ in
self.draw(in: CGRect(origin: .zero, size: size))
}
.withRenderingMode(self.renderingMode)
}

func resizeImage(size: CGSize, isAspectRation: Bool = true) -> UIImage? {
let originRatio = self.size.width / self.size.height
let newRatio = size.width / size.height
Expand All @@ -51,7 +69,6 @@ extension UIImage {
}

func fixedOrientation() -> UIImage? {

guard imageOrientation != UIImage.Orientation.up else {
// This is default orientation, don't need to do anything
return self.copy() as? UIImage
Expand Down
20 changes: 9 additions & 11 deletions iOSClient/Menu/NCContextMenuMain.swift
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,6 @@ class NCContextMenuMain: NSObject {

let deleteMenu = buildDeleteMenu(metadata: metadata)

if !NCNetworking.shared.isOnline {
return UIMenu()
}

// Assemble final menu
let baseChildren = [
UIMenu(title: "", options: .displayInline, children: mainActionsMenu),
Expand Down Expand Up @@ -503,16 +499,18 @@ class NCContextMenuMain: NSObject {
let deferredElement = UIDeferredMenuElement { completion in
Task {
var iconImage = UIImage()

if let iconUrl = item.icon {
if let image = await NCUtility().convertSVGtoPNGWriteToUserData(serverUrl: metadata.urlBase + iconUrl,
rewrite: false,
account: metadata.account).image {
if let image = image.withTintColor(
if let image = await NCUtility().convertSVGtoPNGWriteToUserData(
serverUrl: metadata.urlBase + iconUrl,
rewrite: false,
account: metadata.account
).image {
let image = image.rasterResized(to: CGSize(width: 20, height: 20))
iconImage = image.withTintColor(
NCBrandColor.shared.iconImageColor,
renderingMode: .alwaysOriginal
).resizeImage(size: CGSize(width: 20, height: 20)) {
iconImage = image
}
)
}
}

Expand Down
Loading
Loading