From b3d90df15e2063cc61461de520b8e6ad0728fd51 Mon Sep 17 00:00:00 2001 From: Morgan Pretty Date: Mon, 19 Aug 2024 09:53:00 +1000 Subject: [PATCH] Fixed a camera bug and minor optimisation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit • Fixed an issue with portrait photo orientation • Fixed a project config which would prevent debugging the framework targets properly • Tweaked an unneeded icon resize --- Session.xcodeproj/project.pbxproj | 4 ++++ .../Content Views/ReactionContainerView.swift | 7 +++---- .../Utilities/UIImage+Utilities.swift | 13 +++++-------- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/Session.xcodeproj/project.pbxproj b/Session.xcodeproj/project.pbxproj index 5625c0930..fcb9b3d61 100644 --- a/Session.xcodeproj/project.pbxproj +++ b/Session.xcodeproj/project.pbxproj @@ -6649,6 +6649,7 @@ PRODUCT_BUNDLE_IDENTIFIER = "com.loki-project.loki-messenger.ShareExtension"; PRODUCT_NAME = "$(TARGET_NAME)"; SKIP_INSTALL = YES; + STRIP_INSTALLED_PRODUCT = NO; SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; SWIFT_OBJC_BRIDGING_HEADER = ""; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; @@ -6780,6 +6781,7 @@ PRODUCT_BUNDLE_IDENTIFIER = "com.loki-project.loki-messenger.NotificationServiceExtension"; PRODUCT_NAME = "$(TARGET_NAME)"; SKIP_INSTALL = YES; + STRIP_INSTALLED_PRODUCT = NO; SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; SWIFT_VERSION = 5.0; @@ -6912,6 +6914,7 @@ PRODUCT_BUNDLE_IDENTIFIER = "com.loki-project.SessionUIKit"; PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)"; SKIP_INSTALL = YES; + STRIP_INSTALLED_PRODUCT = NO; SUPPORTS_MACCATALYST = NO; SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; @@ -7378,6 +7381,7 @@ PRODUCT_BUNDLE_IDENTIFIER = "com.loki-project.SessionUtilitiesKit"; PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)"; SKIP_INSTALL = YES; + STRIP_INSTALLED_PRODUCT = NO; SUPPORTS_MACCATALYST = NO; SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; SWIFT_INCLUDE_PATHS = "$(inherited) \"$(TARGET_BUILD_DIR)/libSessionUtil\""; diff --git a/Session/Conversations/Message Cells/Content Views/ReactionContainerView.swift b/Session/Conversations/Message Cells/Content Views/ReactionContainerView.swift index cf7953634..d18a34bab 100644 --- a/Session/Conversations/Message Cells/Content Views/ReactionContainerView.swift +++ b/Session/Conversations/Message Cells/Content Views/ReactionContainerView.swift @@ -56,12 +56,11 @@ final class ReactionContainerView: UIView { lazy var collapseButton: UIView = { let arrow: UIImageView = UIImageView( - image: UIImage(named: "ic_chevron_up")? - .resized(to: ReactionContainerView.arrowSize)? - .withRenderingMode(.alwaysTemplate) + image: UIImage(named: "ic_chevron_up")?.withRenderingMode(.alwaysTemplate) ) arrow.themeTintColor = .textPrimary - arrow.setContentHuggingPriority(.required, for: .horizontal) + arrow.set(.width, to: ReactionContainerView.arrowSize.width) + arrow.set(.height, to: ReactionContainerView.arrowSize.height) let textLabel: UILabel = UILabel() textLabel.setContentHuggingPriority(.required, for: .vertical) diff --git a/SessionUtilitiesKit/Utilities/UIImage+Utilities.swift b/SessionUtilitiesKit/Utilities/UIImage+Utilities.swift index 92cca4760..59c9a370f 100644 --- a/SessionUtilitiesKit/Utilities/UIImage+Utilities.swift +++ b/SessionUtilitiesKit/Utilities/UIImage+Utilities.swift @@ -4,10 +4,7 @@ import UIKit.UIImage public extension UIImage { func normalizedImage() -> UIImage { - guard - let imgRef: CGImage = self.cgImage, - imageOrientation != .up - else { return self } + guard imageOrientation != .up else { return self } // The actual resize: draw the image on a new context, applying a transform matrix let bounds: CGRect = CGRect(x: 0, y: 0, width: size.width, height: size.height) @@ -15,10 +12,10 @@ public extension UIImage { format.scale = self.scale format.opaque = false - let renderer: UIGraphicsImageRenderer = UIGraphicsImageRenderer(bounds: bounds, format: format) - - return renderer.image { rendererContext in - rendererContext.cgContext.draw(imgRef, in: bounds, byTiling: false) + // Note: We use the UIImage.draw function here instead of using the CGContext because UIImage + // automatically deals with orientations so we don't have to + return UIGraphicsImageRenderer(bounds: bounds, format: format).image { _ in + self.draw(in: bounds) } }