├── .flowconfig ├── .gitignore ├── .npmignore ├── AppDispatcher.js ├── README.md ├── actions └── applicationActions.js ├── assets └── twitch.gif ├── components ├── ChannelGridItem.js ├── ChannelListItem.js ├── ChannelsModal.js ├── ChannelsTabs.js ├── GameItem.js └── Player.js ├── components_scene ├── ChannelsScene.js ├── DrawerScene.js ├── GamesScene.js └── StreamScene.js ├── constants └── applicationConstants.js ├── iOS ├── AppDelegate.h ├── AppDelegate.m ├── Base.lproj │ └── LaunchScreen.xib ├── Images.xcassets │ ├── AppIcon.appiconset │ │ └── Contents.json │ ├── Contents.json │ ├── Games.imageset │ │ ├── Contents.json │ │ ├── games-1.png │ │ ├── games-2.png │ │ └── games.png │ ├── active_channels.imageset │ │ ├── Contents.json │ │ ├── active_channels-1.png │ │ ├── active_channels-2.png │ │ └── active_channels.png │ ├── boxart.imageset │ │ ├── Contents.json │ │ ├── boxart-1.png │ │ ├── boxart-2.png │ │ └── boxart.png │ ├── channels.imageset │ │ ├── Contents.json │ │ ├── channels-1.png │ │ ├── channels-2.png │ │ └── channels.png │ ├── recent.imageset │ │ ├── Contents.json │ │ ├── recent-1.png │ │ ├── recent-2.png │ │ └── recent.png │ └── tabnav_list.imageset │ │ ├── Contents.json │ │ ├── tabnav_list-1.png │ │ ├── tabnav_list-2.png │ │ └── tabnav_list.png ├── Info.plist ├── main.jsbundle └── main.m ├── index.ios.js ├── mock_data ├── games.json ├── menu_data_list.json ├── msgs.json └── streams.json ├── package.json ├── services └── kraken.js ├── stores └── applicationStore.js ├── twitch.xcodeproj ├── project.pbxproj └── xcshareddata │ └── xcschemes │ └── twitch.xcscheme ├── utils └── index.js └── vendor └── react-native-drawer ├── Tweener.js └── index.js /.flowconfig: -------------------------------------------------------------------------------- 1 | [ignore] 2 | 3 | # We fork some components by platform. 4 | .*/*.web.js 5 | .*/*.android.js 6 | 7 | # Some modules have their own node_modules with overlap 8 | .*/node_modules/node-haste/.* 9 | 10 | # Ignore react-tools where there are overlaps, but don't ignore anything that 11 | # react-native relies on 12 | .*/node_modules/react-tools/src/vendor/core/ExecutionEnvironment.js 13 | .*/node_modules/react-tools/src/browser/eventPlugins/ResponderEventPlugin.js 14 | .*/node_modules/react-tools/src/browser/ui/React.js 15 | .*/node_modules/react-tools/src/core/ReactInstanceHandles.js 16 | .*/node_modules/react-tools/src/event/EventPropagators.js 17 | 18 | # Ignore commoner tests 19 | .*/node_modules/commoner/test/.* 20 | 21 | # See https://github.com/facebook/flow/issues/442 22 | .*/react-tools/node_modules/commoner/lib/reader.js 23 | 24 | # Ignore jest 25 | .*/react-native/node_modules/jest-cli/.* 26 | 27 | [include] 28 | 29 | [libs] 30 | node_modules/react-native/Libraries/react-native/react-native-interface.js 31 | 32 | [options] 33 | module.system=haste 34 | 35 | suppress_type=$FlowIssue 36 | suppress_type=$FlowFixMe 37 | suppress_type=$FixMe 38 | 39 | suppress_comment=\\(.\\|\n\\)*\\$FlowFixMe\\($\\|[^(]\\|(\\(>=0\\.\\(1[0-3]\\|[0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\) 40 | suppress_comment=\\(.\\|\n\\)*\\$FlowIssue\\((\\(>=0\\.\\(1[0-3]\\|[0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)? #[0-9]+ 41 | suppress_comment=\\(.\\|\n\\)*\\$FlowFixedInNextDeploy 42 | 43 | [version] 44 | 0.13.1 45 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # OSX 2 | # 3 | .DS_Store 4 | 5 | # Xcode 6 | # 7 | build/ 8 | *.pbxuser 9 | !default.pbxuser 10 | *.mode1v3 11 | !default.mode1v3 12 | *.mode2v3 13 | !default.mode2v3 14 | *.perspectivev3 15 | !default.perspectivev3 16 | xcuserdata 17 | *.xccheckout 18 | *.moved-aside 19 | DerivedData 20 | *.hmap 21 | *.ipa 22 | *.xcuserstate 23 | project.xcworkspace 24 | 25 | # node.js 26 | # 27 | node_modules/ 28 | npm-debug.log 29 | -------------------------------------------------------------------------------- /.npmignore: -------------------------------------------------------------------------------- 1 | # OSX 2 | # 3 | .DS_Store 4 | 5 | # Xcode 6 | # 7 | build/ 8 | *.pbxuser 9 | !default.pbxuser 10 | *.mode1v3 11 | !default.mode1v3 12 | *.mode2v3 13 | !default.mode2v3 14 | *.perspectivev3 15 | !default.perspectivev3 16 | xcuserdata 17 | *.xccheckout 18 | *.moved-aside 19 | DerivedData 20 | *.hmap 21 | *.ipa 22 | *.xcuserstate 23 | 24 | # node.js 25 | # 26 | node_modules/ 27 | npm-debug.log 28 | -------------------------------------------------------------------------------- /AppDispatcher.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | var Dispatcher = require('flux').Dispatcher; 4 | 5 | module.exports = new Dispatcher(); 6 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Notes 2 | 3 | I'm going to rewrite this project 😉. Be ready to new Twitch application. 4 | 5 | # Twitch 6 | 7 | This project was built for [The Rolling Scopes](http://rollingscopes.com/) #18 meetup. 8 | As of now, Twitch app is able to run as: 9 | 10 | - iOS App 11 | 12 | See **Running the project** if you want to run this project. 13 | 14 | ## Demo 15 | 16 | ### Mobile App (iOS) 17 | ![Demo](assets/twitch.gif) 18 | 19 | ## Libraries 20 | 21 | - [react-native](https://facebook.github.io/react-native) for the iOS & Android Apps 22 | - [flux](https://facebook.github.io/flux) to organize the data flow management 23 | - [react-native-linear-gradient](https://github.com/brentvatne/react-native-linear-gradient) for grid item title 24 | - [react-native-drawer](https://github.com/root-two/react-native-drawer) for drawer :) 25 | 26 | ## Running the project 27 | - [react-native requirements](https://facebook.github.io/react-native/docs/getting-started.html#requirements) 28 | - `npm install` to install all dependencies 29 | - open twitch.xcodeproj and run Twitch application 30 | 31 | ## What's next 32 | - es6/es7 33 | - ~~integrate [twitch api](https://github.com/justintv/Twitch-API)~~ 34 | - [relay with custom server???](https://facebook.github.io/relay/) 35 | - Android version??? 36 | - Settings component for ChannelsScene. 37 | 38 | -------------------------------------------------------------------------------- /actions/applicationActions.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | var dispatcher = require('../AppDispatcher'); 4 | 5 | var applicationConstants = require('../constants/applicationConstants'); 6 | 7 | var actions = { 8 | setPlayerStream: function(value) { 9 | dispatcher.dispatch({ 10 | actionType: applicationConstants.SET_PLAYER_STREAM, 11 | value: value, 12 | }); 13 | }, 14 | 15 | setPlayerStatus: function(status, stream) { 16 | dispatcher.dispatch({ 17 | actionType: applicationConstants.SET_PLAYER_STATUS, 18 | status: status, 19 | stream: stream, 20 | }); 21 | }, 22 | 23 | setChannelItemsView: function(type) { 24 | dispatcher.dispatch({ 25 | actionType: applicationConstants.SET_CHANNEL_ITEMS_VIEW, 26 | type: type, 27 | }); 28 | }, 29 | 30 | setDrawerStatus: function(value) { 31 | dispatcher.dispatch({ 32 | actionType: applicationConstants.SET_DRAWER_STATUS, 33 | value: value, 34 | }); 35 | }, 36 | }; 37 | 38 | module.exports = actions; 39 | -------------------------------------------------------------------------------- /assets/twitch.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ifours/react-native-twitch/b5d22d1b029220c34d3075119c3591846e095e56/assets/twitch.gif -------------------------------------------------------------------------------- /components/ChannelGridItem.js: -------------------------------------------------------------------------------- 1 | /* @flow */ 2 | 'use strict'; 3 | 4 | var React = require('react-native'); 5 | var LinearGradient = require('react-native-linear-gradient'); 6 | var Dimensions = require('Dimensions'); 7 | 8 | var { 9 | StyleSheet, 10 | View, 11 | ScrollView, 12 | Image, 13 | PixelRatio, 14 | Text, 15 | Animated, 16 | TouchableHighlight, 17 | } = React; 18 | 19 | var StreamScene = require('../components_scene/StreamScene'); 20 | 21 | var ChannelGridItem = React.createClass({ 22 | getInitialState: function() { 23 | return { 24 | bounceValueScale: new Animated.Value(1), 25 | bounceValueOpacity: new Animated.Value(0), 26 | bounceValueTranslateY: new Animated.Value(-200 * (this.props.itemIndex + 1)) 27 | }; 28 | }, 29 | 30 | componentDidMount: function() { 31 | Animated.parallel([ 32 | Animated.timing( 33 | this.state.bounceValueTranslateY, 34 | { 35 | toValue: 0, 36 | duration: 300, 37 | } 38 | ), 39 | Animated.timing( 40 | this.state.bounceValueOpacity, 41 | { 42 | toValue: 1, 43 | duration: 200, 44 | } 45 | ), 46 | ]).start(); 47 | }, 48 | 49 | animatePressIn: function() { 50 | return Animated.timing( 51 | this.state.bounceValueScale, 52 | { 53 | toValue: 0.98, 54 | duration: 70, 55 | } 56 | ); 57 | }, 58 | 59 | animatePressOut: function() { 60 | return Animated.timing( 61 | this.state.bounceValueScale, 62 | { 63 | toValue: 1, 64 | duration: 70, 65 | } 66 | ); 67 | }, 68 | 69 | onPressIn: function() { 70 | this.animatePressIn().start(); 71 | }, 72 | 73 | onPressOut: function() { 74 | this.animatePressOut().start(); 75 | }, 76 | 77 | onPress: function() { 78 | this.props.onPressStream(); 79 | }, 80 | 81 | renderBloker: function() { 82 | return ( 83 | true} 93 | onResponderTerminationRequest={(evt) => false} /> 94 | ); 95 | }, 96 | 97 | render: function() { 98 | // debugger; 99 | return ( 100 | 107 | 108 | 117 | 118 | 122 | 123 | 124 | 127 | 128 | {this.props.stream.display_name} 129 | 130 | 131 | {this.props.stream.status} 132 | 133 | 134 | {this.props.stream.views} viewers 135 | 136 | 137 | 138 | 139 | {this.renderBloker()} 140 | 141 | 142 | ); 143 | } 144 | }); 145 | 146 | var SCREEN_WIDTH = Dimensions.get('window').width; 147 | 148 | var ratio = 180 / 320, 149 | offset = 10, 150 | containerWidth = (SCREEN_WIDTH - offset * 2) / 1, 151 | containerHeight = ratio * containerWidth; 152 | 153 | var styles = StyleSheet.create({ 154 | 155 | streamContainer: { 156 | paddingBottom: offset, 157 | paddingRight: offset, 158 | paddingLeft: offset, 159 | }, 160 | 161 | streamView: { 162 | justifyContent: 'flex-end', 163 | width: containerWidth, 164 | height: containerHeight, 165 | }, 166 | streamBox: { 167 | padding: 10, 168 | }, 169 | 170 | streamTitleText: { 171 | color: '#fff', 172 | fontWeight: 'bold', 173 | }, 174 | 175 | streamNameText: { 176 | color: '#fff', 177 | fontSize: 12, 178 | paddingVertical: 5, 179 | }, 180 | 181 | streamViewesText: { 182 | color: '#B9A5E1', 183 | fontSize: 12, 184 | fontWeight: 'bold', 185 | }, 186 | }); 187 | 188 | module.exports = ChannelGridItem; 189 | -------------------------------------------------------------------------------- /components/ChannelListItem.js: -------------------------------------------------------------------------------- 1 | /* @flow */ 2 | 'use strict'; 3 | 4 | var React = require('react-native'); 5 | var Dimensions = require('Dimensions'); 6 | 7 | var { 8 | StyleSheet, 9 | View, 10 | ScrollView, 11 | Image, 12 | PixelRatio, 13 | Text, 14 | Animated, 15 | TouchableHighlight, 16 | } = React; 17 | 18 | var StreamScene = require('../components_scene/StreamScene'); 19 | 20 | var ChannelListItem = React.createClass({ 21 | renderBloker: function() { 22 | return ( 23 | true} 33 | onResponderTerminationRequest={(evt) => false} /> 34 | ); 35 | }, 36 | 37 | render: function() { 38 | return ( 39 | 40 | 41 | 44 | 45 | 46 | 49 | 50 | 51 | 53 | 54 | {this.props.stream.display_name} 55 | 56 | 58 | 59 | {this.props.stream.status} 60 | 61 | 63 | 64 | {this.props.stream.views} viewers 65 | 66 | 67 | 68 | {this.renderBloker()} 69 | 70 | 71 | 72 | ); 73 | } 74 | }); 75 | 76 | var SCREEN_WIDTH = Dimensions.get('window').width; 77 | 78 | var imgRatio = 180 / 320, 79 | offset = 9, 80 | containerWidth = 95, 81 | containerHeight = imgRatio * containerWidth; 82 | 83 | 84 | var styles = StyleSheet.create({ 85 | streamView: { 86 | flexDirection: 'row', 87 | padding: offset, 88 | }, 89 | 90 | streamImage: { 91 | width: containerWidth, 92 | height: containerHeight, 93 | }, 94 | 95 | infoView: { 96 | flex: 1, 97 | marginLeft: 10, 98 | }, 99 | 100 | titleText: { 101 | fontWeight: '500', 102 | fontSize: 14, 103 | }, 104 | 105 | nameText: { 106 | fontSize: 12, 107 | paddingVertical: 3, 108 | }, 109 | 110 | viewersText: { 111 | color: '#694BA6', 112 | fontWeight: '600', 113 | fontSize: 12, 114 | }, 115 | 116 | separator: { 117 | backgroundColor: 'rgba(0, 0, 0, 0.1)', 118 | height: 1 / PixelRatio.get(), 119 | } 120 | }); 121 | 122 | module.exports = ChannelListItem; 123 | -------------------------------------------------------------------------------- /components/ChannelsModal.js: -------------------------------------------------------------------------------- 1 | /* @flow */ 2 | 'use strict'; 3 | 4 | var React = require('react-native'); 5 | 6 | var { 7 | StyleSheet, 8 | View, 9 | } = React; 10 | 11 | var ChannelsModal = React.createClass({ 12 | render: function() { 13 | return ( 14 | 15 | ); 16 | } 17 | }); 18 | 19 | 20 | var styles = StyleSheet.create({ 21 | 22 | }); 23 | 24 | 25 | module.exports = ChannelsModal; 26 | -------------------------------------------------------------------------------- /components/ChannelsTabs.js: -------------------------------------------------------------------------------- 1 | /* @flow */ 2 | 'use strict'; 3 | 4 | var React = require('react-native'); 5 | 6 | var { 7 | Touchable, 8 | StyleSheet, 9 | View, 10 | Text, 11 | Image, 12 | } = React; 13 | 14 | var ChannelsTabs = React.createClass({ 15 | render: function() { 16 | return ( 17 | 18 | 19 | 21 | 22 | Live Channels 23 | 24 | 25 | 27 | 28 | Recent Videos 29 | 30 | 31 | ); 32 | } 33 | }); 34 | 35 | 36 | var styles = StyleSheet.create({ 37 | container: { 38 | backgroundColor: 'rgba(255, 255, 255, 0.65)', 39 | 40 | position: 'absolute', 41 | bottom: 0, 42 | left: 0, 43 | right: 0, 44 | 45 | paddingHorizontal: 45, 46 | paddingBottom: 2, 47 | 48 | flexDirection: 'row', 49 | justifyContent: 'space-around', 50 | }, 51 | 52 | tab: { 53 | alignItems: 'center', 54 | }, 55 | 56 | icon: { 57 | width: 25, 58 | height: 25, 59 | 60 | marginBottom: 3, 61 | }, 62 | 63 | text: { 64 | color: '#B9A5E1', 65 | fontSize: 11, 66 | }, 67 | 68 | textActive: { 69 | color: '#5A3F94', 70 | }, 71 | }); 72 | 73 | 74 | module.exports = ChannelsTabs; 75 | -------------------------------------------------------------------------------- /components/GameItem.js: -------------------------------------------------------------------------------- 1 | /* @flow */ 2 | 'use strict'; 3 | 4 | var React = require('react-native'), 5 | Dimensions = require('Dimensions'); 6 | 7 | var { 8 | StyleSheet, 9 | View, 10 | Animated, 11 | Image, 12 | Text, 13 | TouchableHighlight, 14 | } = React; 15 | 16 | var SCREEN_WIDTH = Dimensions.get('window').width; 17 | 18 | var GameItem = React.createClass({ 19 | getInitialState: function() { 20 | return { bounceValue: new Animated.Value(0), } 21 | }, 22 | 23 | _onImageLoad: function() { 24 | Animated.timing( 25 | this.state.bounceValue, 26 | { 27 | toValue: 1, 28 | duration: 200, 29 | } 30 | ).start(); 31 | }, 32 | 33 | render: function() { 34 | 35 | return ( 36 | 41 | 42 | 43 | 47 | {this.props.game.name} 48 | 49 | 55 | 56 | 57 | 58 | ); 59 | }, 60 | }); 61 | 62 | var imgRatio = 202 / 145, 63 | imgMargin = 10, 64 | perRow = 2, 65 | imgWidth = (SCREEN_WIDTH - imgMargin * (perRow + 1)) / perRow, 66 | imgHeight = imgRatio * imgWidth; 67 | 68 | 69 | var styles = StyleSheet.create({ 70 | gameView: { 71 | marginLeft: imgMargin, 72 | marginTop: imgMargin, 73 | }, 74 | 75 | gameContainer: { 76 | flexDirection: 'row', 77 | backgroundColor: '#19191E', 78 | 79 | width: imgWidth, 80 | height: imgHeight, 81 | }, 82 | 83 | boxartView: { 84 | flex: 1, 85 | // alignItems: 'center', 86 | // marginTop: imgHeight / 2 - 50, 87 | }, 88 | 89 | boxartConatianer: { 90 | width: imgWidth, 91 | padding: 10, 92 | height: 70, 93 | flex: 1, 94 | justifyContent: 'flex-end', 95 | alignItems: 'center', 96 | }, 97 | 98 | gameTitle: { 99 | color: '#B9A5E1', 100 | fontSize: 16, 101 | fontWeight: '600', 102 | textAlign: 'center', 103 | }, 104 | 105 | gameImg: { 106 | position: 'absolute', 107 | top: 0, 108 | left: 0, 109 | right: 0, 110 | bottom: 0, 111 | 112 | width: imgWidth, 113 | height: imgHeight, 114 | }, 115 | }); 116 | 117 | 118 | module.exports = GameItem; 119 | -------------------------------------------------------------------------------- /components/Player.js: -------------------------------------------------------------------------------- 1 | /* @flow */ 2 | 'use strict'; 3 | 4 | var React = require('react-native'); 5 | var Dimensions = require('Dimensions'); 6 | 7 | var StreamScene = require('../components_scene/StreamScene'); 8 | 9 | var { 10 | StyleSheet, 11 | View, 12 | ScrollView, 13 | Image, 14 | PixelRatio, 15 | Text, 16 | Animated, 17 | TouchableHighlight, 18 | } = React; 19 | 20 | var SCREEN_WIDTH = Dimensions.get('window').width; 21 | 22 | var appActions = require('../actions/applicationActions'); 23 | var appConsts = require('../constants/applicationConstants'); 24 | 25 | var Player = React.createClass({ 26 | getInitialState: function() { 27 | return { 28 | bounceValueLeft: new Animated.Value(0), 29 | bounceValueOpacity: new Animated.Value(0), 30 | }; 31 | }, 32 | 33 | componentWillMount: function() { 34 | this._setupStyles(); 35 | }, 36 | 37 | componentDidMount: function() { 38 | Animated.timing( 39 | this.state.bounceValueOpacity, 40 | { 41 | toValue: 1, 42 | duration: 300, 43 | } 44 | ).start(); 45 | }, 46 | 47 | onResponderMove: function(evt) { 48 | var offset = - this._previousLeft + evt.nativeEvent.pageX; 49 | 50 | this._playerStyles.left = offset; 51 | this._playerStyles.opacity = 1 - ( Math.abs(offset) / 200 ) * 0.6; 52 | 53 | this._updatePosition(); 54 | }, 55 | 56 | onResponderGrant: function(evt) { 57 | this._previousLeft = evt.nativeEvent.pageX; 58 | }, 59 | 60 | onResponderRelease: function(evt) { 61 | this.state.bounceValueLeft.setValue(this._playerStyles.left); 62 | 63 | if (this._playerStyles.left + this._previousLeft === this._previousLeft) { 64 | 65 | this.props.navigator.push({ 66 | title: this.props.stream.title, 67 | component: StreamScene, 68 | passProps: { stream: this.props.stream }, 69 | }); 70 | 71 | return appActions.setPlayerStatus(appConsts.PLAYER_SUSPEND); 72 | } 73 | 74 | if (this._playerStyles.left > 200 || this._playerStyles.left < -200) { 75 | this.state.bounceValueOpacity.setValue(this._playerStyles.opacity); 76 | 77 | Animated.timing( 78 | this.state.bounceValueOpacity, 79 | { 80 | toValue: 0, 81 | duration: 400, 82 | } 83 | ).start(() => { 84 | appActions.setPlayerStatus(appConsts.PLAYER_OFF); 85 | }); 86 | } else { 87 | Animated.timing( 88 | this.state.bounceValueLeft, 89 | { 90 | toValue: 0, 91 | duration: 300, 92 | } 93 | ).start(() => { 94 | this._setupStyles(); 95 | }); 96 | } 97 | }, 98 | 99 | _setupStyles: function() { 100 | this._previousLeft = 0; 101 | this._previousOpacity = 1; 102 | 103 | this._playerStyles = { 104 | left: this._previousLeft, 105 | opacity: this._previousOpacity, 106 | }; 107 | }, 108 | 109 | _updatePosition: function() { 110 | this.stream && this.stream.setNativeProps({style: this._playerStyles}); 111 | }, 112 | 113 | render: function() { 114 | return ( 115 | true} 125 | onMoveShouldSetResponder={(evt) => true} 126 | 127 | onResponderGrant={this.onResponderGrant} 128 | onResponderMove={this.onResponderMove} 129 | onResponderRelease={this.onResponderRelease} 130 | onResponderTerminationRequest={(evt) => false} 131 | 132 | ref={(stream) => { 133 | this.stream = stream; 134 | }} > 135 | 136 | 139 | 140 | 142 | 143 | {this.props.stream.channel.display_name} 144 | 145 | 147 | 148 | Playing 149 | 150 | 151 | 152 | ); 153 | }, 154 | }); 155 | 156 | var imgRatio = 180 / 320, 157 | imgOffset = 9, 158 | imgWidth = 95, 159 | imgHeight = imgRatio * imgWidth; 160 | 161 | var styles = StyleSheet.create({ 162 | playerView: { 163 | flexDirection: 'row', 164 | padding: 9, 165 | }, 166 | 167 | playerImage: { 168 | width: imgWidth, 169 | height: imgHeight, 170 | }, 171 | 172 | infoView: { 173 | flex: 1, 174 | marginLeft: 10, 175 | }, 176 | 177 | titleText: { 178 | fontWeight: '500', 179 | fontSize: 14, 180 | }, 181 | }); 182 | 183 | module.exports = Player; 184 | -------------------------------------------------------------------------------- /components_scene/ChannelsScene.js: -------------------------------------------------------------------------------- 1 | /* @flow */ 2 | 'use strict'; 3 | 4 | var React = require('react-native'); 5 | 6 | var { 7 | StyleSheet, 8 | View, 9 | ScrollView, 10 | Image, 11 | PixelRatio, 12 | Text, 13 | Animated, 14 | ActivityIndicatorIOS, 15 | AlertIOS, 16 | TouchableHighlight, 17 | } = React; 18 | 19 | var ChannelsTabs = require('../components/ChannelsTabs'), 20 | ChannelListItem = require('../components/ChannelListItem'), 21 | ChannelGridItem = require('../components/ChannelGridItem'), 22 | StreamScene = require('./StreamScene'); 23 | 24 | var appStore = require('../stores/applicationStore'); 25 | var appActions = require('../actions/applicationActions'); 26 | var appConsts = require('../constants/applicationConstants'); 27 | var kraken = require('../services/kraken'); 28 | 29 | var ChannelsScene = React.createClass({ 30 | getInitialState: function() { 31 | return { 32 | channels: [], 33 | gridCount: 4, 34 | itemsView: appStore.getChannelItemsView(), 35 | playerStatus: appStore.getPlayerStatus(), 36 | }; 37 | }, 38 | 39 | componentDidMount: function() { 40 | appStore.addChangeListener(this._onChange); 41 | 42 | kraken.getStreams(this.props.game.name).then((body) => { 43 | this.setState({ channels: body.streams }); 44 | }).catch(() => { 45 | AlertIOS.alert('Twitch server error'); 46 | }); 47 | }, 48 | 49 | componentWillUnmount: function() { 50 | appStore.removeChangeListener(this._onChange); 51 | }, 52 | 53 | _onChange: function() { 54 | this.setState({ 55 | playerStatus: appStore.getPlayerStatus(), 56 | itemsView: appStore.getChannelItemsView(), 57 | }); 58 | }, 59 | 60 | _onPressStream: function(stream) { 61 | this.props.navigator.push({ 62 | title: stream.channel.status, 63 | component: StreamScene, 64 | passProps: { stream }, 65 | }); 66 | 67 | if (!(this.state.playerStatus === appConsts.PLAYER_OFF)) { 68 | appActions.setPlayerStatus(appConsts.PLAYER_SUSPEND); 69 | } 70 | 71 | }, 72 | 73 | 74 | renderGridItem: function(stream, index) { 75 | return ( 76 | this._onPressStream(stream) } 78 | stream={stream.channel} 79 | itemIndex={index} 80 | preview={stream.preview.large} 81 | key={stream._id} /> 82 | ) 83 | }, 84 | 85 | renderListItem: function(stream, index) { 86 | return ( 87 | this._onPressStream(stream) } 89 | stream={stream.channel} 90 | itemIndex={index} 91 | preview={stream.preview.large} 92 | key={stream._id} /> 93 | ) 94 | }, 95 | 96 | _getArrayOfChannels: function({ startIndex, endIndex }) { 97 | var channels = []; 98 | 99 | for (var i = startIndex; i != endIndex; i++) { 100 | channels[i] = this.state.channels[i]; 101 | } 102 | return channels; 103 | }, 104 | 105 | renderListChannels: function() { 106 | return this._getArrayOfChannels({ 107 | startIndex: this.state.gridCount, 108 | endIndex: this.state.channels.length, 109 | }) 110 | .map(this.renderListItem); 111 | }, 112 | 113 | rednerGridChannels: function() { 114 | return this._getArrayOfChannels({ 115 | startIndex: 0, 116 | endIndex: this.state.gridCount, 117 | }) 118 | .map(this.renderGridItem);; 119 | }, 120 | 121 | renderItems: function() { 122 | switch (this.state.itemsView) { 123 | 124 | case appConsts.GRID: 125 | return this.state.channels.map(this.renderGridItem); 126 | 127 | case appConsts.LIST: 128 | return this.state.channels.map(this.renderListItem); 129 | 130 | case appConsts.GRID_LIST: 131 | return this.rednerGridChannels().concat(this.renderListChannels()); 132 | } 133 | }, 134 | 135 | render: function() { 136 | var marginTop = ( 137 | this.state.playerStatus === appConsts.PLAYER_SUSPEND || 138 | this.state.playerStatus === appConsts.PLAYER_ON ) ? 65 : 0; 139 | 140 | return ( 141 | 142 | 143 | {this.state.channels.length ? this.renderItems() : } 146 | 147 | 148 | 149 | ); 150 | } 151 | }); 152 | 153 | var styles = StyleSheet.create({ 154 | centering: { 155 | flex: 1, 156 | height: 80, 157 | alignItems: 'center', 158 | justifyContent: 'center', 159 | }, 160 | }); 161 | 162 | module.exports = ChannelsScene; 163 | -------------------------------------------------------------------------------- /components_scene/DrawerScene.js: -------------------------------------------------------------------------------- 1 | /* @flow */ 2 | 'use strict'; 3 | 4 | var React = require('react-native'); 5 | var Dimensions = require('Dimensions'); 6 | 7 | var SCREEN_WIDTH = Dimensions.get('window').width; 8 | var { DRAWER_OFFSET } = require('../constants/applicationConstants'); 9 | 10 | var { 11 | StyleSheet, 12 | View, 13 | scrollViewew, 14 | Image, 15 | PixelRatio, 16 | TextInput, 17 | Text, 18 | ListView, 19 | TouchableHighlight, 20 | } = React; 21 | 22 | var DrawerScreen = React.createClass({ 23 | render: function() { 24 | return ( 25 | 26 | 27 | 28 | 29 | 30 | 31 | ); 32 | } 33 | }); 34 | 35 | var Actions = React.createClass({ 36 | render: function() { 37 | return ( 38 | 39 | 40 | Log In 41 | 42 | 43 | Sign Up 44 | 45 | 46 | ); 47 | }, 48 | }); 49 | 50 | var Search = React.createClass({ 51 | render: function() { 52 | return ( 53 | 54 | 55 | 56 | 59 | Search 60 | 61 | 62 | 63 | ); 64 | } 65 | }); 66 | 67 | var Logo = React.createClass({ 68 | render: function() { 69 | return ( 70 | 71 | 75 | 76 | ); 77 | } 78 | }); 79 | 80 | 81 | var MenuList = React.createClass({ 82 | getInitialState: function() { 83 | var getSectionData = (dataBlob, sectionID) => { 84 | return dataBlob[sectionID]; 85 | }; 86 | var getRowData = (dataBlob, sectionID, rowID) => { 87 | return dataBlob[rowID]; 88 | }; 89 | 90 | var dataSource = new ListView.DataSource({ 91 | getRowData: getRowData, 92 | getSectionHeaderData: getSectionData, 93 | rowHasChanged: (row1, row2) => row1 !== row2, 94 | sectionHeaderHasChanged: (s1, s2) => s1 !== s2, 95 | }); 96 | 97 | var dataBlob = {}; 98 | var sectionIDs = []; 99 | var rowIDs = []; 100 | var menuDataList = require('../mock_data/menu_data_list'); 101 | 102 | for (var ii = 0; ii < menuDataList.length; ii++) { 103 | var sectionName = menuDataList[ii].section; 104 | sectionIDs.push(sectionName); 105 | 106 | dataBlob[sectionName] = sectionName; 107 | rowIDs[ii] = []; 108 | 109 | for (var jj = 0; jj < menuDataList[ii].items.length; jj++) { 110 | var rowData = menuDataList[ii].items[jj]; 111 | rowIDs[ii].push(rowData.title); 112 | dataBlob[rowData.title] = rowData; 113 | } 114 | } 115 | 116 | var dataSource = dataSource.cloneWithRowsAndSections(dataBlob, sectionIDs, rowIDs); 117 | 118 | return { dataSource }; 119 | }, 120 | 121 | renderRow: function(rowData: string, sectionID: string, rowID: string): ReactElement { 122 | var activeView = rowID === 'Games' ? { backgroundColor: '#000' } : {}, 123 | activeText = rowID === 'Games' ? { color: '#CCB3FD' } : { color: '#DBDBEA' }, 124 | imageSrc, systemImageStyle = {}; 125 | 126 | if (!rowData.img) { 127 | switch (rowData.systemImg) { 128 | case 'games': 129 | imageSrc = require('image!games'); 130 | break; 131 | case 'channels': 132 | imageSrc = require('image!channels'); 133 | break; 134 | } 135 | } else { 136 | imageSrc = {uri: rowData.img}; 137 | } 138 | 139 | if (sectionID === 'Browse') { 140 | systemImageStyle.width = 30; 141 | systemImageStyle.height = 30; 142 | } 143 | 144 | return ( 145 | this.props.closeDrawer()} 147 | > 148 | 149 | 150 | 155 | 156 | {rowData.title} 157 | 158 | 159 | 160 | 161 | 162 | 163 | ); 164 | }, 165 | 166 | renderSectionHeader: function(sectionData: string, sectionID: string) { 167 | return ( 168 | 169 | 170 | {sectionData.toUpperCase()} 171 | 172 | 173 | ); 174 | }, 175 | 176 | renderFooter: function() { 177 | return ( 178 | 179 | 183 | 184 | Twitch App by Ilja Satchok 185 | 186 | 187 | ); 188 | }, 189 | 190 | render: function() { 191 | return ( 192 | 200 | ); 201 | } 202 | }); 203 | 204 | var imgWidth = 22, 205 | imgHeight = 30; 206 | 207 | var styles = StyleSheet.create({ 208 | container: { 209 | backgroundColor: '#211F27', 210 | flex: 1, 211 | marginRight: DRAWER_OFFSET, 212 | }, 213 | 214 | contentContainer: { 215 | 216 | }, 217 | 218 | scrollView: { 219 | 220 | }, 221 | 222 | listView: { 223 | // backgroundColor: 'red', 224 | }, 225 | 226 | rowView: { 227 | backgroundColor: '#19191F', 228 | flexDirection: 'row', 229 | alignItems: 'center', 230 | paddingVertical: 12, 231 | }, 232 | 233 | rowImg: { 234 | width: imgWidth, 235 | height: imgHeight, 236 | marginHorizontal: 15, 237 | }, 238 | 239 | rowText: { 240 | fontSize: 17, 241 | }, 242 | 243 | sectionView: { 244 | padding: 2, 245 | paddingLeft: 10, 246 | }, 247 | 248 | sectionText: { 249 | color: '#FCFCFC', 250 | fontSize: 15, 251 | fontWeight: '500', 252 | }, 253 | 254 | logoImg: { 255 | width: SCREEN_WIDTH - DRAWER_OFFSET - 100, 256 | height: 100, 257 | marginTop: 15, 258 | }, 259 | 260 | selectedRow: { 261 | backgroundColor: '#1A191F', 262 | }, 263 | 264 | textRow: { 265 | color: '#DAD9E9', 266 | }, 267 | 268 | searchView: { 269 | flexDirection: 'row', 270 | backgroundColor: '#19191F', 271 | padding: 6, 272 | margin: 10, 273 | }, 274 | 275 | searchSeparator: { 276 | backgroundColor: '#19191F', 277 | height: 1 / PixelRatio.get(), 278 | }, 279 | 280 | rowSeparator: { 281 | backgroundColor: '#211F27', 282 | height: 1 / PixelRatio.get(), 283 | }, 284 | 285 | searchText: { 286 | color: '#BFBFBF', 287 | paddingLeft: 5, 288 | // fontSize: 12, 289 | fontWeight: '600', 290 | }, 291 | 292 | actionsView: { 293 | position: 'absolute', 294 | bottom: 0, 295 | left: 0, 296 | right: 0, 297 | 298 | flexDirection: 'row', 299 | justifyContent: 'space-around', 300 | backgroundColor: 'rgba(33,31,39,0.9)', 301 | }, 302 | 303 | actionText: { 304 | color: '#CCB3FD', 305 | fontSize: 17, 306 | }, 307 | 308 | action: { 309 | margin: 12, 310 | }, 311 | }); 312 | 313 | module.exports = DrawerScreen; 314 | -------------------------------------------------------------------------------- /components_scene/GamesScene.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | var React = require('react-native'); 4 | 5 | var { 6 | AppRegistry, 7 | StyleSheet, 8 | Text, 9 | View, 10 | Image, 11 | Animated, 12 | LayoutAnimation, 13 | ScrollView, 14 | NavigatorIOS, 15 | TouchableHighlight, 16 | ActivityIndicatorIOS, 17 | AlertIOS, 18 | StatusBarIOS, 19 | } = React; 20 | 21 | var ChannelsScene = require('./ChannelsScene'), 22 | Game = require('../components/GameItem'); 23 | 24 | var appStore = require('../stores/applicationStore'); 25 | var appConst = require('../constants/applicationConstants'); 26 | var kraken = require('../services/kraken'); 27 | 28 | var GamesScreen = React.createClass({ 29 | getInitialState: function() { 30 | return { 31 | games: [], 32 | playerStatus: appStore.getPlayerStatus(), 33 | drawerStatus: appStore.getDrawerStatus(), 34 | } 35 | }, 36 | 37 | componentDidMount: function() { 38 | appStore.addChangeListener(this._onChange) 39 | 40 | kraken.getGames().then((body) => { 41 | this.setState({ games: body.top }); 42 | }).catch(() => { 43 | AlertIOS.alert('Twitch server error'); 44 | }); 45 | }, 46 | 47 | componentWillUnmount: function() { 48 | appStore.removeChangeListener(this._onChange); 49 | }, 50 | 51 | _onChange: function() { 52 | this.setState({ 53 | playerStatus: appStore.getPlayerStatus(), 54 | drawerStatus: appStore.getDrawerStatus(), 55 | }); 56 | }, 57 | 58 | _onPressGame: function(game) { 59 | if (this.state.drawerStatus) { 60 | return this.props.closeDrawer(); 61 | } 62 | 63 | this.props.navigator.push({ 64 | title: game.name, 65 | component: ChannelsScene, 66 | passProps: { game }, 67 | }); 68 | }, 69 | 70 | renderGame: function(item) { 71 | var game = item.game; 72 | return this._onPressGame(game) }/> 73 | }, 74 | 75 | renderGames: function() { 76 | return this.state.games.map(this.renderGame); 77 | }, 78 | 79 | render: function() { 80 | var marginTop = ( 81 | this.state.playerStatus === appConst.PLAYER_SUSPEND || 82 | this.state.playerStatus === appConst.PLAYER_ON ) ? 65 : 0; 83 | 84 | return ( 85 | 86 | {this.state.games.length ? this.renderGames() : } 89 | 90 | ); 91 | } 92 | }); 93 | 94 | var styles = StyleSheet.create({ 95 | container: { 96 | flexDirection: 'row', 97 | flexWrap: 'wrap', 98 | 99 | paddingBottom: 10, 100 | }, 101 | centering: { 102 | flex: 1, 103 | height: 80, 104 | alignItems: 'center', 105 | justifyContent: 'center', 106 | }, 107 | }); 108 | 109 | module.exports = GamesScreen; 110 | -------------------------------------------------------------------------------- /components_scene/StreamScene.js: -------------------------------------------------------------------------------- 1 | /* @flow */ 2 | 'use strict'; 3 | 4 | var React = require('react-native'); 5 | 6 | var Dimensions = require('Dimensions'); 7 | var SCREEN_WIDTH = Dimensions.get('window').width, 8 | ratio = 320 / 180; 9 | 10 | var { getRandomColor } = require('../utils'); 11 | 12 | var { 13 | StyleSheet, 14 | View, 15 | Image, 16 | ScrollView, 17 | Text, 18 | } = React; 19 | 20 | var appActions = require('../actions/applicationActions'); 21 | var appConst = require('../constants/applicationConstants'); 22 | 23 | var StreamScreen = React.createClass({ 24 | getInitialState: function() { 25 | var msgs = require('../mock_data/msgs'); 26 | return { 27 | msgs: msgs.concat(msgs).concat(msgs) 28 | }; 29 | }, 30 | 31 | componentWillUnmount: function() { 32 | appActions.setPlayerStatus(appConst.PLAYER_ON, this.props.stream); 33 | }, 34 | 35 | renderMsg: function(message, index) { 36 | return ( 37 | 38 | 39 | {'@'}{message.name}{': '} 40 | {message.text} 41 | 42 | 43 | ) 44 | }, 45 | 46 | render: function() { 47 | 48 | return ( 49 | 50 | 51 | 56 | 57 | 60 | {this.state.msgs.map(this.renderMsg)} 61 | 62 | 63 | ); 64 | } 65 | }); 66 | 67 | 68 | var styles = StyleSheet.create({ 69 | container: { 70 | marginTop: 64, 71 | flex: 1, 72 | position: 'relative' 73 | }, 74 | 75 | mainImgView: { 76 | 77 | }, 78 | 79 | mainImg: { 80 | width: SCREEN_WIDTH, 81 | height: SCREEN_WIDTH / ratio, 82 | backgroundColor: 'grey', 83 | }, 84 | 85 | messagesView: { 86 | // marginTop: -64, 87 | }, 88 | 89 | messageContainer: { 90 | // flexDirection: 'row', 91 | marginLeft: 10, 92 | marginRight: 10, 93 | } 94 | 95 | }); 96 | 97 | module.exports = StreamScreen; 98 | -------------------------------------------------------------------------------- /constants/applicationConstants.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | var keyMirror = require('keyMirror'); 4 | var assign = require('object-assign'); 5 | 6 | var consts = keyMirror({ 7 | 8 | SET_PLAYER_STREAM: null, 9 | SET_PLAYER_STATUS: null, 10 | SET_CHANNEL_ITEMS_VIEW: null, 11 | 12 | SET_DRAWER_STATUS: null, 13 | 14 | PLAYER_OFF: null, 15 | PLAYER_ON: null, 16 | PLAYER_SUSPEND: null, 17 | 18 | GRID_LIST: null, 19 | GRID: null, 20 | LIST: null, 21 | }); 22 | 23 | module.exports = assign(consts, { 24 | DRAWER_OFFSET: 60, 25 | }); 26 | -------------------------------------------------------------------------------- /iOS/AppDelegate.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015-present, Facebook, Inc. 3 | * All rights reserved. 4 | * 5 | * This source code is licensed under the BSD-style license found in the 6 | * LICENSE file in the root directory of this source tree. An additional grant 7 | * of patent rights can be found in the PATENTS file in the same directory. 8 | */ 9 | 10 | #import 11 | 12 | @interface AppDelegate : UIResponder 13 | 14 | @property (nonatomic, strong) UIWindow *window; 15 | 16 | @end 17 | -------------------------------------------------------------------------------- /iOS/AppDelegate.m: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015-present, Facebook, Inc. 3 | * All rights reserved. 4 | * 5 | * This source code is licensed under the BSD-style license found in the 6 | * LICENSE file in the root directory of this source tree. An additional grant 7 | * of patent rights can be found in the PATENTS file in the same directory. 8 | */ 9 | 10 | #import "AppDelegate.h" 11 | 12 | #import "RCTRootView.h" 13 | 14 | @implementation AppDelegate 15 | 16 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions 17 | { 18 | NSURL *jsCodeLocation; 19 | 20 | /** 21 | * Loading JavaScript code - uncomment the one you want. 22 | * 23 | * OPTION 1 24 | * Load from development server. Start the server from the repository root: 25 | * 26 | * $ npm start 27 | * 28 | * To run on device, change `localhost` to the IP address of your computer 29 | * (you can get this by typing `ifconfig` into the terminal and selecting the 30 | * `inet` value under `en0:`) and make sure your computer and iOS device are 31 | * on the same Wi-Fi network. 32 | */ 33 | 34 | jsCodeLocation = [NSURL URLWithString:@"http://localhost:8081/index.ios.bundle?platform=ios&dev=true"]; 35 | 36 | /** 37 | * OPTION 2 38 | * Load from pre-bundled file on disk. To re-generate the static bundle 39 | * from the root of your project directory, run 40 | * 41 | * $ react-native bundle --minify 42 | * 43 | * see http://facebook.github.io/react-native/docs/runningondevice.html 44 | */ 45 | 46 | // jsCodeLocation = [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"]; 47 | 48 | RCTRootView *rootView = [[RCTRootView alloc] initWithBundleURL:jsCodeLocation 49 | moduleName:@"twitch" 50 | initialProperties:nil 51 | launchOptions:launchOptions]; 52 | 53 | self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds]; 54 | UIViewController *rootViewController = [[UIViewController alloc] init]; 55 | rootViewController.view = rootView; 56 | self.window.rootViewController = rootViewController; 57 | [self.window makeKeyAndVisible]; 58 | return YES; 59 | } 60 | 61 | @end 62 | -------------------------------------------------------------------------------- /iOS/Base.lproj/LaunchScreen.xib: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 21 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | -------------------------------------------------------------------------------- /iOS/Images.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "29x29", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "29x29", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "40x40", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "40x40", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "60x60", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "60x60", 31 | "scale" : "3x" 32 | } 33 | ], 34 | "info" : { 35 | "version" : 1, 36 | "author" : "xcode" 37 | } 38 | } -------------------------------------------------------------------------------- /iOS/Images.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "version" : 1, 4 | "author" : "xcode" 5 | } 6 | } -------------------------------------------------------------------------------- /iOS/Images.xcassets/Games.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "games.png", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "filename" : "games-1.png", 11 | "scale" : "2x" 12 | }, 13 | { 14 | "idiom" : "universal", 15 | "filename" : "games-2.png", 16 | "scale" : "3x" 17 | } 18 | ], 19 | "info" : { 20 | "version" : 1, 21 | "author" : "xcode" 22 | } 23 | } -------------------------------------------------------------------------------- /iOS/Images.xcassets/Games.imageset/games-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ifours/react-native-twitch/b5d22d1b029220c34d3075119c3591846e095e56/iOS/Images.xcassets/Games.imageset/games-1.png -------------------------------------------------------------------------------- /iOS/Images.xcassets/Games.imageset/games-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ifours/react-native-twitch/b5d22d1b029220c34d3075119c3591846e095e56/iOS/Images.xcassets/Games.imageset/games-2.png -------------------------------------------------------------------------------- /iOS/Images.xcassets/Games.imageset/games.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ifours/react-native-twitch/b5d22d1b029220c34d3075119c3591846e095e56/iOS/Images.xcassets/Games.imageset/games.png -------------------------------------------------------------------------------- /iOS/Images.xcassets/active_channels.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "active_channels.png", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "filename" : "active_channels-1.png", 11 | "scale" : "2x" 12 | }, 13 | { 14 | "idiom" : "universal", 15 | "filename" : "active_channels-2.png", 16 | "scale" : "3x" 17 | } 18 | ], 19 | "info" : { 20 | "version" : 1, 21 | "author" : "xcode" 22 | } 23 | } -------------------------------------------------------------------------------- /iOS/Images.xcassets/active_channels.imageset/active_channels-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ifours/react-native-twitch/b5d22d1b029220c34d3075119c3591846e095e56/iOS/Images.xcassets/active_channels.imageset/active_channels-1.png -------------------------------------------------------------------------------- /iOS/Images.xcassets/active_channels.imageset/active_channels-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ifours/react-native-twitch/b5d22d1b029220c34d3075119c3591846e095e56/iOS/Images.xcassets/active_channels.imageset/active_channels-2.png -------------------------------------------------------------------------------- /iOS/Images.xcassets/active_channels.imageset/active_channels.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ifours/react-native-twitch/b5d22d1b029220c34d3075119c3591846e095e56/iOS/Images.xcassets/active_channels.imageset/active_channels.png -------------------------------------------------------------------------------- /iOS/Images.xcassets/boxart.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "boxart.png", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "filename" : "boxart-1.png", 11 | "scale" : "2x" 12 | }, 13 | { 14 | "idiom" : "universal", 15 | "filename" : "boxart-2.png", 16 | "scale" : "3x" 17 | } 18 | ], 19 | "info" : { 20 | "version" : 1, 21 | "author" : "xcode" 22 | } 23 | } -------------------------------------------------------------------------------- /iOS/Images.xcassets/boxart.imageset/boxart-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ifours/react-native-twitch/b5d22d1b029220c34d3075119c3591846e095e56/iOS/Images.xcassets/boxart.imageset/boxart-1.png -------------------------------------------------------------------------------- /iOS/Images.xcassets/boxart.imageset/boxart-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ifours/react-native-twitch/b5d22d1b029220c34d3075119c3591846e095e56/iOS/Images.xcassets/boxart.imageset/boxart-2.png -------------------------------------------------------------------------------- /iOS/Images.xcassets/boxart.imageset/boxart.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ifours/react-native-twitch/b5d22d1b029220c34d3075119c3591846e095e56/iOS/Images.xcassets/boxart.imageset/boxart.png -------------------------------------------------------------------------------- /iOS/Images.xcassets/channels.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "channels.png", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "filename" : "channels-1.png", 11 | "scale" : "2x" 12 | }, 13 | { 14 | "idiom" : "universal", 15 | "filename" : "channels-2.png", 16 | "scale" : "3x" 17 | } 18 | ], 19 | "info" : { 20 | "version" : 1, 21 | "author" : "xcode" 22 | } 23 | } -------------------------------------------------------------------------------- /iOS/Images.xcassets/channels.imageset/channels-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ifours/react-native-twitch/b5d22d1b029220c34d3075119c3591846e095e56/iOS/Images.xcassets/channels.imageset/channels-1.png -------------------------------------------------------------------------------- /iOS/Images.xcassets/channels.imageset/channels-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ifours/react-native-twitch/b5d22d1b029220c34d3075119c3591846e095e56/iOS/Images.xcassets/channels.imageset/channels-2.png -------------------------------------------------------------------------------- /iOS/Images.xcassets/channels.imageset/channels.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ifours/react-native-twitch/b5d22d1b029220c34d3075119c3591846e095e56/iOS/Images.xcassets/channels.imageset/channels.png -------------------------------------------------------------------------------- /iOS/Images.xcassets/recent.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "recent-1.png", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "filename" : "recent-2.png", 11 | "scale" : "2x" 12 | }, 13 | { 14 | "idiom" : "universal", 15 | "filename" : "recent.png", 16 | "scale" : "3x" 17 | } 18 | ], 19 | "info" : { 20 | "version" : 1, 21 | "author" : "xcode" 22 | } 23 | } -------------------------------------------------------------------------------- /iOS/Images.xcassets/recent.imageset/recent-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ifours/react-native-twitch/b5d22d1b029220c34d3075119c3591846e095e56/iOS/Images.xcassets/recent.imageset/recent-1.png -------------------------------------------------------------------------------- /iOS/Images.xcassets/recent.imageset/recent-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ifours/react-native-twitch/b5d22d1b029220c34d3075119c3591846e095e56/iOS/Images.xcassets/recent.imageset/recent-2.png -------------------------------------------------------------------------------- /iOS/Images.xcassets/recent.imageset/recent.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ifours/react-native-twitch/b5d22d1b029220c34d3075119c3591846e095e56/iOS/Images.xcassets/recent.imageset/recent.png -------------------------------------------------------------------------------- /iOS/Images.xcassets/tabnav_list.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "tabnav_list.png", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "filename" : "tabnav_list-1.png", 11 | "scale" : "2x" 12 | }, 13 | { 14 | "idiom" : "universal", 15 | "filename" : "tabnav_list-2.png", 16 | "scale" : "3x" 17 | } 18 | ], 19 | "info" : { 20 | "version" : 1, 21 | "author" : "xcode" 22 | } 23 | } -------------------------------------------------------------------------------- /iOS/Images.xcassets/tabnav_list.imageset/tabnav_list-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ifours/react-native-twitch/b5d22d1b029220c34d3075119c3591846e095e56/iOS/Images.xcassets/tabnav_list.imageset/tabnav_list-1.png -------------------------------------------------------------------------------- /iOS/Images.xcassets/tabnav_list.imageset/tabnav_list-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ifours/react-native-twitch/b5d22d1b029220c34d3075119c3591846e095e56/iOS/Images.xcassets/tabnav_list.imageset/tabnav_list-2.png -------------------------------------------------------------------------------- /iOS/Images.xcassets/tabnav_list.imageset/tabnav_list.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ifours/react-native-twitch/b5d22d1b029220c34d3075119c3591846e095e56/iOS/Images.xcassets/tabnav_list.imageset/tabnav_list.png -------------------------------------------------------------------------------- /iOS/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | org.reactjs.native.example.$(PRODUCT_NAME:rfc1034identifier) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | LSRequiresIPhoneOS 24 | 25 | NSAppTransportSecurity 26 | 27 | NSAllowsArbitraryLoads 28 | 29 | 30 | NSLocationWhenInUseUsageDescription 31 | 32 | UILaunchStoryboardName 33 | LaunchScreen 34 | UIRequiredDeviceCapabilities 35 | 36 | armv7 37 | 38 | UISupportedInterfaceOrientations 39 | 40 | UIInterfaceOrientationPortrait 41 | 42 | UIViewControllerBasedStatusBarAppearance 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /iOS/main.m: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015-present, Facebook, Inc. 3 | * All rights reserved. 4 | * 5 | * This source code is licensed under the BSD-style license found in the 6 | * LICENSE file in the root directory of this source tree. An additional grant 7 | * of patent rights can be found in the PATENTS file in the same directory. 8 | */ 9 | 10 | #import 11 | 12 | #import "AppDelegate.h" 13 | 14 | int main(int argc, char * argv[]) { 15 | @autoreleasepool { 16 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /index.ios.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | var React = require('react-native'), 4 | Drawer = require('./vendor/react-native-drawer'); 5 | 6 | var DrawerScene = require('./components_scene/DrawerScene'), 7 | Player = require('./components/Player'), 8 | GamesScene = require('./components_scene/GamesScene'); 9 | 10 | var { 11 | AppRegistry, 12 | StyleSheet, 13 | Text, 14 | View, 15 | Image, 16 | ScrollView, 17 | NavigatorIOS, 18 | TouchableHighlight, 19 | StatusBarIOS, 20 | } = React; 21 | 22 | var applicationStore = require('./stores/applicationStore'), 23 | applicationActions = require('./actions/applicationActions'), 24 | { DRAWER_OFFSET } = require('./constants/applicationConstants'); 25 | 26 | StatusBarIOS.setStyle('light-content'); 27 | 28 | var MainView = React.createClass({ 29 | getInitialState: function() { 30 | return { 31 | playerStream: applicationStore.getPlayerStream(), 32 | isDrawerOpened: applicationStore.getDrawerStatus() 33 | }; 34 | }, 35 | 36 | componentDidMount: function() { 37 | applicationStore.addChangeListener(this._onChange); 38 | }, 39 | 40 | componentWillUnmount: function() { 41 | applicationStore.removeChangeListener(this._onChange); 42 | }, 43 | 44 | _onChange: function() { 45 | this.setState({ 46 | playerStream: applicationStore.getPlayerStream(), 47 | isDrawerOpened: applicationStore.getDrawerStatus(), 48 | }); 49 | }, 50 | 51 | renderPlayer: function() { 52 | if (!this.state.playerStream) { 53 | return null; 54 | } 55 | return ( 56 | 57 | ); 58 | }, 59 | 60 | render: function() { 61 | 62 | return ( 63 | 64 | { 74 | this.state.isDrawerOpened ? this.props.closeDrawer() : this.props.openDrawer() 75 | }, 76 | passProps: { 77 | closeDrawer: this.props.closeDrawer, 78 | }, 79 | }} /> 80 | {this.renderPlayer()} 81 | 82 | ); 83 | } 84 | }); 85 | 86 | var App = React.createClass({ 87 | getInitialState: function() { 88 | return { 89 | isDrawerOpened: applicationStore.getDrawerStatus() 90 | }; 91 | }, 92 | 93 | componentDidMount: function() { 94 | applicationStore.addChangeListener(this._onChange); 95 | }, 96 | 97 | componentWillUnmount: function() { 98 | applicationStore.removeChangeListener(this._onChange); 99 | }, 100 | 101 | _onChange: function() { 102 | this.setState({ isDrawerOpened: applicationStore.getDrawerStatus() }); 103 | }, 104 | 105 | closeDrawer: function() { 106 | applicationActions.setDrawerStatus(false); 107 | this.refs.drawer.close(); 108 | }, 109 | 110 | openDrawer: function() { 111 | applicationActions.setDrawerStatus(true); 112 | this.refs.drawer.open(); 113 | }, 114 | 115 | setDrawerState: function(value) { 116 | this.setState({ isDrawerOpened: value }); 117 | }, 118 | 119 | render: function() { 120 | return ( 121 | this.setDrawerState(true)} 126 | onClose={() => this.setDrawerState(false)} 127 | content={} > 128 | 129 | 134 | 135 | ); 136 | } 137 | }); 138 | 139 | AppRegistry.registerComponent('twitch', () => App); 140 | -------------------------------------------------------------------------------- /mock_data/games.json: -------------------------------------------------------------------------------- 1 | [ 2 | { "uri": "http://static-cdn.jtvnw.net/ttv-boxart/Hearthstone:%20Heroes%20of%20Warcraft-272x380.jpg", "key": 0, "name": "Hearthstone: Heroes of Warcraft"}, 3 | { "uri": "http://static-cdn.jtvnw.net/ttv-boxart/Counter-Strike:%20Global%20Offensive-272x380.jpg", "key": 1, "name": "Counter-Strike: Global Offensive"}, 4 | { "uri": "http://static-cdn.jtvnw.net/ttv-boxart/Dota%202-272x380.jpg", "key": 2, "name": "Dota 2"}, 5 | { "uri": "http://static-cdn.jtvnw.net/ttv-boxart/League%20of%20Legends-272x380.jpg", "key": 3, "name": "League of Legends"}, 6 | { "uri": "http://static-cdn.jtvnw.net/ttv-boxart/StarCraft%20II-272x380.jpg", "key": 4, "name": "StarCraft 2"}, 7 | { "uri": "http://static-cdn.jtvnw.net/ttv-boxart/World%20of%20Warcraft-272x380.jpg", "key": 5, "name": "World of Warcraft"}, 8 | { "uri": "http://static-cdn.jtvnw.net/ttv-boxart/World%20of%20Tanks-272x380.jpg", "key": 6, "name": "World of Tanks"}, 9 | { "uri": "http://static-cdn.jtvnw.net/ttv-boxart/Grand%20Theft%20Auto%20V-272x380.jpg", "key": 7, "name": "Grand Theft Auto"}, 10 | { "uri": "http://static-cdn.jtvnw.net/ttv-boxart/Destiny-272x380.jpg", "key": 8, "name": "Destiny"}, 11 | { "uri": "http://static-cdn.jtvnw.net/ttv-boxart/RuneScape-272x380.jpg", "key": 9, "name": "RuneScape"} 12 | ] 13 | -------------------------------------------------------------------------------- /mock_data/menu_data_list.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "section": "Watch", 4 | "items": [ 5 | { "img": "http://xstream.net/sites/default/files/Icon_game_console.png", "title": "Games" }, 6 | { "img": "http://www.3visiondistribution.com/uploads/images/tv-icon.png", "title": "Channels" }, 7 | ], 8 | }, 9 | { 10 | "section": "Promoted games", 11 | "items": [ 12 | { "img": "http://static-cdn.jtvnw.net/ttv-boxart/League%20of%20Legends-140x196.jpg", "title": "League of Legends" }, 13 | { "img": "http://static-cdn.jtvnw.net/ttv-boxart/Hearthstone:%20Heroes%20of%20Warcraft-140x196.jpg", "title": "Hearthstone" }, 14 | { "img": "http://static-cdn.jtvnw.net/ttv-boxart/Dota%202-140x196.jpg", "title": "Dota 2" }, 15 | { "img": "http://static-cdn.jtvnw.net/ttv-boxart/Counter-Strike:%20Global%20Offensive-140x196.jpg", "title": "Counter-Strike" }, 16 | { "img": "http://static-cdn.jtvnw.net/ttv-boxart/StarCraft%20II-140x196.jpg", "title": "StarCraft 2" }, 17 | { "img": "http://static-cdn.jtvnw.net/ttv-boxart/Heroes%20of%20the%20Storm-140x196.jpg", "title": "Heroes of the Storm" }, 18 | ] 19 | }, 20 | { 21 | "section": "Promoted channels", 22 | "items": [ 23 | { "img": "http://static-cdn.jtvnw.net/jtv_user_pictures/riotgames-profile_image-4be3ad99629ac9ba-300x300.jpeg", "title": "Riot Games" }, 24 | { "img": "http://static-cdn.jtvnw.net/jtv_user_pictures/emstarcraft-profile_image-340ca92c394d06e5-300x300.jpeg", "title": "FinestKO" }, 25 | { "img": "http://static-cdn.jtvnw.net/jtv_user_pictures/disstream-profile_image-49cb71b9ba541dcf-300x300.png", "title": "Ellhime" }, 26 | { "img": "http://static-cdn.jtvnw.net/jtv_user_pictures/riotgames-profile_image-4be3ad99629ac9ba-300x300.jpeg", "title": "WolfsGoRawr" }, 27 | { "img": "http://static-cdn.jtvnw.net/jtv_user_pictures/emstarcraft-profile_image-340ca92c394d06e5-300x300.jpeg", "title": "DethridgeCraft" }, 28 | { "img": "http://static-cdn.jtvnw.net/jtv_user_pictures/disstream-profile_image-49cb71b9ba541dcf-300x300.png", "title": "CohhCarnage" }, 29 | ] 30 | } 31 | ] -------------------------------------------------------------------------------- /mock_data/msgs.json: -------------------------------------------------------------------------------- 1 | [ 2 | { "name": "Hazzdota", "text": "Lorem ipsum dolor sit amet" }, 3 | { "name": "5chief", "text": "consectetur adipisicing elit" }, 4 | { "name": "Zitraff", "text": "ed do eiusmod tempor incididunt ut" }, 5 | { "name": "Dubbyman", "text": "labore et dolore" }, 6 | { "name": "Borgg", "text": "magna aliqua. Ut enim ad minim veniam" }, 7 | { "name": "Titan", "text": "quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo" }, 8 | { "name": "BigDaddy", "text": "consequat. Duis aute irure dolor in reprehenderit" }, 9 | { "name": "Frommet", "text": "in voluptate velit esse" }, 10 | { "name": "Rolling", "text": "cillum dolore eu fugiat nulla pariatur" }, 11 | { "name": "Scropes", "text": "xcepteur sint occaecat cupidatat" }, 12 | { "name": "React", "text": "non" }, 13 | { "name": "Native", "text": "proident, sunt in culpa qui officia deserunt mollit anim id est laborum" }, 14 | ] -------------------------------------------------------------------------------- /mock_data/streams.json: -------------------------------------------------------------------------------- 1 | [ 2 | { "uri": "http://static-cdn.jtvnw.net/previews-ttv/live_user_tempo_storm-320x180.jpg", "key": 0, "title": "BLOODBORNE - FINISH THE FIGHT", "views": "4 678", "streamer": "SoulDM", "name": "SK Zelatoto - New Season" }, 3 | { "uri": "http://static-cdn.jtvnw.net/previews-ttv/live_user_amazhs-320x180.jpg", "key": 1, "title": "New Build !Vote http://mugenmonkey.com/bloodborne/4126 OR http://mugenmonkey.com/bloodborne/4503", "views": "4 678", "streamer": "SoulDM", "name": "SK Zelatoto - New Season" }, 4 | { "uri": "http://static-cdn.jtvnw.net/previews-ttv/live_user_thijshs-320x180.jpg", "key": 2, "title": "Level 4 no death run attempts", "views": "4 678", "streamer": "SoulDM", "name": "SK Zelatoto - New Season" }, 5 | { "uri": "http://static-cdn.jtvnw.net/previews-ttv/live_user_nightblue3-320x180.jpg", "key": 3, "title": "Bloodborne - New Game, New Character, New Class, New Story", "views": "4 678", "streamer": "SoulDM", "name": "SK Zelatoto - New Season" }, 6 | 7 | { "uri": "http://static-cdn.jtvnw.net/previews-ttv/live_user_lvpes-320x180.jpg", "key": 10, "title": "Destiny Year Two Reveal", "views": "244 520", "streamer": "SoulDM", "name": "SK Zelatoto - New Season" }, 8 | { "uri": "http://static-cdn.jtvnw.net/previews-ttv/live_user_milleniumtvlol-320x180.jpg", "key": 11, "title": "Directo de Bungie | El Rey de los Poseídos", "views": "244 520", "streamer": "SoulDM", "name": "SK Zelatoto - New Season" }, 9 | { "uri": "http://static-cdn.jtvnw.net/previews-ttv/live_user_demuslim-320x180.jpg", "key": 12, "title": "QC-FR Commentaire sur le Live Stream", "views": "244 520", "streamer": "SoulDM", "name": "SK Zelatoto - New Season" }, 10 | { "uri": "http://static-cdn.jtvnw.net/previews-ttv/live_user_basetradetv-320x180.jpg", "key": 13, "title": "BUNGIE Re`stream...Ger", "views": "244 520", "streamer": "SoulDM", "name": "SK Zelatoto - New Season" }, 11 | { "uri": "http://static-cdn.jtvnw.net/previews-ttv/live_user_starladder1-320x180.jpg", "key": 14, "title": "Taken King Reveal LIVE", "views": "244 520", "streamer": "SoulDM", "name": "SK Zelatoto - New Season" }, 12 | { "uri": "http://static-cdn.jtvnw.net/previews-ttv/live_user_followkudes-320x180.jpg", "key": 15, "title": "Destiny Year Two Reveal", "views": "244 520", "streamer": "SoulDM", "name": "SK Zelatoto - New Season" }, 13 | ] -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "react-native-twitch", 3 | "version": "0.1.0", 4 | "private": true, 5 | "scripts": { 6 | "start": "node_modules/react-native/packager/packager.sh" 7 | }, 8 | "dependencies": { 9 | "events": "^1.1.0", 10 | "flux": "^2.1.1", 11 | "keymirror": "^0.1.1", 12 | "object-assign": "^4.0.1", 13 | "react-native": "^0.15.0", 14 | "react-native-drawer": "^1.8.0", 15 | "react-native-linear-gradient": "^1.1.0-alpha", 16 | "tween-functions": "^1.2.0" 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /services/kraken.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | const BASE_URL = 'https://api.twitch.tv/kraken'; 4 | 5 | class Kraken { 6 | constructor() { 7 | this._urls = {}; 8 | this.accept = 'application/vnd.twitchtv.v3+json'; 9 | 10 | this._urls.games = `${BASE_URL}/games/top`; 11 | this._urls.streams = `${BASE_URL}/streams`; 12 | } 13 | 14 | async getGames() { 15 | let response = await fetch(this._urls.games); 16 | let body = await response.json(); 17 | 18 | return body; 19 | } 20 | 21 | async getStreams(game) { 22 | let response = await fetch(`${this._urls.streams}?game=${encodeURIComponent(game)}&limit=15`); 23 | let body = await response.json(); 24 | 25 | return body; 26 | } 27 | } 28 | 29 | export default new Kraken(); 30 | -------------------------------------------------------------------------------- /stores/applicationStore.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | var dispatcher = require('../AppDispatcher'), 4 | EventEmitter = require('events'), 5 | assign = require('object-assign'); 6 | 7 | var constants = require('../constants/applicationConstants'); 8 | 9 | var EVENT = 'fromApplicationStore'; 10 | 11 | 12 | // TODO: 13 | var _state = { 14 | playerStream: null, 15 | playerStatus: constants.PLAYER_OFF, 16 | isDrawerOpened: false, 17 | channelItemsViewType: constants.GRID_LIST, 18 | }; 19 | 20 | var store = assign({}, EventEmitter.prototype, { 21 | getState: function() { 22 | return _state; 23 | }, 24 | 25 | getPlayerStatus: function() { 26 | return _state.playerStatus; 27 | }, 28 | 29 | getPlayerStream: function() { 30 | return _state.playerStream; 31 | }, 32 | 33 | getChannelItemsView: function() { 34 | return _state.channelItemsViewType; 35 | }, 36 | 37 | getDrawerStatus: function() { 38 | return _state.isDrawerOpened; 39 | }, 40 | 41 | 42 | emitChange: function() { 43 | this.emit(EVENT); 44 | }, 45 | 46 | addChangeListener: function(callback) { 47 | this.on(EVENT, callback); 48 | }, 49 | 50 | removeChangeListener: function(callback) { 51 | this.removeListener(EVENT, callback); 52 | }, 53 | 54 | 55 | dispatchToken: dispatcher.register(function(action) { 56 | switch(action.actionType) { 57 | 58 | case constants.SET_PLAYER_STREAM: 59 | _state.playerStream = action.value; 60 | store.emitChange(); 61 | break; 62 | 63 | case constants.SET_CHANNEL_ITEMS_VIEW: 64 | _state.channelItemsViewType = action.type; 65 | store.emitChange(); 66 | break; 67 | 68 | case constants.SET_PLAYER_STATUS: 69 | _state.playerStatus = action.status; 70 | _state.playerStream = action.stream || null; 71 | 72 | store.emitChange(); 73 | break; 74 | 75 | case constants.SET_DRAWER_STATUS: 76 | _state.isDrawerOpened = action.value; 77 | 78 | store.emitChange(); 79 | break; 80 | } 81 | }), 82 | }); 83 | 84 | module.exports = store; 85 | -------------------------------------------------------------------------------- /twitch.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 008F07F31AC5B25A0029DE68 /* main.jsbundle in Resources */ = {isa = PBXBuildFile; fileRef = 008F07F21AC5B25A0029DE68 /* main.jsbundle */; }; 11 | 00C302E51ABCBA2D00DB3ED1 /* libRCTActionSheet.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 00C302AC1ABCB8CE00DB3ED1 /* libRCTActionSheet.a */; }; 12 | 00C302E71ABCBA2D00DB3ED1 /* libRCTGeolocation.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 00C302BA1ABCB90400DB3ED1 /* libRCTGeolocation.a */; }; 13 | 00C302E81ABCBA2D00DB3ED1 /* libRCTImage.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 00C302C01ABCB91800DB3ED1 /* libRCTImage.a */; }; 14 | 00C302E91ABCBA2D00DB3ED1 /* libRCTNetwork.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 00C302DC1ABCB9D200DB3ED1 /* libRCTNetwork.a */; }; 15 | 00C302EA1ABCBA2D00DB3ED1 /* libRCTVibration.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 00C302E41ABCB9EE00DB3ED1 /* libRCTVibration.a */; }; 16 | 133E29F31AD74F7200F7D852 /* libRCTLinking.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 78C398B91ACF4ADC00677621 /* libRCTLinking.a */; }; 17 | 139105C61AF99C1200B5F7CC /* libRCTSettings.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 139105C11AF99BAD00B5F7CC /* libRCTSettings.a */; }; 18 | 139FDEF61B0652A700C62182 /* libRCTWebSocket.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 139FDEF41B06529B00C62182 /* libRCTWebSocket.a */; }; 19 | 13B07FBC1A68108700A75B9A /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 13B07FB01A68108700A75B9A /* AppDelegate.m */; }; 20 | 13B07FBD1A68108700A75B9A /* LaunchScreen.xib in Resources */ = {isa = PBXBuildFile; fileRef = 13B07FB11A68108700A75B9A /* LaunchScreen.xib */; }; 21 | 13B07FBF1A68108700A75B9A /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 13B07FB51A68108700A75B9A /* Images.xcassets */; }; 22 | 13B07FC11A68108700A75B9A /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 13B07FB71A68108700A75B9A /* main.m */; }; 23 | 146834051AC3E58100842450 /* libReact.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 146834041AC3E56700842450 /* libReact.a */; }; 24 | 832341BD1AAA6AB300B99B32 /* libRCTText.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 832341B51AAA6A8300B99B32 /* libRCTText.a */; }; 25 | AFFCDBCB1BBF23F800E76614 /* libBVLinearGradient.a in Frameworks */ = {isa = PBXBuildFile; fileRef = AFFCDBC01BBF23A900E76614 /* libBVLinearGradient.a */; }; 26 | /* End PBXBuildFile section */ 27 | 28 | /* Begin PBXContainerItemProxy section */ 29 | 00C302AB1ABCB8CE00DB3ED1 /* PBXContainerItemProxy */ = { 30 | isa = PBXContainerItemProxy; 31 | containerPortal = 00C302A71ABCB8CE00DB3ED1 /* RCTActionSheet.xcodeproj */; 32 | proxyType = 2; 33 | remoteGlobalIDString = 134814201AA4EA6300B7C361; 34 | remoteInfo = RCTActionSheet; 35 | }; 36 | 00C302B91ABCB90400DB3ED1 /* PBXContainerItemProxy */ = { 37 | isa = PBXContainerItemProxy; 38 | containerPortal = 00C302B51ABCB90400DB3ED1 /* RCTGeolocation.xcodeproj */; 39 | proxyType = 2; 40 | remoteGlobalIDString = 134814201AA4EA6300B7C361; 41 | remoteInfo = RCTGeolocation; 42 | }; 43 | 00C302BF1ABCB91800DB3ED1 /* PBXContainerItemProxy */ = { 44 | isa = PBXContainerItemProxy; 45 | containerPortal = 00C302BB1ABCB91800DB3ED1 /* RCTImage.xcodeproj */; 46 | proxyType = 2; 47 | remoteGlobalIDString = 58B5115D1A9E6B3D00147676; 48 | remoteInfo = RCTImage; 49 | }; 50 | 00C302DB1ABCB9D200DB3ED1 /* PBXContainerItemProxy */ = { 51 | isa = PBXContainerItemProxy; 52 | containerPortal = 00C302D31ABCB9D200DB3ED1 /* RCTNetwork.xcodeproj */; 53 | proxyType = 2; 54 | remoteGlobalIDString = 58B511DB1A9E6C8500147676; 55 | remoteInfo = RCTNetwork; 56 | }; 57 | 00C302E31ABCB9EE00DB3ED1 /* PBXContainerItemProxy */ = { 58 | isa = PBXContainerItemProxy; 59 | containerPortal = 00C302DF1ABCB9EE00DB3ED1 /* RCTVibration.xcodeproj */; 60 | proxyType = 2; 61 | remoteGlobalIDString = 832C81801AAF6DEF007FA2F7; 62 | remoteInfo = RCTVibration; 63 | }; 64 | 139105C01AF99BAD00B5F7CC /* PBXContainerItemProxy */ = { 65 | isa = PBXContainerItemProxy; 66 | containerPortal = 139105B61AF99BAD00B5F7CC /* RCTSettings.xcodeproj */; 67 | proxyType = 2; 68 | remoteGlobalIDString = 134814201AA4EA6300B7C361; 69 | remoteInfo = RCTSettings; 70 | }; 71 | 139FDEF31B06529B00C62182 /* PBXContainerItemProxy */ = { 72 | isa = PBXContainerItemProxy; 73 | containerPortal = 139FDEE61B06529A00C62182 /* RCTWebSocket.xcodeproj */; 74 | proxyType = 2; 75 | remoteGlobalIDString = 3C86DF461ADF2C930047B81A; 76 | remoteInfo = RCTWebSocket; 77 | }; 78 | 146834031AC3E56700842450 /* PBXContainerItemProxy */ = { 79 | isa = PBXContainerItemProxy; 80 | containerPortal = 146833FF1AC3E56700842450 /* React.xcodeproj */; 81 | proxyType = 2; 82 | remoteGlobalIDString = 83CBBA2E1A601D0E00E9B192; 83 | remoteInfo = React; 84 | }; 85 | 78C398B81ACF4ADC00677621 /* PBXContainerItemProxy */ = { 86 | isa = PBXContainerItemProxy; 87 | containerPortal = 78C398B01ACF4ADC00677621 /* RCTLinking.xcodeproj */; 88 | proxyType = 2; 89 | remoteGlobalIDString = 134814201AA4EA6300B7C361; 90 | remoteInfo = RCTLinking; 91 | }; 92 | 832341B41AAA6A8300B99B32 /* PBXContainerItemProxy */ = { 93 | isa = PBXContainerItemProxy; 94 | containerPortal = 832341B01AAA6A8300B99B32 /* RCTText.xcodeproj */; 95 | proxyType = 2; 96 | remoteGlobalIDString = 58B5119B1A9E6C1200147676; 97 | remoteInfo = RCTText; 98 | }; 99 | AFFCDBBF1BBF23A900E76614 /* PBXContainerItemProxy */ = { 100 | isa = PBXContainerItemProxy; 101 | containerPortal = AFFCDBBB1BBF23A900E76614 /* BVLinearGradient.xcodeproj */; 102 | proxyType = 2; 103 | remoteGlobalIDString = 134814201AA4EA6300B7C361; 104 | remoteInfo = BVLinearGradient; 105 | }; 106 | /* End PBXContainerItemProxy section */ 107 | 108 | /* Begin PBXFileReference section */ 109 | 008F07F21AC5B25A0029DE68 /* main.jsbundle */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = main.jsbundle; path = iOS/main.jsbundle; sourceTree = ""; }; 110 | 00C302A71ABCB8CE00DB3ED1 /* RCTActionSheet.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTActionSheet.xcodeproj; path = "node_modules/react-native/Libraries/ActionSheetIOS/RCTActionSheet.xcodeproj"; sourceTree = ""; }; 111 | 00C302B51ABCB90400DB3ED1 /* RCTGeolocation.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTGeolocation.xcodeproj; path = "node_modules/react-native/Libraries/Geolocation/RCTGeolocation.xcodeproj"; sourceTree = ""; }; 112 | 00C302BB1ABCB91800DB3ED1 /* RCTImage.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTImage.xcodeproj; path = "node_modules/react-native/Libraries/Image/RCTImage.xcodeproj"; sourceTree = ""; }; 113 | 00C302D31ABCB9D200DB3ED1 /* RCTNetwork.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTNetwork.xcodeproj; path = "node_modules/react-native/Libraries/Network/RCTNetwork.xcodeproj"; sourceTree = ""; }; 114 | 00C302DF1ABCB9EE00DB3ED1 /* RCTVibration.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTVibration.xcodeproj; path = "node_modules/react-native/Libraries/Vibration/RCTVibration.xcodeproj"; sourceTree = ""; }; 115 | 139105B61AF99BAD00B5F7CC /* RCTSettings.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTSettings.xcodeproj; path = "node_modules/react-native/Libraries/Settings/RCTSettings.xcodeproj"; sourceTree = ""; }; 116 | 139FDEE61B06529A00C62182 /* RCTWebSocket.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTWebSocket.xcodeproj; path = "node_modules/react-native/Libraries/WebSocket/RCTWebSocket.xcodeproj"; sourceTree = ""; }; 117 | 13B07F961A680F5B00A75B9A /* twitch.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = twitch.app; sourceTree = BUILT_PRODUCTS_DIR; }; 118 | 13B07FAF1A68108700A75B9A /* AppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = AppDelegate.h; path = iOS/AppDelegate.h; sourceTree = ""; }; 119 | 13B07FB01A68108700A75B9A /* AppDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = AppDelegate.m; path = iOS/AppDelegate.m; sourceTree = ""; }; 120 | 13B07FB21A68108700A75B9A /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/LaunchScreen.xib; sourceTree = ""; }; 121 | 13B07FB51A68108700A75B9A /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; name = Images.xcassets; path = iOS/Images.xcassets; sourceTree = ""; }; 122 | 13B07FB61A68108700A75B9A /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = Info.plist; path = iOS/Info.plist; sourceTree = ""; }; 123 | 13B07FB71A68108700A75B9A /* main.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = main.m; path = iOS/main.m; sourceTree = ""; }; 124 | 146833FF1AC3E56700842450 /* React.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = React.xcodeproj; path = "node_modules/react-native/React/React.xcodeproj"; sourceTree = ""; }; 125 | 78C398B01ACF4ADC00677621 /* RCTLinking.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTLinking.xcodeproj; path = "node_modules/react-native/Libraries/LinkingIOS/RCTLinking.xcodeproj"; sourceTree = ""; }; 126 | 832341B01AAA6A8300B99B32 /* RCTText.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTText.xcodeproj; path = "node_modules/react-native/Libraries/Text/RCTText.xcodeproj"; sourceTree = ""; }; 127 | AFFCDBBB1BBF23A900E76614 /* BVLinearGradient.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = BVLinearGradient.xcodeproj; path = "node_modules/react-native-linear-gradient/BVLinearGradient.xcodeproj"; sourceTree = ""; }; 128 | /* End PBXFileReference section */ 129 | 130 | /* Begin PBXFrameworksBuildPhase section */ 131 | 13B07F8C1A680F5B00A75B9A /* Frameworks */ = { 132 | isa = PBXFrameworksBuildPhase; 133 | buildActionMask = 2147483647; 134 | files = ( 135 | AFFCDBCB1BBF23F800E76614 /* libBVLinearGradient.a in Frameworks */, 136 | 146834051AC3E58100842450 /* libReact.a in Frameworks */, 137 | 00C302E51ABCBA2D00DB3ED1 /* libRCTActionSheet.a in Frameworks */, 138 | 00C302E71ABCBA2D00DB3ED1 /* libRCTGeolocation.a in Frameworks */, 139 | 00C302E81ABCBA2D00DB3ED1 /* libRCTImage.a in Frameworks */, 140 | 133E29F31AD74F7200F7D852 /* libRCTLinking.a in Frameworks */, 141 | 00C302E91ABCBA2D00DB3ED1 /* libRCTNetwork.a in Frameworks */, 142 | 139105C61AF99C1200B5F7CC /* libRCTSettings.a in Frameworks */, 143 | 832341BD1AAA6AB300B99B32 /* libRCTText.a in Frameworks */, 144 | 00C302EA1ABCBA2D00DB3ED1 /* libRCTVibration.a in Frameworks */, 145 | 139FDEF61B0652A700C62182 /* libRCTWebSocket.a in Frameworks */, 146 | ); 147 | runOnlyForDeploymentPostprocessing = 0; 148 | }; 149 | /* End PBXFrameworksBuildPhase section */ 150 | 151 | /* Begin PBXGroup section */ 152 | 00C302A81ABCB8CE00DB3ED1 /* Products */ = { 153 | isa = PBXGroup; 154 | children = ( 155 | 00C302AC1ABCB8CE00DB3ED1 /* libRCTActionSheet.a */, 156 | ); 157 | name = Products; 158 | sourceTree = ""; 159 | }; 160 | 00C302B61ABCB90400DB3ED1 /* Products */ = { 161 | isa = PBXGroup; 162 | children = ( 163 | 00C302BA1ABCB90400DB3ED1 /* libRCTGeolocation.a */, 164 | ); 165 | name = Products; 166 | sourceTree = ""; 167 | }; 168 | 00C302BC1ABCB91800DB3ED1 /* Products */ = { 169 | isa = PBXGroup; 170 | children = ( 171 | 00C302C01ABCB91800DB3ED1 /* libRCTImage.a */, 172 | ); 173 | name = Products; 174 | sourceTree = ""; 175 | }; 176 | 00C302D41ABCB9D200DB3ED1 /* Products */ = { 177 | isa = PBXGroup; 178 | children = ( 179 | 00C302DC1ABCB9D200DB3ED1 /* libRCTNetwork.a */, 180 | ); 181 | name = Products; 182 | sourceTree = ""; 183 | }; 184 | 00C302E01ABCB9EE00DB3ED1 /* Products */ = { 185 | isa = PBXGroup; 186 | children = ( 187 | 00C302E41ABCB9EE00DB3ED1 /* libRCTVibration.a */, 188 | ); 189 | name = Products; 190 | sourceTree = ""; 191 | }; 192 | 139105B71AF99BAD00B5F7CC /* Products */ = { 193 | isa = PBXGroup; 194 | children = ( 195 | 139105C11AF99BAD00B5F7CC /* libRCTSettings.a */, 196 | ); 197 | name = Products; 198 | sourceTree = ""; 199 | }; 200 | 139FDEE71B06529A00C62182 /* Products */ = { 201 | isa = PBXGroup; 202 | children = ( 203 | 139FDEF41B06529B00C62182 /* libRCTWebSocket.a */, 204 | ); 205 | name = Products; 206 | sourceTree = ""; 207 | }; 208 | 13B07FAE1A68108700A75B9A /* twitch */ = { 209 | isa = PBXGroup; 210 | children = ( 211 | 008F07F21AC5B25A0029DE68 /* main.jsbundle */, 212 | 13B07FAF1A68108700A75B9A /* AppDelegate.h */, 213 | 13B07FB01A68108700A75B9A /* AppDelegate.m */, 214 | 13B07FB51A68108700A75B9A /* Images.xcassets */, 215 | 13B07FB61A68108700A75B9A /* Info.plist */, 216 | 13B07FB11A68108700A75B9A /* LaunchScreen.xib */, 217 | 13B07FB71A68108700A75B9A /* main.m */, 218 | ); 219 | name = twitch; 220 | sourceTree = ""; 221 | }; 222 | 146834001AC3E56700842450 /* Products */ = { 223 | isa = PBXGroup; 224 | children = ( 225 | 146834041AC3E56700842450 /* libReact.a */, 226 | ); 227 | name = Products; 228 | sourceTree = ""; 229 | }; 230 | 78C398B11ACF4ADC00677621 /* Products */ = { 231 | isa = PBXGroup; 232 | children = ( 233 | 78C398B91ACF4ADC00677621 /* libRCTLinking.a */, 234 | ); 235 | name = Products; 236 | sourceTree = ""; 237 | }; 238 | 832341AE1AAA6A7D00B99B32 /* Libraries */ = { 239 | isa = PBXGroup; 240 | children = ( 241 | AFFCDBBB1BBF23A900E76614 /* BVLinearGradient.xcodeproj */, 242 | 146833FF1AC3E56700842450 /* React.xcodeproj */, 243 | 00C302A71ABCB8CE00DB3ED1 /* RCTActionSheet.xcodeproj */, 244 | 00C302B51ABCB90400DB3ED1 /* RCTGeolocation.xcodeproj */, 245 | 00C302BB1ABCB91800DB3ED1 /* RCTImage.xcodeproj */, 246 | 78C398B01ACF4ADC00677621 /* RCTLinking.xcodeproj */, 247 | 00C302D31ABCB9D200DB3ED1 /* RCTNetwork.xcodeproj */, 248 | 139105B61AF99BAD00B5F7CC /* RCTSettings.xcodeproj */, 249 | 832341B01AAA6A8300B99B32 /* RCTText.xcodeproj */, 250 | 00C302DF1ABCB9EE00DB3ED1 /* RCTVibration.xcodeproj */, 251 | 139FDEE61B06529A00C62182 /* RCTWebSocket.xcodeproj */, 252 | ); 253 | name = Libraries; 254 | sourceTree = ""; 255 | }; 256 | 832341B11AAA6A8300B99B32 /* Products */ = { 257 | isa = PBXGroup; 258 | children = ( 259 | 832341B51AAA6A8300B99B32 /* libRCTText.a */, 260 | ); 261 | name = Products; 262 | sourceTree = ""; 263 | }; 264 | 83CBB9F61A601CBA00E9B192 = { 265 | isa = PBXGroup; 266 | children = ( 267 | 13B07FAE1A68108700A75B9A /* twitch */, 268 | 832341AE1AAA6A7D00B99B32 /* Libraries */, 269 | 83CBBA001A601CBA00E9B192 /* Products */, 270 | ); 271 | indentWidth = 2; 272 | sourceTree = ""; 273 | tabWidth = 2; 274 | }; 275 | 83CBBA001A601CBA00E9B192 /* Products */ = { 276 | isa = PBXGroup; 277 | children = ( 278 | 13B07F961A680F5B00A75B9A /* twitch.app */, 279 | ); 280 | name = Products; 281 | sourceTree = ""; 282 | }; 283 | AFFCDBBC1BBF23A900E76614 /* Products */ = { 284 | isa = PBXGroup; 285 | children = ( 286 | AFFCDBC01BBF23A900E76614 /* libBVLinearGradient.a */, 287 | ); 288 | name = Products; 289 | sourceTree = ""; 290 | }; 291 | /* End PBXGroup section */ 292 | 293 | /* Begin PBXNativeTarget section */ 294 | 13B07F861A680F5B00A75B9A /* twitch */ = { 295 | isa = PBXNativeTarget; 296 | buildConfigurationList = 13B07F931A680F5B00A75B9A /* Build configuration list for PBXNativeTarget "twitch" */; 297 | buildPhases = ( 298 | 13B07F871A680F5B00A75B9A /* Sources */, 299 | 13B07F8C1A680F5B00A75B9A /* Frameworks */, 300 | 13B07F8E1A680F5B00A75B9A /* Resources */, 301 | ); 302 | buildRules = ( 303 | ); 304 | dependencies = ( 305 | ); 306 | name = twitch; 307 | productName = "Hello World"; 308 | productReference = 13B07F961A680F5B00A75B9A /* twitch.app */; 309 | productType = "com.apple.product-type.application"; 310 | }; 311 | /* End PBXNativeTarget section */ 312 | 313 | /* Begin PBXProject section */ 314 | 83CBB9F71A601CBA00E9B192 /* Project object */ = { 315 | isa = PBXProject; 316 | attributes = { 317 | LastUpgradeCheck = 0610; 318 | ORGANIZATIONNAME = Facebook; 319 | TargetAttributes = { 320 | 13B07F861A680F5B00A75B9A = { 321 | DevelopmentTeam = 93EGD877N5; 322 | }; 323 | }; 324 | }; 325 | buildConfigurationList = 83CBB9FA1A601CBA00E9B192 /* Build configuration list for PBXProject "twitch" */; 326 | compatibilityVersion = "Xcode 3.2"; 327 | developmentRegion = English; 328 | hasScannedForEncodings = 0; 329 | knownRegions = ( 330 | en, 331 | Base, 332 | ); 333 | mainGroup = 83CBB9F61A601CBA00E9B192; 334 | productRefGroup = 83CBBA001A601CBA00E9B192 /* Products */; 335 | projectDirPath = ""; 336 | projectReferences = ( 337 | { 338 | ProductGroup = AFFCDBBC1BBF23A900E76614 /* Products */; 339 | ProjectRef = AFFCDBBB1BBF23A900E76614 /* BVLinearGradient.xcodeproj */; 340 | }, 341 | { 342 | ProductGroup = 00C302A81ABCB8CE00DB3ED1 /* Products */; 343 | ProjectRef = 00C302A71ABCB8CE00DB3ED1 /* RCTActionSheet.xcodeproj */; 344 | }, 345 | { 346 | ProductGroup = 00C302B61ABCB90400DB3ED1 /* Products */; 347 | ProjectRef = 00C302B51ABCB90400DB3ED1 /* RCTGeolocation.xcodeproj */; 348 | }, 349 | { 350 | ProductGroup = 00C302BC1ABCB91800DB3ED1 /* Products */; 351 | ProjectRef = 00C302BB1ABCB91800DB3ED1 /* RCTImage.xcodeproj */; 352 | }, 353 | { 354 | ProductGroup = 78C398B11ACF4ADC00677621 /* Products */; 355 | ProjectRef = 78C398B01ACF4ADC00677621 /* RCTLinking.xcodeproj */; 356 | }, 357 | { 358 | ProductGroup = 00C302D41ABCB9D200DB3ED1 /* Products */; 359 | ProjectRef = 00C302D31ABCB9D200DB3ED1 /* RCTNetwork.xcodeproj */; 360 | }, 361 | { 362 | ProductGroup = 139105B71AF99BAD00B5F7CC /* Products */; 363 | ProjectRef = 139105B61AF99BAD00B5F7CC /* RCTSettings.xcodeproj */; 364 | }, 365 | { 366 | ProductGroup = 832341B11AAA6A8300B99B32 /* Products */; 367 | ProjectRef = 832341B01AAA6A8300B99B32 /* RCTText.xcodeproj */; 368 | }, 369 | { 370 | ProductGroup = 00C302E01ABCB9EE00DB3ED1 /* Products */; 371 | ProjectRef = 00C302DF1ABCB9EE00DB3ED1 /* RCTVibration.xcodeproj */; 372 | }, 373 | { 374 | ProductGroup = 139FDEE71B06529A00C62182 /* Products */; 375 | ProjectRef = 139FDEE61B06529A00C62182 /* RCTWebSocket.xcodeproj */; 376 | }, 377 | { 378 | ProductGroup = 146834001AC3E56700842450 /* Products */; 379 | ProjectRef = 146833FF1AC3E56700842450 /* React.xcodeproj */; 380 | }, 381 | ); 382 | projectRoot = ""; 383 | targets = ( 384 | 13B07F861A680F5B00A75B9A /* twitch */, 385 | ); 386 | }; 387 | /* End PBXProject section */ 388 | 389 | /* Begin PBXReferenceProxy section */ 390 | 00C302AC1ABCB8CE00DB3ED1 /* libRCTActionSheet.a */ = { 391 | isa = PBXReferenceProxy; 392 | fileType = archive.ar; 393 | path = libRCTActionSheet.a; 394 | remoteRef = 00C302AB1ABCB8CE00DB3ED1 /* PBXContainerItemProxy */; 395 | sourceTree = BUILT_PRODUCTS_DIR; 396 | }; 397 | 00C302BA1ABCB90400DB3ED1 /* libRCTGeolocation.a */ = { 398 | isa = PBXReferenceProxy; 399 | fileType = archive.ar; 400 | path = libRCTGeolocation.a; 401 | remoteRef = 00C302B91ABCB90400DB3ED1 /* PBXContainerItemProxy */; 402 | sourceTree = BUILT_PRODUCTS_DIR; 403 | }; 404 | 00C302C01ABCB91800DB3ED1 /* libRCTImage.a */ = { 405 | isa = PBXReferenceProxy; 406 | fileType = archive.ar; 407 | path = libRCTImage.a; 408 | remoteRef = 00C302BF1ABCB91800DB3ED1 /* PBXContainerItemProxy */; 409 | sourceTree = BUILT_PRODUCTS_DIR; 410 | }; 411 | 00C302DC1ABCB9D200DB3ED1 /* libRCTNetwork.a */ = { 412 | isa = PBXReferenceProxy; 413 | fileType = archive.ar; 414 | path = libRCTNetwork.a; 415 | remoteRef = 00C302DB1ABCB9D200DB3ED1 /* PBXContainerItemProxy */; 416 | sourceTree = BUILT_PRODUCTS_DIR; 417 | }; 418 | 00C302E41ABCB9EE00DB3ED1 /* libRCTVibration.a */ = { 419 | isa = PBXReferenceProxy; 420 | fileType = archive.ar; 421 | path = libRCTVibration.a; 422 | remoteRef = 00C302E31ABCB9EE00DB3ED1 /* PBXContainerItemProxy */; 423 | sourceTree = BUILT_PRODUCTS_DIR; 424 | }; 425 | 139105C11AF99BAD00B5F7CC /* libRCTSettings.a */ = { 426 | isa = PBXReferenceProxy; 427 | fileType = archive.ar; 428 | path = libRCTSettings.a; 429 | remoteRef = 139105C01AF99BAD00B5F7CC /* PBXContainerItemProxy */; 430 | sourceTree = BUILT_PRODUCTS_DIR; 431 | }; 432 | 139FDEF41B06529B00C62182 /* libRCTWebSocket.a */ = { 433 | isa = PBXReferenceProxy; 434 | fileType = archive.ar; 435 | path = libRCTWebSocket.a; 436 | remoteRef = 139FDEF31B06529B00C62182 /* PBXContainerItemProxy */; 437 | sourceTree = BUILT_PRODUCTS_DIR; 438 | }; 439 | 146834041AC3E56700842450 /* libReact.a */ = { 440 | isa = PBXReferenceProxy; 441 | fileType = archive.ar; 442 | path = libReact.a; 443 | remoteRef = 146834031AC3E56700842450 /* PBXContainerItemProxy */; 444 | sourceTree = BUILT_PRODUCTS_DIR; 445 | }; 446 | 78C398B91ACF4ADC00677621 /* libRCTLinking.a */ = { 447 | isa = PBXReferenceProxy; 448 | fileType = archive.ar; 449 | path = libRCTLinking.a; 450 | remoteRef = 78C398B81ACF4ADC00677621 /* PBXContainerItemProxy */; 451 | sourceTree = BUILT_PRODUCTS_DIR; 452 | }; 453 | 832341B51AAA6A8300B99B32 /* libRCTText.a */ = { 454 | isa = PBXReferenceProxy; 455 | fileType = archive.ar; 456 | path = libRCTText.a; 457 | remoteRef = 832341B41AAA6A8300B99B32 /* PBXContainerItemProxy */; 458 | sourceTree = BUILT_PRODUCTS_DIR; 459 | }; 460 | AFFCDBC01BBF23A900E76614 /* libBVLinearGradient.a */ = { 461 | isa = PBXReferenceProxy; 462 | fileType = archive.ar; 463 | path = libBVLinearGradient.a; 464 | remoteRef = AFFCDBBF1BBF23A900E76614 /* PBXContainerItemProxy */; 465 | sourceTree = BUILT_PRODUCTS_DIR; 466 | }; 467 | /* End PBXReferenceProxy section */ 468 | 469 | /* Begin PBXResourcesBuildPhase section */ 470 | 13B07F8E1A680F5B00A75B9A /* Resources */ = { 471 | isa = PBXResourcesBuildPhase; 472 | buildActionMask = 2147483647; 473 | files = ( 474 | 008F07F31AC5B25A0029DE68 /* main.jsbundle in Resources */, 475 | 13B07FBF1A68108700A75B9A /* Images.xcassets in Resources */, 476 | 13B07FBD1A68108700A75B9A /* LaunchScreen.xib in Resources */, 477 | ); 478 | runOnlyForDeploymentPostprocessing = 0; 479 | }; 480 | /* End PBXResourcesBuildPhase section */ 481 | 482 | /* Begin PBXSourcesBuildPhase section */ 483 | 13B07F871A680F5B00A75B9A /* Sources */ = { 484 | isa = PBXSourcesBuildPhase; 485 | buildActionMask = 2147483647; 486 | files = ( 487 | 13B07FBC1A68108700A75B9A /* AppDelegate.m in Sources */, 488 | 13B07FC11A68108700A75B9A /* main.m in Sources */, 489 | ); 490 | runOnlyForDeploymentPostprocessing = 0; 491 | }; 492 | /* End PBXSourcesBuildPhase section */ 493 | 494 | /* Begin PBXVariantGroup section */ 495 | 13B07FB11A68108700A75B9A /* LaunchScreen.xib */ = { 496 | isa = PBXVariantGroup; 497 | children = ( 498 | 13B07FB21A68108700A75B9A /* Base */, 499 | ); 500 | name = LaunchScreen.xib; 501 | path = iOS; 502 | sourceTree = ""; 503 | }; 504 | /* End PBXVariantGroup section */ 505 | 506 | /* Begin XCBuildConfiguration section */ 507 | 13B07F941A680F5B00A75B9A /* Debug */ = { 508 | isa = XCBuildConfiguration; 509 | buildSettings = { 510 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 511 | CODE_SIGN_IDENTITY = "iPhone Developer"; 512 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 513 | HEADER_SEARCH_PATHS = ( 514 | "$(inherited)", 515 | /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include, 516 | "$(SRCROOT)/node_modules/react-native/React/**", 517 | ); 518 | INFOPLIST_FILE = iOS/Info.plist; 519 | IPHONEOS_DEPLOYMENT_TARGET = 8.2; 520 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 521 | OTHER_LDFLAGS = "-ObjC"; 522 | PRODUCT_NAME = twitch; 523 | PROVISIONING_PROFILE = ""; 524 | TREAT_MISSING_BASELINES_AS_TEST_FAILURES = YES; 525 | }; 526 | name = Debug; 527 | }; 528 | 13B07F951A680F5B00A75B9A /* Release */ = { 529 | isa = XCBuildConfiguration; 530 | buildSettings = { 531 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 532 | CODE_SIGN_IDENTITY = "iPhone Developer"; 533 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 534 | HEADER_SEARCH_PATHS = ( 535 | "$(inherited)", 536 | /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include, 537 | "$(SRCROOT)/node_modules/react-native/React/**", 538 | ); 539 | INFOPLIST_FILE = iOS/Info.plist; 540 | IPHONEOS_DEPLOYMENT_TARGET = 8.2; 541 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 542 | OTHER_LDFLAGS = "-ObjC"; 543 | PRODUCT_NAME = twitch; 544 | PROVISIONING_PROFILE = ""; 545 | TREAT_MISSING_BASELINES_AS_TEST_FAILURES = YES; 546 | }; 547 | name = Release; 548 | }; 549 | 83CBBA201A601CBA00E9B192 /* Debug */ = { 550 | isa = XCBuildConfiguration; 551 | buildSettings = { 552 | ALWAYS_SEARCH_USER_PATHS = NO; 553 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 554 | CLANG_CXX_LIBRARY = "libc++"; 555 | CLANG_ENABLE_MODULES = YES; 556 | CLANG_ENABLE_OBJC_ARC = YES; 557 | CLANG_WARN_BOOL_CONVERSION = YES; 558 | CLANG_WARN_CONSTANT_CONVERSION = YES; 559 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 560 | CLANG_WARN_EMPTY_BODY = YES; 561 | CLANG_WARN_ENUM_CONVERSION = YES; 562 | CLANG_WARN_INT_CONVERSION = YES; 563 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 564 | CLANG_WARN_UNREACHABLE_CODE = YES; 565 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 566 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 567 | COPY_PHASE_STRIP = NO; 568 | ENABLE_STRICT_OBJC_MSGSEND = YES; 569 | GCC_C_LANGUAGE_STANDARD = gnu99; 570 | GCC_DYNAMIC_NO_PIC = NO; 571 | GCC_OPTIMIZATION_LEVEL = 0; 572 | GCC_PREPROCESSOR_DEFINITIONS = ( 573 | "DEBUG=1", 574 | "$(inherited)", 575 | ); 576 | GCC_SYMBOLS_PRIVATE_EXTERN = NO; 577 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 578 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 579 | GCC_WARN_UNDECLARED_SELECTOR = YES; 580 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 581 | GCC_WARN_UNUSED_FUNCTION = YES; 582 | GCC_WARN_UNUSED_VARIABLE = YES; 583 | HEADER_SEARCH_PATHS = ( 584 | "$(inherited)", 585 | /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include, 586 | "$(SRCROOT)/node_modules/react-native/React/**", 587 | ); 588 | IPHONEOS_DEPLOYMENT_TARGET = 7.0; 589 | MTL_ENABLE_DEBUG_INFO = YES; 590 | ONLY_ACTIVE_ARCH = YES; 591 | SDKROOT = iphoneos; 592 | }; 593 | name = Debug; 594 | }; 595 | 83CBBA211A601CBA00E9B192 /* Release */ = { 596 | isa = XCBuildConfiguration; 597 | buildSettings = { 598 | ALWAYS_SEARCH_USER_PATHS = NO; 599 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 600 | CLANG_CXX_LIBRARY = "libc++"; 601 | CLANG_ENABLE_MODULES = YES; 602 | CLANG_ENABLE_OBJC_ARC = YES; 603 | CLANG_WARN_BOOL_CONVERSION = YES; 604 | CLANG_WARN_CONSTANT_CONVERSION = YES; 605 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 606 | CLANG_WARN_EMPTY_BODY = YES; 607 | CLANG_WARN_ENUM_CONVERSION = YES; 608 | CLANG_WARN_INT_CONVERSION = YES; 609 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 610 | CLANG_WARN_UNREACHABLE_CODE = YES; 611 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 612 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 613 | COPY_PHASE_STRIP = YES; 614 | ENABLE_NS_ASSERTIONS = NO; 615 | ENABLE_STRICT_OBJC_MSGSEND = YES; 616 | GCC_C_LANGUAGE_STANDARD = gnu99; 617 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 618 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 619 | GCC_WARN_UNDECLARED_SELECTOR = YES; 620 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 621 | GCC_WARN_UNUSED_FUNCTION = YES; 622 | GCC_WARN_UNUSED_VARIABLE = YES; 623 | HEADER_SEARCH_PATHS = ( 624 | "$(inherited)", 625 | /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include, 626 | "$(SRCROOT)/node_modules/react-native/React/**", 627 | ); 628 | IPHONEOS_DEPLOYMENT_TARGET = 7.0; 629 | MTL_ENABLE_DEBUG_INFO = NO; 630 | SDKROOT = iphoneos; 631 | VALIDATE_PRODUCT = YES; 632 | }; 633 | name = Release; 634 | }; 635 | /* End XCBuildConfiguration section */ 636 | 637 | /* Begin XCConfigurationList section */ 638 | 13B07F931A680F5B00A75B9A /* Build configuration list for PBXNativeTarget "twitch" */ = { 639 | isa = XCConfigurationList; 640 | buildConfigurations = ( 641 | 13B07F941A680F5B00A75B9A /* Debug */, 642 | 13B07F951A680F5B00A75B9A /* Release */, 643 | ); 644 | defaultConfigurationIsVisible = 0; 645 | defaultConfigurationName = Release; 646 | }; 647 | 83CBB9FA1A601CBA00E9B192 /* Build configuration list for PBXProject "twitch" */ = { 648 | isa = XCConfigurationList; 649 | buildConfigurations = ( 650 | 83CBBA201A601CBA00E9B192 /* Debug */, 651 | 83CBBA211A601CBA00E9B192 /* Release */, 652 | ); 653 | defaultConfigurationIsVisible = 0; 654 | defaultConfigurationName = Release; 655 | }; 656 | /* End XCConfigurationList section */ 657 | }; 658 | rootObject = 83CBB9F71A601CBA00E9B192 /* Project object */; 659 | } 660 | -------------------------------------------------------------------------------- /twitch.xcodeproj/xcshareddata/xcschemes/twitch.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 29 | 35 | 36 | 37 | 38 | 39 | 44 | 45 | 46 | 47 | 53 | 54 | 55 | 56 | 57 | 58 | 68 | 70 | 76 | 77 | 78 | 79 | 80 | 81 | 87 | 89 | 95 | 96 | 97 | 98 | 100 | 101 | 104 | 105 | 106 | -------------------------------------------------------------------------------- /utils/index.js: -------------------------------------------------------------------------------- 1 | function getRandomColor() { 2 | var letters = '0123456789ABCDEF'.split(''); 3 | var color = '#'; 4 | 5 | for (var i = 0; i < 6; i++ ) { 6 | color += letters[Math.floor(Math.random() * 16)]; 7 | } 8 | return color; 9 | } 10 | 11 | module.exports.getRandomColor = getRandomColor; 12 | -------------------------------------------------------------------------------- /vendor/react-native-drawer/Tweener.js: -------------------------------------------------------------------------------- 1 | var easingTypes = require('tween-functions'); 2 | 3 | module.exports = function(config) { 4 | return new Tween(config) 5 | } 6 | 7 | function Tween(config){ 8 | this._rafLoop = this._rafLoop.bind(this) 9 | this.terminate = this.terminate.bind(this) 10 | 11 | this._t0 = Date.now() 12 | this._config = config 13 | this._rafLoop() 14 | } 15 | 16 | Tween.prototype._rafLoop = function() { 17 | if(this._break){ return } 18 | 19 | var {duration, start, end, easingType} = this._config 20 | var now = Date.now() 21 | var elapsed = now - this._t0 22 | 23 | if(elapsed >= duration){ 24 | this._config.onFrame(end) 25 | this._config.onEnd() 26 | return 27 | } 28 | 29 | var tweenVal = easingTypes[easingType](elapsed, start, end, duration) 30 | this._config.onFrame(tweenVal) 31 | 32 | requestAnimationFrame(this._rafLoop) 33 | } 34 | 35 | Tween.prototype.terminate = function(){ 36 | this._break = true 37 | } 38 | -------------------------------------------------------------------------------- /vendor/react-native-drawer/index.js: -------------------------------------------------------------------------------- 1 | var React = require('react-native') 2 | var { PanResponder, View, StyleSheet, Dimensions } = React 3 | var deviceScreen = Dimensions.get('window') 4 | var tween = require('./Tweener') 5 | 6 | 7 | /** 8 | * Check if the current gesture offset bigger than allowed one 9 | * before opening menu 10 | * @param {Number} dx Gesture offset from the left side of the window 11 | * @return {Boolean} 12 | */ 13 | var drawer = React.createClass({ 14 | 15 | _left: 0, 16 | _prevLeft: 0, 17 | _offsetOpen: 0, 18 | _offsetClosed: 0, 19 | _open: false, 20 | _panning: false, 21 | _tweenPending: false, 22 | _lastPress: 0, 23 | 24 | propTypes: { 25 | type: React.PropTypes.string, 26 | closedDrawerOffset: React.PropTypes.number, 27 | openDrawerOffset: React.PropTypes.number, 28 | openDrawerThreshold: React.PropTypes.number, 29 | relativeDrag: React.PropTypes.bool, 30 | panStartCompensation: React.PropTypes.bool, 31 | panOpenMask: React.PropTypes.number, 32 | panCloseMask: React.PropTypes.number, 33 | captureGestures: React.PropTypes.bool, 34 | initializeOpen: React.PropTypes.bool, 35 | tweenHandler: React.PropTypes.func, 36 | tweenDuration: React.PropTypes.number, 37 | tweenEasing: React.PropTypes.string, 38 | disabled: React.PropTypes.bool, 39 | acceptDoubleTap: React.PropTypes.bool, 40 | acceptTap: React.PropTypes.bool, 41 | acceptPan: React.PropTypes.bool, 42 | styles: React.PropTypes.object, 43 | onOpen: React.PropTypes.func, 44 | onClose: React.PropTypes.func, 45 | side: React.PropTypes.oneOf(['left', 'right']), 46 | }, 47 | 48 | getDefaultProps () { 49 | return { 50 | type: 'displace', 51 | closedDrawerOffset: 0, 52 | openDrawerOffset: 0, 53 | openDrawerThreshold: .25, 54 | relativeDrag: true, 55 | panStartCompensation: true, 56 | panOpenMask: .25, 57 | panCloseMask: .25, 58 | captureGestures: false, 59 | initializeOpen: false, 60 | tweenHandler: null, 61 | tweenDuration: 250, 62 | tweenEasing: 'linear', 63 | disabled: false, 64 | acceptDoubleTap: false, 65 | acceptTap: false, 66 | acceptPan: true, 67 | styles: {}, 68 | onOpen: () => {}, 69 | onClose: () => {}, 70 | side: 'left', 71 | } 72 | }, 73 | 74 | statics: { 75 | tweenPresets: { 76 | parallax: (ratio) => { 77 | var drawer = {} 78 | drawer.left = -150*(1-ratio) 79 | return { drawer: drawer } 80 | } 81 | } 82 | }, 83 | 84 | propsWhomRequireUpdate: [ 85 | 'closedDrawerOffset', 86 | 'openDrawerOffset', 87 | 'type' 88 | ], 89 | 90 | //@TODO can this be optimization? 91 | shouldComponentUpdate(nextProps, nextState) { 92 | // this.propsWhomRequireUpdate.forEach((key) => { 93 | // if(this.props[key] !== nextProps[key]){ return true } 94 | // }) 95 | // if(!shallowEquals(this.props.children.props, nextProps.children.props)){ return true } 96 | return true 97 | }, 98 | 99 | requiresIntialize(nextProps){ 100 | this.propsWhomRequireUpdate.forEach((key) => { 101 | if(this.props[key] !== nextProps[key]){ return true } 102 | }) 103 | }, 104 | 105 | componentWillReceiveProps(nextProps){ 106 | if(this.requiresIntialize(nextProps)){ 107 | this.initialize(nextProps) 108 | } 109 | }, 110 | 111 | initialize(props){ 112 | var fullWidth = deviceScreen.width 113 | this._offsetClosed = props.closedDrawerOffset%1 === 0 ? props.closedDrawerOffset : props.closedDrawerOffset*fullWidth 114 | this._offsetOpen = props.openDrawerOffset%1 === 0 ? props.openDrawerOffset : props.openDrawerOffset*fullWidth 115 | 116 | var styles = { 117 | container: { 118 | flex: 1, 119 | justifyContent: 'center', 120 | alignItems: 'center', 121 | }, 122 | } 123 | styles.main = Object.assign({ 124 | flex: 1, 125 | position: 'absolute', 126 | top: 0, 127 | height: deviceScreen.height, 128 | }, this.props.styles.main) 129 | styles.drawer = Object.assign({ 130 | flex: 1, 131 | position: 'absolute', 132 | top: 0, 133 | height: deviceScreen.height, 134 | }, this.props.styles.drawer) 135 | 136 | //open 137 | if(props.initializeOpen === true){ 138 | this._open = true 139 | this._left = fullWidth - this._offsetOpen 140 | this._prevLeft = this._left 141 | if(props.type === 'static'){ 142 | styles.main[this.props.side] = fullWidth - this._offsetOpen 143 | styles.drawer[this.props.side] = 0 144 | styles.main.width = fullWidth - this._offsetClosed 145 | styles.drawer.width = fullWidth 146 | } 147 | if(props.type === 'overlay'){ 148 | styles.main[this.props.side] = 0 149 | styles.drawer[this.props.side] = 0 150 | styles.main.width = fullWidth 151 | styles.drawer.width = fullWidth - this._offsetOpen 152 | } 153 | if(props.type === 'displace'){ 154 | styles.main[this.props.side] = fullWidth - this._offsetOpen 155 | styles.drawer[this.props.side] = 0 156 | styles.main.width = fullWidth - this._offsetClosed 157 | styles.drawer.width = fullWidth - this._offsetOpen 158 | } 159 | } 160 | //closed 161 | else{ 162 | this._open = false 163 | this._left = this._offsetClosed 164 | this._prevLeft = this._left 165 | if(props.type === 'static'){ 166 | styles.main[this.props.side] = this._offsetClosed 167 | styles.drawer[this.props.side] = 0 168 | styles.main.width = fullWidth - this._offsetClosed 169 | styles.drawer.width = fullWidth 170 | } 171 | if(props.type === 'overlay'){ 172 | styles.main[this.props.side] = this._offsetClosed 173 | styles.drawer[this.props.side] = this._offsetClosed + this._offsetOpen - fullWidth 174 | styles.main.width = fullWidth 175 | styles.drawer.width = fullWidth - this._offsetOpen 176 | } 177 | if(props.type === 'displace'){ 178 | styles.main[this.props.side] = this._offsetClosed 179 | styles.drawer[this.props.side] = - fullWidth + this._offsetClosed + this._offsetOpen 180 | styles.main.width = fullWidth - this._offsetClosed 181 | styles.drawer.width = fullWidth - this._offsetOpen 182 | } 183 | } 184 | 185 | if(this.refs.main){ 186 | this.refs.drawer.setNativeProps({style: { left: styles.drawer.left}}); 187 | this.refs.main.setNativeProps({style: { left: styles.main.left}}); 188 | } 189 | else{ 190 | this.stylesheet = StyleSheet.create(styles) 191 | 192 | this.responder = PanResponder.create({ 193 | onStartShouldSetPanResponder: this.handleStartShouldSetPanResponder, 194 | onStartShouldSetPanResponderCapture: this.handleStartShouldSetPanResponderCapture, 195 | onPanResponderMove: this.handlePanResponderMove, 196 | onPanResponderRelease: this.handlePanResponderEnd, 197 | }) 198 | } 199 | }, 200 | 201 | componentWillMount: function() { 202 | this.initialize(this.props) 203 | }, 204 | 205 | /** 206 | * Change `left` style attributes 207 | * Works only if `drawer` is a ref to React.Component 208 | * @return {Void} 209 | */ 210 | updatePosition: function() { 211 | var mainProps = {} 212 | var drawerProps = {} 213 | 214 | var ratio = (this._left-this._offsetClosed)/(this.getOpenLeft()-this._offsetClosed) 215 | 216 | switch(this.props.type){ 217 | case 'overlay': 218 | drawerProps[this.props.side] = -deviceScreen.width+this._offsetOpen+this._left 219 | mainProps[this.props.side] = this._offsetClosed 220 | break 221 | case 'static': 222 | mainProps[this.props.side] = this._left 223 | drawerProps[this.props.side] = 0 224 | break 225 | case 'displace': 226 | mainProps[this.props.side] = this._left 227 | drawerProps[this.props.side] = -deviceScreen.width+this._left+this._offsetOpen 228 | break 229 | } 230 | 231 | if(this.props.tweenHandler){ 232 | var propsFrag = this.props.tweenHandler(ratio) 233 | mainProps = Object.assign(mainProps, propsFrag.main) 234 | drawerProps = Object.assign(drawerProps, propsFrag.drawer) 235 | } 236 | this.refs.drawer.setNativeProps({ style: drawerProps }) 237 | this.refs.main.setNativeProps({ style: mainProps }) 238 | }, 239 | 240 | shouldOpenDrawer(dx: Number) { 241 | if(this._open){ 242 | return dx < deviceScreen.width*this.props.openDrawerThreshold 243 | } 244 | else{ 245 | return dx > deviceScreen.width*this.props.openDrawerThreshold 246 | } 247 | }, 248 | 249 | handleStartShouldSetPanResponderCapture: function(e, gestureState){ 250 | if(this.props.captureGestures){ 251 | return this.handleStartShouldSetPanResponder(e, gestureState) 252 | } 253 | }, 254 | 255 | /** 256 | * Permission to use responder 257 | * @return {Boolean} true 258 | */ 259 | handleStartShouldSetPanResponder: function(e: Object, gestureState: Object) { 260 | if(this.props.disabled){ return false } 261 | var x0 = e.nativeEvent.pageX 262 | 263 | if (x0 < 25) { 264 | return false; 265 | } 266 | 267 | var deltaOpen = this.props.side === 'left' ? deviceScreen.width - x0 : x0 268 | var deltaClose = this.props.side === 'left' ? x0 : deviceScreen.width - x0 269 | 270 | //@TODO lol formatting? 271 | if( this._open && deltaOpen > deviceScreen.width*this.props.panCloseMask 272 | || !this._open && deltaClose > deviceScreen.width*this.props.panOpenMask 273 | ){ 274 | return false 275 | } 276 | 277 | if(this.props.acceptTap){ 278 | this._open ? this.close() : this.open() 279 | } 280 | else if(this.props.acceptDoubleTap){ 281 | var now = new Date().getTime() 282 | if(now - this._lastPress < 500){ 283 | this._open ? this.close() : this.open() 284 | } 285 | this._lastPress = now 286 | } 287 | 288 | if(!this.props.acceptPan){ 289 | return false 290 | } 291 | return true 292 | }, 293 | 294 | /** 295 | * Handler on responder move 296 | * @param {Synthetic Event} e 297 | * @param {Object} gestureState 298 | * @return {Void} 299 | */ 300 | handlePanResponderMove: function(e: Object, gestureState: Object) { 301 | //Math is ugly overly verbose here, probably can be greatly cleaned up 302 | var dx = gestureState.dx 303 | //@TODO store adjustedDx max so that it does not uncompensate when panning back 304 | var dx = gestureState.dx 305 | //Do nothing if we are panning the wrong way 306 | if(this._open ^ dx < 0 ^ this.props.side === 'right'){ return false } 307 | 308 | var absDx = Math.abs(dx) 309 | var moveX = gestureState.moveX 310 | var relMoveX = this.props.side === 'left' 311 | ? this._open ? -deviceScreen.width + moveX : moveX 312 | : this._open ? -moveX : deviceScreen.width - moveX 313 | var delta = relMoveX - dx 314 | var factor = absDx/Math.abs(relMoveX) 315 | var adjustedDx = dx + delta*factor 316 | var left = this.props.panStartCompensation ? this._prevLeft + adjustedDx : this._prevLeft + dx 317 | left = Math.min(left, this.getOpenLeft()) 318 | left = Math.max(left, this.getClosedLeft()) 319 | this._left = left 320 | this.updatePosition() 321 | this._panning = true 322 | }, 323 | 324 | /** 325 | * Open drawer 326 | * @return {Void} 327 | */ 328 | open: function() { 329 | if(this.props.disabled){ return null } 330 | tween({ 331 | start: this._left, 332 | end: this.getOpenLeft(), 333 | duration: this.props.tweenDuration, 334 | easingType: this.props.tweenEasing, 335 | onFrame: (tweenValue) => { 336 | this._left = tweenValue 337 | this.updatePosition() 338 | }, 339 | onEnd: () => { 340 | this._open = true 341 | this._prevLeft = this._left 342 | this.props.onOpen() 343 | // @TODO _initializeAfterAnimation ???? 344 | } 345 | }) 346 | }, 347 | 348 | /** 349 | * Close drawer 350 | * @return {Void} 351 | */ 352 | close: function() { 353 | if(this.props.disabled){ return null } 354 | tween({ 355 | start: this._left, 356 | end: this.getClosedLeft(), 357 | easingType: this.props.tweenEasing, 358 | duration: this.props.tweenDuration, 359 | onFrame: (tweenValue) => { 360 | this._left = tweenValue 361 | this.updatePosition() 362 | }, 363 | onEnd: () => { 364 | this._open = false 365 | this._prevLeft = this._left 366 | this.props.onClose() 367 | // @TODO _initializeAfterAnimation ???? 368 | } 369 | }) 370 | }, 371 | 372 | toggle: function() { 373 | this._open ? this.close() : this.open() 374 | }, 375 | 376 | /** 377 | * Handler on responder move ending 378 | * @param {Synthetic Event} e 379 | * @param {Object} gestureState 380 | * @return {Void} 381 | */ 382 | handlePanResponderEnd: function(e: Object, gestureState: Object) { 383 | //Do nothing if we are not in an active pan state 384 | if(!this._panning){ return } 385 | //@TODO:Reevaluate - If we are panning the wrong way when the pan ends, 386 | // which animation should trigger? 387 | // if(this._open ^ gestureState.dx < 0){ return } 388 | 389 | var absRelMoveX = this.props.side === 'left' 390 | ? this._open ? deviceScreen.width - gestureState.moveX : gestureState.moveX 391 | : this._open ? gestureState.moveX : deviceScreen.width - gestureState.moveX 392 | var calcPos = this.props.relativeDrag ? Math.abs(gestureState.dx) : absRelMoveX 393 | if (this.shouldOpenDrawer(calcPos)) { 394 | this.open() 395 | } else { 396 | this.close() 397 | } 398 | 399 | this.updatePosition() 400 | this._prevLeft = this._left 401 | this._panning = false 402 | }, 403 | 404 | /** 405 | * Get content view. This view will be rendered over menu 406 | * @return {React.Component} 407 | */ 408 | getMainView: function() { 409 | return ( 410 | 415 | {this.props.children} 416 | 417 | ) 418 | }, 419 | 420 | /** 421 | * Get menu view. This view will be rendered under 422 | * content view. Also, this function will decorate 423 | * passed `menu` component with side menu API 424 | * @return {React.Component} 425 | */ 426 | getDrawerView: function() { 427 | var drawerActions = { 428 | close: this.closeDrawer 429 | } 430 | 431 | return ( 432 | 437 | {this.props.content} 438 | 439 | ) 440 | }, 441 | 442 | /** 443 | * Compose and render menu and content view 444 | * @return {React.Component} 445 | */ 446 | render: function() { 447 | switch(this.props.type){ 448 | case 'overlay': 449 | var first = this.getMainView() 450 | var second = this.getDrawerView() 451 | break 452 | default: 453 | var first = this.getDrawerView() 454 | var second = this.getMainView() 455 | break 456 | } 457 | return ( 458 | 459 | {first} 460 | {second} 461 | 462 | ) 463 | }, 464 | 465 | getOpenLeft: function(){ 466 | return deviceScreen.width - this._offsetOpen 467 | }, 468 | 469 | getClosedLeft() { 470 | return this._offsetClosed 471 | }, 472 | 473 | }) 474 | 475 | module.exports = drawer 476 | --------------------------------------------------------------------------------