Skip to content

Commit 60b5645

Browse files
committed
Merge pull request facebook#1858 from a2/Update_Thu_3_Jul
Updates from Thursday, 3 July
2 parents 1d1386e + e37e794 commit 60b5645

File tree

15 files changed

+158
-31
lines changed

15 files changed

+158
-31
lines changed

Examples/UIExplorer/UIExplorerApp.ios.js

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -43,22 +43,23 @@ var UIExplorerApp = React.createClass({
4343
/>
4444
);
4545
}
46-
return (
47-
<NavigatorIOS
48-
style={styles.container}
49-
initialRoute={{
50-
title: 'UIExplorer',
51-
component: UIExplorerList,
52-
passProps: {
53-
onExternalExampleRequested: (example) => {
54-
this.setState({ openExternalExample: example, });
55-
},
56-
}
57-
}}
58-
itemWrapperStyle={styles.itemWrapper}
59-
tintColor="#008888"
60-
/>
61-
);
46+
47+
return (
48+
<NavigatorIOS
49+
style={styles.container}
50+
initialRoute={{
51+
title: 'UIExplorer',
52+
component: UIExplorerList,
53+
passProps: {
54+
onExternalExampleRequested: (example) => {
55+
this.setState({ openExternalExample: example, });
56+
},
57+
}
58+
}}
59+
itemWrapperStyle={styles.itemWrapper}
60+
tintColor="#008888"
61+
/>
62+
);
6263
}
6364
});
6465

Loading
Loading
Loading
Loading
Loading

Examples/UIExplorer/UIExplorerList.js

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ var {
3232
var { TestModule } = React.addons;
3333

3434
import type { ExampleModule } from 'ExampleTypes';
35+
import type { NavigationContext } from 'NavigationContext';
3536

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

@@ -129,7 +130,10 @@ COMPONENTS.concat(APIS).forEach((Example) => {
129130
});
130131

131132
type Props = {
132-
navigator: Array<{title: string, component: ReactClass<any,any,any>}>,
133+
navigator: {
134+
navigationContext: NavigationContext,
135+
push: (route: {title: string, component: ReactClass<any,any,any>}) => void,
136+
},
133137
onExternalExampleRequested: Function,
134138
onSelectExample: Function,
135139
isInDrawer: bool,
@@ -149,8 +153,25 @@ class UIExplorerList extends React.Component {
149153
};
150154
}
151155

156+
componentWillMount() {
157+
this.props.navigator.navigationContext.addListener('didfocus', function(event) {
158+
if (event.data.route.title === 'UIExplorer') {
159+
Settings.set({visibleExample: null});
160+
}
161+
});
162+
}
163+
152164
componentDidMount() {
153165
this._search(this.state.searchText);
166+
167+
var visibleExampleTitle = Settings.get('visibleExample');
168+
if (visibleExampleTitle) {
169+
var predicate = (example) => example.title === visibleExampleTitle;
170+
var foundExample = APIS.find(predicate) || COMPONENTS.find(predicate);
171+
if (foundExample) {
172+
setTimeout(() => this._openExample(foundExample), 100);
173+
}
174+
}
154175
}
155176

156177
render() {
@@ -240,11 +261,12 @@ class UIExplorerList extends React.Component {
240261
Settings.set({searchText: text});
241262
}
242263

243-
_onPressRow(example: any) {
264+
_openExample(example: any) {
244265
if (example.external) {
245266
this.props.onExternalExampleRequested(example);
246267
return;
247268
}
269+
248270
var Component = makeRenderable(example);
249271
if (Platform.OS === 'ios') {
250272
this.props.navigator.push({
@@ -258,6 +280,11 @@ class UIExplorerList extends React.Component {
258280
});
259281
}
260282
}
283+
284+
_onPressRow(example: any) {
285+
Settings.set({visibleExample: example.title});
286+
this._openExample(example);
287+
}
261288
}
262289

263290
var styles = StyleSheet.create({

Examples/UIExplorer/UIExplorerPage.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ var UIExplorerPage = React.createClass({
4040
ContentWrapper = (View: ReactClass<any, any, any>);
4141
} else {
4242
ContentWrapper = (ScrollView: ReactClass<any, any, any>);
43+
wrapperProps.automaticallyAdjustContentInsets = !this.props.title;
4344
wrapperProps.keyboardShouldPersistTaps = true;
4445
wrapperProps.keyboardDismissMode = 'interactive';
4546
}
@@ -64,14 +65,14 @@ var UIExplorerPage = React.createClass({
6465
var styles = StyleSheet.create({
6566
container: {
6667
backgroundColor: '#e9eaed',
67-
paddingTop: 15,
6868
flex: 1,
6969
},
7070
spacer: {
7171
height: 270,
7272
},
7373
wrapper: {
7474
flex: 1,
75+
paddingTop: 10,
7576
},
7677
});
7778

Examples/UIExplorer/UIExplorerTitle.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ var styles = StyleSheet.create({
4141
borderWidth: 0.5,
4242
borderColor: '#d6d7da',
4343
margin: 10,
44+
marginBottom: 0,
4445
height: 45,
4546
padding: 10,
4647
backgroundColor: 'white',

Examples/UIExplorer/ViewExample.js

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,14 @@
1515
*/
1616
'use strict';
1717

18+
var Platform = require('Platform');
1819
var React = require('react-native');
1920
var {
2021
StyleSheet,
2122
Text,
2223
View,
2324
} = React;
25+
var TouchableWithoutFeedback = require('TouchableWithoutFeedback');
2426

2527
var styles = StyleSheet.create({
2628
box: {
@@ -30,6 +32,58 @@ var styles = StyleSheet.create({
3032
}
3133
});
3234

35+
var ViewBorderStyleExample = React.createClass({
36+
getInitialState() {
37+
return {
38+
showBorder: true
39+
};
40+
},
41+
42+
render() {
43+
if (Platform.OS !== 'android') {
44+
return (
45+
<View style={{backgroundColor: 'red'}}>
46+
<Text style={{color: 'white'}}>
47+
borderStyle is only supported on android for now.
48+
</Text>
49+
</View>
50+
);
51+
}
52+
53+
return (
54+
<TouchableWithoutFeedback onPress={this._handlePress}>
55+
<View>
56+
<View style={{
57+
borderWidth: 1,
58+
borderRadius: 5,
59+
borderStyle: this.state.showBorder ? 'dashed' : null,
60+
padding: 5
61+
}}>
62+
<Text style={{fontSize: 11}}>
63+
Dashed border style
64+
</Text>
65+
</View>
66+
<View style={{
67+
marginTop: 5,
68+
borderWidth: 1,
69+
borderRadius: 5,
70+
borderStyle: this.state.showBorder ? 'dotted' : null,
71+
padding: 5
72+
}}>
73+
<Text style={{fontSize: 11}}>
74+
Dotted border style
75+
</Text>
76+
</View>
77+
</View>
78+
</TouchableWithoutFeedback>
79+
);
80+
},
81+
82+
_handlePress() {
83+
this.setState({showBorder: !this.state.showBorder});
84+
}
85+
});
86+
3387
exports.title = '<View>';
3488
exports.description = 'Basic building block of all UI.';
3589
exports.displayName = 'ViewExample';
@@ -89,6 +143,11 @@ exports.examples = [
89143
</View>
90144
);
91145
},
146+
}, {
147+
title: 'Border Style',
148+
render: function() {
149+
return <ViewBorderStyleExample />;
150+
},
92151
}, {
93152
title: 'Circle with Border Radius',
94153
render: function() {

0 commit comments

Comments
 (0)