Skip to content

Commit

Permalink
Make it compiling
Browse files Browse the repository at this point in the history
  • Loading branch information
ptmt committed May 16, 2017
1 parent ea48414 commit cdf30fd
Show file tree
Hide file tree
Showing 85 changed files with 1,089 additions and 1,539 deletions.
226 changes: 73 additions & 153 deletions Examples/UIExplorer/UIExplorer.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion Examples/UIExplorer/UIExplorer/AppDelegate.m
Expand Up @@ -20,6 +20,7 @@
#import <React/RCTJavaScriptLoader.h>
#import <React/RCTLinkingManager.h>
#import <React/RCTRootView.h>
#import <React/RCTEventDispatcher.h>

@interface AppDelegate() <RCTBridgeDelegate, NSSearchFieldDelegate>

Expand Down Expand Up @@ -80,7 +81,7 @@ - (void)applicationDidFinishLaunching:(NSNotification * __unused)aNotification

- (void)setDefaultURL
{
return [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"Examples/UIExplorer/js/UIExplorerApp.ios"
_sourceURL = [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"Examples/UIExplorer/js/UIExplorerApp.ios"
fallbackResource:nil];
}

Expand Down
Expand Up @@ -13,8 +13,6 @@
*/

#import <AppKit/AppKit.h>
#import "RCTView.h"

#import <React/RCTView.h>

@interface FlexibleSizeExampleView : RCTView
Expand Down
Expand Up @@ -63,7 +63,6 @@ - (instancetype)initWithFrame:(CGRect)frame
[_resizableRootView setSizeFlexibility:RCTRootViewSizeFlexibilityHeight];

_currentSizeTextView = [NSTextView new];
#ifndef TARGET_OS_TV
_currentSizeTextView.editable = NO;
[_currentSizeTextView setString:@"Resizable view has not been resized yet"];
_currentSizeTextView.textColor = [NSColor blackColor];
Expand Down
Expand Up @@ -13,8 +13,6 @@
*/

#import <AppKit/AppKit.h>
#import "RCTView.h"

#import <React/RCTView.h>

@interface UpdatePropertiesExampleView : RCTView
Expand Down
7 changes: 1 addition & 6 deletions Examples/UIExplorer/UIExplorerUnitTests/RCTUIManagerTests.m
Expand Up @@ -14,13 +14,8 @@

#import <XCTest/XCTest.h>

<<<<<<< HEAD
#import "RCTUIManager.h"
#import "NSView+React.h"
=======
#import <React/RCTUIManager.h>
#import <React/UIView+React.h>
>>>>>>> 1dd7bc151571f9d92a7bac30ee36d79be86ac506
#import <React/NSView+React.h>

@interface RCTUIManager (Testing)

Expand Down
4 changes: 4 additions & 0 deletions Libraries/ART/ART.xcodeproj/project.pbxproj
Expand Up @@ -404,16 +404,20 @@
0CF68AD61AF0540F00FF9E5C /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
MACOSX_DEPLOYMENT_TARGET = 10.11;
OTHER_LDFLAGS = "-ObjC";
PRODUCT_NAME = "$(TARGET_NAME)";
SDKROOT = macosx;
};
name = Debug;
};
0CF68AD71AF0540F00FF9E5C /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
MACOSX_DEPLOYMENT_TARGET = 10.11;
OTHER_LDFLAGS = "-ObjC";
PRODUCT_NAME = "$(TARGET_NAME)";
SDKROOT = macosx;
};
name = Release;
};
Expand Down
56 changes: 28 additions & 28 deletions Libraries/ART/RCTConvert+ART.m
Expand Up @@ -89,35 +89,35 @@ + (ARTTextFrame)ARTTextFrame:(id)json
}

NSDictionary *fontDict = dict[@"font"];
CTFontRef font = (__bridge CTFontRef)[self NSFont:nil withFamily:fontDict[@"fontFamily"] size:fontDict[@"fontSize"] weight:fontDict[@"fontWeight"] style:fontDict[@"fontStyle"] scaleMultiplier:1.0];
if (!font) {
return frame;
}

// Create a dictionary for this font
CFDictionaryRef attributes = (__bridge CFDictionaryRef)@{
(NSString *)kCTFontAttributeName:(__bridge id)font,
(NSString *)kCTForegroundColorFromContextAttributeName: @YES
};

// Set up text frame with font metrics
CGFloat size = CTFontGetSize(font);
frame.count = lineCount;
frame.baseLine = size; // estimate base line
frame.lineHeight = size * 1.1; // Base on ART canvas line height estimate
frame.lines = malloc(sizeof(CTLineRef) * lineCount);
frame.widths = malloc(sizeof(CGFloat) * lineCount);

[lines enumerateObjectsUsingBlock:^(NSString *text, NSUInteger i, BOOL *stop) {

CFStringRef string = (__bridge CFStringRef)text;
CFAttributedStringRef attrString = CFAttributedStringCreate(kCFAllocatorDefault, string, attributes);
CTLineRef line = CTLineCreateWithAttributedString(attrString);
CFRelease(attrString);
CTFontRef font = (__bridge CTFontRef)[self NSFont:dict[@"font"]];
if (!font) {
return frame;
}

frame.lines[i] = line;
frame.widths[i] = CTLineGetTypographicBounds(line, NULL, NULL, NULL);
}];
// Create a dictionary for this font
CFDictionaryRef attributes = (__bridge CFDictionaryRef)@{
(NSString *)kCTFontAttributeName:(__bridge id)font,
(NSString *)kCTForegroundColorFromContextAttributeName: @YES
};

