From 6d04e7af512b11d8013a1c5f0e0e835c0e102423 Mon Sep 17 00:00:00 2001 From: Jason John Date: Mon, 22 Feb 2016 10:49:22 -0500 Subject: [PATCH] Signup flow --- ios/App.xcodeproj/project.pbxproj | 32 ++++++++ ios/App/Info.plist | 8 ++ src/components/Register.js | 128 +++++++++++++++++++++++++++++- src/lib/API.js | 8 ++ 4 files changed, 174 insertions(+), 2 deletions(-) diff --git a/ios/App.xcodeproj/project.pbxproj b/ios/App.xcodeproj/project.pbxproj index adcaa35..095dc9e 100644 --- a/ios/App.xcodeproj/project.pbxproj +++ b/ios/App.xcodeproj/project.pbxproj @@ -31,6 +31,14 @@ 7488E33E30EE415291BA5EC2 /* MaterialIcons.ttf in Resources */ = {isa = PBXBuildFile; fileRef = B57157CDA44A47A08A7262CC /* MaterialIcons.ttf */; }; B28129E0C77A49E0BC0EB0E7 /* Octicons.ttf in Resources */ = {isa = PBXBuildFile; fileRef = A3FA33E014E348BAB0EF2341 /* Octicons.ttf */; }; C3BF0830856B4081B1B765C4 /* Zocial.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 4215E041E3724038988B91EC /* Zocial.ttf */; }; + 59D0B2F60F324C4C8DD35CFA /* Entypo.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 12374597394B4924847C203E /* Entypo.ttf */; }; + 603BBF17B2344039B38CE2CF /* EvilIcons.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 48B6DE8925774B5F8C56500D /* EvilIcons.ttf */; }; + ADA72D3C74524C948C8982C6 /* FontAwesome.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 047B4B159BBB4F25A0148FBB /* FontAwesome.ttf */; }; + 28132C81FA454DC6A12664DA /* Foundation.ttf in Resources */ = {isa = PBXBuildFile; fileRef = F42044CD99184BA89321FB44 /* Foundation.ttf */; }; + 1544752BB45144F09A3F3AA5 /* Ionicons.ttf in Resources */ = {isa = PBXBuildFile; fileRef = E96734634E6743E5A2947F0B /* Ionicons.ttf */; }; + 8D75A5047CB841B2A0B311A2 /* MaterialIcons.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 8D31C08529F84506964B2DC0 /* MaterialIcons.ttf */; }; + CAC3A2DCBFB84BEF87F766AA /* Octicons.ttf in Resources */ = {isa = PBXBuildFile; fileRef = CDE7865F23AA415A98F0A0AA /* Octicons.ttf */; }; + 4133A1E3125748F195EDD7BB /* Zocial.ttf in Resources */ = {isa = PBXBuildFile; fileRef = BDF036C851D742D0A2F0FECA /* Zocial.ttf */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ @@ -145,6 +153,14 @@ B57157CDA44A47A08A7262CC /* MaterialIcons.ttf */ = {isa = PBXFileReference; name = "MaterialIcons.ttf"; path = "../node_modules/react-native-vector-icons/Fonts/MaterialIcons.ttf"; sourceTree = ""; fileEncoding = undefined; lastKnownFileType = unknown; explicitFileType = undefined; includeInIndex = 0; }; A3FA33E014E348BAB0EF2341 /* Octicons.ttf */ = {isa = PBXFileReference; name = "Octicons.ttf"; path = "../node_modules/react-native-vector-icons/Fonts/Octicons.ttf"; sourceTree = ""; fileEncoding = undefined; lastKnownFileType = unknown; explicitFileType = undefined; includeInIndex = 0; }; 4215E041E3724038988B91EC /* Zocial.ttf */ = {isa = PBXFileReference; name = "Zocial.ttf"; path = "../node_modules/react-native-vector-icons/Fonts/Zocial.ttf"; sourceTree = ""; fileEncoding = undefined; lastKnownFileType = unknown; explicitFileType = undefined; includeInIndex = 0; }; + 12374597394B4924847C203E /* Entypo.ttf */ = {isa = PBXFileReference; name = "Entypo.ttf"; path = "../node_modules/react-native-vector-icons/Fonts/Entypo.ttf"; sourceTree = ""; fileEncoding = undefined; lastKnownFileType = unknown; explicitFileType = undefined; includeInIndex = 0; }; + 48B6DE8925774B5F8C56500D /* EvilIcons.ttf */ = {isa = PBXFileReference; name = "EvilIcons.ttf"; path = "../node_modules/react-native-vector-icons/Fonts/EvilIcons.ttf"; sourceTree = ""; fileEncoding = undefined; lastKnownFileType = unknown; explicitFileType = undefined; includeInIndex = 0; }; + 047B4B159BBB4F25A0148FBB /* FontAwesome.ttf */ = {isa = PBXFileReference; name = "FontAwesome.ttf"; path = "../node_modules/react-native-vector-icons/Fonts/FontAwesome.ttf"; sourceTree = ""; fileEncoding = undefined; lastKnownFileType = unknown; explicitFileType = undefined; includeInIndex = 0; }; + F42044CD99184BA89321FB44 /* Foundation.ttf */ = {isa = PBXFileReference; name = "Foundation.ttf"; path = "../node_modules/react-native-vector-icons/Fonts/Foundation.ttf"; sourceTree = ""; fileEncoding = undefined; lastKnownFileType = unknown; explicitFileType = undefined; includeInIndex = 0; }; + E96734634E6743E5A2947F0B /* Ionicons.ttf */ = {isa = PBXFileReference; name = "Ionicons.ttf"; path = "../node_modules/react-native-vector-icons/Fonts/Ionicons.ttf"; sourceTree = ""; fileEncoding = undefined; lastKnownFileType = unknown; explicitFileType = undefined; includeInIndex = 0; }; + 8D31C08529F84506964B2DC0 /* MaterialIcons.ttf */ = {isa = PBXFileReference; name = "MaterialIcons.ttf"; path = "../node_modules/react-native-vector-icons/Fonts/MaterialIcons.ttf"; sourceTree = ""; fileEncoding = undefined; lastKnownFileType = unknown; explicitFileType = undefined; includeInIndex = 0; }; + CDE7865F23AA415A98F0A0AA /* Octicons.ttf */ = {isa = PBXFileReference; name = "Octicons.ttf"; path = "../node_modules/react-native-vector-icons/Fonts/Octicons.ttf"; sourceTree = ""; fileEncoding = undefined; lastKnownFileType = unknown; explicitFileType = undefined; includeInIndex = 0; }; + BDF036C851D742D0A2F0FECA /* Zocial.ttf */ = {isa = PBXFileReference; name = "Zocial.ttf"; path = "../node_modules/react-native-vector-icons/Fonts/Zocial.ttf"; sourceTree = ""; fileEncoding = undefined; lastKnownFileType = unknown; explicitFileType = undefined; includeInIndex = 0; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -338,6 +354,14 @@ B57157CDA44A47A08A7262CC /* MaterialIcons.ttf */, A3FA33E014E348BAB0EF2341 /* Octicons.ttf */, 4215E041E3724038988B91EC /* Zocial.ttf */, + 12374597394B4924847C203E /* Entypo.ttf */, + 48B6DE8925774B5F8C56500D /* EvilIcons.ttf */, + 047B4B159BBB4F25A0148FBB /* FontAwesome.ttf */, + F42044CD99184BA89321FB44 /* Foundation.ttf */, + E96734634E6743E5A2947F0B /* Ionicons.ttf */, + 8D31C08529F84506964B2DC0 /* MaterialIcons.ttf */, + CDE7865F23AA415A98F0A0AA /* Octicons.ttf */, + BDF036C851D742D0A2F0FECA /* Zocial.ttf */, ); name = Resources; path = ""; @@ -553,6 +577,14 @@ 7488E33E30EE415291BA5EC2 /* MaterialIcons.ttf in Resources */, B28129E0C77A49E0BC0EB0E7 /* Octicons.ttf in Resources */, C3BF0830856B4081B1B765C4 /* Zocial.ttf in Resources */, + 59D0B2F60F324C4C8DD35CFA /* Entypo.ttf in Resources */, + 603BBF17B2344039B38CE2CF /* EvilIcons.ttf in Resources */, + ADA72D3C74524C948C8982C6 /* FontAwesome.ttf in Resources */, + 28132C81FA454DC6A12664DA /* Foundation.ttf in Resources */, + 1544752BB45144F09A3F3AA5 /* Ionicons.ttf in Resources */, + 8D75A5047CB841B2A0B311A2 /* MaterialIcons.ttf in Resources */, + CAC3A2DCBFB84BEF87F766AA /* Octicons.ttf in Resources */, + 4133A1E3125748F195EDD7BB /* Zocial.ttf in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/ios/App/Info.plist b/ios/App/Info.plist index 40ef453..0dbc310 100644 --- a/ios/App/Info.plist +++ b/ios/App/Info.plist @@ -51,6 +51,14 @@ MaterialIcons.ttf Octicons.ttf Zocial.ttf + Entypo.ttf + EvilIcons.ttf + FontAwesome.ttf + Foundation.ttf + Ionicons.ttf + MaterialIcons.ttf + Octicons.ttf + Zocial.ttf \ No newline at end of file diff --git a/src/components/Register.js b/src/components/Register.js index 7f3e417..a44148a 100644 --- a/src/components/Register.js +++ b/src/components/Register.js @@ -2,19 +2,143 @@ * This screen handles registration for a new user on the app. * After the user signs up successfully, it'll redirect them to the Dashboard. **/ +import React, {View, StyleSheet, Text, Alert,BackAndroid} from 'react-native'; -import React, {View, Text, BackAndroid} from 'react-native'; +import API from '../lib/API'; +import RPButton from './RPButton' +import RPLink from './RPLink' +import RPRouter from '../lib/RPRouter'; +import RPStorage from '../lib/RPStorage'; +import RPTextInput from './RPTextInput' +import {COLORS} from '../constants/Colors'; class Register extends React.Component { constructor(props) { super(props) + this.state = { + email: '', + password: '', + isLoading: false + } + } + async requestSignup() { + this.setState({ isLoading: true }); + try { + let request = await API.register({ + email: this.state.email, + password: this.state.password + }); + if (request.response.status === 200 ) { + await RPStorage.setUserSession(request.body); + this.props.navigator.push(RPRouter.getHomeRoute()); + return; + } + this.setState({ + error: request.body, + isLoading: false + }); + } + catch (error) { + Alert.alert('Signup Error', 'Error') + this.setState({ + error: 'Could not reach the server.', + isLoading: false + }); + throw error; + } + } + handleOnLoginTextChanged(textValue) { + this.setState({ email: textValue }) + } + handleOnPasswordTextChanged(textValue) { + this.setState({ password: textValue }) + } + handlePressLogin() { + this.requestSignup(); + } + handlePressGoBack() { + this.props.navigator.pop(); } render() { + let errorText = null; + if (this.state.error) { + errorText = {this.state.error} + } + return ( - Hello World! + + {errorText} + + + + + Sign Up! + + + + Facebook + + + + Go Back + ); } } +let styles = StyleSheet.create({ + container: { + flex: 1, + justifyContent: 'center', + alignItems: 'center', + backgroundColor: COLORS.BASE + }, + textInput: { + width: 260, + alignSelf: 'center', + borderBottomWidth: 1, + borderColor: COLORS.GRAY, + marginBottom: 8, + color: COLORS.LIGHT_GRAY, + padding: 8 + }, + error: { + width: 260, + padding: 8, + marginBottom: 8, + backgroundColor: COLORS.RED, + color: COLORS.WHITE + }, + loginButtons: { + flexDirection: 'row', + marginBottom: 12 + }, + loginButton: { + width: 125 + }, + loginButtonLeft: { + marginRight: 10 + }, + loginButtonRight: { + } +}); + export default Register; module.exports = Register; diff --git a/src/lib/API.js b/src/lib/API.js index 5297d99..c34603a 100644 --- a/src/lib/API.js +++ b/src/lib/API.js @@ -21,6 +21,14 @@ export default API = { }) }); }, + register(data) { + return api.post('/sessions/sign_up', { + body: JSON.stringify({ + email: data.email, + password: data.password + }) + }); + }, getUserRaps(params) { path = '/raps?' + qs.stringify(params, { encode: false }); return api.get(path);