Skip to content

Commit

Permalink
- [react-packager] Switch from Q to Bluebird as promises library | Pi…
Browse files Browse the repository at this point in the history
…lwon Huh

- [Touchable] Change default `activeOpacity` to 0.2 to match iOS | James Ide
- [ReactNative] Normalize name for examples | Christopher Chedeau
- [ReactNative] Added support for 3 digit hex colors | Arthur Lee
- [react-packager] Fix EISDIR error | Amjad Masad
- make renderError and renderLoading props optional for WebView | Don Yu
  • Loading branch information
sahrens committed Apr 1, 2015
1 parent b66710c commit 2cced4b
Show file tree
Hide file tree
Showing 29 changed files with 172 additions and 221 deletions.
File renamed without changes.
File renamed without changes.
1 change: 0 additions & 1 deletion Examples/UIExplorer/ListViewPagingExample.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
* 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 ListViewPagingExample
* @flow
*/
'use strict';
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
72 changes: 0 additions & 72 deletions Examples/UIExplorer/UIExplorer.xcodeproj/project.pbxproj.rej

This file was deleted.

12 changes: 6 additions & 6 deletions Examples/UIExplorer/UIExplorerList.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,19 +33,19 @@ var { TestModule } = React.addons;
var createExamplePage = require('./createExamplePage');

