Skip to content

Commit

Permalink
Merge pull request #1264 from vjeux/Update_Wed_13_May
Browse files Browse the repository at this point in the history
Update wed 13 may
  • Loading branch information
vjeux committed May 13, 2015
2 parents 8917f81 + 1e42fea commit fec8194
Show file tree
Hide file tree
Showing 103 changed files with 1,853 additions and 730 deletions.
2 changes: 1 addition & 1 deletion Examples/2048/Game2048.js
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ class Game2048 extends React.Component {
startX: number;
startY: number;

constructor(props) {
constructor(props: {}) {
super(props);
this.state = {
board: new GameBoard(),
Expand Down
91 changes: 90 additions & 1 deletion Examples/UIExplorer/AlertIOSExample.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,98 @@ exports.examples = [{
</TouchableHighlight>
</View>
);
},
}
},
{
title: 'Prompt',
render(): React.Component {
return <PromptExample />
}
}];

class PromptExample extends React.Component {
constructor(props) {
super(props);

this.promptResponse = this.promptResponse.bind(this);
this.state = {
promptValue: undefined,
};

this.title = 'Type a value';
this.defaultValue = 'Default value';
this.buttons = [{
text: 'Custom cancel',
}, {
text: 'Custom OK',
onPress: this.promptResponse
}];
}

render() {
return (
<View>
<Text style={{marginBottom: 10}}>
<Text style={{fontWeight: 'bold'}}>Prompt value:</Text> {this.state.promptValue}
</Text>

<TouchableHighlight
style={styles.wrapper}
onPress={this.prompt.bind(this, this.title, this.promptResponse)}>

<View style={styles.button}>
<Text>
prompt with title & callback
</Text>
</View>
</TouchableHighlight>

<TouchableHighlight
style={styles.wrapper}
onPress={this.prompt.bind(this, this.title, this.buttons)}>

<View style={styles.button}>
<Text>
prompt with title & custom buttons
</Text>
</View>
</TouchableHighlight>

<TouchableHighlight
style={styles.wrapper}
onPress={this.prompt.bind(this, this.title, this.defaultValue, this.promptResponse)}>

<View style={styles.button}>
<Text>
prompt with title, default value & callback
</Text>
</View>
</TouchableHighlight>

<TouchableHighlight
style={styles.wrapper}
onPress={this.prompt.bind(this, this.title, this.defaultValue, this.buttons)}>

<View style={styles.button}>
<Text>
prompt with title, default value & custom buttons
</Text>
</View>
</TouchableHighlight>
</View>
);
}

prompt() {
// Flow's apply support is broken: #7035621
((AlertIOS.prompt: any).apply: any)(AlertIOS, arguments);
}

promptResponse(promptValue) {
this.setState({ promptValue });
}
}

var styles = StyleSheet.create({
wrapper: {
borderRadius: 5,
Expand Down
19 changes: 19 additions & 0 deletions Examples/UIExplorer/BorderExample.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,18 @@ var styles = StyleSheet.create({
borderLeftWidth: 40,
borderLeftColor: 'blue',
},
border6: {
borderTopWidth: 10,
borderTopColor: 'red',
borderRightWidth: 20,
borderRightColor: 'yellow',
borderBottomWidth: 30,
borderBottomColor: 'green',
borderLeftWidth: 40,
borderLeftColor: 'blue',

borderTopLeftRadius: 100,
},
});

exports.title = 'Border';
Expand Down Expand Up @@ -115,4 +127,11 @@ exports.examples = [
return <View style={[styles.box, styles.border5]} />;
}
},
{
title: 'Custom Borders',
description: 'border*Width & border*Color',
render() {
return <View style={[styles.box, styles.border6]} />;
}
},
];
30 changes: 30 additions & 0 deletions Examples/UIExplorer/ExampleTypes.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/**
* The examples provided by Facebook are for non-commercial testing and
* evaluation purposes only.
*
* Facebook reserves all rights not expressly granted.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NON INFRINGEMENT. IN NO EVENT SHALL
* FACEBOOK BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
* @providesModule ExampleTypes
* @flow
*/

export type Example = {
title: string,
render: () => ?ReactElement<any, any, any>,
description?: string,
};

export type ExampleModule = {
title: string;
description: string;
examples: Array<Example>;
external?: bool;
};

2 changes: 1 addition & 1 deletion Examples/UIExplorer/MapViewExample.js
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ var MapViewExample = React.createClass({
/>
<MapRegionInput
onChange={this._onRegionInputChanged}
region={this.state.mapRegionInput}
region={this.state.mapRegionInput || undefined}
/>
</View>
);
Expand Down
8 changes: 7 additions & 1 deletion Examples/UIExplorer/PointerEventsExample.js
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,13 @@ var BoxOnlyExample = React.createClass({
}
});

var exampleClasses = [
type ExampleClass = {
Component: ReactClass<any, any, any>,
title: string,
description: string,
};

var exampleClasses: Array<ExampleClass> = [
{
Component: NoneExample,
title: '`none`',
Expand Down
20 changes: 20 additions & 0 deletions Examples/UIExplorer/TextExample.ios.js
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,26 @@ exports.examples = [
</View>
);
},
}, {
title: 'Letter Spacing',
render: function() {
return (
<View>
<Text style={{letterSpacing: 0}}>
letterSpacing = 0
</Text>
<Text style={{letterSpacing: 2, marginTop: 5}}>
letterSpacing = 2
</Text>
<Text style={{letterSpacing: 9, marginTop: 5}}>
letterSpacing = 9
</Text>
<Text style={{letterSpacing: -1, marginTop: 5}}>
letterSpacing = -1
</Text>
</View>
);
},
}, {
title: 'Spaces',
render: function() {
Expand Down
7 changes: 4 additions & 3 deletions Examples/UIExplorer/UIExplorerBlock.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,10 @@ var styles = StyleSheet.create({
overflow: 'hidden',
},
titleContainer: {
borderWidth: 0.5,
borderRadius: 2.5,
borderColor: '#d6d7da',
borderBottomWidth: 0.5,
borderTopLeftRadius: 3,
borderTopRightRadius: 2.5,
borderBottomColor: '#d6d7da',
backgroundColor: '#f6f7f8',
paddingHorizontal: 10,
paddingVertical: 5,
Expand Down
20 changes: 15 additions & 5 deletions Examples/UIExplorer/UIExplorerList.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ var {
var { TestModule } = React.addons;
var Settings = require('Settings');

import type { Example, ExampleModule } from 'ExampleTypes';

var createExamplePage = require('./createExamplePage');

var COMPONENTS = [
Expand Down Expand Up @@ -107,9 +109,17 @@ COMPONENTS.concat(APIS).forEach((Example) => {
}
});

type Props = {
navigator: Array<{title: string, component: ReactClass<any,any,any>}>,
onExternalExampleRequested: Function,
};



class UIExplorerList extends React.Component {
props: Props;

constructor(props) {
constructor(props: Props) {
super(props);
this.state = {
dataSource: ds.cloneWithRowsAndSections({
Expand Down Expand Up @@ -149,7 +159,7 @@ class UIExplorerList extends React.Component {
);
}

_renderSectionHeader(data, section) {
_renderSectionHeader(data: any, section: string) {
return (
<View style={styles.sectionHeader}>
<Text style={styles.sectionHeaderTitle}>
Expand All @@ -159,7 +169,7 @@ class UIExplorerList extends React.Component {
);
}

_renderRow(example, i) {
_renderRow(example: ExampleModule, i: number) {
return (
<View key={i}>
<TouchableHighlight onPress={() => this._onPressRow(example)}>
Expand All @@ -177,7 +187,7 @@ class UIExplorerList extends React.Component {
);
}

_search(text) {
_search(text: mixed) {
var regex = new RegExp(text, 'i');
var filter = (component) => regex.test(component.title);

Expand All @@ -191,7 +201,7 @@ class UIExplorerList extends React.Component {
Settings.set({searchText: text});
}

_onPressRow(example) {
_onPressRow(example: ExampleModule) {
if (example.external) {
this.props.onExternalExampleRequested(example);
return;
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
38 changes: 11 additions & 27 deletions Examples/UIExplorer/UIExplorerTests/UIExplorerTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -88,35 +88,19 @@ - (void)testAAA_RootViewLoadsAndRenders
XCTAssertTrue(foundElement, @"Cound't find element with '<View>' text in %d seconds", TIMEOUT_SECONDS);
}

- (void)testViewExampleSnapshot
{
[_runner runTest:_cmd module:@"ViewExample"];
}

- (void)testLayoutExampleSnapshot
{
[_runner runTest:_cmd module:@"LayoutExample"];
#define RCT_SNAPSHOT_TEST(name, reRecord) \
- (void)test##name##Snapshot \
{ \
_runner.recordMode |= reRecord; \
[_runner runTest:_cmd module:@#name]; \
}

- (void)testTextExampleSnapshot
{
[_runner runTest:_cmd module:@"TextExample"];
}

- (void)testSwitchExampleSnapshot
{
[_runner runTest:_cmd module:@"SwitchExample"];
}

- (void)testSliderExampleSnapshot
{
[_runner runTest:_cmd module:@"SliderExample"];
}

- (void)testTabBarExampleSnapshot
{
[_runner runTest:_cmd module:@"TabBarExample"];
}
RCT_SNAPSHOT_TEST(ViewExample, NO)
RCT_SNAPSHOT_TEST(LayoutExample, NO)
RCT_SNAPSHOT_TEST(TextExample, NO)
RCT_SNAPSHOT_TEST(SwitchExample, NO)
RCT_SNAPSHOT_TEST(SliderExample, NO)
RCT_SNAPSHOT_TEST(TabBarExample, NO)

// Make sure this test runs last
- (void)testZZZ_NotInRecordMode
Expand Down
Loading

0 comments on commit fec8194

Please sign in to comment.