Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(iOS): refactor RCTImageUtils, RCTTextView & RCTParagraphComponentView.mm to use UTType #46532

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
6 changes: 4 additions & 2 deletions packages/react-native/Libraries/Image/RCTImageUtils.mm
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@

#import <tgmath.h>

#import <UniformTypeIdentifiers/UniformTypeIdentifiers.h>

#import <ImageIO/ImageIO.h>
#import <MobileCoreServices/UTCoreTypes.h>

Expand Down Expand Up @@ -337,10 +339,10 @@ BOOL RCTUpscalingRequired(
CFMutableDataRef imageData = CFDataCreateMutable(NULL, 0);
if (RCTImageHasAlpha(cgImage)) {
// get png data
destination = CGImageDestinationCreateWithData(imageData, kUTTypePNG, 1, NULL);
destination = CGImageDestinationCreateWithData(imageData, (__bridge CFStringRef)[UTTypePNG identifier], 1, NULL);
} else {
// get jpeg data
destination = CGImageDestinationCreateWithData(imageData, kUTTypeJPEG, 1, NULL);
destination = CGImageDestinationCreateWithData(imageData, (__bridge CFStringRef)[UTTypeJPEG identifier], 1, NULL);
[properties setValue:@(quality) forKey:(id)kCGImageDestinationLossyCompressionQuality];
}
if (!destination) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ Pod::Spec.new do |s|
"CLANG_CXX_LANGUAGE_STANDARD" => rct_cxx_language_standard(),
"HEADER_SEARCH_PATHS" => header_search_paths.join(' ')
}
s.framework = ["Accelerate", "UIKit", "QuartzCore", "ImageIO", "CoreGraphics"]
s.framework = ["Accelerate", "UIKit", "QuartzCore", "ImageIO", "CoreGraphics", "UniformTypeIdentifiers"]

s.dependency "RCT-Folly", folly_version
s.dependency "RCTTypeSafety"
Expand Down
2 changes: 1 addition & 1 deletion packages/react-native/Libraries/Text/React-RCTText.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ Pod::Spec.new do |s|
s.source_files = "**/*.{h,m,mm}"
s.preserve_paths = "package.json", "LICENSE", "LICENSE-docs"
s.header_dir = "RCTText"
s.framework = ["MobileCoreServices"]
s.framework = ["MobileCoreServices", "UniformTypeIdentifiers"]
s.pod_target_xcconfig = { "CLANG_CXX_LANGUAGE_STANDARD" => rct_cxx_language_standard() }

s.dependency "Yoga"
Expand Down
6 changes: 4 additions & 2 deletions packages/react-native/Libraries/Text/Text/RCTTextView.mm
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@

#import <MobileCoreServices/UTCoreTypes.h>

#import <UniformTypeIdentifiers/UniformTypeIdentifiers.h>

#import <React/RCTUtils.h>
#import <React/UIView+React.h>

Expand Down Expand Up @@ -282,10 +284,10 @@ - (void)copy:(id)sender
error:nil];

if (rtf) {
[item setObject:rtf forKey:(id)kUTTypeFlatRTFD];
[item setObject:rtf forKey:(id)UTTypeFlatRTFD];
}

[item setObject:attributedText.string forKey:(id)kUTTypeUTF8PlainText];
[item setObject:attributedText.string forKey:(id)UTTypeUTF8PlainText];

UIPasteboard *pasteboard = [UIPasteboard generalPasteboard];
pasteboard.items = @[ item ];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#import "RCTParagraphComponentView.h"
#import "RCTParagraphComponentAccessibilityProvider.h"

#import <UniformTypeIdentifiers/UniformTypeIdentifiers.h>
#import <MobileCoreServices/UTCoreTypes.h>
#import <react/renderer/components/text/ParagraphComponentDescriptor.h>
#import <react/renderer/components/text/ParagraphProps.h>
Expand Down Expand Up @@ -306,10 +307,10 @@ - (void)copy:(id)sender
error:nil];

if (rtf) {
[item setObject:rtf forKey:(id)kUTTypeFlatRTFD];
[item setObject:rtf forKey:(id)UTTypeFlatRTFD];
}

[item setObject:attributedText.string forKey:(id)kUTTypeUTF8PlainText];
[item setObject:attributedText.string forKey:(id)UTTypeUTF8PlainText];

UIPasteboard *pasteboard = [UIPasteboard generalPasteboard];
pasteboard.items = @[ item ];
Expand Down
Loading