// Set up text frame with font metrics
CGFloat size = CTFontGetSize(font);
frame.count = lineCount;
frame.baseLine = size; // estimate base line
frame.lineHeight = size * 1.1; // Base on ART canvas line height estimate
frame.lines = malloc(sizeof(CTLineRef) * lineCount);
frame.widths = malloc(sizeof(CGFloat) * lineCount);

[lines enumerateObjectsUsingBlock:^(NSString *text, NSUInteger i, BOOL *stop) {

CFStringRef string = (__bridge CFStringRef)text;
CFAttributedStringRef attrString = CFAttributedStringCreate(kCFAllocatorDefault, string, attributes);
CTLineRef line = CTLineCreateWithAttributedString(attrString);
CFRelease(attrString);

frame.lines[i] = line;
frame.widths[i] = CTLineGetTypographicBounds(line, NULL, NULL, NULL);
}];

return frame;
}
Expand Down
92 changes: 84 additions & 8 deletions Libraries/Components/Button.js
Expand Up @@ -23,6 +23,13 @@ const View = require('View');

const invariant = require('fbjs/lib/invariant');

const requireNativeComponent = require('requireNativeComponent');
const NativeModules = require('NativeModules');

const RCTButton = requireNativeComponent('RCTButton', Button, {
nativeOnly: {},
});

/**
* A basic button component that should render nicely on any platform. Supports
* a minimal level of customization.
Expand All @@ -49,7 +56,6 @@ const invariant = require('fbjs/lib/invariant');
*/

class Button extends React.Component {

props: {
title: string,
onPress: () => any,
Expand Down Expand Up @@ -84,6 +90,63 @@ class Button extends React.Component {
* Used to locate this view in end-to-end tests.
*/
testID: PropTypes.string,
/**
* macOS Specific
*/
type: PropTypes.oneOf([
'momentaryLight',
'push',
'switch',
'toggle',
'radio',
'onOff',
'accelerator',
]),
/*
* https://developer.apple.com/library/mac/documentation/UserExperience/Conceptual/OSXHIGuidelines/SystemProvided.html
*/
systemImage: PropTypes.string,
alternateTitle: PropTypes.string,
image: PropTypes.oneOfType([
PropTypes.shape({
uri: PropTypes.string,
}),
// Opaque type returned by require('./image.jpg')
PropTypes.number,
]),
alternateImage: PropTypes.oneOfType([
PropTypes.shape({
uri: PropTypes.string,
}),
// Opaque type returned by require('./image.jpg')
PropTypes.number,
]),
bezelStyle: PropTypes.oneOf([
'rounded',
'regularSquare',
'thickSquare',
'thickerSquare',
'disclosure',
'shadowlessSquare',
'circular',
'texturedSquare',
'helpButton',
'smallSquare',
'texturedRounded',
'roundRect',
'recessed',
'roundedDisclosure',
'inline',
]),
toolTip: PropTypes.string,
/**
* Invoked on mouse click
*
* {nativeEvent: { state }}.
*/
onClick: PropTypes.func,
allowsMixedState: PropTypes.bool,
state: PropTypes.oneOfType([PropTypes.number, PropTypes.bool]),
};

render() {
Expand All @@ -97,25 +160,34 @@ class Button extends React.Component {
} = this.props;
const buttonStyles = [styles.button];
const textStyles = [styles.text];
const Touchable = Platform.OS === 'android' ? TouchableNativeFeedback : TouchableOpacity;
const Touchable = Platform.OS === 'android'
? TouchableNativeFeedback
: TouchableOpacity;
if (color && Platform.OS === 'ios') {
textStyles.push({color: color});
textStyles.push({ color: color });
} else if (color) {
buttonStyles.push({backgroundColor: color});
buttonStyles.push({ backgroundColor: color });
}
if (disabled) {
buttonStyles.push(styles.buttonDisabled);
textStyles.push(styles.textDisabled);
}
invariant(
typeof title === 'string',
'The title prop of a Button must be a string',
'The title prop of a Button must be a string'
);
const formattedTitle = Platform.OS === 'android' ? title.toUpperCase() : title;
const formattedTitle = Platform.OS === 'android'
? title.toUpperCase()
: title;
const accessibilityTraits = ['button'];
if (disabled) {
accessibilityTraits.push('disabled');
}
if (Platform.OS === 'macos') {
return (
<RCTButton {...this.props} style={[styles.button, this.props.style]} />
);
}
return (
<Touchable
accessibilityComponentType="button"
Expand Down Expand Up @@ -147,6 +219,10 @@ const styles = StyleSheet.create({
backgroundColor: defaultBlue,
borderRadius: 2,
},
macos: {
height: NativeModules.ButtonManager.ComponentHeight,
width: NativeModules.ButtonManager.ComponentWidth,
},
}),
text: Platform.select({
ios: {
Expand All @@ -167,15 +243,15 @@ const styles = StyleSheet.create({
android: {
elevation: 0,
backgroundColor: '#dfdfdf',
}
},
}),
textDisabled: Platform.select({
ios: {
color: '#cdcdcd',
},
android: {
color: '#a1a1a1',
}
},
}),
});

Expand Down

0 comments on commit cdf30fd

Please sign in to comment.