mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-04-30 05:55:48 +08:00
2015-02-07 updates
- Random little fixes | Andres Suarez - Add backButtonTitle to Navigator | Nick Poulden - [react-pacakger] Ignore malformed package.json | Amjad Masad - Renamed hasMove to hasMark | Rich Seymour - Update XMLHttpRequest.ios.js | Nick Poulden - Warn about missing dependencies for issue #16 | Andrew McCloud
This commit is contained in:
@@ -40,7 +40,7 @@ class Board {
|
||||
return this;
|
||||
}
|
||||
|
||||
hasMove(row: number, col: number): boolean {
|
||||
hasMark(row: number, col: number): boolean {
|
||||
return this.grid[row][col] !== 0;
|
||||
}
|
||||
|
||||
@@ -132,7 +132,10 @@ var Cell = React.createClass({
|
||||
|
||||
render() {
|
||||
return (
|
||||
<TouchableHighlight onPress={this.props.onPress} underlayColor={'clear'} activeOpacity={0.5}>
|
||||
<TouchableHighlight
|
||||
onPress={this.props.onPress}
|
||||
underlayColor="transparent"
|
||||
activeOpacity={0.5}>
|
||||
<View style={[styles.cell, this.cellStyle()]}>
|
||||
<Image source={{uri: this.imageContents()}} />
|
||||
</View>
|
||||
@@ -161,7 +164,10 @@ var GameEndOverlay = React.createClass({
|
||||
return (
|
||||
<View style={styles.overlay}>
|
||||
<Text style={styles.overlayMessage}>{message}</Text>
|
||||
<TouchableHighlight onPress={this.props.onRestart} underlayColor={'clear'} activeOpacity={0.5}>
|
||||
<TouchableHighlight
|
||||
onPress={this.props.onRestart}
|
||||
underlayColor="transparent"
|
||||
activeOpacity={0.5}>
|
||||
<View style={styles.newGame}>
|
||||
<Text style={styles.newGameText}>New Game</Text>
|
||||
</View>
|
||||
@@ -185,7 +191,7 @@ var TicTacToeApp = React.createClass({
|
||||
},
|
||||
|
||||
handleCellPress(row: number, col: number) {
|
||||
if (this.state.board.hasMove(row, col)) {
|
||||
if (this.state.board.hasMark(row, col)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -214,7 +220,10 @@ var TicTacToeApp = React.createClass({
|
||||
<View style={styles.board}>
|
||||
{rows}
|
||||
</View>
|
||||
<GameEndOverlay board={this.state.board} onRestart={this.restartGame} />
|
||||
<GameEndOverlay
|
||||
board={this.state.board}
|
||||
onRestart={this.restartGame}
|
||||
/>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -124,7 +124,7 @@ var LayoutExample = React.createClass({
|
||||
</UIExplorerBlock>
|
||||
<UIExplorerBlock title="Flex Wrap">
|
||||
<CircleBlock style={{flexWrap: 'wrap'}}>
|
||||
{'oooooooooooooooo'.split('').map(() => <Circle />)}
|
||||
{'oooooooooooooooo'.split('').map((char, i) => <Circle key={i} />)}
|
||||
</CircleBlock>
|
||||
</UIExplorerBlock>
|
||||
</UIExplorerPage>
|
||||
|
||||
@@ -60,6 +60,7 @@ var NavigatorIOSExample = React.createClass({
|
||||
this.props.navigator.push({
|
||||
title: NavigatorIOSExample.title,
|
||||
component: NavigatorIOSExample,
|
||||
backButtonTitle: 'Custom Back',
|
||||
passProps: {topExampleRoute: this.props.topExampleRoute || this.props.route},
|
||||
});
|
||||
})}
|
||||
|
||||
@@ -54,7 +54,7 @@ var Thumb = React.createClass({
|
||||
|
||||
var THUMBS = ['https://fbcdn-dragon-a.akamaihd.net/hphotos-ak-ash3/t39.1997/p128x128/851549_767334479959628_274486868_n.png', 'https://fbcdn-dragon-a.akamaihd.net/hphotos-ak-prn1/t39.1997/p128x128/851561_767334496626293_1958532586_n.png', 'https://fbcdn-dragon-a.akamaihd.net/hphotos-ak-ash3/t39.1997/p128x128/851579_767334503292959_179092627_n.png', 'https://fbcdn-dragon-a.akamaihd.net/hphotos-ak-prn1/t39.1997/p128x128/851589_767334513292958_1747022277_n.png', 'https://fbcdn-dragon-a.akamaihd.net/hphotos-ak-prn1/t39.1997/p128x128/851563_767334559959620_1193692107_n.png', 'https://fbcdn-dragon-a.akamaihd.net/hphotos-ak-prn1/t39.1997/p128x128/851593_767334566626286_1953955109_n.png', 'https://fbcdn-dragon-a.akamaihd.net/hphotos-ak-prn1/t39.1997/p128x128/851591_767334523292957_797560749_n.png', 'https://fbcdn-dragon-a.akamaihd.net/hphotos-ak-prn1/t39.1997/p128x128/851567_767334529959623_843148472_n.png', 'https://fbcdn-dragon-a.akamaihd.net/hphotos-ak-prn1/t39.1997/p128x128/851548_767334489959627_794462220_n.png', 'https://fbcdn-dragon-a.akamaihd.net/hphotos-ak-prn1/t39.1997/p128x128/851575_767334539959622_441598241_n.png', 'https://fbcdn-dragon-a.akamaihd.net/hphotos-ak-ash3/t39.1997/p128x128/851573_767334549959621_534583464_n.png', 'https://fbcdn-dragon-a.akamaihd.net/hphotos-ak-prn1/t39.1997/p128x128/851583_767334573292952_1519550680_n.png'];
|
||||
THUMBS = THUMBS.concat(THUMBS); // double length of THUMBS
|
||||
var createThumbRow = (uri, i) => <Thumb uri={uri}/>;
|
||||
var createThumbRow = (uri, i) => <Thumb key={i} uri={uri} />;
|
||||
|
||||
var styles = StyleSheet.create({
|
||||
scrollView: {
|
||||
|
||||
@@ -45,10 +45,10 @@ var UIExplorerList = React.createClass({
|
||||
);
|
||||
},
|
||||
|
||||
_renderRow: function(example) {
|
||||
_renderRow: function(example, i) {
|
||||
invariant(example.title, 'Example must provide a title.');
|
||||
return (
|
||||
<View>
|
||||
<View key={i}>
|
||||
<TouchableHighlight onPress={() => this._onPressRow(example)}>
|
||||
<View style={styles.row}>
|
||||
<Text style={styles.rowTitleText}>
|
||||
|
||||
@@ -20,7 +20,7 @@ var createExamplePage = function(title, exampleModule) {
|
||||
description: exampleModule.description,
|
||||
},
|
||||
|
||||
getBlock: function(example) {
|
||||
getBlock: function(example, i) {
|
||||
// Hack warning: This is a hack because the www UI explorer requires
|
||||
// renderComponent to be called.
|
||||
var originalRenderComponent = React.renderComponent;
|
||||
@@ -37,6 +37,7 @@ var createExamplePage = function(title, exampleModule) {
|
||||
React.render = originalRender;
|
||||
return (
|
||||
<UIExplorerBlock
|
||||
key={i}
|
||||
title={example.title}
|
||||
description={example.description}>
|
||||
{renderedComponent}
|
||||
|
||||
@@ -104,7 +104,7 @@ var ListView = React.createClass({
|
||||
initialListSize: PropTypes.number,
|
||||
/**
|
||||
* Called when all rows have been rendered and the list has been scrolled
|
||||
* to within onEndReachedThreashold of the bottom. The native scroll
|
||||
* to within onEndReachedThreshold of the bottom. The native scroll
|
||||
* event is provided.
|
||||
*/
|
||||
onEndReached: PropTypes.func,
|
||||
|
||||
@@ -179,6 +179,13 @@ var NavigatorIOS = React.createClass({
|
||||
*/
|
||||
passProps: PropTypes.object,
|
||||
|
||||
/**
|
||||
* If set, the left header button will appear with this name. Note that
|
||||
* this doesn't apply for the header of the current view, but the ones
|
||||
* of the views that are pushed afterward.
|
||||
*/
|
||||
backButtonTitle: PropTypes.string,
|
||||
|
||||
/**
|
||||
* If set, the right header button will appear with this name
|
||||
*/
|
||||
@@ -493,6 +500,7 @@ var NavigatorIOS = React.createClass({
|
||||
this.props.itemWrapperStyle,
|
||||
route.wrapperStyle
|
||||
]}
|
||||
backButtonTitle={route.backButtonTitle}
|
||||
rightButtonTitle={route.rightButtonTitle}
|
||||
onNavRightButtonTap={route.onRightButtonPress}
|
||||
tintColor={this.props.tintColor}>
|
||||
|
||||
@@ -58,6 +58,11 @@ class XMLHttpRequest {
|
||||
return '';
|
||||
}
|
||||
|
||||
getResponseHeader(header: string): ?string {
|
||||
/* Stub */
|
||||
return '';
|
||||
}
|
||||
|
||||
setRequestHeader(header: string, value: any): void {
|
||||
this._headers[header] = value;
|
||||
}
|
||||
|
||||
@@ -355,7 +355,6 @@ RCT_STRUCT_CONVERTER(CGAffineTransform, (@[@"a", @"b", @"c", @"d", @"tx", @"ty"]
|
||||
|
||||
// Nonstandard color extensions
|
||||
@"transparent": @"rgba(0,0,0,0)",
|
||||
@"clear": @"rgba(0,0,0,0)",
|
||||
};
|
||||
});
|
||||
NSString *colorString = namedColors[json];
|
||||
|
||||
@@ -3,13 +3,25 @@
|
||||
*/
|
||||
'use strict';
|
||||
|
||||
var fs = require('fs');
|
||||
var path = require('path');
|
||||
|
||||
if (!fs.existsSync(path.resolve(__dirname, '..', 'node_modules'))) {
|
||||
console.log(
|
||||
'\n' +
|
||||
'Could not find dependencies.\n' +
|
||||
'Ensure dependencies are installed - ' +
|
||||
'run \'npm install\' from project root.\n'
|
||||
);
|
||||
process.exit();
|
||||
}
|
||||
|
||||
var ReactPackager = require('./react-packager');
|
||||
var blacklist = require('./blacklist.js');
|
||||
var connect = require('connect');
|
||||
var http = require('http');
|
||||
var launchEditor = require('./launchEditor.js');
|
||||
var parseCommandLine = require('./parseCommandLine.js');
|
||||
var path = require('path');
|
||||
|
||||
var options = parseCommandLine([{
|
||||
command: 'port',
|
||||
|
||||
@@ -122,6 +122,32 @@ describe('DependencyGraph', function() {
|
||||
});
|
||||
});
|
||||
|
||||
pit('should ignore malformed packages', function() {
|
||||
var root = '/root';
|
||||
fs.__setMockFilesystem({
|
||||
'root': {
|
||||
'index.js': [
|
||||
'/**',
|
||||
' * @providesModule index',
|
||||
' */',
|
||||
'require("aPackage")',
|
||||
].join('\n'),
|
||||
'aPackage': {
|
||||
'package.json': 'lol',
|
||||
'main.js': 'lol'
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
var dgraph = new DependencyGraph({roots: [root], fileWatcher: fileWatcher});
|
||||
return dgraph.load().then(function() {
|
||||
expect(dgraph.getOrderedDependencies('/root/index.js'))
|
||||
.toEqual([
|
||||
{id: 'index', path: '/root/index.js', dependencies: ['aPackage']},
|
||||
]);
|
||||
});
|
||||
});
|
||||
|
||||
pit('can have multiple modules with the same name', function() {
|
||||
var root = '/root';
|
||||
fs.__setMockFilesystem({
|
||||
|
||||
@@ -267,9 +267,15 @@ DependecyGraph.prototype._findAndProcessPackage = function(files, root) {
|
||||
if (packagePath != null) {
|
||||
return readFile(packagePath, 'utf8')
|
||||
.then(function(content) {
|
||||
var packageJson = JSON.parse(content);
|
||||
if (packageJson.name == null) {
|
||||
var packageJson;
|
||||
try {
|
||||
packageJson = JSON.parse(content);
|
||||
} catch (e) {
|
||||
debug('WARNING: malformed package.json: ', packagePath);
|
||||
return q();
|
||||
}
|
||||
|
||||
if (packageJson.name == null) {
|
||||
debug(
|
||||
'WARNING: package.json `%s` is missing a name field',
|
||||
packagePath
|
||||
|
||||
Reference in New Issue
Block a user