Skip to content

Commit 0293def

Browse files
author
Eric Vicenti
committed
Updates from Fri 5 Jun
2 parents 8b93b99 + bb95400 commit 0293def

File tree

67 files changed

+1760
-657
lines changed

Some content is hidden

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

67 files changed

+1760
-657
lines changed

Examples/Movies/SearchScreen.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,7 @@ var SearchScreen = React.createClass({
281281
renderRow={this.renderRow}
282282
onEndReached={this.onEndReached}
283283
automaticallyAdjustContentInsets={false}
284-
keyboardDismissMode="onDrag"
284+
keyboardDismissMode="on-drag"
285285
keyboardShouldPersistTaps={true}
286286
showsVerticalScrollIndicator={false}
287287
/>;
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
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+
* @flow
15+
*/
16+
'use strict';
17+
18+
var React = require('react-native');
19+
var {
20+
ProgressViewIOS,
21+
StyleSheet,
22+
View,
23+
} = React;
24+
var TimerMixin = require('react-timer-mixin');
25+
26+
var ProgressViewExample = React.createClass({
27+
mixins: [TimerMixin],
28+
29+
getInitialState() {
30+
return {
31+
progress: 0,
32+
};
33+
},
34+
35+
componentDidMount() {
36+
this.updateProgress();
37+
},
38+
39+
updateProgress() {
40+
var progress = this.state.progress + 0.01;
41+
this.setState({ progress });
42+
this.requestAnimationFrame(() => this.updateProgress());
43+
},
44+
45+
getProgress(offset) {
46+
var progress = this.state.progress + offset;
47+
return Math.sin(progress % Math.PI) % 1;
48+
},
49+
50+
render() {
51+
return (
52+
<View style={styles.container}>
53+
<ProgressViewIOS style={styles.progressView} progress={this.getProgress(0)}/>
54+
<ProgressViewIOS style={styles.progressView} progressTintColor="purple" progress={this.getProgress(0.2)}/>
55+
<ProgressViewIOS style={styles.progressView} progressTintColor="red" progress={this.getProgress(0.4)}/>
56+
<ProgressViewIOS style={styles.progressView} progressTintColor="orange" progress={this.getProgress(0.6)}/>
57+
<ProgressViewIOS style={styles.progressView} progressTintColor="yellow" progress={this.getProgress(0.8)}/>
58+
</View>
59+
);
60+
},
61+
});
62+
63+
exports.framework = 'React';
64+
exports.title = 'ProgressViewIOS';
65+
exports.description = 'ProgressViewIOS';
66+
exports.examples = [{
67+
title: 'ProgressViewIOS',
68+
render() {
69+
return (
70+
<ProgressViewExample/>
71+
);
72+
}
73+
}];
74+
75+
var styles = StyleSheet.create({
76+
container: {
77+
marginTop: -20,
78+
backgroundColor: 'transparent',
79+
},
80+
progressView: {
81+
marginTop: 20,
82+
}
83+
});

Examples/UIExplorer/StatusBarIOSExample.js

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,11 @@ exports.examples = [{
3232
render() {
3333
return (
3434
<View>
35-
{Object.keys(StatusBarIOS.Style).map((key) =>
35+
{['default', 'light-content'].map((style) =>
3636
<TouchableHighlight style={styles.wrapper}
37-
onPress={() => StatusBarIOS.setStyle(StatusBarIOS.Style[key])}>
37+
onPress={() => StatusBarIOS.setStyle(style)}>
3838
<View style={styles.button}>
39-
<Text>setStyle(StatusBarIOS.Style.{key})</Text>
39+
<Text>setStyle('{style}')</Text>
4040
</View>
4141
</TouchableHighlight>
4242
)}
@@ -48,11 +48,11 @@ exports.examples = [{
4848
render() {
4949
return (
5050
<View>
51-
{Object.keys(StatusBarIOS.Style).map((key) =>
51+
{['default', 'light-content'].map((style) =>
5252
<TouchableHighlight style={styles.wrapper}
53-
onPress={() => StatusBarIOS.setStyle(StatusBarIOS.Style[key], true)}>
53+
onPress={() => StatusBarIOS.setStyle(style, true)}>
5454
<View style={styles.button}>
55-
<Text>setStyle(StatusBarIOS.Style.{key}, true)</Text>
55+
<Text>setStyle('{style}', true)</Text>
5656
</View>
5757
</TouchableHighlight>
5858
)}
@@ -64,18 +64,18 @@ exports.examples = [{
6464
render() {
6565
return (
6666
<View>
67-
{Object.keys(StatusBarIOS.Animation).map((key) =>
67+
{['none', 'fade', 'slide'].map((animation) =>
6868
<View>
6969
<TouchableHighlight style={styles.wrapper}
70-
onPress={() => StatusBarIOS.setHidden(true, StatusBarIOS.Animation[key])}>
70+
onPress={() => StatusBarIOS.setHidden(true, animation)}>
7171
<View style={styles.button}>
72-
<Text>setHidden(true, StatusBarIOS.Animation.{key})</Text>
72+
<Text>setHidden(true, '{animation}')</Text>
7373
</View>
7474
</TouchableHighlight>
7575
<TouchableHighlight style={styles.wrapper}
76-
onPress={() => StatusBarIOS.setHidden(false, StatusBarIOS.Animation[key])}>
76+
onPress={() => StatusBarIOS.setHidden(false, animation)}>
7777
<View style={styles.button}>
78-
<Text>setHidden(false, StatusBarIOS.Animation.{key})</Text>
78+
<Text>setHidden(false, '{animation}')</Text>
7979
</View>
8080
</TouchableHighlight>
8181
</View>

Examples/UIExplorer/TouchableExample.js

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,14 @@ exports.examples = [
7575
render: function(): ReactElement {
7676
return <TouchableFeedbackEvents />;
7777
},
78+
}, {
79+
title: 'Touchable delay for events',
80+
description: '<Touchable*> components also accept delayPressIn, ' +
81+
'delayPressOut, and delayLongPress as props. These props impact the ' +
82+
'timing of feedback events.',
83+
render: function(): ReactElement {
84+
return <TouchableDelayEvents />;
85+
},
7886
}];
7987

8088
var TextOnPressBox = React.createClass({
@@ -148,6 +156,44 @@ var TouchableFeedbackEvents = React.createClass({
148156
},
149157
});
150158

159+
var TouchableDelayEvents = React.createClass({
160+
getInitialState: function() {
161+
return {
162+
eventLog: [],
163+
};
164+
},
165+
render: function() {
166+
return (
167+
<View>
168+
<View style={[styles.row, {justifyContent: 'center'}]}>
169+
<TouchableOpacity
170+
style={styles.wrapper}
171+
onPress={() => this._appendEvent('press')}
172+
delayPressIn={400}
173+
onPressIn={() => this._appendEvent('pressIn - 400ms delay')}
174+
delayPressOut={1000}
175+
onPressOut={() => this._appendEvent('pressOut - 1000ms delay')}
176+
delayLongPress={800}
177+
onLongPress={() => this._appendEvent('longPress - 800ms delay')}>
178+
<Text style={styles.button}>
179+
Press Me
180+
</Text>
181+
</TouchableOpacity>
182+
</View>
183+
<View style={styles.eventLogBox}>
184+
{this.state.eventLog.map((e, ii) => <Text key={ii}>{e}</Text>)}
185+
</View>
186+
</View>
187+
);
188+
},
189+
_appendEvent: function(eventName) {
190+
var limit = 6;
191+
var eventLog = this.state.eventLog.slice(0, limit - 1);
192+
eventLog.unshift(eventName);
193+
this.setState({eventLog});
194+
},
195+
});
196+
151197
var heartImage = {uri: 'https://pbs.twimg.com/media/BlXBfT3CQAA6cVZ.png:small'};
152198

153199
var styles = StyleSheet.create({

Examples/UIExplorer/UIExplorer/AppDelegate.m

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,10 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(
5050

5151
// jsCodeLocation = [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"];
5252

53+
#if RUNNING_ON_CI
54+
jsCodeLocation = [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"];
55+
#endif
56+
5357
RCTRootView *rootView = [[RCTRootView alloc] initWithBundleURL:jsCodeLocation
5458
moduleName:@"UIExplorerApp"
5559
launchOptions:launchOptions];

Examples/UIExplorer/UIExplorer/Info.plist

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<key>CFBundleExecutable</key>
88
<string>$(EXECUTABLE_NAME)</string>
99
<key>CFBundleIdentifier</key>
10-
<string>com.facebook.$(PRODUCT_NAME:rfc1034identifier)</string>
10+
<string>com.facebook.internal.uiexplorer.local</string>
1111
<key>CFBundleInfoDictionaryVersion</key>
1212
<string>6.0</string>
1313
<key>CFBundleName</key>
@@ -22,6 +22,8 @@
2222
<string>1</string>
2323
<key>LSRequiresIPhoneOS</key>
2424
<true/>
25+
<key>NSLocationWhenInUseUsageDescription</key>
26+
<string>You need to add NSLocationWhenInUseUsageDescription key in Info.plist to enable geolocation, otherwise it is going to *fail silently*!</string>
2527
<key>UILaunchStoryboardName</key>
2628
<string>LaunchScreen</string>
2729
<key>UIRequiredDeviceCapabilities</key>
@@ -34,8 +36,6 @@
3436
<string>UIInterfaceOrientationLandscapeLeft</string>
3537
<string>UIInterfaceOrientationLandscapeRight</string>
3638
</array>
37-
<key>NSLocationWhenInUseUsageDescription</key>
38-
<string>You need to add NSLocationWhenInUseUsageDescription key in Info.plist to enable geolocation, otherwise it is going to *fail silently*!</string>
3939
<key>UIViewControllerBasedStatusBarAppearance</key>
4040
<false/>
4141
</dict>

Examples/UIExplorer/UIExplorerList.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ var COMPONENTS = [
4545
require('./NavigatorIOSColorsExample'),
4646
require('./NavigatorIOSExample'),
4747
require('./PickerIOSExample'),
48+
require('./ProgressViewIOSExample'),
4849
require('./ScrollViewExample'),
4950
require('./SegmentedControlIOSExample'),
5051
require('./SliderIOSExample'),
@@ -156,7 +157,7 @@ class UIExplorerList extends React.Component {
156157
renderSectionHeader={this._renderSectionHeader}
157158
keyboardShouldPersistTaps={true}
158159
automaticallyAdjustContentInsets={false}
159-
keyboardDismissMode="onDrag"
160+
keyboardDismissMode="on-drag"
160161
/>
161162
</View>
162163
);

IntegrationTests/AsyncStorageTest.js

Lines changed: 36 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,19 @@ var {
1616
View,
1717
} = React;
1818

19+
var deepDiffer = require('deepDiffer');
20+
1921
var DEBUG = false;
2022

2123
var KEY_1 = 'key_1';
2224
var VAL_1 = 'val_1';
2325
var KEY_2 = 'key_2';
2426
var VAL_2 = 'val_2';
27+
var KEY_MERGE = 'key_merge';
28+
var VAL_MERGE_1 = {'foo': 1, 'bar': {'hoo': 1, 'boo': 1}, 'moo': {'a': 3}};
29+
var VAL_MERGE_2 = {'bar': {'hoo': 2}, 'baz': 2, 'moo': {'a': 3}};
30+
var VAL_MERGE_EXPECT =
31+
{'foo': 1, 'bar': {'hoo': 2, 'boo': 1}, 'baz': 2, 'moo': {'a': 3}};
2532

2633
// setup in componentDidMount
2734
var done;
@@ -40,8 +47,9 @@ function expectTrue(condition, message) {
4047

4148
function expectEqual(lhs, rhs, testname) {
4249
expectTrue(
43-
lhs === rhs,
44-
'Error in test ' + testname + ': expected ' + rhs + ', got ' + lhs
50+
!deepDiffer(lhs, rhs),
51+
'Error in test ' + testname + ': expected\n' + JSON.stringify(rhs) +
52+
'\ngot\n' + JSON.stringify(lhs)
4553
);
4654
}
4755

@@ -93,25 +101,25 @@ function testRemoveItem() {
93101
'Missing KEY_1 or KEY_2 in ' + '(' + result + ')'
94102
);
95103
updateMessage('testRemoveItem - add two items');
96-
AsyncStorage.removeItem(KEY_1, (err) => {
97-
expectAsyncNoError(err);
104+
AsyncStorage.removeItem(KEY_1, (err2) => {
105+
expectAsyncNoError(err2);
98106
updateMessage('delete successful ');
99-
AsyncStorage.getItem(KEY_1, (err, result) => {
100-
expectAsyncNoError(err);
107+
AsyncStorage.getItem(KEY_1, (err3, result2) => {
108+
expectAsyncNoError(err3);
101109
expectEqual(
102-
result,
110+
result2,
103111
null,
104112
'testRemoveItem: key_1 present after delete'
105113
);
106114
updateMessage('key properly removed ');
107-
AsyncStorage.getAllKeys((err, result2) => {
108-
expectAsyncNoError(err);
115+
AsyncStorage.getAllKeys((err4, result3) => {
116+
expectAsyncNoError(err4);
109117
expectTrue(
110-
result2.indexOf(KEY_1) === -1,
111-
'Unexpected: KEY_1 present in ' + result2
118+
result3.indexOf(KEY_1) === -1,
119+
'Unexpected: KEY_1 present in ' + result3
112120
);
113-
updateMessage('proper length returned.\nDone!');
114-
done();
121+
updateMessage('proper length returned.');
122+
runTestCase('should merge values', testMerge);
115123
});
116124
});
117125
});
@@ -120,6 +128,21 @@ function testRemoveItem() {
120128
});
121129
}
122130

131+
function testMerge() {
132+
AsyncStorage.setItem(KEY_MERGE, JSON.stringify(VAL_MERGE_1), (err1) => {
133+
expectAsyncNoError(err1);
134+
AsyncStorage.mergeItem(KEY_MERGE, JSON.stringify(VAL_MERGE_2), (err2) => {
135+
expectAsyncNoError(err2);
136+
AsyncStorage.getItem(KEY_MERGE, (err3, result) => {
137+
expectAsyncNoError(err3);
138+
expectEqual(JSON.parse(result), VAL_MERGE_EXPECT, 'testMerge');
139+
updateMessage('objects deeply merged\nDone!');
140+
done();
141+
});
142+
});
143+
});
144+
}
145+
123146
var AsyncStorageTest = React.createClass({
124147
getInitialState() {
125148
return {

Libraries/BatchedBridge/BatchedBridgedModules/POPAnimation.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
* of patent rights can be found in the PATENTS file in the same directory.
88
*
99
* @providesModule POPAnimation
10-
* @flow
1110
*/
1211
'use strict';
1312

@@ -17,7 +16,7 @@ if (!RCTPOPAnimationManager) {
1716
// workaround to enable its availability to be determined at runtime.
1817
// For Flow let's pretend like we always export POPAnimation
1918
// so all our users don't need to do null checks
20-
module.exports = ((null: any): typeof POPAnimation);
19+
module.exports = null;
2120
} else {
2221

2322
var ReactPropTypes = require('ReactPropTypes');

Libraries/Components/DatePicker/DatePickerIOS.ios.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -120,15 +120,15 @@ var DatePickerIOS = React.createClass({
120120
<View style={props.style}>
121121
<RCTDatePickerIOS
122122
ref={DATEPICKER}
123-
style={styles.rkDatePickerIOS}
123+
style={styles.datePickerIOS}
124124
date={props.date.getTime()}
125125
maximumDate={
126126
props.maximumDate ? props.maximumDate.getTime() : undefined
127127
}
128128
minimumDate={
129129
props.minimumDate ? props.minimumDate.getTime() : undefined
130130
}
131-
mode={RCTDatePickerIOSConsts.DatePickerModes[props.mode]}
131+
mode={props.mode}
132132
minuteInterval={props.minuteInterval}
133133
timeZoneOffsetInMinutes={props.timeZoneOffsetInMinutes}
134134
onChange={this._onChange}
@@ -139,7 +139,7 @@ var DatePickerIOS = React.createClass({
139139
});
140140

141141
var styles = StyleSheet.create({
142-
rkDatePickerIOS: {
142+
datePickerIOS: {
143143
height: RCTDatePickerIOSConsts.ComponentHeight,
144144
width: RCTDatePickerIOSConsts.ComponentWidth,
145145
},

0 commit comments

Comments
 (0)