diff --git a/.babelrc b/.babelrc index 8df53fe..a9ce136 100644 --- a/.babelrc +++ b/.babelrc @@ -1,3 +1,3 @@ { -"presets": ["react-native"] -} \ No newline at end of file + "presets": ["react-native"] +} diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..361fab3 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,11 @@ +root = true + +[*] +indent_style = space +indent_size = 2 + +end_of_line = lf +charset = utf-8 +trim_trailing_whitespace = true +insert_final_newline = true +charset = utf-8 \ No newline at end of file diff --git a/.flowconfig b/.flowconfig index c693a48..0b611f0 100644 --- a/.flowconfig +++ b/.flowconfig @@ -12,35 +12,43 @@ ; For RN Apps installed via npm, "Libraries" folder is inside ; "node_modules/react-native" but in the source repo it is in the root .*/Libraries/react-native/React.js -.*/Libraries/react-native/ReactNative.js + +; Ignore polyfills +.*/Libraries/polyfills/.* + +; Ignore metro +.*/node_modules/metro/.* [include] [libs] node_modules/react-native/Libraries/react-native/react-native-interface.js -node_modules/react-native/flow -flow/ +node_modules/react-native/flow/ +node_modules/react-native/flow-github/ [options] emoji=true module.system=haste -experimental.strict_type_args=true - munge_underscores=true module.name_mapper='^[./a-zA-Z0-9$_-]+\.\(bmp\|gif\|jpg\|jpeg\|png\|psd\|svg\|webp\|m4v\|mov\|mp4\|mpeg\|mpg\|webm\|aac\|aiff\|caf\|m4a\|mp3\|wav\|html\|pdf\)$' -> 'RelativeImageStub' +module.file_ext=.js +module.file_ext=.jsx +module.file_ext=.json +module.file_ext=.native.js + suppress_type=$FlowIssue suppress_type=$FlowFixMe -suppress_type=$FixMe +suppress_type=$FlowFixMeProps +suppress_type=$FlowFixMeState -suppress_comment=\\(.\\|\n\\)*\\$FlowFixMe\\($\\|[^(]\\|(\\(>=0\\.\\(3[0-8]\\|[1-2][0-9]\\|[0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\) -suppress_comment=\\(.\\|\n\\)*\\$FlowIssue\\((\\(>=0\\.\\(3[0-8]\\|1[0-9]\\|[1-2][0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)?:? #[0-9]+ +suppress_comment=\\(.\\|\n\\)*\\$FlowFixMe\\($\\|[^(]\\|(\\(\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\) +suppress_comment=\\(.\\|\n\\)*\\$FlowIssue\\((\\(\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)?:? #[0-9]+ suppress_comment=\\(.\\|\n\\)*\\$FlowFixedInNextDeploy - -unsafe.enable_getters_and_setters=true +suppress_comment=\\(.\\|\n\\)*\\$FlowExpectedError [version] -^0.38.0 +^0.63.0 diff --git a/.gitignore b/.gitignore index 1927b01..4837030 100644 --- a/.gitignore +++ b/.gitignore @@ -22,21 +22,36 @@ DerivedData *.xcuserstate project.xcworkspace -# Android/IJ +# Android/IntelliJ # +build/ .idea .gradle local.properties +*.iml # node.js # node_modules/ npm-debug.log +yarn-error.log # BUCK buck-out/ \.buckd/ -android/app/libs -android/keystores/debug.keystore +*.keystore + +# fastlane +# +# It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the +# screenshots whenever they are needed. +# For more information about the recommended setup visit: +# https://docs.fastlane.tools/best-practices/source-control/ -# React Webpack Bundle +*/fastlane/report.xml +*/fastlane/Preview.html +*/fastlane/screenshots + +# VScode +# +.vscode/ diff --git a/App.js b/App.js new file mode 100644 index 0000000..e3b4298 --- /dev/null +++ b/App.js @@ -0,0 +1,30 @@ +import React from 'react' +import { + AppRegistry +} from 'react-native' +import { Provider } from 'react-redux' +import { createStore } from 'redux' +import NBA from './App/reducers' + +import { getFormattedDate } from './App/utils/date' + +const store = createStore( + NBA +) + +console.log(store.getState()) +console.disableYellowBox = true // for development + +import NBAreact from './App/NBAreact' + +const App = () => { + return ( + + + + ) +} + +export default App + +AppRegistry.registerComponent('Swish', () => App) diff --git a/App/Assets/Images/atl.png b/App/Assets/Images/atl.png index efaa83d..b5f8a05 100755 Binary files a/App/Assets/Images/atl.png and b/App/Assets/Images/atl.png differ diff --git a/App/Assets/Images/bkn.png b/App/Assets/Images/bkn.png index 75333d1..5c79452 100755 Binary files a/App/Assets/Images/bkn.png and b/App/Assets/Images/bkn.png differ diff --git a/App/Assets/Images/bos.png b/App/Assets/Images/bos.png index a3e35e8..173b082 100755 Binary files a/App/Assets/Images/bos.png and b/App/Assets/Images/bos.png differ diff --git a/App/Assets/Images/cha.png b/App/Assets/Images/cha.png index e4a05ec..335f84a 100755 Binary files a/App/Assets/Images/cha.png and b/App/Assets/Images/cha.png differ diff --git a/App/Assets/Images/chi.png b/App/Assets/Images/chi.png index 1dae300..e9f3031 100755 Binary files a/App/Assets/Images/chi.png and b/App/Assets/Images/chi.png differ diff --git a/App/Assets/Images/cle2.png b/App/Assets/Images/cle2.png new file mode 100755 index 0000000..b4f49a8 Binary files /dev/null and b/App/Assets/Images/cle2.png differ diff --git a/App/Assets/Images/dal.png b/App/Assets/Images/dal.png index ee70cc6..6346710 100755 Binary files a/App/Assets/Images/dal.png and b/App/Assets/Images/dal.png differ diff --git a/App/Assets/Images/den2.png b/App/Assets/Images/den2.png new file mode 100755 index 0000000..4c22e36 Binary files /dev/null and b/App/Assets/Images/den2.png differ diff --git a/App/Assets/Images/det2.png b/App/Assets/Images/det2.png new file mode 100755 index 0000000..a43da89 Binary files /dev/null and b/App/Assets/Images/det2.png differ diff --git a/App/Assets/Images/east.png b/App/Assets/Images/east.png new file mode 100755 index 0000000..7ad9fda Binary files /dev/null and b/App/Assets/Images/east.png differ diff --git a/App/Assets/Images/gsw.png b/App/Assets/Images/gsw.png index c4a7fed..a89439d 100755 Binary files a/App/Assets/Images/gsw.png and b/App/Assets/Images/gsw.png differ diff --git a/App/Assets/Images/hou.png b/App/Assets/Images/hou.png index 90d4ab9..717a9c6 100755 Binary files a/App/Assets/Images/hou.png and b/App/Assets/Images/hou.png differ diff --git a/App/Assets/Images/ind.png b/App/Assets/Images/ind.png index 5f3da21..7e6ccf7 100755 Binary files a/App/Assets/Images/ind.png and b/App/Assets/Images/ind.png differ diff --git a/App/Assets/Images/lac2.png b/App/Assets/Images/lac2.png new file mode 100755 index 0000000..58587bf Binary files /dev/null and b/App/Assets/Images/lac2.png differ diff --git a/App/Assets/Images/lal.png b/App/Assets/Images/lal.png index ebaa847..1768f0c 100755 Binary files a/App/Assets/Images/lal.png and b/App/Assets/Images/lal.png differ diff --git a/App/Assets/Images/mem.png b/App/Assets/Images/mem.png index 7e47160..4865bec 100755 Binary files a/App/Assets/Images/mem.png and b/App/Assets/Images/mem.png differ diff --git a/App/Assets/Images/mia.png b/App/Assets/Images/mia.png index 9c0bf58..673ef81 100755 Binary files a/App/Assets/Images/mia.png and b/App/Assets/Images/mia.png differ diff --git a/App/Assets/Images/mil.png b/App/Assets/Images/mil.png index 85307d1..f16257e 100755 Binary files a/App/Assets/Images/mil.png and b/App/Assets/Images/mil.png differ diff --git a/App/Assets/Images/min.png b/App/Assets/Images/min.png index 08d1218..e7201a6 100755 Binary files a/App/Assets/Images/min.png and b/App/Assets/Images/min.png differ diff --git a/App/Assets/Images/nba.png b/App/Assets/Images/nba.png old mode 100644 new mode 100755 index 41d114c..bcdf0ad Binary files a/App/Assets/Images/nba.png and b/App/Assets/Images/nba.png differ diff --git a/App/Assets/Images/nop2.png b/App/Assets/Images/nop2.png new file mode 100755 index 0000000..d9c1dc7 Binary files /dev/null and b/App/Assets/Images/nop2.png differ diff --git a/App/Assets/Images/nyk.png b/App/Assets/Images/nyk.png index 04f06ec..954f4d3 100755 Binary files a/App/Assets/Images/nyk.png and b/App/Assets/Images/nyk.png differ diff --git a/App/Assets/Images/okc.png b/App/Assets/Images/okc.png index cf1a335..c6612cc 100755 Binary files a/App/Assets/Images/okc.png and b/App/Assets/Images/okc.png differ diff --git a/App/Assets/Images/orl.png b/App/Assets/Images/orl.png index dacd6fb..a6aec66 100755 Binary files a/App/Assets/Images/orl.png and b/App/Assets/Images/orl.png differ diff --git a/App/Assets/Images/phi.png b/App/Assets/Images/phi.png index 11ac180..fa3507a 100755 Binary files a/App/Assets/Images/phi.png and b/App/Assets/Images/phi.png differ diff --git a/App/Assets/Images/phx.png b/App/Assets/Images/phx.png index 4fc5acc..195b5a1 100755 Binary files a/App/Assets/Images/phx.png and b/App/Assets/Images/phx.png differ diff --git a/App/Assets/Images/por.png b/App/Assets/Images/por.png index 09b74fa..d08ca82 100755 Binary files a/App/Assets/Images/por.png and b/App/Assets/Images/por.png differ diff --git a/App/Assets/Images/sac.png b/App/Assets/Images/sac.png index 26184aa..4384614 100755 Binary files a/App/Assets/Images/sac.png and b/App/Assets/Images/sac.png differ diff --git a/App/Assets/Images/sas.png b/App/Assets/Images/sas.png index 618b43f..c2be7ad 100755 Binary files a/App/Assets/Images/sas.png and b/App/Assets/Images/sas.png differ diff --git a/App/Assets/Images/sea.png b/App/Assets/Images/sea.png new file mode 100755 index 0000000..48cbb17 Binary files /dev/null and b/App/Assets/Images/sea.png differ diff --git a/App/Assets/Images/tor2.png b/App/Assets/Images/tor2.png new file mode 100755 index 0000000..3ebf00f Binary files /dev/null and b/App/Assets/Images/tor2.png differ diff --git a/App/Assets/Images/uta.png b/App/Assets/Images/uta.png index ec5a3ad..5e3f818 100755 Binary files a/App/Assets/Images/uta.png and b/App/Assets/Images/uta.png differ diff --git a/App/Assets/Images/was.png b/App/Assets/Images/was.png index b6ca0f3..cea849f 100755 Binary files a/App/Assets/Images/was.png and b/App/Assets/Images/was.png differ diff --git a/App/Assets/Images/west.png b/App/Assets/Images/west.png new file mode 100755 index 0000000..af57d96 Binary files /dev/null and b/App/Assets/Images/west.png differ diff --git a/App/Assets/Images/whitebballstraight.png b/App/Assets/Images/whitebballstraight.png new file mode 100755 index 0000000..9ea9909 Binary files /dev/null and b/App/Assets/Images/whitebballstraight.png differ diff --git a/App/Assets/fonts/Rubik-Light.ttf b/App/Assets/fonts/Rubik-Light.ttf new file mode 100755 index 0000000..5ffda61 Binary files /dev/null and b/App/Assets/fonts/Rubik-Light.ttf differ diff --git a/App/Assets/icons/basketball.png b/App/Assets/icons/basketball.png new file mode 100644 index 0000000..97fdf14 Binary files /dev/null and b/App/Assets/icons/basketball.png differ diff --git a/App/Assets/icons/scoreboard.png b/App/Assets/icons/scoreboard.png new file mode 100644 index 0000000..33af2c5 Binary files /dev/null and b/App/Assets/icons/scoreboard.png differ diff --git a/App/Assets/icons/trophy.png b/App/Assets/icons/trophy.png new file mode 100644 index 0000000..997558c Binary files /dev/null and b/App/Assets/icons/trophy.png differ diff --git a/App/Assets/oldImages/atl.png b/App/Assets/oldImages/atl.png new file mode 100755 index 0000000..efaa83d Binary files /dev/null and b/App/Assets/oldImages/atl.png differ diff --git a/App/Assets/Images/back_button_green.png b/App/Assets/oldImages/back_button_green.png similarity index 100% rename from App/Assets/Images/back_button_green.png rename to App/Assets/oldImages/back_button_green.png diff --git a/App/Assets/Images/back_button_white.png b/App/Assets/oldImages/back_button_white.png similarity index 100% rename from App/Assets/Images/back_button_white.png rename to App/Assets/oldImages/back_button_white.png diff --git a/App/Assets/oldImages/bkn.png b/App/Assets/oldImages/bkn.png new file mode 100755 index 0000000..75333d1 Binary files /dev/null and b/App/Assets/oldImages/bkn.png differ diff --git a/App/Assets/oldImages/bos.png b/App/Assets/oldImages/bos.png new file mode 100755 index 0000000..a3e35e8 Binary files /dev/null and b/App/Assets/oldImages/bos.png differ diff --git a/App/Assets/Images/calendar.png b/App/Assets/oldImages/calendar.png similarity index 100% rename from App/Assets/Images/calendar.png rename to App/Assets/oldImages/calendar.png diff --git a/App/Assets/oldImages/cha.png b/App/Assets/oldImages/cha.png new file mode 100755 index 0000000..e4a05ec Binary files /dev/null and b/App/Assets/oldImages/cha.png differ diff --git a/App/Assets/oldImages/chi.png b/App/Assets/oldImages/chi.png new file mode 100755 index 0000000..1dae300 Binary files /dev/null and b/App/Assets/oldImages/chi.png differ diff --git a/App/Assets/oldImages/cle.png b/App/Assets/oldImages/cle.png new file mode 100755 index 0000000..4de6bd0 Binary files /dev/null and b/App/Assets/oldImages/cle.png differ diff --git a/App/Assets/oldImages/dal.png b/App/Assets/oldImages/dal.png new file mode 100755 index 0000000..ee70cc6 Binary files /dev/null and b/App/Assets/oldImages/dal.png differ diff --git a/App/Assets/oldImages/den.png b/App/Assets/oldImages/den.png new file mode 100755 index 0000000..a3ca34a Binary files /dev/null and b/App/Assets/oldImages/den.png differ diff --git a/App/Assets/oldImages/det.png b/App/Assets/oldImages/det.png new file mode 100755 index 0000000..51d61ce Binary files /dev/null and b/App/Assets/oldImages/det.png differ diff --git a/App/Assets/oldImages/gsw.png b/App/Assets/oldImages/gsw.png new file mode 100755 index 0000000..c4a7fed Binary files /dev/null and b/App/Assets/oldImages/gsw.png differ diff --git a/App/Assets/oldImages/hou.png b/App/Assets/oldImages/hou.png new file mode 100755 index 0000000..90d4ab9 Binary files /dev/null and b/App/Assets/oldImages/hou.png differ diff --git a/App/Assets/Images/hou2.png b/App/Assets/oldImages/hou2.png similarity index 100% rename from App/Assets/Images/hou2.png rename to App/Assets/oldImages/hou2.png diff --git a/App/Assets/oldImages/ind.png b/App/Assets/oldImages/ind.png new file mode 100755 index 0000000..5f3da21 Binary files /dev/null and b/App/Assets/oldImages/ind.png differ diff --git a/App/Assets/oldImages/lac.png b/App/Assets/oldImages/lac.png new file mode 100755 index 0000000..412bd46 Binary files /dev/null and b/App/Assets/oldImages/lac.png differ diff --git a/App/Assets/oldImages/lal.png b/App/Assets/oldImages/lal.png new file mode 100755 index 0000000..ebaa847 Binary files /dev/null and b/App/Assets/oldImages/lal.png differ diff --git a/App/Assets/Images/left_arrow.png b/App/Assets/oldImages/left_arrow.png similarity index 100% rename from App/Assets/Images/left_arrow.png rename to App/Assets/oldImages/left_arrow.png diff --git a/App/Assets/oldImages/mem.png b/App/Assets/oldImages/mem.png new file mode 100755 index 0000000..7e47160 Binary files /dev/null and b/App/Assets/oldImages/mem.png differ diff --git a/App/Assets/oldImages/mia.png b/App/Assets/oldImages/mia.png new file mode 100755 index 0000000..9c0bf58 Binary files /dev/null and b/App/Assets/oldImages/mia.png differ diff --git a/App/Assets/oldImages/mil.png b/App/Assets/oldImages/mil.png new file mode 100755 index 0000000..85307d1 Binary files /dev/null and b/App/Assets/oldImages/mil.png differ diff --git a/App/Assets/oldImages/min.png b/App/Assets/oldImages/min.png new file mode 100755 index 0000000..08d1218 Binary files /dev/null and b/App/Assets/oldImages/min.png differ diff --git a/App/Assets/oldImages/nba.png b/App/Assets/oldImages/nba.png new file mode 100644 index 0000000..41d114c Binary files /dev/null and b/App/Assets/oldImages/nba.png differ diff --git a/App/Assets/oldImages/nop.png b/App/Assets/oldImages/nop.png new file mode 100755 index 0000000..e1603fd Binary files /dev/null and b/App/Assets/oldImages/nop.png differ diff --git a/App/Assets/oldImages/nyk.png b/App/Assets/oldImages/nyk.png new file mode 100755 index 0000000..04f06ec Binary files /dev/null and b/App/Assets/oldImages/nyk.png differ diff --git a/App/Assets/oldImages/okc.png b/App/Assets/oldImages/okc.png new file mode 100755 index 0000000..cf1a335 Binary files /dev/null and b/App/Assets/oldImages/okc.png differ diff --git a/App/Assets/oldImages/orl.png b/App/Assets/oldImages/orl.png new file mode 100755 index 0000000..dacd6fb Binary files /dev/null and b/App/Assets/oldImages/orl.png differ diff --git a/App/Assets/oldImages/phi.png b/App/Assets/oldImages/phi.png new file mode 100755 index 0000000..11ac180 Binary files /dev/null and b/App/Assets/oldImages/phi.png differ diff --git a/App/Assets/oldImages/phx.png b/App/Assets/oldImages/phx.png new file mode 100755 index 0000000..4fc5acc Binary files /dev/null and b/App/Assets/oldImages/phx.png differ diff --git a/App/Assets/oldImages/por.png b/App/Assets/oldImages/por.png new file mode 100755 index 0000000..09b74fa Binary files /dev/null and b/App/Assets/oldImages/por.png differ diff --git a/App/Assets/Images/right_arrow.png b/App/Assets/oldImages/right_arrow.png similarity index 100% rename from App/Assets/Images/right_arrow.png rename to App/Assets/oldImages/right_arrow.png diff --git a/App/Assets/Images/ring.gif b/App/Assets/oldImages/ring.gif similarity index 100% rename from App/Assets/Images/ring.gif rename to App/Assets/oldImages/ring.gif diff --git a/App/Assets/oldImages/sac.png b/App/Assets/oldImages/sac.png new file mode 100755 index 0000000..26184aa Binary files /dev/null and b/App/Assets/oldImages/sac.png differ diff --git a/App/Assets/oldImages/sas.png b/App/Assets/oldImages/sas.png new file mode 100755 index 0000000..618b43f Binary files /dev/null and b/App/Assets/oldImages/sas.png differ diff --git a/App/Assets/oldImages/tor.png b/App/Assets/oldImages/tor.png new file mode 100755 index 0000000..5ffa280 Binary files /dev/null and b/App/Assets/oldImages/tor.png differ diff --git a/App/Assets/oldImages/trophy.png b/App/Assets/oldImages/trophy.png new file mode 100644 index 0000000..ef2be92 Binary files /dev/null and b/App/Assets/oldImages/trophy.png differ diff --git a/App/Assets/oldImages/uta.png b/App/Assets/oldImages/uta.png new file mode 100755 index 0000000..ec5a3ad Binary files /dev/null and b/App/Assets/oldImages/uta.png differ diff --git a/App/Assets/oldImages/was.png b/App/Assets/oldImages/was.png new file mode 100755 index 0000000..b6ca0f3 Binary files /dev/null and b/App/Assets/oldImages/was.png differ diff --git a/App/Assets/svg/basketball.svg b/App/Assets/svg/basketball.svg new file mode 100644 index 0000000..7c81d1a --- /dev/null +++ b/App/Assets/svg/basketball.svg @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/App/Assets/svg/scoreboard.svg b/App/Assets/svg/scoreboard.svg new file mode 100644 index 0000000..0dc032f --- /dev/null +++ b/App/Assets/svg/scoreboard.svg @@ -0,0 +1,27 @@ + + + + + + + + + + + + + + + diff --git a/App/Assets/svg/trophy.svg b/App/Assets/svg/trophy.svg new file mode 100644 index 0000000..f569651 --- /dev/null +++ b/App/Assets/svg/trophy.svg @@ -0,0 +1,19 @@ + + + + + + + + + diff --git a/App/Components/Date.js b/App/Components/Date.js deleted file mode 100644 index 6769082..0000000 --- a/App/Components/Date.js +++ /dev/null @@ -1,194 +0,0 @@ -/* eslint-disable semi, space-before-function-paren, space-before-blocks*/ -import React from 'react'; -import { - Text, - View, - StyleSheet -} from 'react-native'; - -import moment from 'moment'; -import DatePicker from 'react-native-datepicker'; - -var STORE = require('../Utilities/Store'); - -class Date extends React.Component { - - constructor(props){ - super(props); - this.state = { - numberOfGames: 0, - loaded: false, - date: moment().format('L'), - dateWithDay: '' - } - STORE.date = moment().format('L'); - } - - componentWillMount(){ - this.fetchGames(); - } - - getDate(){ - var date1 = moment().format('LLLL'); - date1 = date1.split(' '); - var day = date1[0].replace(',',''); - var dayNum = date1[2].replace(',',''); - var month = date1[1]; - var combinedDate = day + ', ' + month + ' ' + dayNum; - return combinedDate; - } - - fetchGames(){ - var date = this.state.date; - if (date.indexOf('-') > -1){ - date = date.split('-'); - } else { - date = date.split('/'); - } - var month = date[0]; - var day = date[1]; - var year = date[2]; - date = year + month + day; - STORE.date = date; - var url = 'http://data.nba.com/data/5s/json/cms/noseason/scoreboard/' + date + '/games.json'; - fetch(url) - .then((response) => response.json()) - .then((jsonResponse) => { - if (jsonResponse['sports_content']['games']['game']){ - var games = jsonResponse['sports_content']['games']['game']; - this.setState({ - numberOfGames: games.length, - loaded: true - }); - } - }) - .catch((error) => { - if (error instanceof SyntaxError){ - this.setState({ - numberOfGames: 0, - loaded: true - }); - } - }); - } - - fetchPlayers(){ - var url = 'http://stats.nba.com/stats/commonallplayers?LeagueID=00&IsOnlyCurrentSeason=1&Season=' + STORE.seasonForPlayerIDLookup; - fetch(url) - .then((response) => response.json()) - .then((jsonResponse) => { - var players = jsonResponse['resultSets'][0]['rowSet']; - STORE.playersInSeason = players; - }) - .catch((error) => { - STORE.playersInSeason = []; - }); - } - - handleDateChange(date){ - var currentSeason = STORE.season; - var date2 = date.split('-'); - var month = date2[0]; - var day = date2[1]; - var year = date2[2]; - date2 = year + '-' + month + '-' + day; - var dateDay = moment(date2).format('LLLL').slice(0, moment(date2).format('LLLL').lastIndexOf(',')); - if (month >= 10 && month <= 12){ - STORE.year = year; - let currentSeasonArray = currentSeason.split(''); - STORE.season = year + '-' + currentSeasonArray[2] + (parseInt(currentSeasonArray[3]) + 1); - } else { - STORE.year = parseInt(year) - 1; - let currentSeasonArray = year.split(''); - STORE.season = (parseInt(year) - 1) + '-' + currentSeasonArray[2] + currentSeasonArray[3]; - } - this.setState({ - date: date, - dateWithDay: dateDay - }, function(){ this.fetchGames(); this.fetchPlayers();}); - } - - render() { - return ( - - - {this.state.dateWithDay || this.getDate()} - - {!this.state.loaded ? 'Checking number of games' : - (() => { - switch (this.state.numberOfGames === 0){ - case true: return 'There are no games today'; - case false: switch (this.state.numberOfGames === 1){ - case true: return 'There is 1 game today'; - case false: return 'There are ' + this.state.numberOfGames + ' games today'; - } - } - })() - } - - - {STORE.date.split('/')[0] === '07' && this.state.numberOfGames !== 0 ? - 'Some games may not be displayed due to Summer League play' : '' - } - - - - { this.handleDateChange(date) }} - /> - - - ) - } -}; - -var styles = StyleSheet.create({ - dateContainer: { - backgroundColor: '#FF5722', - padding: 35, - flexDirection: 'column', - flex: 1 - }, - dateText: { - fontSize: 17, - fontWeight: '500', - marginTop: 20, - textAlign: 'center', - color: '#FFFFFF' - }, - numberOfGamesText: { - fontSize: 12, - marginTop: 10, - textAlign: 'center', - color: '#FFFFFF' - }, - summerLeagueText: { - fontSize: 10, - marginTop: 5, - textAlign: 'center', - color: '#FFFFFF' - } -}); - -module.exports = Date; -/* eslint-enable semi, space-before-function-paren, space-before-blocks*/ diff --git a/App/NBAreact.js b/App/NBAreact.js index 37afdfd..0789ad2 100644 --- a/App/NBAreact.js +++ b/App/NBAreact.js @@ -1,45 +1,124 @@ -/* eslint-disable semi, space-before-function-paren, space-before-blocks*/ -import React from 'react'; -import { - StyleSheet -} from 'react-native'; +import React, { Component } from 'react' +import { Text, View, Image } from 'react-native' +import { StackNavigator, TabNavigator } from 'react-navigation' -import {Scene, Router} from 'react-native-router-flux'; +import ScoresScreen from './components/ScoresScreen' +import GameDetailScreen from './components/GameDetailScreen' +import StandingsScreen from './components/StandingsScreen' +import TeamScreen from './components/TeamScreen' +import PlayerScreen from './components/PlayerScreen' +import TeamStats from './components/GameDetailScreen/TeamStats' +import BoxScore from './components/GameDetailScreen/BoxScore' +import PlayByPlay from './components/GameDetailScreen/PlayByPlay' -import MainWindow from './Views/Main/MainWindow'; -import GameStatsPage from './Views/Game/GameStatsPage'; -import TeamStatsPage from './Views/Team/TeamStatsPage'; -import IndividualPlayerPage from './Views/Player/IndividualPlayerPage'; - -var STORE = require('./Utilities/Store'); +const GameDetailNavigator = TabNavigator({ + 'Team Stats': { screen: TeamStats }, + 'Boxscore': { screen: BoxScore }, + 'Play by Play': { screen: PlayByPlay } +}, { + tabBarPosition: 'top', + swipeEnabled: false, + tabBarOptions: { + activeTintColor: '#FFFFFF', + inactiveTintColor: '#777777', + inactiveBackgroundColor: '#151516', + activeBackgroundColor: '#171717', + showIcon: false, + indicatorStyle: { + borderBottomColor: '#F7971E', + borderBottomWidth: 2, + }, + labelStyle:{ + fontSize: 14, + justifyContent: 'center', + alignItems: 'center', + }, + style:{ + backgroundColor: '#111111' + }, + tabStyle: { + justifyContent: 'center', + alignItems: 'center', + } + }, +}) -class NBAreact extends React.Component { - render() { - return ( - - - - - - - - - ) +const ScoresStack = StackNavigator({ + Home: { + screen: ScoresScreen, + navigationOptions: { header: null } + }, + Game: { + screen: GameDetailNavigator, + navigationOptions: { + headerTintColor: '#D3D3D3', + headerStyle: { + backgroundColor: '#171717', + borderBottomWidth: 0 + }, + headerTitleStyle: { + fontSize: 18, + } + } } -}; +}) -var styles = StyleSheet.create({ - gameStatsPageTab: { - backgroundColor: '#03A9F4' +const StandingsStack = StackNavigator({ + Home: { + screen: StandingsScreen, + navigationOptions: { header: null } }, - teamPageTab: { - backgroundColor: STORE.navBarColorForTeamPage + Team: { + screen: TeamScreen, + navigationOptions: { + headerTintColor: '#D3D3D3', + headerStyle: { + backgroundColor: '#171717', + borderBottomWidth: 0 + }, + headerTitleStyle: { + fontSize: 18, + } + } }, - playerTab: { - backgroundColor: '#000', - borderBottomWidth: 0 + Player: { + screen: PlayerScreen, + navigationOptions: { + headerTintColor: '#D3D3D3', + headerStyle: { + backgroundColor: '#171717', + borderBottomWidth: 0 + }, + headerTitleStyle: { + fontSize: 18, + } + } } -}); +}) -module.exports = NBAreact; -/* eslint-enable semi, space-before-function-paren, space-before-blocks*/ +export default TabNavigator({ + Scores: { screen: ScoresStack }, + Standings: { screen: StandingsStack } +},{ + navigationOptions: ({ navigation }) => ({ + tabBarIcon: ({ focused, tintColor }) => { + const { routeName } = navigation.state + let iconName + if (routeName === 'Scores') { + iconName = require('./Assets/icons/scoreboard.png') + } else if (routeName === 'Standings') { + iconName = require('./Assets/icons/trophy.png') + } + + return + }, + }), + tabBarOptions: { + activeTintColor: '#F7971E', + inactiveTintColor: 'gray', + style: { + backgroundColor: '#171717', + } + }, + tabBarPosition: 'bottom' +}) diff --git a/App/Utilities/Store.js b/App/Utilities/Store.js deleted file mode 100644 index bf78309..0000000 --- a/App/Utilities/Store.js +++ /dev/null @@ -1,20 +0,0 @@ -/* eslint-disable semi */ -import moment from 'moment'; -/* - season will always be YYYY-YY - ex1: if the season is in the month March 2016, - year will be 2015 - season will be 2015-16 - ex2: if the season is in the month October 2016, - year will be 2016 - season will be 2016-17 -*/ -module.exports = { - date: moment().format('L'), - season: '2016-17', - seasonForPlayerIDLookup: '2016-17', - year: 2016, - playersInSeason: [], - navBarColorForTeamPage: '#4CAF50' -}; -/* eslint-enable semi */ diff --git a/App/Views/Game/GameStatsPage.js b/App/Views/Game/GameStatsPage.js deleted file mode 100644 index 16e6674..0000000 --- a/App/Views/Game/GameStatsPage.js +++ /dev/null @@ -1,44 +0,0 @@ -/* eslint-disable semi, space-before-function-paren, space-before-blocks*/ - -import React from 'react'; -import { - View, - StyleSheet -} from 'react-native'; - -import ScrollableTabView, { - DefaultTabBar -} from 'react-native-scrollable-tab-view'; - -import GameStatsTeam from './GameStatsTeam'; -import GameStatsPlayers from './GameStatsPlayers'; - -class GameStatsPage extends React.Component { - - render(){ - var game = this.props.game; - return ( - - } - tabBarActiveTextColor='#FFFFFF' - tabBarInactiveTextColor='#e5e5e5' - tabBarUnderlineColor='#b3dbf1' - > - - - - - ) - } -} - -var styles = StyleSheet.create({ - main: { - flex: 1, - backgroundColor: '#FCFCFC' - } -}); - -module.exports = GameStatsPage; -/* eslint-enable semi, space-before-function-paren, space-before-blocks*/ diff --git a/App/Views/Game/GameStatsPlayerCell.js b/App/Views/Game/GameStatsPlayerCell.js deleted file mode 100644 index 2cf2262..0000000 --- a/App/Views/Game/GameStatsPlayerCell.js +++ /dev/null @@ -1,138 +0,0 @@ -/* eslint-disable semi, space-before-function-paren, space-before-blocks*/ -import React from 'react'; -import { - Text, - View, - StyleSheet, - Image, - TouchableHighlight -} from 'react-native'; - -import { Actions } from 'react-native-router-flux'; - -var STORE = require('../../Utilities/Store'); - -class GameStatsPlayerCell extends React.Component { - - goToIndividualPlayerPage(player){ - Actions.IndividualPlayerPage({player: player}); - } - - /* used for historical stats since a player id isn't returned with historical data. - * STORE.playersInSeason is an array with every player in current season. player_code is - * essentially the player's name, so we look up the player_code in the array and get - * the player id - */ - getPersonID(){ - for (var i = 0; i < STORE.playersInSeason.length; i++){ - if (STORE.playersInSeason[i][6] === this.props.player.player_code){ - return STORE.playersInSeason[i][0]; - } - } - } - - render(){ - var player = this.props.player; - var id = player.person_id === undefined ? this.getPersonID() : player.person_id; - return ( - - - - - - - - {player.first_name} {player.last_name} - #{player.jersey_number} - {player.position_short} - - - - - {player.minutes} - MINUTES PLAYED - - - - - {player.points} - PTS - - - {parseInt(player.rebounds_offensive) + parseInt(player.rebounds_defensive)} - REB - - - {player.assists} - AST - - - - - - - ) - } -} - -var styles = StyleSheet.create({ - body: { - height: 70, - backgroundColor: '#FCFCFC', - flexDirection: 'row', - borderColor: '#E1E1E1', - borderBottomWidth: 0.5 - }, - imageBlock: { - flex: 1, - justifyContent: 'center' - }, - playerImage: { - height: 60, - width: 60, - marginTop: 3, - marginLeft: 2, - borderRadius: 25 - }, - playerName: { - marginLeft: 8, - flex: 2, - justifyContent: 'center' - }, - gameStats: { - flex: 3, - justifyContent: 'center' - }, - gameStatsItem: { - alignItems: 'flex-end', - flexDirection: 'row', - marginRight: 10 - }, - statsLine1: { - marginTop: 5, - flexDirection: 'row', - justifyContent: 'center' - }, - statsLine2: { - flexDirection: 'row', - justifyContent: 'center' - }, - itemNumber: { - fontSize: 14, - fontWeight: '500', - position: 'relative', - top: 1, - color: '#2c333f' - }, - itemLabel: { - fontSize: 12, - fontWeight: '200', - color: '#16191f' - } -}); - -module.exports = GameStatsPlayerCell; -/* eslint-enable semi, space-before-function-paren, space-before-blocks*/ diff --git a/App/Views/Game/GameStatsPlayers.js b/App/Views/Game/GameStatsPlayers.js deleted file mode 100644 index 5846a98..0000000 --- a/App/Views/Game/GameStatsPlayers.js +++ /dev/null @@ -1,125 +0,0 @@ -/* eslint-disable semi, space-before-function-paren, space-before-blocks*/ -import React from 'react'; -import { - Text, - View, - StyleSheet, - ListView, - Dimensions, - Image -} from 'react-native'; - -import TeamMap from '../../Utilities/TeamMap'; -import GameStatsPlayerCell from './GameStatsPlayerCell'; - -let windowHeight = Dimensions.get('window').height; - -class GameStatsPlayers extends React.Component { - - constructor(props){ - super(props); - this.state = { - loaded: false, - homePlayerStats: [], - awayPlayerStats: [], - allPlayers: {}, - allPlayersDataSource: new FlatList.DataSource({ - rowHasChanged: (r1, r2) => r1 !== r2, - sectionHeaderHasChanged: (s1, s2) => s1 !== s2 - }) - }; - } - - componentWillMount(){ - this.getGamePlayerStats(); - } - - // retrieves player stats for a specific game - getGamePlayerStats(){ - var game = this.props.game; - var date = game.date; - var gameID = game.id; - var url = 'http://data.nba.com/data/10s/json/cms/noseason/game/' + date + '/' + gameID + '/boxscore.json'; - fetch(url) - .then((response) => response.json()) - .then((jsonResponse) => { - var homePlayers = jsonResponse.sports_content.game.home.players.player; - var awayPlayers = jsonResponse.sports_content.game.visitor.players.player; - var allPlayers = {}; - allPlayers[game.visitor.city] = awayPlayers; - allPlayers[game.home.city] = homePlayers; - this.setState({ - loaded: true, - homePlayerStats: homePlayers, - awayPlayerStats: awayPlayers, - allPlayers: allPlayers, - allPlayersDataSource: this.state.allPlayersDataSource.cloneWithRowsAndSections(allPlayers) - }); - }) - .catch((error) => { - this.setState({ - loaded: true, - allPlayers: [], - allPlayersDataSource: this.state.allPlayersDataSource.cloneWithRowsAndSections([]) - }); - }); - } - - render(){ - var awayTeamColor = TeamMap[this.props.game.visitor.abbreviation.toLowerCase()].color; - var homeTeamColor = TeamMap[this.props.game.home.abbreviation.toLowerCase()].color; - if (!this.state.loaded){ - return ( - - - - ) - } - if(this.state.loaded && this.state.allPlayers.length === 0){ - return ( - - Player data should be available at tipoff - - ) - } - return ( - - - - - } - renderSectionHeader={(rowData, sectionID, rowID) => - - {sectionID} - - } - /> - - - ) - } -} - -var styles = StyleSheet.create({ - header: { - height: 50, - backgroundColor: '#e2e2e2' - }, - headerText: { - alignSelf: 'center', - marginTop: 10, - fontSize: 16, - color: '#FFFFFF' - } -}); - -module.exports = GameStatsPlayers; -/* eslint-enable semi, space-before-function-paren, space-before-blocks*/ diff --git a/App/Views/Game/GameStatsTeam.js b/App/Views/Game/GameStatsTeam.js deleted file mode 100644 index 83f652f..0000000 --- a/App/Views/Game/GameStatsTeam.js +++ /dev/null @@ -1,374 +0,0 @@ -/* eslint-disable semi, space-before-function-paren, space-before-blocks*/ - -import React from 'react'; -import { - Text, - View, - StyleSheet, - Image, - TouchableHighlight -} from 'react-native'; - -import { Actions } from 'react-native-router-flux'; - -import TeamMap from '../../Utilities/TeamMap'; - -class GameStatsTeam extends React.Component { - - constructor(props){ - super(props); - this.state = { - homeStats: [], - awayStats: [], - homeScores: this.props.game.home, - awayScores: this.props.game.visitor, - homeRecord: '', - awayRecord: '', - loaded: false - } - } - - componentWillMount(){ - this.getGameStats(); - } - - // retrieves game stats for a specific game - getGameStats(){ - var game = this.props.game; - var date = game.date; - var gameID = game.id; - var url = 'http://data.nba.com/data/10s/json/cms/noseason/game/' + date + '/' + gameID + '/boxscore.json'; - fetch(url) - .then((response) => response.json()) - .then((jsonResponse) => { - var homeStats = jsonResponse.sports_content.game.home; - var awayStats = jsonResponse.sports_content.game.visitor; - this.setState({ - homeStats: homeStats, - awayStats: awayStats, - loaded: true - }); - }) - .catch((error) => { - console.log(error); - }); - } - - render(){ - if (!this.state.loaded){ - return ( - - - - ) - } - var h1 = 0; - var h2 = 0; - var h3 = 0; - var h4 = 0; - var hFinal = 0; - var a1 = 0; - var a2 = 0; - var a3 = 0; - var a4 = 0; - var aFinal = 0; - if (this.state.awayScores.linescores && this.state.homeScores.linescores){ - switch (this.state.awayScores.linescores.period.length){ - case 1: - a1 = this.state.awayScores.linescores.period[0].score; - break; - case 2: - a1 = this.state.awayScores.linescores.period[0].score; - a2 = this.state.awayScores.linescores.period[1].score; - break; - case 3: - a1 = this.state.awayScores.linescores.period[0].score; - a2 = this.state.awayScores.linescores.period[1].score; - a3 = this.state.awayScores.linescores.period[2].score; - break; - case 4: - a1 = this.state.awayScores.linescores.period[0].score; - a2 = this.state.awayScores.linescores.period[1].score; - a3 = this.state.awayScores.linescores.period[2].score; - a4 = this.state.awayScores.linescores.period[3].score; - break; - default: - a1 = 0; - a2 = 0; - a3 = 0; - a4 = 0; - break; - } - switch (this.state.homeScores.linescores.period.length){ - case 1: - h1 = this.state.homeScores.linescores.period[0].score; - break; - case 2: - h1 = this.state.homeScores.linescores.period[0].score; - h2 = this.state.homeScores.linescores.period[1].score; - break; - case 3: - h1 = this.state.homeScores.linescores.period[0].score; - h2 = this.state.homeScores.linescores.period[1].score; - h3 = this.state.homeScores.linescores.period[2].score; - break; - case 4: - h1 = this.state.homeScores.linescores.period[0].score; - h2 = this.state.homeScores.linescores.period[1].score; - h3 = this.state.homeScores.linescores.period[2].score; - h4 = this.state.homeScores.linescores.period[3].score; - break; - default: - h1 = 0; - h2 = 0; - h3 = 0; - h4 = 0; - break; - } - } - aFinal = parseInt(a1) + parseInt(a2) + parseInt(a3) + parseInt(a4); - hFinal = parseInt(h1) + parseInt(h2) + parseInt(h3) + parseInt(h4); - return ( - - - - - - - - Q1 - - - Q2 - - - Q3 - - - Q4 - - - Final - - - - - - - {this.state.awayStats.abbreviation} - - - {a1} - - - {a2} - - - {a3} - - - {a4} - - - {aFinal} - - - - - - {this.state.homeStats.abbreviation} - - - {h1} - - - {h2} - - - {h3} - - - {h4} - - - {hFinal} - - - - - - - Actions.TeamStats({team: this.state.awayStats.abbreviation.toLowerCase()})} underlayColor='#FFFFFF'> - - - - Stats - - Actions.TeamStats({team: this.state.homeStats.abbreviation.toLowerCase()})} underlayColor='#FFFFFF'> - - - - - - - {this.state.awayStats.stats.points === '' ? '0' : this.state.awayStats.stats.points} - {this.state.awayStats.stats.field_goals_made === '' ? '-' : this.state.awayStats.stats.field_goals_made + '/' + this.state.awayStats.stats.field_goals_attempted + '(' + this.state.awayStats.stats.field_goals_percentage + '%)'} - {this.state.awayStats.stats.three_pointers_made === '' ? '-' : this.state.awayStats.stats.three_pointers_made + '/' + this.state.awayStats.stats.three_pointers_attempted + '(' + this.state.awayStats.stats.three_pointers_percentage + '%)'} - {this.state.awayStats.stats.free_throws_made === '' ? '-' : this.state.awayStats.stats.free_throws_made + '/' + this.state.awayStats.stats.free_throws_attempted + '(' + this.state.awayStats.stats.free_throws_percentage + '%)'} - {this.state.awayStats.stats.assists === '' ? '0' : this.state.awayStats.stats.assists} - {this.state.awayStats.stats.rebounds_offensive === '' ? '0' : this.state.awayStats.stats.rebounds_offensive} - {this.state.awayStats.stats.rebounds_defensive === '' ? '0' : this.state.awayStats.stats.rebounds_defensive} - {this.state.awayStats.stats.steals === '' ? '0' : this.state.awayStats.stats.steals} - {this.state.awayStats.stats.blocks === '' ? '0' : this.state.awayStats.stats.blocks} - {this.state.awayStats.stats.turnovers === '' ? '0' : this.state.awayStats.stats.turnovers} - {this.state.awayStats.stats.fouls === '' ? '0' : this.state.awayStats.stats.fouls} - - - Points - Field Goals - 3 Pointers - Free Throws - Assists - O. Rebounds - D. Rebounds - Steals - Blocks - Turnovers - Fouls - - - {this.state.homeStats.stats.points === '' ? '0' : this.state.homeStats.stats.points} - {this.state.homeStats.stats.field_goals_made === '' ? '-' : this.state.homeStats.stats.field_goals_made + '/' + this.state.homeStats.stats.field_goals_attempted + '(' + this.state.homeStats.stats.field_goals_percentage + '%)'} - {this.state.homeStats.stats.three_pointers_made === '' ? '-' : this.state.homeStats.stats.three_pointers_made + '/' + this.state.homeStats.stats.three_pointers_attempted + '(' + this.state.homeStats.stats.three_pointers_percentage + '%)'} - {this.state.homeStats.stats.free_throws_made === '' ? '-' : this.state.homeStats.stats.free_throws_made + '/' + this.state.homeStats.stats.free_throws_attempted + '(' + this.state.homeStats.stats.free_throws_percentage + '%)'} - {this.state.homeStats.stats.assists === '' ? '0' : this.state.homeStats.stats.assists} - {this.state.homeStats.stats.rebounds_offensive === '' ? '0' : this.state.homeStats.stats.rebounds_offensive} - {this.state.homeStats.stats.rebounds_defensive === '' ? '0' : this.state.homeStats.stats.rebounds_defensive} - {this.state.homeStats.stats.steals === '' ? '0' : this.state.homeStats.stats.steals} - {this.state.homeStats.stats.blocks === '' ? '0' : this.state.homeStats.stats.blocks} - {this.state.homeStats.stats.turnovers === '' ? '0' : this.state.homeStats.stats.turnovers} - {this.state.homeStats.stats.fouls === '' ? '0' : this.state.homeStats.stats.fouls} - - - - ) - } -} - -var styles = StyleSheet.create({ - main: { - flex: 1, - backgroundColor: '#FCFCFC' - }, - quarterScores: { - flex: 1 - // marginLeft: 15 - }, - scoreHead: { - flex: 0.5 - }, - scoreboardHeader: { - flexDirection: 'row', - justifyContent: 'center', - justifyContent: 'space-between', - // marginLeft: 75, - // marginRight: 15, - marginLeft: 12, - marginRight: 20, - marginTop: 10, - // marginBottom: -5, - flex: 0.5 - }, - scoreboardHeaderLabel: { - flex: 1, - justifyContent: 'center', - alignItems: 'center' - }, - head: { - flexDirection: 'row', - justifyContent: 'space-between', - alignItems: 'center', - marginLeft: 30, - marginRight: 30, - marginTop: 10, - marginBottom: 10 - }, - logo: { - width: 70, - height: 70, - shadowColor: '#000000', - shadowOpacity: 0.8, - shadowRadius: 1, - shadowOffset: { - height: 1, - width: 0 - } - }, - body: { - flex: 1, - flexDirection: 'row', - justifyContent: 'space-between', - marginLeft: 12, - marginRight: 12, - marginTop: 10 - }, - line: { - marginLeft: 5, - marginRight: 5, - height: 1, - backgroundColor: '#000' - }, - vertical: { - marginLeft: 15, - marginRight: 15, - width: 1, - marginTop: -10, - marginBottom: -10, - backgroundColor: '#000' - }, - verticalScores: { - marginLeft: 15, - marginRight: 15, - marginTop: -10, - width: 1, - backgroundColor: '#000' - }, - teamScores: { - flexDirection: 'row', - justifyContent: 'space-between', - marginLeft: 40, - marginRight: 30, - flex: 1, - // marginTop: 10, - marginLeft: 20 - }, - teamQuarterCell: { - borderRightWidth: 1, - borderRightColor: '#000', - flex: 1, - justifyContent: 'center', - alignItems: 'center' - }, - teamQuarterCellEnd: { - flex: 1, - justifyContent: 'center', - alignItems: 'center' - }, - statsColumn: { - flexDirection: 'column', - alignItems: 'center', - flex: 1 - } -}); - -module.exports = GameStatsTeam; -/* eslint-enable semi, space-before-function-paren, space-before-blocks*/ diff --git a/App/Views/Main/MainWindow.js b/App/Views/Main/MainWindow.js deleted file mode 100644 index 88834aa..0000000 --- a/App/Views/Main/MainWindow.js +++ /dev/null @@ -1,53 +0,0 @@ -/* eslint-disable semi, space-before-function-paren, space-before-blocks*/ -console.disableYellowBox = true; -import React from 'react'; -import { - View, - StyleSheet, - StatusBar, - Platform -} from 'react-native'; - -import ScrollableTabView, { - DefaultTabBar -} from 'react-native-scrollable-tab-view'; - -import ScoresPage from './Scores/ScoresPage'; -import StandingsPage from './Standings/StandingsPage'; -import Date from '../../Components/Date'; - -class MainWindow extends React.Component { - render() { - return ( - - - ) - } -}; - -var styles = StyleSheet.create({ - tabBar2: { - backgroundColor: '#E64A19' - }, - underline: { - backgroundColor: '#FFCCBC' - } -}); - -module.exports = MainWindow; -/* eslint-enable semi, space-before-function-paren, space-before-blocks*/ diff --git a/App/Views/Main/Scores/GameCell.js b/App/Views/Main/Scores/GameCell.js deleted file mode 100644 index b14f722..0000000 --- a/App/Views/Main/Scores/GameCell.js +++ /dev/null @@ -1,148 +0,0 @@ -/* eslint-disable semi, space-before-function-paren, space-before-blocks*/ - -import React from 'react'; -import { - Text, - View, - StyleSheet, - Image, - TouchableHighlight -} from 'react-native'; - -import { Actions } from 'react-native-router-flux'; - -import TeamMap from '../../../Utilities/TeamMap'; - -class GameCell extends React.Component { - - goToGameStats(game){ - Actions.GameStats({game: game}); - } - - render(){ - var game = this.props.game; - var homeTeam = game.home; - var awayTeam = game.visitor; - /* will cause the number of games to be inconsistent with the number of game cells - displayed, but the game cells that aren't displayed are for games with - teams that aren't in the NBA (Primarily Orlando White and Orlando Blue). Only seems to be an off-season/minor league (D-Team?) - issue. - */ - if (!TeamMap[awayTeam.abbreviation.toLowerCase()] || !TeamMap[homeTeam.abbreviation.toLowerCase()]){ - return null; - } - return ( - - - - - - {awayTeam.city} - {awayTeam.nickname} - - - {game.period_time.period_status} - {(game.period_time.game_clock === '' || game.period_time.period_status === 'Halftime') ? '' : game.period_time.game_clock} - - {awayTeam.score} - - {homeTeam.score} - - - - - {homeTeam.city} - {homeTeam.nickname} - - - - - ) - } -} - -var styles = StyleSheet.create({ - container: { - height: 100, - marginHorizontal: 12, - marginBottom: 10, - borderRadius: 5, - flex: 1, - flexDirection: 'row' - }, - teamInfo: { - alignItems: 'center', - flex: 2, - marginTop: 4 - }, - awayText: { - flex: 1.5, - fontSize: 14, - color: '#FFFFFF' - }, - teamText: { - fontSize: 10, - color: '#FFFFFF' - }, - teamText2: { - fontSize: 11, - fontWeight: '300', - color: '#FFFFFF' - }, - homeText: { - flex: 1.5, - fontSize: 14, - color: '#FFFFFF' - }, - logo: { - height: 50, - width: 50, - marginTop: 10 - }, - gameInfo: { - alignItems: 'center', - flexDirection: 'column', - flex: 2 - }, - gameInfoText: { - color: '#FFFFFF', - marginTop: 15 - }, - gameScoresView: { - flexDirection: 'row', - // flex: 1, - justifyContent: 'center', - marginTop: 17 - }, - gameScores: { - color: '#FFFFFF', - fontSize: 14, - textAlign: 'center', - width: 40 - }, - divider: { - backgroundColor: '#e9e9e9', - height: 30, - width: 1, - marginLeft: 5, - marginRight: 5 - } -}); - -module.exports = GameCell; -/* eslint-enable semi, space-before-function-paren, space-before-blocks*/ diff --git a/App/Views/Main/Scores/ScoresPage.js b/App/Views/Main/Scores/ScoresPage.js deleted file mode 100644 index 948cf79..0000000 --- a/App/Views/Main/Scores/ScoresPage.js +++ /dev/null @@ -1,176 +0,0 @@ -/* eslint-disable semi, space-before-function-paren, space-before-blocks*/ -import React from 'react'; -import { - View, - StyleSheet, - ListView, - RefreshControl, - Image, - Text -} from 'react-native'; - -import GameCell from './GameCell'; - -import moment from 'moment'; - -var STORE = require('../../../Utilities/Store'); - -class ScoresPage extends React.Component { - - constructor(props){ - super(props); - var ds = new ListView.DataSource({ - rowHasChanged: (r1, r2) => r1 !== r2 - }); - this.state = { - date: STORE.date, - refreshing: false, - db: [], - dataSource: ds.cloneWithRows([]), - loaded: false, - gamesToday: false - } - this.onRefresh = this.onRefresh.bind(this); - } - - componentWillMount(){ - this.fetchGames(); - } - - // not sure if this is the 'proper react way' but it seems to be working - componentDidMount(){ - setInterval( () => { - if(this.state.date.toString() !== STORE.date){ - this.fetchGames(); - } - }, 1000); - } - - // refresh control to update game stats - onRefresh(){ - this.setState({loaded: false}); - var date = STORE.date; - date = date.split('/'); - var month = date[0]; - var day = date[1]; - var year = date[2]; - date = year+month+day; - var url = 'http://data.nba.com/data/5s/json/cms/noseason/scoreboard/' + date + '/games.json'; - fetch(url) - .then((response) => response.json()) - .then((jsonResponse) => { - if (jsonResponse['sports_content']['games']['game']){ - var games = jsonResponse['sports_content']['games']['game']; - this.setState({ - db: games, - dataSource: this.state.dataSource.cloneWithRows(games), - loaded: true, - date: date - }); - } - }) - .catch((error) => { - if(error instanceof SyntaxError){ - this.setState({ - db: [], - loaded: true, - date: date - }); - } - }); - } - - // retrieves games being played for a date. date is in YYYYMMDD format - fetchGames(){ - var date = STORE.date; - date = date.split('/'); - var month = date[0]; - var day = date[1]; - var year = date[2]; - var url = 'http://data.nba.com/data/5s/json/cms/noseason/scoreboard/' + date + '/games.json'; - fetch(url) - .then((response) => response.json()) - .then((jsonResponse) => { - if (jsonResponse['sports_content']['games']['game']){ - var games = jsonResponse['sports_content']['games']['game']; - var gamesToday = games.length > 0 ? true : false; - this.setState({ - db: games, - dataSource: this.state.dataSource.cloneWithRows(games), - loaded: true, - date: date, - gamesToday: gamesToday - }); - } - }) - .catch((error) => { - if(error instanceof SyntaxError){ - this.setState({ - db: [], - loaded: true, - date: date, - gamesToday: false - }); - } - }); - } - - render() { - if (!this.state.loaded && this.state.db.length === 0){ // maybe this.state.db.length === 0 is not needed - return ( - - - - ) - } - if (!this.state.db.length > 0 && !this.state.gamesToday){ - return ( - - - No games today 😢 - - ) - } - return ( - - - } - style={styles.flatlistview} - dataSource={this.state.dataSource} - renderRow={(rowData, sectionID, rowID) => - this.props.goToGameStats(rowData)} - /> - } - /> - - ) - } -}; - -var styles = StyleSheet.create({ - logo: { - width: 70, - height: 70 - }, - flatlistview: { - flex: 1, - backgroundColor: '#FCFCFC', - marginTop: 5 - } -}); - -module.exports = ScoresPage; -/* eslint-enable semi, space-before-function-paren, space-before-blocks*/ diff --git a/App/Views/Main/Standings/StandingsPage.js b/App/Views/Main/Standings/StandingsPage.js deleted file mode 100644 index 349e55d..0000000 --- a/App/Views/Main/Standings/StandingsPage.js +++ /dev/null @@ -1,114 +0,0 @@ -/* eslint-disable semi, space-before-function-paren, space-before-blocks*/ -// url http://data.nba.com/data/json/cms/YEAR/league/standings.json <-- LEAGUE standings -// YEAR will be start of season -> ex: 2015/2016 season, YEAR would be 2016 - -import React from 'react'; -import { - Text, - View, - StyleSheet, - ListView, - Platform -} from 'react-native'; - -var STORE = require('../../../Utilities/Store'); - -import TeamStandingsCell from './TeamStandingsCell'; -import { getLeagueStandings } from '../../../actions' - -class StandingsPage extends React.Component { - - constructor(props){ - super(props); - var ds = new FlatList.DataSource({ - rowHasChanged: (r1, r2) => r1 !== r2 - }); - this.state = { - year: STORE.year, - standings: [], - dataSource: ds.cloneWithRows([]), - loaded: false - } - } - - componentWillMount(){ - this.fetchStandings(); - } - - componentDidMount(){ - setInterval( () => { - if(this.state.year !== STORE.year){ - this.fetchStandings(); - } - }, 1000); - } - - // retrieves league standings for a given year - fetchStandings(){ - dispatch(getLeagueStandings(2015)) - // var year = STORE.year; - // var url = 'http://data.nba.com/data/json/cms/' + year + '/league/standings.json'; - // fetch(url) - // .then((response) => response.json()) - // .then((jsonResponse) => { - // var standings = jsonResponse.sports_content.standings.team; - // this.setState({ - // year: year, - // standings: standings, - // dataSource: this.state.dataSource.cloneWithRows(standings) - // }); - // }) - // .catch((error) => { - // console.log(error); - // }); - } - - render() { - return ( - - - Team - Wins - Losses - Last 10 - Streak - - - - this.props.onPress(rowData)} - /> - } - /> - - ) - } -}; - -var styles = StyleSheet.create({ - view: { - flex: 1, - backgroundColor: Platform.OS === 'android' ? '#d8dade' : '#FCFCFC' - }, - listHeader: { - flexDirection: 'row', - justifyContent: 'space-between', - alignItems: 'center', - marginTop: 5, - marginBottom: 10, - marginLeft: 20, - marginRight: 20 - }, - line: { - marginLeft: 15, - marginRight: 15, - height: 1, - backgroundColor: '#000' - } -}); - -module.exports = StandingsPage; -/* eslint-enable semi, space-before-function-paren, space-before-blocks*/ diff --git a/App/Views/Main/Standings/TeamStandingsCell.js b/App/Views/Main/Standings/TeamStandingsCell.js deleted file mode 100644 index 84647a2..0000000 --- a/App/Views/Main/Standings/TeamStandingsCell.js +++ /dev/null @@ -1,95 +0,0 @@ -/* eslint-disable semi, space-before-function-paren, space-before-blocks*/ -import React from 'react'; -import { - Text, - View, - StyleSheet, - Image, - TouchableHighlight -} from 'react-native'; - -import TeamMap from '../../../Utilities/TeamMap'; - -import { Actions } from 'react-native-router-flux'; - -class TeamStandingsCell extends React.Component { - - onPress(team){ - Actions.TeamStats({team: team.abbreviation.toLowerCase()}); - } - - render(){ - var team = this.props.team; - var teamStats = team.team_stats; - return ( - - - - - - - - - {teamStats.wins} - - - {teamStats.losses} - - - {teamStats.l10} - - - {teamStats.streak} - - - - - - - ) - } -} - -var styles = StyleSheet.create({ - row: { - flex: 1, - height: 50, - marginBottom: 20, - marginRight: 10, - marginLeft: 10 - }, - rowContent: { - flex: 1, - flexDirection: 'row' - }, - logo: { - height: 40, - width: 40, - marginLeft: 10, - marginBottom: 8, - shadowColor: '#000000', - shadowOpacity: 0.8, - shadowRadius: 1, - shadowOffset: { - height: 1, - width: 0 - } - }, - numbersForRowContainer: { - flex: 3, - flexDirection: 'row', - alignItems: 'center' - }, - divider: { - marginLeft: 15, - marginRight: 15, - height: 1, - backgroundColor: '#000' - } -}); - -module.exports = TeamStandingsCell; -/* eslint-enable semi, space-before-function-paren, space-before-blocks*/ diff --git a/App/Views/Player/IndividualPlayerPage.js b/App/Views/Player/IndividualPlayerPage.js deleted file mode 100644 index b10ef1a..0000000 --- a/App/Views/Player/IndividualPlayerPage.js +++ /dev/null @@ -1,439 +0,0 @@ -/* eslint-disable semi, space-before-function-paren, space-before-blocks*/ -import React from 'react'; -import { - Text, - View, - StyleSheet, - Image, - Dimensions, - Animated, - TouchableHighlight, - ScrollView, - Platform -} from 'react-native'; - -var STORE = require('../../Utilities/Store'); -var playoffStats = []; - -class IndividualPlayerPage extends React.Component { - - constructor(props){ - super(props); - this.state = { - loaded: false, - gameStats: [], - noStats: false, - currentIndex: 0 - } - } - - componentWillMount(){ - this.getPlayoffStats(); - setTimeout(() => {},1000); - this.getGameStatsForYear(); - } - - /* used for historical stats since a player id isn't returned with historical data. - * STORE.playersInSeason is an array with every player in current season. player_code is - * essentially the player's name, so we look up the player_code in the array and get - * the player id - */ - getPersonID(){ - for (var i = 0; i < STORE.playersInSeason.length; i++){ - if (STORE.playersInSeason[i][6] === this.props.player.player_code){ - return STORE.playersInSeason[i][0]; - } - } - } - - // retrieves playoff stats, if any, for a player - getPlayoffStats(){ - var season = STORE.season; // IMPORTANT - var id = this.props.player.person_id || this.getPersonID(); - var url = 'http://stats.nba.com/stats/playergamelog?LeagueID=00&PerMode=PerGame&PlayerID=+' + id + '&Season=' + season + '&SeasonType=Playoffs'; - fetch(url) - .then((response) => response.json()) - .then((jsonResponse) => { - playoffStats = jsonResponse.resultSets[0].rowSet; - }) - .catch((error) => { - this.setState({ - loaded: true, - noStats: true - }); - }); - } - - // retrieves game stats for every game the player played in during the season - getGameStatsForYear(){ - var season = STORE.season; // IMPORTANT - var id = this.props.player.person_id === undefined ? this.getPersonID() : this.props.player.person_id; - var url = 'http://stats.nba.com/stats/playergamelog?LeagueID=00&PerMode=PerGame&PlayerID=' + id + '&Season=' + season + '&SeasonType=Regular+Season'; - fetch(url) - .then((response) => response.json()) - .then((jsonResponse) => { - var games = jsonResponse.resultSets[0].rowSet; - if (playoffStats.length > 0){ - var stats = playoffStats.concat(games); - }else{ - var stats = games; - } - var width = this.getWidth(stats[0]); - this.setState({ - gameStats: stats, - loaded: true, - pts: new Animated.Value(width.pts), - ast: new Animated.Value(width.ast), - reb: new Animated.Value(width.reb), - stl: new Animated.Value(width.stl), - blk: new Animated.Value(width.blk), - to: new Animated.Value(width.to), - min: new Animated.Value(width.min), - fgm: new Animated.Value(width.fgm), - fga: new Animated.Value(width.fga), - _3pm: new Animated.Value(width._3pm), - _3pa: new Animated.Value(width._3pa), - ftm: new Animated.Value(width.ftm), - fta: new Animated.Value(width.fta) - }); - }) - .catch((error) => { - this.setState({ - loaded: true, - noStats: true - }); - }); - } - - // determines the proper width for each stat bar - getWidth(data){ - const mapper = {pts: 24, min: 6, reb: 18, ast: 19, stl: 20, blk: 21, to: 22, fgm: 7, fga: 8, _3pm: 10, _3pa: 11, ftm: 13, fta: 14}; // position in data where those values can be found - const deviceWidth = Dimensions.get('window').width; - const maxWidth = 350; - const indicators = ['pts', 'ast', 'reb', 'stl', 'blk', 'to', 'min', 'fgm', 'fga', '_3pm', '_3pa', 'ftm', 'fta']; - const unit = { - ptsUnit: Math.floor(maxWidth / 45), - astUnit: Math.floor(maxWidth / 15), - rebUnit: Math.floor(maxWidth / 20), - stlUnit: Math.floor(maxWidth / 6), - blkUnit: Math.floor(maxWidth / 7), - toUnit: Math.floor(maxWidth / 10), - minUnit: Math.floor(maxWidth / 60), - fgmUnit: Math.floor(maxWidth / 55), - fgaUnit: Math.floor(maxWidth / 55), - _3pmUnit: Math.floor(maxWidth / 55), - _3paUnit: Math.floor(maxWidth / 55), - ftmUnit: Math.floor(maxWidth / 55), - ftaUnit: Math.floor(maxWidth / 55) - }; - let width = {}; - let widthCap; // Give with a max cap - indicators.forEach(item => { - widthCap = data[mapper[item]] * unit[`${item}Unit`] || 0; // nothing is displayed if value is 0 - width[item] = widthCap <= (deviceWidth - 50) ? widthCap : (deviceWidth - 50); - }); - return width - } - - // animates the bar graphs - handleAnimation(index){ - const timing = Animated.timing; - const width = this.getWidth(this.state.gameStats[index]); - const indicators = ['pts', 'ast', 'reb', 'stl', 'blk', 'to', 'min', 'fgm', 'fga', '_3pm', '_3pa', 'ftm', 'fta']; - Animated.parallel(indicators.map(item => { - return timing(this.state[item], {toValue: width[item]}); - })).start(); - this.setState({ - currentIndex: index - }); - } - - onRight(){ - if (this.state.currentIndex > 0){ - this.handleAnimation(this.state.currentIndex - 1); - } - } - - onLeft(){ - if (this.state.currentIndex < this.state.gameStats.length - 1){ - this.handleAnimation(this.state.currentIndex + 1); - } - } - - render(){ - var player = this.props.player; - var id = player.person_id === undefined ? this.getPersonID() : player.person_id; - var nextAvailable = this.state.currentIndex === 0 ? 0 : 1; - var previousAvailable = this.state.currentIndex === this.state.gameStats.length - 1 ? 0 : 1; - const {pts, ast, reb, stl, blk, to, min, fgm, fga, _3pm, _3pa, ftm, fta} = this.state; - if (!this.state.loaded || this.state.gameStats === []){ - return ( - - - - ) - } - if (this.state.noStats){ - return ( - - No player data available - - ) - } - return ( - - - - - - - {this.props.player.first_name} {this.props.player.last_name} - #{this.props.player.jersey_number} - {this.props.player.position_full} - - - - - - Points - - {pts && - - } - {this.state.gameStats[this.state.currentIndex][24]} - - - - Rebounds - - {reb && - - } - {this.state.gameStats[this.state.currentIndex][18]} - - - - Assists - - {ast && - - } - {this.state.gameStats[this.state.currentIndex][19]} - - - - Steals - - {stl && - - } - {this.state.gameStats[this.state.currentIndex][20]} - - - - Blocks - - {blk && - - } - {this.state.gameStats[this.state.currentIndex][21]} - - - - Turnovers - - {to && - - } - {this.state.gameStats[this.state.currentIndex][22]} - - - - Minutes - - {min && - - } - {this.state.gameStats[this.state.currentIndex][6]} - - - - FGM/FGA - - - - {this.state.gameStats[this.state.currentIndex][7]}/{this.state.gameStats[this.state.currentIndex][8]} - - - - 3PM/3PA - - - - {this.state.gameStats[this.state.currentIndex][10]}/{this.state.gameStats[this.state.currentIndex][11]} - - - - FTM/FTA - - - - {this.state.gameStats[this.state.currentIndex][13]}/{this.state.gameStats[this.state.currentIndex][14]} - - - - {this.state.gameStats[this.state.currentIndex][5]} {this.state.gameStats[this.state.currentIndex][4].slice(3)} - - - - - - {this.state.gameStats[this.state.currentIndex][3]} - - - - - - - - ) - } -} - -var styles = StyleSheet.create({ - body: { - flexDirection: 'column', - backgroundColor: '#FCFCFC', - height: Dimensions.get('window').height - }, - header: { - marginTop: 62, - height: 120, - flexDirection: 'row', - backgroundColor: '#000' - }, - imageBlock: { - flex: 1.5, - justifyContent: 'center', - alignItems: 'center', - marginLeft: 30 - }, - playerImage: { - height: 100, - width: 100, - borderRadius: 50, - marginBottom: 7, - shadowColor: '#151515', - shadowOpacity: 0.9, - shadowRadius: 2, - shadowOffset: { - height: 1, - width: 0 - } - }, - playerName: { - flex: 3, - alignItems: 'center', - flexDirection: 'column', - justifyContent: 'center', - marginRight: 15, - marginBottom: 8 - }, - // play around with - statItem: { - flexDirection: 'column', - marginBottom: 2, - paddingHorizontal: 10, - marginTop: 2 - }, - itemLabel: { - color: '#CBCBCB', - flex: 1, - fontSize: 14, - position: 'relative', - top: 1 - }, - itemData: { - flex: 2, - flexDirection: 'row' - }, - bar: { - alignSelf: 'center', - borderRadius: 5, - height: 10, - marginRight: 9 - }, - overlayBar: { - position: 'absolute', - top: Platform.OS === 'android' ? 4.5 : 3.5, - left: 0 - }, - points: { - backgroundColor: '#EC644B' - }, - rebounds: { - backgroundColor: '#F4D03F' - }, - assists: { - backgroundColor: '#F39C12' - }, - steals: { - backgroundColor: '#19B5FE' - }, - blocks: { - backgroundColor: '#3FC380' - }, - turnovers: { - backgroundColor: '#BF55EC' - }, - minutes: { - backgroundColor: '#8AA8AD' - }, - fgm: { - backgroundColor: '#ff8557' - }, - attempted: { - backgroundColor: '#8e8499' - }, - _3pm: { - backgroundColor: '#95E7ED' - }, - ftm: { - backgroundColor: '#FFEB3B' - }, - dataNumber: { - color: '#CBCBCB', - fontSize: 14 - }, - // - gameStatus: { - fontSize: 20, - fontWeight: '200' - }, - date: { - flexDirection: 'row', - justifyContent: 'center', - flex: 1 - }, - dateText: { - fontSize: 24, - textAlign: 'center', - marginTop: 6, - fontWeight: '200' - } -}); - -module.exports = IndividualPlayerPage; -/* eslint-enable semi, space-before-function-paren, space-before-blocks*/ diff --git a/App/Views/Team/PlayerCell.js b/App/Views/Team/PlayerCell.js deleted file mode 100644 index efb081c..0000000 --- a/App/Views/Team/PlayerCell.js +++ /dev/null @@ -1,156 +0,0 @@ -/* eslint-disable semi, space-before-function-paren, space-before-blocks*/ -import React from 'react'; -import { - Text, - View, - StyleSheet, - Image -} from 'react-native'; - -class PlayerCell extends React.Component { - constructor(props){ - super(props); - this.state = { - basicPlayerInfo: [] - }; - } - - componentWillMount(){ - this.setBasicInfo(); - } - - // finds the player's stats from the team roster and uses that data to fill in the player cell - setBasicInfo(){ - var roster = this.props.roster; - var playerName = this.props.player[2]; - for (var i = 0; i < roster.length; i++){ - if (roster[i][3] === playerName){ - this.setState({ - basicPlayerInfo: roster[i] - }); - break; - } - } - } - - render(){ - var player = this.props.player; - if (this.state.basicPlayerInfo === []){ - return fetching data - } - if (parseInt(this.state.basicPlayerInfo[4])){ // if no jersey number is returned, they are no longer on the team despite callback response. if this happens, we skip over them - return ( - - - - - - {player[2]} - #{this.state.basicPlayerInfo[4]} - {this.state.basicPlayerInfo[5]} - Years Pro: {this.state.basicPlayerInfo[10]} - - - - Age: {this.state.basicPlayerInfo[9]} - Height: {this.state.basicPlayerInfo[6]} - Weight: {this.state.basicPlayerInfo[7]} - - - - {player[3]} - GP - - - {player[7]} - MIN - - - - - {player[27]} - PPG - - - {player[19]} - RPG - - - {player[20]} - APG - - - - - ) - } else { - return null - } - } -} - -var styles = StyleSheet.create({ - body: { - height: 60, - backgroundColor: '#FCFCFC', - flexDirection: 'row', - borderColor: '#E1E1E1', - borderBottomWidth: 0.5 - }, - imageBlock: { - flex: 1, - justifyContent: 'center' - }, - playerImage: { - height: 50, - width: 50, - marginTop: 5, - marginLeft: 2, - borderRadius: 25 - }, - playerPositionNumber: { - marginLeft: 15, - flex: 2, - justifyContent: 'center' - }, - data: { - flex: 5, - marginRight: 5, - justifyContent: 'center' - }, - playerData: { - flexDirection: 'row' - }, - playerGameData1: { - marginTop: 5, - flexDirection: 'row', - justifyContent: 'center' - }, - playerGameData: { - flexDirection: 'row' - }, - playerDataItem: { - alignItems: 'flex-end', - flexDirection: 'row', - marginRight: 10, - flex: 1 - }, - playerDataNumber: { - color: '#404a5a', - fontSize: 12, - fontWeight: 'bold', - position: 'relative', - top: 1 - }, - playerDataLabel: { - color: '#4a5669', - fontSize: 10, - fontWeight: '200' - } -}); - -module.exports = PlayerCell; -/* eslint-enable semi, space-before-function-paren, space-before-blocks*/ diff --git a/App/Views/Team/TeamStatsPage.js b/App/Views/Team/TeamStatsPage.js deleted file mode 100644 index cec7cdd..0000000 --- a/App/Views/Team/TeamStatsPage.js +++ /dev/null @@ -1,247 +0,0 @@ -/* eslint-disable semi, space-before-function-paren, space-before-blocks*/ -import React from 'react'; -import { - Text, - View, - StyleSheet, - Image, - ListView, - Dimensions -} from 'react-native'; - -import {Actions} from 'react-native-router-flux' - -import TeamMap from '../../Utilities/TeamMap'; -import PlayerCell from './PlayerCell'; - -let windowHeight = Dimensions.get('window').height; - -var STORE = require('../../Utilities/Store'); - -class GameStatsTeam extends React.Component { - - constructor(props){ - super(props); - var ds = new FlatList.DataSource({ - rowHasChanged: (r1, r2) => r1 !== r2 - }); - this.state = { - loaded: false, - teamStatsRecord: [], - teamStatsLeague: [], - playerStats: [], - playersBasicStats: [], - dataSource: ds.cloneWithRows([]) - } - } - - // adds suffix to a number for league ranking. ex: 1 -> 1st - rankingSuffix(number){ - switch (parseInt(number)){ - case 1: - return '1st'; - case 2: - return '2nd'; - case 3: - return '3rd'; - default: - return number + 'th'; - } - } - - componentWillMount(){ - this.changeNavBarColor(); - this.getTeamStats(); - this.getPlayers(); - this.getBasicPlayerInfo(); - } - - changeNavBarColor(){ - STORE.navBarColorForTeamPage = TeamMap[this.props.team].color; - Actions.refresh({navigationBarStyle: {backgroundColor: STORE.navBarColorForTeamPage, borderBottomWidth: 0}}); - } - - getTeamStats(){ - var team = this.props.team; - var teamID = TeamMap[team].id; - var season = STORE.season; - var url = 'http://stats.nba.com/stats/teaminfocommon?LeagueID=00&SeasonType=Regular+Season&TeamID=' + teamID + '&season=' + season; - fetch(url) - .then((response) => response.json()) - .then((jsonResponse) => { - this.setState({ - teamStatsRecord: jsonResponse.resultSets[0].rowSet, - teamStatsLeague: jsonResponse.resultSets[1].rowSet - }); - }) - .catch((error) => { - console.log(error); - }); - } - - getPlayers(){ - var season = STORE.season; - var team = this.props.team; - var teamID = TeamMap[team].id; - var url = 'http://stats.nba.com/stats/teamplayerdashboard?DateFrom=&DateTo=&GameSegment=&LastNGames=0&LeagueID=00&Location=&MeasureType=Base&Month=0&OpponentTeamID=0&Outcome=&PaceAdjust=N&PerMode=PerGame&Period=0&PlusMinus=N&Rank=N&Season=' + season + '&SeasonSegment=&SeasonType=Regular+Season&TeamID=' + teamID + '&VsConference=&VsDivision'; - fetch(url) - .then((response) => response.json()) - .then((jsonResponse) => { - this.setState({ - playerStats: jsonResponse.resultSets[1].rowSet, - dataSource: this.state.dataSource.cloneWithRows(jsonResponse.resultSets[1].rowSet) - }); - }) - .catch((error) => { - console.log(error); - }); - } - - getBasicPlayerInfo(){ - var season = STORE.season; - var teamID = TeamMap[this.props.team].id; - var url = 'http://stats.nba.com/stats/commonteamroster?LeagueID=00&Season=' + season + '&TeamID=' + teamID; // <-- basic player info, position, number, height, weight, etc. - fetch(url) - .then((response) => response.json()) - .then((jsonResponse) => { - this.setState({ - playersBasicStats: jsonResponse.resultSets[0].rowSet, - loaded: true - }); - }) - .catch((error) => { - console.log(error); - }); - } - - render(){ - if (!this.state.loaded){ - return ( - - - - ) - } - return ( - - - - {this.state.teamStatsRecord[0][2]} - {this.state.teamStatsRecord[0][3]} - - - - - - Wins: {this.state.teamStatsRecord[0][8]} - Losses: {this.state.teamStatsRecord[0][9]} - {this.rankingSuffix(this.state.teamStatsRecord[0][11])} in the {this.state.teamStatsRecord[0][5]} - {this.rankingSuffix(this.state.teamStatsRecord[0][12])} in the {this.state.teamStatsRecord[0][6]} - - - - - PPG - {this.state.teamStatsLeague[0][4]} - ({this.rankingSuffix(this.state.teamStatsLeague[0][3])}) - - - OPP PPG - {this.state.teamStatsLeague[0][10]} - ({this.rankingSuffix(this.state.teamStatsLeague[0][9])}) - - - RPG - {this.state.teamStatsLeague[0][6]} - ({this.rankingSuffix(this.state.teamStatsLeague[0][5])}) - - - APG - {this.state.teamStatsLeague[0][8]} - ({this.rankingSuffix(this.state.teamStatsLeague[0][7])}) - - - - - } - /> - - ) - } -} - -var styles = StyleSheet.create({ - body: { - flexDirection: 'column', - backgroundColor: '#FCFCFC' - }, - header: { - marginTop: 62, - height: 100, - flexDirection: 'row' - }, - city: { - flexDirection: 'column', - justifyContent: 'center', - flex: 1.5, - marginLeft: 15 - }, - logo: { - flex: 1, - justifyContent: 'center' - }, - rankings1: { - flex: 1.5, - justifyContent: 'center', - marginRight: 15 - }, - leagueRankingsText: { - fontWeight: '400', - fontSize: 12, - color: '#FCFCFC' - }, - secondHeader: { - flexDirection: 'row', - justifyContent: 'space-between' - }, - teamStatsRankings: { - alignItems: 'center', - flexDirection: 'row', - height: 65 - }, - rankingItem: { - alignItems: 'center', - flex: 1, - flexDirection: 'column', - justifyContent: 'center' - }, - itemLabel: { - color: '#4a5669', - fontSize: 12, - fontWeight: '200' - }, - itemData: { - color: '#404a5a', - fontSize: 14, - fontWeight: 'bold', - marginLeft: 2, - position: 'relative', - top: 2 - } -}); - -module.exports = GameStatsTeam; -/* eslint-enable semi, space-before-function-paren, space-before-blocks*/ diff --git a/App/actions/actions.js b/App/actions/actions.js new file mode 100644 index 0000000..afb4550 --- /dev/null +++ b/App/actions/actions.js @@ -0,0 +1,27 @@ +export function changeDate(date) { + return { + type: 'CHANGE_DATE', + date + } +} + +export function selectGame(selectedGame) { + return { + type: 'SELECT_GAME', + selectedGame + } +} + +export function selectTeam(selectedTeam) { + return { + type: 'SELECT_TEAM', + selectedTeam + } +} + +export function selectPlayer(selectedPlayer) { + return { + type: 'SELECT_PLAYER', + selectedPlayer + } +} diff --git a/App/components/GameDetailScreen/BoxScore/BoxScore.js b/App/components/GameDetailScreen/BoxScore/BoxScore.js new file mode 100644 index 0000000..a061b01 --- /dev/null +++ b/App/components/GameDetailScreen/BoxScore/BoxScore.js @@ -0,0 +1,212 @@ +import React, { Component } from 'react' +import { Text, View, StyleSheet, Button, FlatList, ScrollView, Platform } from 'react-native' +import { connect } from 'react-redux' +import PlayerBoxCell from './PlayerBoxCell' +import Loader from '../../common/Loader' +import NBA from '../../../utils/nba' + +const headers = ['Player', 'Pos', 'Min', 'Pts', 'Ast', 'Reb', 'Stl', 'Blk', '+/-', 'FGM', 'FGA', 'FG%', '3PM', '3PA', '3P%', 'FTM', 'FTA', 'FT%', 'OREB', 'DREB', 'TOV', 'PF'] + +class BoxScore extends Component { + + constructor() { + super() + + this.nba = new NBA() + this.state = { + loading: true, + boxscore: {}, + homeTeamStats: [], + awayTeamStats: [], + homeTeam: null, + awayTeam: null, + playersInLeague: null, + activeTeam: 'away' + } + } + + componentDidMount() { + this.getPlayers() + this.fetchBoxscore() + } + + fetchBoxscore() { + this.nba.getBoxscore(this.props.gameID, this.props.date) + .then((data) => { + const homePlayers = '' + const awayPlayers = '' + this.setState({ + loading: false, + boxscore: data.stats ? data.stats : {}, + }) + }) + } + + getPlayers() { + this.nba.getPlayers(this.props.season) + .then((data) => { + this.setState({ + playersInLeague: data.league.standard + }) + }) + } + + _selectTeam(team) { + this.setState({ + activeTeam: team + }) + } + + _createBoxscoreTable(stats) { + let players = stats.activePlayers + players.unshift(headers) // make the headers the first element + if (players[0] === players[1] && players[0].personId === undefined && players[1].personId === undefined) { + players.shift() // if we already have the headers as the first element, there will be a duplicate array of headers added. in that case one of the copies should be removed + } + + const teamToShowID = this.state.activeTeam === 'away' ? this.props.awayTeamID : this.props.homeTeamID + const playersToShow = players.filter((player) => { + return player.personId === undefined || player.teamId === teamToShowID // include header array and players for specified team + }) + + const updatedPlayers = [] + const playersInLeague = this.state.playersInLeague + + // modifying original array; playersToShow + playersToShow.forEach((player, index, arr) => { + // skip header + if (index != 0) { + const desiredPlayer = playersInLeague.filter((somePlayer, index) => { + return somePlayer.personId === player.personId + }) + + const newPlayerData = { + display_fi_last: desiredPlayer[0].firstName.charAt(0) + '. ' + desiredPlayer[0].lastName + } + + player = {...player, ...newPlayerData} + // arr[index] = player + updatedPlayers.push(player) + } else { + updatedPlayers.push(player) + } + }) + + return ( + ( + + )} + /> + ) + } + + render() { + return ( + + + { + this.props.awayTeam && this.props.awayTeam && + + + + +