Skip to content

Commit

Permalink
Merge branch 'release/0.0.3'
Browse files Browse the repository at this point in the history
  • Loading branch information
bartonhammond committed Dec 8, 2015
2 parents 2905e06 + bfcf461 commit 403e60d
Show file tree
Hide file tree
Showing 48 changed files with 2,262 additions and 469 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ Snowflake ![snowflake](https://cloud.githubusercontent.com/assets/1282364/115993
- [Screens](#screens)
- [Hot Reloading](#hot-reloading)
- [Summary](#summary)
- [Source documentation](http://bartonhammond.github.io/snowflake/snowflake.js.html)
- [Technologies](#technologies)
- [Setup](#setup)
- [Redux State Management](#redux-state-management)
Expand Down
8 changes: 2 additions & 6 deletions index.android.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
/**
* Sample React Native App
* https://github.com/facebook/react-native
*/
'use strict';

import native from './src/native';
import snowflake from './src/snowflake';

native('android');
snowflake('android');


10 changes: 2 additions & 8 deletions index.ios.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
/**
* Sample React Native App
* https://github.com/facebook/react-native
*/
'use strict';

import native from './src/native';

native('ios');

import snowflake from './src/snowflake';

snowflake('ios');
8 changes: 5 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "snowflake",
"version": "0.0.2",
"version": "0.0.3",
"private": true,
"jest": {
"scriptPreprocessor": "jestSupport/scriptProcessor.js",
Expand Down Expand Up @@ -28,10 +28,11 @@
"collectCoverage": true
},
"scripts": {
"test": "rm -rf ./node_module/jest-cli/.haste_cache && ./node_modules/.bin/jest ",
"test": "rm -rf ./node_modules/jest-cli/.haste_cache && ./node_modules/.bin/jest ",
"start": "react-native start",
"test:watch": "npm run test -- --watch",
"test-chrome": "node-debug --preload false --nodejs --harmony ./node_modules/.bin/jest --runInBand"
"test-chrome": "node-debug --preload false --nodejs --harmony ./node_modules/.bin/jest --runInBand",
"docs": "./node_modules/docker/docker -w -i src/ -o ../snowflake-pages "
},
"dependencies": {
"apsl-react-native-button": "[email protected]:bartonhammond/react-native-button.git",
Expand All @@ -53,6 +54,7 @@
},
"devDependencies": {
"babel-core": "~5.8.34",
"docker": "^0.2.14",
"jest-cli": "^0.8.0",
"react": "^0.14.3",
"react-addons-test-utils": "^0.14.3"
Expand Down
13 changes: 11 additions & 2 deletions src/__mocks__/react-native-simpledialog-android.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,17 @@
/**
* # __mocks__/SimpleAlert.js
*
* A simple mock for a simple class
*
*/
'use strict';

var SimpleAlert = {};
// Override the default behavior of the `alert` mock
SimpleAlert.alert = jest.genMockFunction();

/**
* ## Override the default behavior of the `alert` mock
*/

SimpleAlert.alert = jest.genMockFunction();

module.exports = SimpleAlert;
23 changes: 19 additions & 4 deletions src/__mocks__/react-native.js
Original file line number Diff line number Diff line change
@@ -1,23 +1,38 @@
/* eslint-disable react/no-multi-comp */
/**
* @see http://www.schibsted.pl/2015/10/testing-react-native-components-with-jest/
* # __mockes__/react-native.js
*
* This class stubs out the React-Native classes with React classes
*/
'use string';
/**
* ## Imports
*
* ReactNative is actually React
*/
import React from 'react';
const ReactNative = React;

/**
* ## These need additional mocking
*
* ReactNative is actually React
*/
ReactNative.StyleSheet = {
create: function create(styles) {
return styles;
}
};

class View extends React.Component {
render() { return false; }
}
class PixelRatio extends React.Component {
static get() { return 1; }
}

/**
* ## Stubs
*
* Simple replacements for testing
*/
ReactNative.View = View;
ReactNative.ScrollView = View;
ReactNative.Text = View;
Expand Down
22 changes: 22 additions & 0 deletions src/components/ErrorAlert.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,34 @@
/**
* # ErrorAlert.js
*
* This class uses a component which displays the appropriate alert
* depending on the platform
*
* The main purpose here is to determine if there is an error and then
* plucking off the message depending on the shape of the error object.
*/
'use strict';

/**
* ## Imports
*
*/
import SimpleAlert from 'react-native-simpledialog-android';
import _ from 'underscore';

var ErrorAlert = class ErrorAlertClass{
/**
* ## ErrorAlert
* setup to support testing
*/
constructor(alerter) {
this.alerter = alerter;
}
/**
* ### checkErro
* determine if there is an error and how deep it is. Take the
* deepest level as the message and display it
*/
checkError(obj) {
if (!this.alerter) {
this.alerter = SimpleAlert;
Expand Down
32 changes: 27 additions & 5 deletions src/components/FormButton.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,29 @@
/**
* # FormButton.js
*
* Display a button that responds to onPress and is colored appropriately
*/
'use strict';

/**
* ## Imports
*
* React
*/
import React,
{
PropTypes,
StyleSheet,
View

} from 'react-native';


/**
* The platform neutral button
*/
import Button from 'apsl-react-native-button';

/**
* ## Styles
*/
var styles = StyleSheet.create({
signin: {
marginLeft: 10,
Expand All @@ -18,13 +32,21 @@ var styles = StyleSheet.create({
});

var FormButton = React.createClass({
/**
* ## FormButon
* Display the text within the button, disable if prop is set and
* when pressed call the ```onPress```
*/
propTypes: {
self: PropTypes.object,
isDisabled:PropTypes.bool,
onPress: PropTypes.func,
buttonText: PropTypes.string
},

/**
* ### render
*
* Display the Button
*/
render() {
return (
<View style={styles.signin}>
Expand Down
78 changes: 70 additions & 8 deletions src/components/Header.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,28 @@
/**
* # Header.js
*
* This component initially displays a image. But when clicked, things
* get interesting.
*
* On the initial display after being clicked, the
* textinput will display the current ```state``` of the application.
*
* The button will be enabled and if clicked, whatever state is now
* contained in the textinput will be processed and the application
* will be restored to that state.
*
* By pasting in a previous state, the application will reset to that
* state
*
* When the mark image is clicked, it is just toggled to display or hide.
*/
'use strict';

/**
* ## Imports
*
* React
*/
import React,
{
Image,
Expand All @@ -11,10 +34,17 @@ import React,
View

} from 'react-native';

/**
* A spiner
*/
import GiftedSpinner from 'react-native-gifted-spinner';
/**
* Project component that will respond to onPress
*/
import FormButton from './FormButton';

/**
* ## Styles
*/
var styles = StyleSheet.create({
container: {
flexDirection: 'column',
Expand All @@ -34,43 +64,75 @@ var styles = StyleSheet.create({
});

var Header = React.createClass({
/**
* ## Header.class
* set the initial state of having the button be disabled.
*/
getInitialState() {
return {
text: '',
isDisabled: true
};
},

/**
* ### propTypes
* * isFetching: display the spinner if true
* * showState: should the JSON state, currentState, be displayed
* * currentState: the JSON state
* * onGetState: the action to call to get the current state
* * onSetState: the action to call to set the state
*/
propTypes: {
isFetching: PropTypes.bool,
showState: PropTypes.bool,
currentState: PropTypes.object,
onGetState: PropTypes.func,
onSetState: PropTypes.func
},

/**
* ### _onPressMark
* Call the onGetState action passing the state prop
*/
_onPressMark() {
this.props.onGetState(!this.props.showState);
},
/**
* ### _onChangeText
* when the textinput value changes, set the state for that component
*/
_onChangeText(text) {
this.setState({
text,
isDisabled: false
});
},

/**
* ### _updateStateButtonPress
* When the button for the state is pressed, call ```onSetState```
*/
_updateStateButtonPress() {
this.props.onSetState(this.state.text);
},


/**
* ### render
*
* if showState, stringify the currentState and display it to the
* browser for copying. Then display to the user.
*
* When the value of the input changes, call ```_onChangeText```
*
* When the 'Update State' button is pressed, we're off to the
* races with Hot Loading...just call the
* ```_updateStateButtonPress``` and away we go...
*
*/
render() {
let showState = <Text> </Text>;
if (this.props.showState) {
let displayText = JSON.stringify(this.props.currentState);

//leave so user can copy/paste
console.log(displayText)
console.log(displayText);

showState =
<View style={styles.container}>
Expand Down
Loading

0 comments on commit 403e60d

Please sign in to comment.