Skip to content

Commit fec8194

Browse files
committed
Merge pull request #1264 from vjeux/Update_Wed_13_May
Update wed 13 may
2 parents 8917f81 + 1e42fea commit fec8194

File tree

103 files changed

+1853
-730
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

103 files changed

+1853
-730
lines changed

Examples/2048/Game2048.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ class Game2048 extends React.Component {
150150
startX: number;
151151
startY: number;
152152

153-
constructor(props) {
153+
constructor(props: {}) {
154154
super(props);
155155
this.state = {
156156
board: new GameBoard(),

Examples/UIExplorer/AlertIOSExample.js

Lines changed: 90 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,9 +95,98 @@ exports.examples = [{
9595
</TouchableHighlight>
9696
</View>
9797
);
98-
},
98+
}
99+
},
100+
{
101+
title: 'Prompt',
102+
render(): React.Component {
103+
return <PromptExample />
104+
}
99105
}];
100106

107+
class PromptExample extends React.Component {
108+
constructor(props) {
109+
super(props);
110+
111+
this.promptResponse = this.promptResponse.bind(this);
112+
this.state = {
113+
promptValue: undefined,
114+
};
115+
116+
this.title = 'Type a value';
117+
this.defaultValue = 'Default value';
118+
this.buttons = [{
119+
text: 'Custom cancel',
120+
}, {
121+
text: 'Custom OK',
122+
onPress: this.promptResponse
123+
}];
124+
}
125+
126+
render() {
127+
return (
128+
<View>
129+
<Text style={{marginBottom: 10}}>
130+
<Text style={{fontWeight: 'bold'}}>Prompt value:</Text> {this.state.promptValue}
131+
</Text>
132+
133+
<TouchableHighlight
134+
style={styles.wrapper}
135+
onPress={this.prompt.bind(this, this.title, this.promptResponse)}>
136+
137+
<View style={styles.button}>
138+
<Text>
139+
prompt with title & callback
140+
</Text>
141+
</View>
142+
</TouchableHighlight>
143+
144+
<TouchableHighlight
145+
style={styles.wrapper}
146+
onPress={this.prompt.bind(this, this.title, this.buttons)}>
147+
148+
<View style={styles.button}>
149+
<Text>
150+
prompt with title & custom buttons
151+
</Text>
152+
</View>
153+
</TouchableHighlight>
154+
155+
<TouchableHighlight
156+
style={styles.wrapper}
157+
onPress={this.prompt.bind(this, this.title, this.defaultValue, this.promptResponse)}>
158+
159+
<View style={styles.button}>
160+
<Text>
161+
prompt with title, default value & callback
162+
</Text>
163+
</View>
164+
</TouchableHighlight>
165+
166+
<TouchableHighlight
167+
style={styles.wrapper}
168+
onPress={this.prompt.bind(this, this.title, this.defaultValue, this.buttons)}>
169+
170+
<View style={styles.button}>
171+
<Text>
172+
prompt with title, default value & custom buttons
173+
</Text>
174+
</View>
175+
</TouchableHighlight>
176+
</View>
177+
);
178+
}
179+
180+
prompt() {
181+
// Flow's apply support is broken: #7035621
182+
((AlertIOS.prompt: any).apply: any)(AlertIOS, arguments);
183+
}
184+
185+
promptResponse(promptValue) {
186+
this.setState({ promptValue });
187+
}
188+
}
189+
101190
var styles = StyleSheet.create({
102191
wrapper: {
103192
borderRadius: 5,

Examples/UIExplorer/BorderExample.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,18 @@ var styles = StyleSheet.create({
6868
borderLeftWidth: 40,
6969
borderLeftColor: 'blue',
7070
},
71+
border6: {
72+
borderTopWidth: 10,
73+
borderTopColor: 'red',
74+
borderRightWidth: 20,
75+
borderRightColor: 'yellow',
76+
borderBottomWidth: 30,
77+
borderBottomColor: 'green',
78+
borderLeftWidth: 40,
79+
borderLeftColor: 'blue',
80+
81+
borderTopLeftRadius: 100,
82+
},
7183
});
7284

7385
exports.title = 'Border';
@@ -115,4 +127,11 @@ exports.examples = [
115127
return <View style={[styles.box, styles.border5]} />;
116128
}
117129
},
130+
{
131+
title: 'Custom Borders',
132+
description: 'border*Width & border*Color',
133+
render() {
134+
return <View style={[styles.box, styles.border6]} />;
135+
}
136+
},
118137
];
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/**
2+
* The examples provided by Facebook are for non-commercial testing and
3+
* evaluation purposes only.
4+
*
5+
* Facebook reserves all rights not expressly granted.
6+
*
7+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
8+
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
9+
* FITNESS FOR A PARTICULAR PURPOSE AND NON INFRINGEMENT. IN NO EVENT SHALL
10+
* FACEBOOK BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
11+
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
12+
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
13+
*
14+
* @providesModule ExampleTypes
15+
* @flow
16+
*/
17+
18+
export type Example = {
19+
title: string,
20+
render: () => ?ReactElement<any, any, any>,
21+
description?: string,
22+
};
23+
24+
export type ExampleModule = {
25+
title: string;
26+
description: string;
27+
examples: Array<Example>;
28+
external?: bool;
29+
};
30+

Examples/UIExplorer/MapViewExample.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ var MapViewExample = React.createClass({
168168
/>
169169
<MapRegionInput
170170
onChange={this._onRegionInputChanged}
171-
region={this.state.mapRegionInput}
171+
region={this.state.mapRegionInput || undefined}
172172
/>
173173
</View>
174174
);

Examples/UIExplorer/PointerEventsExample.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,13 @@ var BoxOnlyExample = React.createClass({
181181
}
182182
});
183183

184-
var exampleClasses = [
184+
type ExampleClass = {
185+
Component: ReactClass<any, any, any>,
186+
title: string,
187+
description: string,
188+
};
189+
190+
var exampleClasses: Array<ExampleClass> = [
185191
{
186192
Component: NoneExample,
187193
title: '`none`',

Examples/UIExplorer/TextExample.ios.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,26 @@ exports.examples = [
218218
</View>
219219
);
220220
},
221+
}, {
222+
title: 'Letter Spacing',
223+
render: function() {
224+
return (
225+
<View>
226+
<Text style={{letterSpacing: 0}}>
227+
letterSpacing = 0
228+
</Text>
229+
<Text style={{letterSpacing: 2, marginTop: 5}}>
230+
letterSpacing = 2
231+
</Text>
232+
<Text style={{letterSpacing: 9, marginTop: 5}}>
233+
letterSpacing = 9
234+
</Text>
235+
<Text style={{letterSpacing: -1, marginTop: 5}}>
236+
letterSpacing = -1
237+
</Text>
238+
</View>
239+
);
240+
},
221241
}, {
222242
title: 'Spaces',
223243
render: function() {

Examples/UIExplorer/UIExplorerBlock.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,10 @@ var styles = StyleSheet.create({
6969
overflow: 'hidden',
7070
},
7171
titleContainer: {
72-
borderWidth: 0.5,
73-
borderRadius: 2.5,
74-
borderColor: '#d6d7da',
72+
borderBottomWidth: 0.5,
73+
borderTopLeftRadius: 3,
74+
borderTopRightRadius: 2.5,
75+
borderBottomColor: '#d6d7da',
7576
backgroundColor: '#f6f7f8',
7677
paddingHorizontal: 10,
7778
paddingVertical: 5,

Examples/UIExplorer/UIExplorerList.js

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ var {
3030
var { TestModule } = React.addons;
3131
var Settings = require('Settings');
3232

33+
import type { Example, ExampleModule } from 'ExampleTypes';
34+
3335
var createExamplePage = require('./createExamplePage');
3436

3537
var COMPONENTS = [
@@ -107,9 +109,17 @@ COMPONENTS.concat(APIS).forEach((Example) => {
107109
}
108110
});
109111

112+
type Props = {
113+
navigator: Array<{title: string, component: ReactClass<any,any,any>}>,
114+
onExternalExampleRequested: Function,
115+
};
116+
117+
118+
110119
class UIExplorerList extends React.Component {
120+
props: Props;
111121

112-
constructor(props) {
122+
constructor(props: Props) {
113123
super(props);
114124
this.state = {
115125
dataSource: ds.cloneWithRowsAndSections({
@@ -149,7 +159,7 @@ class UIExplorerList extends React.Component {
149159
);
150160
}
151161

152-
_renderSectionHeader(data, section) {
162+
_renderSectionHeader(data: any, section: string) {
153163
return (
154164
<View style={styles.sectionHeader}>
155165
<Text style={styles.sectionHeaderTitle}>
@@ -159,7 +169,7 @@ class UIExplorerList extends React.Component {
159169
);
160170
}
161171

162-
_renderRow(example, i) {
172+
_renderRow(example: ExampleModule, i: number) {
163173
return (
164174
<View key={i}>
165175
<TouchableHighlight onPress={() => this._onPressRow(example)}>
@@ -177,7 +187,7 @@ class UIExplorerList extends React.Component {
177187
);
178188
}
179189

180-
_search(text) {
190+
_search(text: mixed) {
181191
var regex = new RegExp(text, 'i');
182192
var filter = (component) => regex.test(component.title);
183193

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

194-
_onPressRow(example) {
204+
_onPressRow(example: ExampleModule) {
195205
if (example.external) {
196206
this.props.onExternalExampleRequested(example);
197207
return;
8.26 KB
Loading

0 commit comments

Comments
 (0)