Skip to content

Commit

Permalink
Merge branch 'master' into fix-touchable-opacity-initial-opacity
Browse files Browse the repository at this point in the history
  • Loading branch information
gorangajic committed Jul 20, 2016
2 parents 90761ee + 12ec213 commit 0effe5e
Show file tree
Hide file tree
Showing 32 changed files with 1,155 additions and 982 deletions.
56 changes: 28 additions & 28 deletions Examples/UIExplorer/UIExplorerUnitTests/RCTShadowViewTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ - (void)setUp
{
[super setUp];

self.parentView = [self _shadowViewWithStyle:^(css_style_t *style) {
style->flex_direction = CSS_FLEX_DIRECTION_COLUMN;
self.parentView = [self _shadowViewWithStyle:^(CSSStyle *style) {
style->flexDirection = CSSFlexDirectionColumn;
style->dimensions[0] = 440;
style->dimensions[1] = 440;
}];
Expand All @@ -50,22 +50,22 @@ - (void)setUp
//
- (void)testApplyingLayoutRecursivelyToShadowView
{
RCTShadowView *leftView = [self _shadowViewWithStyle:^(css_style_t *style) {
RCTShadowView *leftView = [self _shadowViewWithStyle:^(CSSStyle *style) {
style->flex = 1;
}];

RCTShadowView *centerView = [self _shadowViewWithStyle:^(css_style_t *style) {
RCTShadowView *centerView = [self _shadowViewWithStyle:^(CSSStyle *style) {
style->flex = 2;
style->margin[0] = 10;
style->margin[2] = 10;
}];

RCTShadowView *rightView = [self _shadowViewWithStyle:^(css_style_t *style) {
RCTShadowView *rightView = [self _shadowViewWithStyle:^(CSSStyle *style) {
style->flex = 1;
}];

RCTShadowView *mainView = [self _shadowViewWithStyle:^(css_style_t *style) {
style->flex_direction = CSS_FLEX_DIRECTION_ROW;
RCTShadowView *mainView = [self _shadowViewWithStyle:^(CSSStyle *style) {
style->flexDirection = CSSFlexDirectionRow;
style->flex = 2;
style->margin[1] = 10;
style->margin[3] = 10;
Expand All @@ -75,11 +75,11 @@ - (void)testApplyingLayoutRecursivelyToShadowView
[mainView insertReactSubview:centerView atIndex:1];
[mainView insertReactSubview:rightView atIndex:2];

RCTShadowView *headerView = [self _shadowViewWithStyle:^(css_style_t *style) {
RCTShadowView *headerView = [self _shadowViewWithStyle:^(CSSStyle *style) {
style->flex = 1;
}];

RCTShadowView *footerView = [self _shadowViewWithStyle:^(css_style_t *style) {
RCTShadowView *footerView = [self _shadowViewWithStyle:^(CSSStyle *style) {
style->flex = 1;
}];

Expand Down Expand Up @@ -108,50 +108,50 @@ - (void)testApplyingLayoutRecursivelyToShadowView

- (void)testAssignsSuggestedWidthDimension
{
[self _withShadowViewWithStyle:^(css_style_t *style) {
style->position[CSS_LEFT] = 0;
style->position[CSS_TOP] = 0;
style->dimensions[CSS_HEIGHT] = 10;
[self _withShadowViewWithStyle:^(CSSStyle *style) {
style->position[CSSPositionLeft] = 0;
style->position[CSSPositionTop] = 0;
style->dimensions[CSSDimensionHeight] = 10;
}
assertRelativeLayout:CGRectMake(0, 0, 3, 10)
withIntrinsicContentSize:CGSizeMake(3, UIViewNoIntrinsicMetric)];
}

- (void)testAssignsSuggestedHeightDimension
{
[self _withShadowViewWithStyle:^(css_style_t *style) {
style->position[CSS_LEFT] = 0;
style->position[CSS_TOP] = 0;
style->dimensions[CSS_WIDTH] = 10;
[self _withShadowViewWithStyle:^(CSSStyle *style) {
style->position[CSSPositionLeft] = 0;
style->position[CSSPositionTop] = 0;
style->dimensions[CSSDimensionWidth] = 10;
}
assertRelativeLayout:CGRectMake(0, 0, 10, 4)
withIntrinsicContentSize:CGSizeMake(UIViewNoIntrinsicMetric, 4)];
}

- (void)testDoesNotOverrideDimensionStyleWithSuggestedDimensions
{
[self _withShadowViewWithStyle:^(css_style_t *style) {
style->position[CSS_LEFT] = 0;
style->position[CSS_TOP] = 0;
style->dimensions[CSS_WIDTH] = 10;
style->dimensions[CSS_HEIGHT] = 10;
[self _withShadowViewWithStyle:^(CSSStyle *style) {
style->position[CSSPositionLeft] = 0;
style->position[CSSPositionTop] = 0;
style->dimensions[CSSDimensionWidth] = 10;
style->dimensions[CSSDimensionHeight] = 10;
}
assertRelativeLayout:CGRectMake(0, 0, 10, 10)
withIntrinsicContentSize:CGSizeMake(3, 4)];
}

- (void)testDoesNotAssignSuggestedDimensionsWhenStyledWithFlexAttribute
{
float parentWidth = self.parentView.cssNode->style.dimensions[CSS_WIDTH];
float parentHeight = self.parentView.cssNode->style.dimensions[CSS_HEIGHT];
[self _withShadowViewWithStyle:^(css_style_t *style) {
float parentWidth = self.parentView.cssNode->style.dimensions[CSSDimensionWidth];
float parentHeight = self.parentView.cssNode->style.dimensions[CSSDimensionHeight];
[self _withShadowViewWithStyle:^(CSSStyle *style) {
style->flex = 1;
}
assertRelativeLayout:CGRectMake(0, 0, parentWidth, parentHeight)
withIntrinsicContentSize:CGSizeMake(3, 4)];
}

- (void)_withShadowViewWithStyle:(void(^)(css_style_t *style))styleBlock
- (void)_withShadowViewWithStyle:(void(^)(CSSStyle *style))styleBlock
assertRelativeLayout:(CGRect)expectedRect
withIntrinsicContentSize:(CGSize)contentSize
{
Expand All @@ -166,11 +166,11 @@ - (void)_withShadowViewWithStyle:(void(^)(css_style_t *style))styleBlock
NSStringFromCGRect(actualRect));
}

- (RCTRootShadowView *)_shadowViewWithStyle:(void(^)(css_style_t *style))styleBlock
- (RCTRootShadowView *)_shadowViewWithStyle:(void(^)(CSSStyle *style))styleBlock
{
RCTRootShadowView *shadowView = [RCTRootShadowView new];

css_style_t style = shadowView.cssNode->style;
CSSStyle style = shadowView.cssNode->style;
styleBlock(&style);
shadowView.cssNode->style = style;

Expand Down
38 changes: 37 additions & 1 deletion Examples/UIExplorer/js/ToastAndroidExample.android.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,43 @@ var ToastExample = React.createClass({
<TouchableWithoutFeedback
onPress={() =>
ToastAndroid.show('This is a toast with long duration', ToastAndroid.LONG)}>
<Text style={styles.text}>Click me too.</Text>
<Text style={styles.text}>Click me.</Text>
</TouchableWithoutFeedback>
</UIExplorerBlock>
<UIExplorerBlock title="Toast with top gravity">
<TouchableWithoutFeedback
onPress={() =>
ToastAndroid.showWithGravity(
'This is a toast with top gravity',
ToastAndroid.SHORT,
ToastAndroid.TOP,
)
}>
<Text style={styles.text}>Click me.</Text>
</TouchableWithoutFeedback>
</UIExplorerBlock>
<UIExplorerBlock title="Toast with center gravity">
<TouchableWithoutFeedback
onPress={() =>
ToastAndroid.showWithGravity(
'This is a toast with center gravity',
ToastAndroid.SHORT,
ToastAndroid.CENTER,
)
}>
<Text style={styles.text}>Click me.</Text>
</TouchableWithoutFeedback>
</UIExplorerBlock>
<UIExplorerBlock title="Toast with bottom gravity">
<TouchableWithoutFeedback
onPress={() =>
ToastAndroid.showWithGravity(
'This is a toast with bottom gravity',
ToastAndroid.SHORT,
ToastAndroid.BOTTOM,
)
}>
<Text style={styles.text}>Click me.</Text>
</TouchableWithoutFeedback>
</UIExplorerBlock>
</UIExplorerPage>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,11 @@ Object.keys(RemoteModules).forEach((moduleName) => {
get: () => {
let module = RemoteModules[moduleName];
if (module && typeof module.moduleID === 'number' && global.nativeRequireModuleConfig) {
const json = global.nativeRequireModuleConfig(moduleName);
const config = json && JSON.parse(json);
// The old bridge (still used by iOS) will send the config as
// a JSON string that needs parsing, so we set config according
// to the type of response we got.
const rawConfig = global.nativeRequireModuleConfig(moduleName);
const config = typeof rawConfig === 'string' ? JSON.parse(rawConfig) : rawConfig;
module = config && BatchedBridge.processModuleConfig(config, module.moduleID);
RemoteModules[moduleName] = module;
}
Expand Down
16 changes: 16 additions & 0 deletions Libraries/Components/ToastAndroid/ToastAndroid.android.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,36 @@ var RCTToastAndroid = require('NativeModules').ToastAndroid;
*
* 1. String message: A string with the text to toast
* 2. int duration: The duration of the toast. May be ToastAndroid.SHORT or ToastAndroid.LONG
*
* There is also a function `showWithGravity` to specify the layout gravity. May be
* ToastAndroid.TOP, ToastAndroid.BOTTOM, ToastAndroid.CENTER
*/

var ToastAndroid = {

// Toast duration constants
SHORT: RCTToastAndroid.SHORT,
LONG: RCTToastAndroid.LONG,

// Toast gravity constants
TOP: RCTToastAndroid.TOP,
BOTTOM: RCTToastAndroid.BOTTOM,
CENTER: RCTToastAndroid.CENTER,

show: function (
message: string,
duration: number
): void {
RCTToastAndroid.show(message, duration);
},

showWithGravity: function (
message: string,
duration: number,
gravity: number,
): void {
RCTToastAndroid.showWithGravity(message, duration, gravity);
},
};

module.exports = ToastAndroid;
6 changes: 0 additions & 6 deletions Libraries/QuickPerformanceLogger/QuickPerformanceLogger.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,6 @@ var fixOpts = function(opts) {
};

var QuickPerformanceLogger = {

// These two empty containers will cause all calls to ActionId.SOMETHING or MarkerId.OTHER
// to equal 'undefined', unless they are given a concrete value elsewhere.
ActionId: {},
MarkerId: {},

markerStart(markerId, opts) {
if (typeof markerId !== 'number') {
return;
Expand Down
Loading

0 comments on commit 0effe5e

Please sign in to comment.