Skip to content
Merged
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
8 changes: 4 additions & 4 deletions Libraries/StyleSheet/PlatformColorValueTypes.macos.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@ export const PlatformColor = (...names: Array<string>): ColorValue => {
return {semantic: names};
};

export type DynamicColorIOSTuplePrivate = {
export type DynamicColorMacOSTuplePrivate = {
light: ColorValue,
dark: ColorValue,
};

export const DynamicColorIOSPrivate = (
tuple: DynamicColorIOSTuplePrivate,
export const DynamicColorMacOSPrivate = (
tuple: DynamicColorMacOSTuplePrivate,
): ColorValue => {
return {dynamic: {light: tuple.light, dark: tuple.dark}};
};
Expand All @@ -40,7 +40,7 @@ export const normalizeColorObject = (
color: NativeColorValue,
): ?ProcessedColorValue => {
if ('semantic' in color) {
// an ios semantic color
// a macOS semantic color
return color;
} else if ('dynamic' in color && color.dynamic !== undefined) {
const normalizeColor = require('./normalizeColor');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,15 @@
'use strict';

import type {ColorValue} from './StyleSheetTypes';
import {DynamicColorIOSPrivate} from './PlatformColorValueTypes';

export type DynamicColorIOSTuple = {
export type DynamicColorMacOSTuple = {
light: ColorValue,
dark: ColorValue,
};

export const DynamicColorIOS = (tuple: DynamicColorIOSTuple): ColorValue => {
return DynamicColorIOSPrivate({light: tuple.light, dark: tuple.dark});
export const DynamicColorMacOS = (
tuple: DynamicColorMacOSTuple,
): ColorValue => {
throw new Error('DynamicColorMacOS is not available on this platform.');
};
// ]TODO(macOS ISS#2323203)
26 changes: 26 additions & 0 deletions Libraries/StyleSheet/PlatformColorValueTypesMacOS.macos.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @format
* @flow strict-local
*/
// [TODO(macOS ISS#2323203)
'use strict';

import type {ColorValue} from './StyleSheetTypes';
import {DynamicColorMacOSPrivate} from './PlatformColorValueTypes';

export type DynamicColorMacOSTuple = {
light: ColorValue,
dark: ColorValue,
};

export const DynamicColorMacOS = (
tuple: DynamicColorMacOSTuple,
): ColorValue => {
return DynamicColorMacOSPrivate({light: tuple.light, dark: tuple.dark});
};
// ]TODO(macOS ISS#2323203)
10 changes: 7 additions & 3 deletions Libraries/Text/RCTTextAttributes.m
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,13 @@ - (instancetype)init
_textShadowRadius = NAN;
_opacity = NAN;
_textTransform = RCTTextTransformUndefined;
#if TARGET_OS_OSX // TODO(macOS ISS#2323203)
_foregroundColor = [NSColor labelColor];
#endif // TODO(macOS ISS#2323203)
// [TODO(OSS Candidate ISS#2710739)
if (@available(iOS 13.0, *)) {
_foregroundColor = [RCTUIColor labelColor];
} else {
_foregroundColor = [RCTUIColor blackColor];
}
// ]TODO(OSS Candidate ISS#2710739)
}

return self;
Expand Down
4 changes: 2 additions & 2 deletions Libraries/Text/TextInput/Multiline/RCTUITextView.m
Original file line number Diff line number Diff line change
Expand Up @@ -340,13 +340,13 @@ - (void)selectAll:(id)sender
{
[super selectAll:sender];

#if !TARGET_OS_OSX // [TODO(macOS v0.63)
#if !TARGET_OS_OSX // TODO(macOS ISS#2323203) For `selectTextOnFocus` prop, which isn't supported on macOS atm.
// `selectAll:` does not work for UITextView when it's being called inside UITextView's delegate methods.
dispatch_async(dispatch_get_main_queue(), ^{
UITextRange *selectionRange = [self textRangeFromPosition:self.beginningOfDocument toPosition:self.endOfDocument];
[self setSelectedTextRange:selectionRange notifyDelegate:NO];
});
#endif // ]TODO(macOS v0.63)
#endif
}

#pragma mark - Layout
Expand Down
4 changes: 2 additions & 2 deletions Libraries/Text/TextInput/RCTBackedTextInputViewProtocol.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@ NS_ASSUME_NONNULL_BEGIN
@property (nonatomic, assign, getter=isEditable) BOOL editable;
@property (nonatomic, assign) BOOL caretHidden;
@property (nonatomic, assign) BOOL enablesReturnKeyAutomatically;
#if !TARGET_OS_OSX // [TODO(macOS v0.63)
#if !TARGET_OS_OSX // TODO(macOS ISS#2323203)
@property (nonatomic, assign) UITextFieldViewMode clearButtonMode;
#endif // ]TODO(macOS v0.63)
#endif // TODO(macOS ISS#2323203)
@property (nonatomic, getter=isScrollEnabled) BOOL scrollEnabled;

// This protocol disallows direct access to `selectedTextRange` property because
Expand Down
16 changes: 7 additions & 9 deletions Libraries/Text/TextInput/RCTBaseTextInputView.m
Original file line number Diff line number Diff line change
Expand Up @@ -69,13 +69,7 @@ - (void)enforceTextAttributesIfNeeded
{
if (![self ignoresTextAttributes]) { // TODO(OSS Candidate ISS#2710739)
id<RCTBackedTextInputViewProtocol> backedTextInputView = self.backedTextInputView;

NSDictionary<NSAttributedStringKey,id> *textAttributes = [[_textAttributes effectiveTextAttributes] mutableCopy];
if ([textAttributes valueForKey:NSForegroundColorAttributeName] == nil) {
[textAttributes setValue:[RCTUIColor blackColor] forKey:NSForegroundColorAttributeName]; // TODO(macOS ISS#2323203)
}

backedTextInputView.defaultTextAttributes = textAttributes;
backedTextInputView.defaultTextAttributes = [_textAttributes effectiveTextAttributes];
} // TODO(OSS Candidate ISS#2710739)
}

Expand Down Expand Up @@ -241,7 +235,7 @@ - (void)setSelection:(RCTTextSelection *)selection
- (void)setSelectionStart:(NSInteger)start
selectionEnd:(NSInteger)end
{
#if !TARGET_OS_OSX // [TODO(macOS v0.63)
#if !TARGET_OS_OSX // TODO(macOS ISS#2323203)
UITextPosition *startPosition = [self.backedTextInputView positionFromPosition:self.backedTextInputView.beginningOfDocument
offset:start];
UITextPosition *endPosition = [self.backedTextInputView positionFromPosition:self.backedTextInputView.beginningOfDocument
Expand All @@ -250,7 +244,11 @@ - (void)setSelectionStart:(NSInteger)start
UITextRange *range = [self.backedTextInputView textRangeFromPosition:startPosition toPosition:endPosition];
[self.backedTextInputView setSelectedTextRange:range notifyDelegate:NO];
}
#endif // ]TODO(macOS v0.63)
#else // [TODO(macOS ISS#2323203)
NSInteger startPosition = MIN(start, end);
NSInteger endPosition = MAX(start, end);
[self.backedTextInputView setSelectedTextRange:NSMakeRange(startPosition, endPosition - startPosition) notifyDelegate:NO];
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's no bounds checking here, so this would raise a objc exception.

#endif // ]TODO(macOS ISS#2323203)
}

- (void)setTextContentType:(NSString *)type
Expand Down
33 changes: 10 additions & 23 deletions Libraries/Text/TextInput/Singleline/RCTUITextField.m
Original file line number Diff line number Diff line change
Expand Up @@ -91,12 +91,6 @@ @implementation RCTUITextField {

#if TARGET_OS_OSX // [TODO(macOS ISS#2323203)
@dynamic delegate;

static RCTUIColor *defaultPlaceholderTextColor()
{
return [NSColor placeholderTextColor];
}

#endif // ]TODO(macOS ISS#2323203)

- (instancetype)initWithFrame:(CGRect)frame
Expand Down Expand Up @@ -321,14 +315,17 @@ - (void)setSecureTextEntry:(BOOL)secureTextEntry
{
NSMutableDictionary<NSAttributedStringKey, id> *textAttributes = [_defaultTextAttributes mutableCopy] ?: [NSMutableDictionary new];

if (self.placeholderColor) {
[textAttributes setValue:self.placeholderColor forKey:NSForegroundColorAttributeName];
// [TODO(OSS Candidate ISS#2710739)
if (@available(iOS 13.0, *)) {
[textAttributes setValue:self.placeholderColor ?: [RCTUIColor placeholderTextColor]
forKey:NSForegroundColorAttributeName];
} else {
#if TARGET_OS_OSX // [TODO(macOS ISS#2323203)
[textAttributes setValue:defaultPlaceholderTextColor() forKey:NSForegroundColorAttributeName];
#else
[textAttributes removeObjectForKey:NSForegroundColorAttributeName];
#endif // ]TODO(macOS ISS#2323203)
// ]TODO(OSS Candidate ISS#2710739)
if (self.placeholderColor) {
[textAttributes setValue:self.placeholderColor forKey:NSForegroundColorAttributeName];
} else {
[textAttributes removeObjectForKey:NSForegroundColorAttributeName];
}
}

return textAttributes;
Expand Down Expand Up @@ -374,16 +371,6 @@ - (CGRect)editingRectForBounds:(CGRect)bounds

#pragma mark - NSTextViewDelegate methods

- (void)setScrollEnabled:(BOOL)enabled
{
// Do noting, compatible with multiline textinput
}

- (BOOL)scrollEnabled
{
return NO;
}

- (void)textDidChange:(NSNotification *)notification
{
[super textDidChange:notification];
Expand Down
71 changes: 10 additions & 61 deletions RNTester/Podfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
require_relative '../scripts/react_native_pods'

source 'https://cdn.cocoapods.org/'
platform :ios, '10.0'

Expand All @@ -15,6 +16,7 @@ end
def pods(options = {})
project 'RNTesterPods.xcodeproj'

# Enable TurboModule
use_react_native!(options.merge(path: ".."))
pod 'ReactCommon/turbomodule/samples', :path => '../ReactCommon'

Expand All @@ -30,81 +32,32 @@ def pods(options = {})
# use_react_native!(path: "..", fabric_enabled: true)
end

def flipper_pods()
flipperkit_version = '0.30.1'
pod 'FlipperKit', '~>' + flipperkit_version, :configuration => 'Debug'
pod 'FlipperKit/FlipperKitLayoutPlugin', '~>' + flipperkit_version, :configuration => 'Debug'
pod 'FlipperKit/SKIOSNetworkPlugin', '~>' + flipperkit_version, :configuration => 'Debug'
pod 'FlipperKit/FlipperKitUserDefaultsPlugin', '~>' + flipperkit_version, :configuration => 'Debug'
pod 'FlipperKit/FlipperKitReactPlugin', '~>' + flipperkit_version, :configuration => 'Debug'

if ENV['USE_FRAMEWORKS'] == '1'
static_frameworks = ['FlipperKit', 'Flipper', 'Flipper-Folly',
'CocoaAsyncSocket', 'ComponentKit', 'Flipper-DoubleConversion',
'Flipper-Glog', 'Flipper-PeerTalk', 'Flipper-RSocket',
'CocoaLibEvent', 'OpenSSL-Universal', 'boost-for-react-native']

pre_install do |installer|
Pod::Installer::Xcode::TargetValidator.send(:define_method, :verify_no_static_framework_transitive_dependencies) {}
installer.pod_targets.each do |pod|
if static_frameworks.include?(pod.name)
def pod.build_type
Pod::Target::BuildType.static_library
end
end
end
end
end
target 'RNTester' do
pods()
use_flipper!
end

# Post Install processing for Flipper
def flipper_post_install(installer)
file_name = Dir.glob("*.xcodeproj")[0]
app_project = Xcodeproj::Project.open(file_name)
app_project.native_targets.each do |target|
target.build_configurations.each do |config|
cflags = config.build_settings['OTHER_CFLAGS'] || '$(inherited) '
unless cflags.include? '-DFB_SONARKIT_ENABLED=1'
puts 'Adding -DFB_SONARKIT_ENABLED=1 in OTHER_CFLAGS...'
cflags << ' -DFB_SONARKIT_ENABLED=1 '
end
config.build_settings['OTHER_CFLAGS'] = cflags
end
app_project.save
end
installer.pods_project.save
target 'RNTesterUnitTests' do
pods()
pod 'React-RCTTest', :path => "./RCTTest"
end

target 'RNTester' do
platform :ios, '10.0'
target 'RNTesterIntegrationTests' do
pods()
flipper_pods()
# use_flipper!
pod 'React-RCTTest', :path => "./RCTTest"
end

target 'RNTester-macOS' do
platform :osx, '10.14'
pods(:hermes_enabled => true)
end

target 'RNTesterUnitTests' do
platform :ios, '10.0'
pods()
pod 'React-RCTTest', :path => "./RCTTest"
end

target 'RNTester-macOSUnitTests' do
platform :osx, '10.14'
pods()
pod 'React-RCTTest', :path => "./RCTTest"
end

target 'RNTesterIntegrationTests' do
platform :ios, '10.0'
pods()
pod 'React-RCTTest', :path => "./RCTTest"
end

target 'RNTester-macOSIntegrationTests' do
platform :osx, '10.14'
pods()
Expand All @@ -129,22 +82,18 @@ end
# ]TODO(macOS ISS#2323203)

post_install do |installer|
# TODO(macOS): How do we reconcile flipper on macOS? For now disabling to unblock merge
flipper_post_install(installer)
installer.pods_project.targets.each do |target|
puts target.name
# [TODO(macOS ISS#2323203): the internal Microsoft build pipeline needs iOS arm64e slices
if target.platform_name == :ios
target.build_configurations.each do |config|
(config.build_settings['ARCHS'] ||= ['$(ARCHS_STANDARD)']) << 'arm64e'
puts ' adding arm64e to ' + config.name
end
end
# TODO(macOS ISS#2323203): the internal Microsoft build pipeline needs macOS arm64 slices
if target.platform_name == :osx
target.build_configurations.each do |config|
(config.build_settings['ARCHS'] ||= ['$(ARCHS_STANDARD)']) << ' arm64'
puts ' adding arm64 to ' + config.name
end
end
# ]TODO(macOS ISS#2323203)
Expand Down
Loading