Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
bartonhammond committed Jan 3, 2016
2 parents f8c31e5 + c8d81ae commit 022270f
Show file tree
Hide file tree
Showing 15 changed files with 676 additions and 200 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
Snowflake ![snowflake](https://cloud.githubusercontent.com/assets/1282364/11599365/1a1c39d2-9a8c-11e5-8819-bc1e48b30525.png)
==================================
#### A React-Native starter mobile app for iOS and Android with a single code base. Using Redux and Immutable, the state of the application is fully testable with Jest, currently at 86% coverage. Snowflake supports Hot Reloading of its state. Snowflake uses CI with [Bitrise.io]( https://www.bitrise.io) and has extensive docs and 45+ min of video demonstrating implementation.
#### A React-Native starter mobile app, or maybe just an example, or maybe a boilerplate (you decide) for iOS and Android with a single code base. Using Redux and Immutable, the state of the application is fully testable with Jest, currently at 86% coverage. Snowflake supports Hot Reloading of its state. Snowflake uses CI with [Bitrise.io]( https://www.bitrise.io) and has extensive docs and 45+ min of video demonstating implementation.

#### Note: Snowflake now (Jan 3, 2016) has a choice of servers, either the original Parse.com or a Hapi Server that runs on Openshift and locally. See [https://github.com/bartonhammond/snowflake-hapi-openshift](https://github.com/bartonhammond/snowflake-hapi-openshift) for more information about the OpenShift server. The setup instructions below describe how to select the server you desire.

[![Join the chat at https://gitter.im/bartonhammond/snowflake](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/bartonhammond/snowflake?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
![ios](https://img.shields.io/badge/IOS--blue.svg) [![Build Status](https://www.bitrise.io/app/348ae0a97c5e147a.svg?token=RmDwzjeIGuo7i9MeazE1fg)](https://www.bitrise.io/app/348ae0a97c5e147a)
Expand Down
68 changes: 51 additions & 17 deletions docs/Setup.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,53 @@
## Setup

1. [Install React-Native](https://facebook.github.io/react-native/docs/getting-started.html#content)
1. ```git clone https://github.com/bartonhammond/snowflake.git```
1. cd snowflake
1. npm install
1. Copy or move ```src/lib/config.example.js``` to ```src/lib/config.js```.
1. Create account and app on Parse.com
1. Copy the Parse.com app keys for APP_ID and REST_API_KEY and update ```src/lib/config.js```
1. Update the Apps Settings -> Authentication
1. Allow username and password-based authentication -> Yes
1. Allow anonymous users -> No
1. Update the Apps Settings -> Email
1. Verify user emails -> Yes
1. On mac, open XCode and load project
1. For android, ```react-native run-android``` assuming you have an emulator or device attached.
1. To run Jest, ```npm test```
1. To debug Jest unit cases, install [node_inspector](https://github.com/node-inspector/node-inspector) and run ```npm run test-chrome```
1. Enjoy!
* [Install React-Native](https://facebook.github.io/react-native/docs/getting-started.html#content)

* Clone snowflake:

```
git clone https://github.com/bartonhammond/snowflake.git
```

* cd snowflake
```
npm install
```

* Copy or move ```src/lib/config.example.js``` to ```src/lib/config.js```.
* Note: you must select one of three options for the ```backend``` as shown below:

```
backend: {
parse: false,
hapiLocal: false,
hapiRemote: true
},
```
* To run Hapi either locally on remotely on OpenShift, update the below ```src/lib/config.js``` file:

```
HAPI: {
local: {
url: 'http://127.0.0.1:5000'
},
remote: {
url: 'https://mysnowflake-bartonhammond.rhcloud.com'
}
}
```

* If you choose Parse.com, create account and app on Parse.com
* Copy the Parse.com app keys for APP_ID and REST_API_KEY and update ```src/lib/config.js```
* Update the Apps Settings -> Authentication
* Allow username and password-based authentication -> Yes
* Allow anonymous users -> No
* Update the Apps Settings -> Email
* Verify user emails -> Yes

### To run:
* On mac, open XCode and load project
* For android, ```react-native run-android``` assuming you have an emulator or device attached.
* To run Jest, ```npm test```
* To debug Jest unit cases, install [node_inspector](https://github.com/node-inspector/node-inspector) and run ```npm run test-chrome```
* Enjoy!
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
"react-native-simple-store": "^0.1.0",
"react-native-simpledialog-android": "^1.0.2",
"react-native-tab-navigator": "^0.2.11",
"react-native-vector-icons": "^1.0.3",
"react-native-vector-icons": "^1.0.4",
"react-redux": "^3.1.0",
"redux": "^3.0.4",
"redux-thunk": "^1.0.0",
Expand Down
28 changes: 0 additions & 28 deletions src/components/ItemCheckbox.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,31 +96,6 @@ var ItemCheckbox = React.createClass({
padding: 2
};
},
/**
* ### _getIconSize
* @return {Number} size
*/
_getIconSize: function() {
if (this.props.iconSize == 'small') {
return this.props.size * 0.5;
} else if (this.props.iconSize == 'normal') {
return this.props.size * 0.6;
} else {
return this.props.size * 0.7;
}
},
/**
* ### _getCircleIconStyle
* @returns {Object} style object
*/
_getCircleIconStyle: function() {
return {
color: this.props.backgroundColor,
flex: 1,
width: this._getIconSize(),
height: this._getIconSize()
};
},
/**
* ### _completeProgress
* If the checkbox is pressable, figure out what state it's in and
Expand Down Expand Up @@ -177,7 +152,6 @@ var ItemCheckbox = React.createClass({
<Icon
name={iconName}
size={20}
style={this._getCircleIconStyle}
/>
<Text> {this.props.text}</Text>
</View>
Expand All @@ -197,8 +171,6 @@ var ItemCheckbox = React.createClass({
<Icon
name={iconName}
size={20}
style={this._getCircleIconStyle}

/>
<Text> {this.props.text}</Text>
</View>
Expand Down
122 changes: 122 additions & 0 deletions src/lib/Backend.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
/**
* # Backend.js
*
* Abstract Base class for Backend support
*
*/
'use string';
/**
* ## Async support
*
*/
require('regenerator/runtime');

/**
* ## Imports
*
* Config for defaults and underscore for a couple of features
*/
import CONFIG from './config';
import _ from 'underscore';

export default class Backend {
/**
* ## Constructor
*
*
* @throws tokenMissing if token is undefined
*/
constructor( token) {
}
/**
* ### signup
*
* @param data object
*
* {username: "barton", email: "[email protected]", password: "Passw0rd!"}
*
* @return
* if ok, {createdAt: "2015-12-30T15:17:05.379Z",
* objectId: "5TgExo2wBA",
* sessionToken: "r:dEgdUkcs2ydMV9Y9mt8HcBrDM"}
*
* if error, {code: xxx, error: 'message'}
*/
async signup(data) {

}
/**
* ### login
* encode the data and and call _fetch
*
* @param data
*
* {username: "barton", password: "Passw0rd!"}
*
* @returns
*
* createdAt: "2015-12-30T15:29:36.611Z"
* email: "[email protected]"
* objectId: "Z4yvP19OeL"
* sessionToken: "r:Kt9wXIBWD0dNijNIq2u5rRllW"
* updatedAt: "2015-12-30T16:08:50.419Z"
* username: "barton"
*
*/
async login(data) {

}
/**
* ### logout
* prepare the request and call _fetch
*/
async logout() {

}
/**
* ### resetPassword
* the data is already in a JSON format, so call _fetch
*
* @param data
* {email: "[email protected]"}
*
* @returns empty object
*
* if error: {code: xxx, error: 'message'}
*/
async resetPassword(data) {

}
/**
* ### getProfile
* Using the sessionToken, we'll get everything about
* the current user.
*
* @returns
*
* if good:
* {createdAt: "2015-12-30T15:29:36.611Z"
* email: "[email protected]"
* objectId: "Z4yvP19OeL"
* sessionToken: "r:uFeYONgIsZMPyxOWVJ6VqJGqv"
* updatedAt: "2015-12-30T15:29:36.611Z"
* username: "barton"}
*
* if error, {code: xxx, error: 'message'}
*/
async getProfile() {
}
/**
* ### updateProfile
* for this user, update their record
* the data is already in JSON format
*
* @param userId _id of Parse.com
* @param data object:
* {username: "barton", email: "[email protected]"}
*/
async updateProfile(userId,data) {
}

};

21 changes: 21 additions & 0 deletions src/lib/BackendFactory.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/**
* # Parse.js
*
* This class interfaces with Parse.com using the rest api
* see [https://parse.com/docs/rest/guide](https://parse.com/docs/rest/guide)
*
*/
'use string';

import CONFIG from './config';
import Parse from './Parse';
import Hapi from './Hapi';

export default function BackendFactory(token = null) {
if (CONFIG.backend.parse) {
return new Parse(token);
} else if (CONFIG.backend.hapiLocal || CONFIG.backend.hapiRemote) {
return new Hapi(token);

}
}
Loading

0 comments on commit 022270f

Please sign in to comment.