diff --git a/assets/Images/react-native.png b/assets/Images/react-native.png deleted file mode 100644 index a24781a..0000000 Binary files a/assets/Images/react-native.png and /dev/null differ diff --git a/package.json b/package.json index 17f4d1f..fb45480 100644 --- a/package.json +++ b/package.json @@ -19,7 +19,7 @@ "react-timer-mixin": "^0.13.3", "redux": "^3.0.4", "redux-thunk": "^1.0.0", - "sendbird": "^2.1.7" + "sendbird": "^2.1.6" }, "devDependencies": { "babel-core": "6.3.17", diff --git a/shared/actions/sendbird.js b/shared/actions/sendbird.js index 6a774d7..c3be496 100644 --- a/shared/actions/sendbird.js +++ b/shared/actions/sendbird.js @@ -1,6 +1,8 @@ import { SENDBIRD_CONNECT, SENDBIRD_CONNECT_ERROR, SENDBIRD_CONNECTED, SENDBIRD_SET_USER } from '../constants/ActionTypes' import { SENDBIRD_APP_ID } from '../constants/Config' +import { listChannels } from './channels' + import sendbird from 'sendbird' function shouldConnect(state) { @@ -27,6 +29,10 @@ function requestConnect(id, user) { image_url: '', access_token: '', successFunc: (data) => { + console.log(data) + + dispatch(listChannels()) + dispatch({ type: SENDBIRD_CONNECTED }) @@ -47,7 +53,7 @@ function getGuestId() { // which we only have 1k to test with, // so save the guest id per client const now = new Date() - return 'dev-native' //now.getTime() + return now.getTime() } export function connectSendbird(user) { diff --git a/shared/components/elements/Bubble.js b/shared/components/atoms/Bubble.js similarity index 100% rename from shared/components/elements/Bubble.js rename to shared/components/atoms/Bubble.js diff --git a/shared/components/elements/Button.js b/shared/components/atoms/Button.js similarity index 100% rename from shared/components/elements/Button.js rename to shared/components/atoms/Button.js diff --git a/shared/components/elements/EmptyState.js b/shared/components/atoms/EmptyState.js similarity index 100% rename from shared/components/elements/EmptyState.js rename to shared/components/atoms/EmptyState.js diff --git a/shared/components/elements/LoadingIndicator.js b/shared/components/atoms/LoadingIndicator.js similarity index 100% rename from shared/components/elements/LoadingIndicator.js rename to shared/components/atoms/LoadingIndicator.js diff --git a/shared/components/elements/MenuGroupLabel.js b/shared/components/atoms/MenuGroupLabel.js similarity index 92% rename from shared/components/elements/MenuGroupLabel.js rename to shared/components/atoms/MenuGroupLabel.js index bc6ab43..572a65f 100644 --- a/shared/components/elements/MenuGroupLabel.js +++ b/shared/components/atoms/MenuGroupLabel.js @@ -3,7 +3,7 @@ import React, { View } from 'react-native' -import Text from './Text' +import Text from 'Text' import globalStyles from '../../constants/GlobalStyles' export default class NavListHeader extends Component { @@ -19,7 +19,6 @@ export default class NavListHeader extends Component { const styles = { text: { ...globalStyles.navigationHeader, - color: '#fff', letterSpacing: 1 }, container: { diff --git a/shared/components/elements/MenuItem.js b/shared/components/atoms/MenuItem.js similarity index 80% rename from shared/components/elements/MenuItem.js rename to shared/components/atoms/MenuItem.js index 86898bd..31f7db0 100644 --- a/shared/components/elements/MenuItem.js +++ b/shared/components/atoms/MenuItem.js @@ -11,8 +11,8 @@ import { navigateTo, closeSideMenu } from '../../actions/navigation' import globalStyles from '../../constants/GlobalStyles' import colors from '../../constants/Colors' -import Bubble from './Bubble' -import Text from './Text' +import Bubble from '../atoms/Bubble' +import Text from '../atoms/Text' export default class MenuItem extends Component { @@ -20,8 +20,7 @@ export default class MenuItem extends Component { text: PropTypes.string, selected: PropTypes.bool, handlePress: PropTypes.func, - notificationCounter: PropTypes.number, - style: PropTypes.any + notificationCounter: PropTypes.number }; _handlePress() { @@ -37,7 +36,7 @@ export default class MenuItem extends Component { return ( - + {this.props.text} {notificationCounterMarkup} @@ -56,10 +55,13 @@ const styles = { active: { backgroundColor: 'rgba(0, 0, 0, 0.1)' }, + icon: { + position: 'relative', + fontSize: 26, + color: 'white' + }, text: { ...globalStyles.navigation, - paddingLeft: 2, - fontSize: 16, - color: '#fff' + paddingLeft: 2 } } diff --git a/shared/components/elements/Separator.js b/shared/components/atoms/Separator.js similarity index 100% rename from shared/components/elements/Separator.js rename to shared/components/atoms/Separator.js diff --git a/shared/components/elements/Text.js b/shared/components/atoms/Text.js similarity index 100% rename from shared/components/elements/Text.js rename to shared/components/atoms/Text.js diff --git a/shared/components/elements/TimePast.js b/shared/components/atoms/TimePast.js similarity index 100% rename from shared/components/elements/TimePast.js rename to shared/components/atoms/TimePast.js diff --git a/shared/components/container/ActionBar.js b/shared/components/container/ActionBar.js index 433fcff..94f1151 100644 --- a/shared/components/container/ActionBar.js +++ b/shared/components/container/ActionBar.js @@ -12,8 +12,8 @@ import { toggleSideMenu, navigateToWithHistory, navigateBack } from '../../actio import globalStyles from '../../constants/GlobalStyles' import colors from '../../constants/Colors' -import Text from '../elements/Text' -import Bubble from '../elements/Bubble' +import Text from './../atoms/Text' +import Bubble from './../atoms/Bubble' class ActionBar extends Component { @@ -99,7 +99,9 @@ const styles = { height: 44, flexDirection: 'row', backgroundColor: colors.MAIN_COLOR, - justifyContent: 'space-between' + justifyContent: 'space-between', + borderBottomColor: colors.BORDER, + borderBottomWidth: 1 }, bubble: { position: 'relative', diff --git a/shared/components/container/ListItem.js b/shared/components/container/ListItem.js index 71785a2..80dc049 100644 --- a/shared/components/container/ListItem.js +++ b/shared/components/container/ListItem.js @@ -6,11 +6,11 @@ import React, { TouchableHighlight } from 'react-native' -import Text from './../elements/Text' -import LoadingIndicator from './../elements/LoadingIndicator' +import Text from './../atoms/Text' +import LoadingIndicator from './../atoms/LoadingIndicator' import colors from '../../constants/Colors' import globalStyles from '../../constants/GlobalStyles' -import Bubble from './../elements/Bubble' +import Bubble from './../atoms/Bubble' export default class ListItem extends Component { static propTypes = { diff --git a/shared/components/container/MenuContainer.js b/shared/components/container/MenuContainer.js index 02cdccc..b185ce5 100644 --- a/shared/components/container/MenuContainer.js +++ b/shared/components/container/MenuContainer.js @@ -12,10 +12,7 @@ import { navigateTo, resetTo } from '../../actions/navigation' import globalStyles from '../../constants/GlobalStyles' -import Profile from '../elements/Profile' -import Text from '../elements/Text' -import MenuGroupLabel from '../elements/MenuGroupLabel' -import MenuItem from '../elements/MenuItem' +import MenuGroupLabel from './../atoms/MenuGroupLabel' import MenuItemContainer from './MenuItemContainer' const window = Dimensions.get('window') @@ -23,48 +20,40 @@ const window = Dimensions.get('window') class MenuContainer extends Component { render() { + console.log() + const publicChannels = [] - let publicChannelsDummy = [] - publicChannelsDummy.forEach((channelName) => { + this.props.channels.forEach((channel) => { publicChannels.push( - + ) }) return ( - + + + {publicChannels} - - - - - {publicChannels.length > 0 ? publicChannels : no joined channels} + + {Platform.OS === 'android' ? : null } - + ) } } const styles = { - background: { - flex: 1, - backgroundColor: '#6e5baa', - }, container: { flexDirection: 'row' }, @@ -107,15 +96,6 @@ const styles = { height: 0, width: window.width * 0.8, flex: 1 - }, - highlight: { - backgroundColor: '#32c5e6', - marginTop: 20, - marginBottom: 20 - }, - noJoinedChannles: { - margin: 20, - color: '#fff' } } @@ -126,8 +106,8 @@ if (Platform.OS === 'ios') { export default connect( (state) => { return { - login: state.login, - notifications: state.notifications + channels: state.channels.list, + } }, (dispatch) => { diff --git a/shared/components/container/MenuItemContainer.js b/shared/components/container/MenuItemContainer.js index efaa006..e085ebc 100644 --- a/shared/components/container/MenuItemContainer.js +++ b/shared/components/container/MenuItemContainer.js @@ -1,18 +1,17 @@ import React, { Component, - View, PropTypes, - TouchableHighlight } from 'react-native' import { connect } from 'react-redux/native' import { navigateTo, closeSideMenu } from '../../actions/navigation' -import MenuItem from '../elements/MenuItem' +import MenuItem from '../atoms/MenuItem' class MenuItemContainer extends Component { static propTypes = { navTarget: PropTypes.string, + channel: PropTypes.object, text: PropTypes.string, handlePress: PropTypes.func, notificationCounter: PropTypes.number @@ -31,7 +30,7 @@ class MenuItemContainer extends Component { if (this.props.handlePress) { this.props.handlePress() } else if (this.props.route !== this.props.navTarget) { - this.props.navigateTo(this.props.navTarget) + this.props.navigateTo(this.props.navTarget, { channel: this.props.channel }) } else { this.props.closeSideMenu() } @@ -44,6 +43,7 @@ class MenuItemContainer extends Component { selected={this.props.navTarget === this.props.route} handlePress={this._handlePress.bind(this)} notificationCounter={this.props.notificationCounter} + channel={this.props.chnnel} /> ) } diff --git a/shared/components/container/SendbirdConnect.js b/shared/components/container/SendbirdConnect.js index f809be8..aa786c7 100644 --- a/shared/components/container/SendbirdConnect.js +++ b/shared/components/container/SendbirdConnect.js @@ -13,7 +13,7 @@ import { connect } from 'react-redux' import { resetTo } from '../../actions/navigation' import { connectSendbird } from '../../actions/sendbird' -import Button from '../elements/Button' +import Button from '../atoms/Button' class SendbirdConnect extends Component { @@ -36,13 +36,13 @@ class SendbirdConnect extends Component { render() { return ( - + - ) } @@ -75,13 +69,6 @@ const styles = { marginBottom: 10, backgroundColor: '#eee', width: 200 - }, - button: { - container: { - width: 200, - marginLeft: 15, - marginRight: 15, - } } } @@ -95,6 +82,6 @@ export default connect( }), dispatch => ({ connect: (id, user) => dispatch(connectSendbird(id, user)), - goToChat: () => dispatch(resetTo('messenger')) + goToChat: () => dispatch(resetTo('settings')) }) )(SendbirdConnect) \ No newline at end of file diff --git a/shared/components/elements/IntroText.js b/shared/components/elements/IntroText.js deleted file mode 100644 index 75a9ad1..0000000 --- a/shared/components/elements/IntroText.js +++ /dev/null @@ -1,55 +0,0 @@ -import React, { - Component, - PropTypes, - View, - TouchableHighlight -} from 'react-native' - -import Text from './Text' - -export default class IntroText extends Component { - - render() { - return ( - - Messenger - - - - - Exercises: - - - 1. Add the team logo - 2. Display the username - 3. Toggle and display the channel list - 4. Join a channel by clicking on it - 5. Open and show a messenger-channel - 6. Send and display messages - - - ) - } -} - -const styles = { - intro: { - flex: 1, - justifyContent: 'center', - alignItems: 'center', - margin: 20 - }, - heading: { - fontSize: 20, - textAlign: 'center', - margin: 10, - color: '#abb8c4', - marginBottom: 20 - }, - instructions: { - textAlign: 'center', - color: '#333333', - marginBottom: 5, - fontSize: 14 - } -} \ No newline at end of file diff --git a/shared/components/elements/Profile.js b/shared/components/elements/Profile.js deleted file mode 100644 index bda52ca..0000000 --- a/shared/components/elements/Profile.js +++ /dev/null @@ -1,24 +0,0 @@ -import React, { - Component, - Image, - View -} from 'react-native' - -import Text from './Text' - -export default class Profile extends Component { - - render() { - return ( - - Username - - ) - } -} - -const styles = { - container: { - margin: 20 - } -} \ No newline at end of file diff --git a/shared/components/elements/TeamLogo.js b/shared/components/elements/TeamLogo.js deleted file mode 100644 index 5a6e7e4..0000000 --- a/shared/components/elements/TeamLogo.js +++ /dev/null @@ -1,31 +0,0 @@ -import React, { - Component, - Image, - View -} from 'react-native' - -import Text from './Text' - -export default class TeamLogo extends Component { - - render() { - return ( - - - HackReact Team - - ) - } -} - -const styles = { - container: { - margin: 20 - }, - image: { - width: 200, - height: 100 - } -} \ No newline at end of file diff --git a/shared/components/pages/ChannelPage.js b/shared/components/pages/ChannelPage.js new file mode 100644 index 0000000..6b29833 --- /dev/null +++ b/shared/components/pages/ChannelPage.js @@ -0,0 +1,124 @@ +import React, { + Platform, + Component, + Dimensions, + DeviceEventEmitter, + View, + ScrollView, + InteractionManager, + TextInput +} from 'react-native' +import { connect } from 'react-redux/native' + +import globalStyles from '../../constants/GlobalStyles' +import colors from '../../constants/Colors' + +import ActionBar from '../container/ActionBar' +import LoadingIndicator from '../atoms/LoadingIndicator' +import Text from '../atoms/Text' +import Button from '../atoms/Button' + +class ChannelPage extends Component { + state = { + interactionsFinished: false, + keyboardHeight: 0 + }; + + componentDidMount() { + InteractionManager.runAfterInteractions(() => { + this.setState({interactionsFinished: true}) + }) + } + + componentWillMount() { + DeviceEventEmitter.addListener('keyboardWillShow', this.keyboardWillShow.bind(this)) + DeviceEventEmitter.addListener('keyboardWillHide', this.keyboardWillHide.bind(this)) + } + + keyboardWillShow(e) { + this.setState({keyboardHeight: e.endCoordinates.height}) + } + + keyboardWillHide(e) { + this.setState({keyboardHeight: 0}) + } + + _sendMessage() { + + } + + render() { + let interactionsFinishedMarkup = + + if (this.state.interactionsFinished) { + interactionsFinishedMarkup = ( + + + message .... + + + { this.setState({text: text}) }} + style={styles.input} + placeholder="Enter comment" /> + +