var COMPONENTS = [
require('./ActivityIndicatorExample'),
require('./DatePickerExample'),
require('./ActivityIndicatorIOSExample'),
require('./DatePickerIOSExample'),
require('./ImageExample'),
require('./ListViewExample'),
require('./ListViewPagingExample'),
require('./ListViewSimpleExample'),
require('./MapViewExample'),
require('./NavigatorIOSExample'),
NavigatorExample,
require('./PickerExample'),
require('./PickerIOSExample'),
require('./ScrollViewExample'),
require('./SliderIOSExample'),
require('./SwitchExample'),
require('./TabBarExample'),
require('./SwitchIOSExample'),
require('./TabBarIOSExample'),
require('./TextExample.ios'),
require('./TextInputExample'),
require('./TouchableExample'),
Expand Down
52 changes: 0 additions & 52 deletions Examples/UIExplorer/WebViewExample.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
var React = require('react-native');
var StyleSheet = require('StyleSheet');
var {
ActivityIndicatorIOS,
StyleSheet,
Text,
TextInput,
Expand Down Expand Up @@ -95,8 +94,6 @@ var WebViewExample = React.createClass({
automaticallyAdjustContentInsets={false}
style={styles.webView}
url={this.state.url}
renderError={this.renderError}
renderLoading={this.renderLoading}
onNavigationStateChange={this.onNavigationStateChange}
startInLoadingState={true}
/>
Expand Down Expand Up @@ -129,33 +126,6 @@ var WebViewExample = React.createClass({
});
},

renderError: function(errorDomain, errorCode, errorDesc) {
return (
<View style={styles.errorContainer}>
<Text style={styles.errorTextTitle}>
Error loading page
</Text>
<Text style={styles.errorText}>
{'Domain: ' + errorDomain}
</Text>
<Text style={styles.errorText}>
{'Error Code: ' + errorCode}
</Text>
<Text style={styles.errorText}>
{'Description: ' + errorDesc}
</Text>
</View>
);
},

renderLoading: function() {
return (
<View style={styles.loadingView}>
<ActivityIndicatorIOS />
</View>
);
},

onSubmitEditing: function(event) {
this.pressGoButton();
},
Expand Down Expand Up @@ -230,28 +200,6 @@ var styles = StyleSheet.create({
borderRadius: 3,
alignSelf: 'stretch',
},
loadingView: {
backgroundColor: BGWASH,
flex: 1,
justifyContent: 'center',
alignItems: 'center',
},
errorContainer: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
backgroundColor: BGWASH,
},
errorTextTitle: {
fontSize: 15,
fontWeight: '500',
marginBottom: 10,
},
errorText: {
fontSize: 14,
textAlign: 'center',
marginBottom: 2,
},
statusBar: {
flexDirection: 'row',
alignItems: 'center',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
</BuildActionEntry>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForRunning = "NO"
buildForProfiling = "NO"
buildForArchiving = "NO"
buildForAnalyzing = "YES">
Expand Down
2 changes: 1 addition & 1 deletion Libraries/Components/Touchable/TouchableOpacity.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ var TouchableOpacity = React.createClass({

getDefaultProps: function() {
return {
activeOpacity: 0.5,
activeOpacity: 0.2,
};
},

Expand Down
64 changes: 57 additions & 7 deletions Libraries/Components/WebView/WebView.ios.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,12 @@
*/
'use strict';

var ActivityIndicatorIOS = require('ActivityIndicatorIOS');
var EdgeInsetsPropType = require('EdgeInsetsPropType');
var React = require('React');
var ReactIOSViewAttributes = require('ReactIOSViewAttributes');
var StyleSheet = require('StyleSheet');
var Text = require('Text');
var View = require('View');

var createReactIOSNativeComponentClass = require('createReactIOSNativeComponentClass');
Expand All @@ -27,6 +29,7 @@ var RCTWebViewManager = require('NativeModules').WebViewManager;

var invariant = require('invariant');

var BGWASH = 'rgba(255,255,255,0.8)';
var RCT_WEBVIEW_REF = 'webview';

var WebViewState = keyMirror({
Expand All @@ -52,16 +55,38 @@ type ErrorEvent = {

type Event = Object;

var defaultRenderLoading = () => (
<View style={styles.loadingView}>
<ActivityIndicatorIOS />
</View>
);
var defaultRenderError = (errorDomain, errorCode, errorDesc) => (
<View style={styles.errorContainer}>
<Text style={styles.errorTextTitle}>
Error loading page
</Text>
<Text style={styles.errorText}>
{'Domain: ' + errorDomain}
</Text>
<Text style={styles.errorText}>
{'Error Code: ' + errorCode}
</Text>
<Text style={styles.errorText}>
{'Description: ' + errorDesc}
</Text>
</View>
);

var WebView = React.createClass({
statics: {
NavigationType: NavigationType,
},

propTypes: {
renderError: PropTypes.func.isRequired, // view to show if there's an error
renderLoading: PropTypes.func.isRequired, // loading indicator to show
url: PropTypes.string,
html: PropTypes.string,
renderError: PropTypes.func, // view to show if there's an error
renderLoading: PropTypes.func, // loading indicator to show
automaticallyAdjustContentInsets: PropTypes.bool,
shouldInjectAJAXHandler: PropTypes.bool,
contentInset: EdgeInsetsPropType,
Expand All @@ -87,20 +112,23 @@ var WebView = React.createClass({
render: function() {
var otherView = null;

if (this.state.viewState === WebViewState.LOADING) {
otherView = this.props.renderLoading();
if (this.state.viewState === WebViewState.LOADING) {
otherView = (this.props.renderLoading || defaultRenderLoading)();
} else if (this.state.viewState === WebViewState.ERROR) {
var errorEvent = this.state.lastErrorEvent;
invariant(
errorEvent != null,
'lastErrorEvent expected to be non-null'
);
otherView = this.props.renderError(
otherView = (this.props.renderError || defaultRenderError)(
errorEvent.domain,
errorEvent.code,
errorEvent.description);
errorEvent.description
);
} else if (this.state.viewState !== WebViewState.IDLE) {
console.error('RCTWebView invalid state encountered: ' + this.state.loading);
console.error(
'RCTWebView invalid state encountered: ' + this.state.loading
);
}

var webViewStyles = [styles.container, this.props.style];
Expand Down Expand Up @@ -196,10 +224,32 @@ var styles = StyleSheet.create({
container: {
flex: 1,
},
errorContainer: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
backgroundColor: BGWASH,
},
errorText: {
fontSize: 14,
textAlign: 'center',
marginBottom: 2,
},
errorTextTitle: {
fontSize: 15,
fontWeight: '500',
marginBottom: 10,
},
hidden: {
height: 0,
flex: 0, // disable 'flex:1' when hiding a View
},
loadingView: {
backgroundColor: BGWASH,
flex: 1,
justifyContent: 'center',
alignItems: 'center',
},
});

module.exports = WebView;
12 changes: 11 additions & 1 deletion React/Base/RCTConvert.m
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,17 @@ + (UIColor *)UIColor:(id)json
NSUInteger blue = -1;
CGFloat alpha = 1.0;
if ([colorString hasPrefix:@"#"]) {
sscanf([colorString UTF8String], "#%02tX%02tX%02tX", &red, &green, &blue);
if (colorString.length == 4) { // 3 digit hex
sscanf([colorString UTF8String], "#%01tX%01tX%01tX", &red, &green, &blue);
// expand to 6 digit hex
red = red | (red << 4);
green = green | (green << 4);
blue = blue | (blue << 4);
} else if (colorString.length == 7) { // normal 6 digit hex
sscanf([colorString UTF8String], "#%02tX%02tX%02tX", &red, &green, &blue);
} else {
RCTLogError(@"Invalid hex color %@. Hex colors should be 3 or 6 digits long", colorString);
}
} else if ([colorString hasPrefix:@"rgba("]) {
double tmpAlpha;
sscanf([colorString UTF8String], "rgba(%zd,%zd,%zd,%lf)", &red, &green, &blue, &tmpAlpha);
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,13 @@
"joi": "~5.1.0",
"module-deps": "3.5.6",
"optimist": "0.6.1",
"q": "1.0.1",
"sane": "1.0.1",
"uglify-js": "~2.4.16",
"underscore": "1.7.0",
"worker-farm": "1.1.0",
"yargs": "1.3.2",
"ws": "0.4.31"
"ws": "0.4.31",
"bluebird": "^2.9.21"
},
"devDependencies": {
"jest-cli": "0.2.1",
Expand Down
5 changes: 5 additions & 0 deletions packager/react-packager/__mocks__/bluebird.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
'use strict';

jest.autoMockOff();
module.exports = require.requireActual('bluebird');
jest.autoMockOn();
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@

jest
.dontMock('../index')
.dontMock('q')
.dontMock('path')
.dontMock('absolute-path')
.dontMock('../docblock')
Expand Down
Loading

0 comments on commit 2cced4b

Please sign in to comment.