From e0777a969e7cfc09961812a84979ac739646ccb1 Mon Sep 17 00:00:00 2001 From: Diego Mello Date: Mon, 25 Sep 2017 10:15:28 -0300 Subject: [PATCH] Create room (#42) * Added select users view * create room working * - Show photo on avatar * Switched state for redux * Navigating to created room --- app/actions/actionsTypes.js | 14 +- app/actions/createChannel.js | 21 +- app/containers/routes/AuthRoutes.js | 56 +- app/lib/createStore.js | 5 +- app/reducers/createChannel.js | 24 +- app/sagas/createChannel.js | 12 +- app/views/CreateChannelView.js | 66 +- app/views/RoomView.js | 71 +- app/views/RoomsListView.js | 2 +- app/views/SelectUsersView.js | 271 + ios/RocketChatRN.xcodeproj/project.pbxproj | 5 +- package-lock.json | 5484 +++----------------- 12 files changed, 1081 insertions(+), 4950 deletions(-) create mode 100644 app/views/SelectUsersView.js diff --git a/app/actions/actionsTypes.js b/app/actions/actionsTypes.js index 0aca14405..ef66104a6 100644 --- a/app/actions/actionsTypes.js +++ b/app/actions/actionsTypes.js @@ -1,11 +1,10 @@ - const REQUEST = 'REQUEST'; const SUCCESS = 'SUCCESS'; const FAILURE = 'FAILURE'; const defaultTypes = [REQUEST, SUCCESS, FAILURE]; function createRequestTypes(base, types = defaultTypes) { const res = {}; - types.forEach(type => res[type] = `${ base }_${ type }`); + types.forEach(type => (res[type] = `${ base }_${ type }`)); return res; } @@ -14,7 +13,16 @@ export const LOGIN = createRequestTypes('LOGIN', [...defaultTypes, 'SET_TOKEN', export const ROOMS = createRequestTypes('ROOMS'); export const APP = createRequestTypes('APP', ['READY', 'INIT']); export const MESSAGES = createRequestTypes('MESSAGES'); -export const CREATE_CHANNEL = createRequestTypes('CREATE_CHANNEL', [...defaultTypes, 'REQUEST_USERS', 'SUCCESS_USERS', 'FAILURE_USERS', 'SET_USERS']); +export const CREATE_CHANNEL = createRequestTypes('CREATE_CHANNEL', [ + ...defaultTypes, + 'REQUEST_USERS', + 'SUCCESS_USERS', + 'FAILURE_USERS', + 'SET_USERS', + 'ADD_USER', + 'REMOVE_USER', + 'RESET' +]); export const NAVIGATION = createRequestTypes('NAVIGATION', ['SET']); export const SERVER = createRequestTypes('SERVER', [...defaultTypes, 'SELECT', 'CHANGED', 'ADD']); export const METEOR = createRequestTypes('METEOR_CONNECT', [...defaultTypes, 'DISCONNECT']); diff --git a/app/actions/createChannel.js b/app/actions/createChannel.js index df4cad35a..435a42ddc 100644 --- a/app/actions/createChannel.js +++ b/app/actions/createChannel.js @@ -21,7 +21,6 @@ export function createChannelFailure(err) { }; } - export function createChannelRequestUsers(data) { return { type: types.CREATE_CHANNEL.REQUEST_USERS, @@ -49,3 +48,23 @@ export function createChannelFailureUsers(err) { err }; } + +export function addUser(user) { + return { + type: types.CREATE_CHANNEL.ADD_USER, + user + }; +} + +export function removeUser(user) { + return { + type: types.CREATE_CHANNEL.REMOVE_USER, + user + }; +} + +export function reset() { + return { + type: types.CREATE_CHANNEL.RESET + }; +} diff --git a/app/containers/routes/AuthRoutes.js b/app/containers/routes/AuthRoutes.js index 471641924..6bef85455 100644 --- a/app/containers/routes/AuthRoutes.js +++ b/app/containers/routes/AuthRoutes.js @@ -1,5 +1,6 @@ import React from 'react'; -import { StackNavigator, DrawerNavigator } from 'react-navigation'; +import { Button } from 'react-native'; +import { StackNavigator, DrawerNavigator, NavigationActions } from 'react-navigation'; // import { Platform } from 'react-native'; import Sidebar from '../../containers/Sidebar'; @@ -8,10 +9,18 @@ import DrawerMenuButton from '../../presentation/DrawerMenuButton'; import RoomsListView from '../../views/RoomsListView'; import RoomView from '../../views/RoomView'; import CreateChannelView from '../../views/CreateChannelView'; +import SelectUsersView from '../../views/SelectUsersView'; const drawerPosition = 'left'; const drawerIconPosition = 'headerLeft'; +const backToScreen = (navigation, routeName) => { + const action = NavigationActions.reset({ + index: 0, + actions: [NavigationActions.navigate({ routeName })] + }); + navigation.dispatch(action); +}; const AuthRoutes = StackNavigator( { @@ -20,7 +29,7 @@ const AuthRoutes = StackNavigator( navigationOptions({ navigation }) { return { title: 'Rooms', - [drawerIconPosition]: () + [drawerIconPosition]: }; } }, @@ -28,7 +37,10 @@ const AuthRoutes = StackNavigator( screen: RoomView, navigationOptions({ navigation }) { return { - title: navigation.state.params.title || 'Room' + title: navigation.state.params.title || 'Room', + headerLeft: ( +