From 125b880760897331393ed2acc4c2b1a41b84fa19 Mon Sep 17 00:00:00 2001 From: gilmarsquinelato Date: Tue, 7 Nov 2017 14:28:02 -0200 Subject: [PATCH] Register user (#44) * Added feature to register a new user * login after register working * Removed username from register and placed on a new view * loading indicator on username submit * register/username logo layout issue * - login and register background white * - logo removed from logo and register --- app/actions/actionsTypes.js | 12 +- app/actions/login.js | 40 ++++++ app/containers/Routes.js | 20 +-- app/containers/routes/AuthRoutes.js | 9 +- app/containers/routes/PublicRoutes.js | 7 + app/images/logo_with_text.png | Bin 0 -> 27580 bytes app/lib/rocketchat.js | 22 +++ app/presentation/KeyboardView.js | 20 ++- app/presentation/Loading.js | 77 ++++++++++ app/reducers/login.js | 41 +++++- app/sagas/login.js | 71 ++++++++-- app/sagas/selectServer.js | 2 +- app/views/CreateChannelView.js | 99 ++++++------- app/views/LoginView.js | 38 ++--- app/views/NewServerView.js | 8 +- app/views/RegisterView.js | 194 ++++++++++++++++++++++++++ app/views/RoomView.js | 2 +- app/views/Styles.js | 36 ++--- package.json | 1 + yarn.lock | 12 +- 20 files changed, 580 insertions(+), 131 deletions(-) create mode 100644 app/images/logo_with_text.png create mode 100644 app/presentation/Loading.js create mode 100644 app/views/RegisterView.js diff --git a/app/actions/actionsTypes.js b/app/actions/actionsTypes.js index ef66104a6..308c4baa6 100644 --- a/app/actions/actionsTypes.js +++ b/app/actions/actionsTypes.js @@ -9,7 +9,17 @@ function createRequestTypes(base, types = defaultTypes) { } // Login events -export const LOGIN = createRequestTypes('LOGIN', [...defaultTypes, 'SET_TOKEN', 'SUBMIT']); +export const LOGIN = createRequestTypes('LOGIN', [ + ...defaultTypes, + 'SET_TOKEN', + 'SUBMIT', + 'REGISTER_SUBMIT', + 'REGISTER_REQUEST', + 'REGISTER_SUCCESS', + 'SET_USERNAME_SUBMIT', + 'SET_USERNAME_REQUEST', + 'SET_USERNAME_SUCCESS' +]); export const ROOMS = createRequestTypes('ROOMS'); export const APP = createRequestTypes('APP', ['READY', 'INIT']); export const MESSAGES = createRequestTypes('MESSAGES'); diff --git a/app/actions/login.js b/app/actions/login.js index 7969c8090..1a8f753e8 100644 --- a/app/actions/login.js +++ b/app/actions/login.js @@ -13,6 +13,46 @@ export function loginRequest(credentials) { }; } + +export function registerSubmit(credentials) { + return { + type: types.LOGIN.REGISTER_SUBMIT, + credentials + }; +} +export function registerRequest(credentials) { + return { + type: types.LOGIN.REGISTER_REQUEST, + credentials + }; +} +export function registerSuccess(credentials) { + return { + type: types.LOGIN.REGISTER_SUCCESS, + credentials + }; +} + +export function setUsernameSubmit(credentials) { + return { + type: types.LOGIN.SET_USERNAME_SUBMIT, + credentials + }; +} + +export function setUsernameRequest(credentials) { + return { + type: types.LOGIN.SET_USERNAME_REQUEST, + credentials + }; +} + +export function setUsernameSuccess() { + return { + type: types.LOGIN.SET_USERNAME_SUCCESS + }; +} + export function loginSuccess(user) { return { type: types.LOGIN.SUCCESS, diff --git a/app/containers/Routes.js b/app/containers/Routes.js index 485dd389d..83268096c 100644 --- a/app/containers/Routes.js +++ b/app/containers/Routes.js @@ -1,15 +1,12 @@ import PropTypes from 'prop-types'; import React from 'react'; -import { View, Image } from 'react-native'; import { bindActionCreators } from 'redux'; import { connect } from 'react-redux'; -import * as Animatable from 'react-native-animatable'; import { appInit } from '../actions'; -import styles from '../views/Styles'; - import AuthRoutes from './routes/AuthRoutes'; import PublicRoutes from './routes/PublicRoutes'; +import Loading from '../presentation/Loading'; @connect( state => ({ @@ -34,21 +31,10 @@ export default class Routes extends React.Component { const { login, app } = this.props; if (app.starting) { - return ( - - - - - - ); + return (); } - if ((login.token && !login.failure) || app.ready) { + if ((login.token && !login.failure && !login.isRegistering) || app.ready) { return (); } diff --git a/app/containers/routes/AuthRoutes.js b/app/containers/routes/AuthRoutes.js index 6bef85455..2c1a9f35e 100644 --- a/app/containers/routes/AuthRoutes.js +++ b/app/containers/routes/AuthRoutes.js @@ -1,7 +1,5 @@ import React from 'react'; -import { Button } from 'react-native'; -import { StackNavigator, DrawerNavigator, NavigationActions } from 'react-navigation'; -// import { Platform } from 'react-native'; +import { StackNavigator, DrawerNavigator, NavigationActions, HeaderBackButton } from 'react-navigation'; import Sidebar from '../../containers/Sidebar'; import DrawerMenuButton from '../../presentation/DrawerMenuButton'; @@ -39,7 +37,10 @@ const AuthRoutes = StackNavigator( return { title: navigation.state.params.title || 'Room', headerLeft: ( -