Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v2.4 #78

Merged
merged 12 commits into from
May 27, 2018
Merged

v2.4 #78

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 13 additions & 15 deletions App/NBAreact.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,21 +132,19 @@ export default TabNavigator({

return <Image source={iconName} style={[ iconStyle, { tintColor: tintColor }]} />
},

// NOTE: this works as intended however there are side effects that I'm not comfortable releasing yet
// tabBarOnPress: ({ scene, jumpToIndex }) => {
// const { route, focused, index } = scene
// if (focused) {
// if (route.index > 0) {
// const { routeName, key } = route.routes[1]
// navigation.dispatch(
// NavigationActions.back({ key })
// )
// }
// } else {
// jumpToIndex(index)
// }
// },
tabBarOnPress: ({ scene, jumpToIndex }) => {
const { route, focused, index } = scene
if (focused) {
if (route.index > 0) {
const { routeName, key } = route.routes[1]
navigation.dispatch(
NavigationActions.back({ key })
)
}
} else {
jumpToIndex(index)
}
},
}),
tabBarOptions: {
activeTintColor: '#F7971E',
Expand Down
90 changes: 67 additions & 23 deletions App/components/GameDetailScreen/BoxScore/BoxScore.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ 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']
const headers = ['Pos', 'Min', 'Pts', 'Ast', 'Reb', 'Stl', 'Blk', '+/-', 'FGM', 'FGA', 'FG%', '3PM', '3PA', '3P%', 'FTM', 'FTA', 'FT%', 'OREB', 'DREB', 'TOV', 'PF']

class BoxScore extends Component<Props> {

Expand Down Expand Up @@ -50,8 +50,8 @@ class BoxScore extends Component<Props> {
})
}

_createBoxscoreTable(stats) {
let players = stats.activePlayers
_createBoxscoreTable() {
let players = this.state.boxscore.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
Expand All @@ -62,39 +62,67 @@ class BoxScore extends Component<Props> {
return player.personId === undefined || player.teamId === teamToShowID // include header array and players for specified team
})

return (
<FlatList
data={playersToShow}
scrollEnabled={false}
renderItem={(player) => (
<PlayerBoxCell
key={player.personId}
player={player}
/>
)}
/>
)
}

_createPlayerlist() {
let players = this.state.boxscore.activePlayers

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.props.playersInLeague

// modifying original array; playersToShow
playersToShow.forEach((player, index, arr) => {
// skip header
if (index != 0) {
// skip header (first element)
if (player.personId) {
const desiredPlayer = playersInLeague.filter((somePlayer, index) => {
return somePlayer.personId === player.personId
})

// edge case: Nene
const name = desiredPlayer[0].lastName ? desiredPlayer[0].firstName.charAt(0) + '. ' + desiredPlayer[0].lastName : desiredPlayer[0].firstName

const newPlayerData = {
display_fi_last: desiredPlayer[0].firstName.charAt(0) + '. ' + desiredPlayer[0].lastName
display_fi_last: name
}

player = {...player, ...newPlayerData}
// arr[index] = player
updatedPlayers.push(player)
} else {
updatedPlayers.push(player)
}
})

return (
<FlatList
data={updatedPlayers}
renderItem={(player) => (
<PlayerBoxCell
key={player.personId}
player={player}
/>
)}
/>
<View style={{ flex: 1, flexDirection: 'column' }}>
<View style={[styles.playerNameCell, { borderBottomColor: '#D1D1D1', borderBottomWidth: 1 }]}>
<Text style={styles.text}> Player </Text>
</View>
{
updatedPlayers.map((player, idx) => {
return (
<View style={styles.playerNameCell} key={idx}>
<Text style={styles.text}> {player.display_fi_last} </Text>
</View>
)
})
}
</View>
)
}

Expand Down Expand Up @@ -131,18 +159,23 @@ class BoxScore extends Component<Props> {
}
{
!this.state.loading && this.state.boxscore.activePlayers && this.props.playersInLeague &&
<ScrollView horizontal={true} contentContainerStyle={{justifyContent: 'center', alignItems: 'center',flexDirection: 'column'}}>
{ this._createBoxscoreTable(this.state.boxscore) }
</ScrollView>
<View>
<ScrollView horizontal={false} contentContainerStyle={{ flexDirection: 'row' }}>
<View style={{ width: 140 }}>
{ this._createPlayerlist() }
</View>
<ScrollView horizontal={true} indicatorStyle='white' showsHorizontalScrollIndicator={true} bounces={false} contentContainerStyle={{ justifyContent: 'center', alignItems: 'center', flexDirection: 'column' }}>
{ this._createBoxscoreTable() }
</ScrollView>
</ScrollView>
</View>
}
{
!this.state.loading && !this.state.boxscore.activePlayers &&
<Text style={{ textAlign: 'center', color: '#D3D3D3' }}> Boxscore available after tip off </Text>
<Text style={styles.text}> Boxscore available after tip off </Text>
}
</View>

</View>

)
}
}
Expand Down Expand Up @@ -178,6 +211,17 @@ const styles = StyleSheet.create({
flex: 1,
justifyContent: 'center',
alignItems: 'center',
},
playerNameCell: {
padding: 10,
justifyContent: 'center',
alignItems: 'center',
width: 140
},
text: {
textAlign: 'center',
color: '#D3D3D3',
fontFamily: 'Rubik-Light'
}
})

Expand Down
2 changes: 1 addition & 1 deletion App/components/GameDetailScreen/BoxScore/PlayerBoxCell.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export default class PlayerBoxCell extends Component<Props> {
)
} else {
const categories = [
'display_fi_last', 'pos', 'min', 'points', 'assists', 'totReb','steals', 'blocks',
'pos', 'min', 'points', 'assists', 'totReb','steals', 'blocks',
'plusMinus', 'fgm', 'fga', 'fgp', 'tpm', 'tpa', 'tpp', 'ftm', 'fta', 'ftp', 'offReb',
'defReb', 'turnovers', 'pFouls'
]
Expand Down
2 changes: 1 addition & 1 deletion App/components/ScoresScreen/GameCell.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ class GameCell extends Component<Props> {
<Text style={[ styles.text, { fontSize: 16 }]}> {clock} </Text>
</View>
:
this.props.teams.item.endTimeUTC ?
this.props.teams.item.endTimeUTC || this.props.teams.item.statusNum === 3 ?
<View style={styles.gameInfo}>
<Text style={[ styles.text, {fontSize: 20 }]}> Final </Text>
</View>
Expand Down
43 changes: 28 additions & 15 deletions App/components/TeamScreen/TeamScreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,33 @@ class TeamScreen extends Component<Props> {
})
}

_renderSelectedPage() {
const {
loading,
teamRoster,
teamGamelog,
pageToShow
} = this.state

const page = pageToShow === 'roster' ?
<Roster
navigator={this.props.navigation}
team={teamRoster}
/>
:
<Games
navigator={this.props.navigation}
games={teamGamelog}
/>

return (
!loading && teamRoster && teamGamelog ?
page
:
<View />
)
}

render() {
const teamColor = getTeamFromTeamMap(this.props.teamID).color // default color could be '#BE0E2C'
// const teamLogo = getTeamFromTeamMap(this.props.teamID).logo
Expand Down Expand Up @@ -104,21 +131,7 @@ class TeamScreen extends Component<Props> {
</View>
</View>
}
{
!this.state.loading && this.state.teamRoster && this.state.pageToShow === 'roster' ?
<Roster
navigator={this.props.navigation}
team={this.state.teamRoster}
/>
:
!this.state.loading && this.state.teamGamelog && this.state.pageToShow === 'games' ?
<Games
navigator={this.props.navigation}
games={this.state.teamGamelog}
/>
:
<View></View>
}
{ this._renderSelectedPage() }
</View>
)
}
Expand Down
3 changes: 3 additions & 0 deletions App/utils/nba.js
Original file line number Diff line number Diff line change
Expand Up @@ -299,8 +299,11 @@ export default class NBA {
this.getLeadTrackerForQuarter(gameID, date, 2),
this.getLeadTrackerForQuarter(gameID, date, 3),
this.getLeadTrackerForQuarter(gameID, date, 4),
this.getLeadTrackerForQuarter(gameID, date, 5),
this.getLeadTrackerForQuarter(gameID, date, 6),
]).then((result) => {
/**
* NOTE: currently accounts for 2 overtime periods
* result is an array of objects representing the lead tracker for each quarter
* each object has a 'plays' property which is the form of an array
* result.map(...) extracts that array containing the plays and adds it into another array
Expand Down
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@

All notable changes to Swish will be documented here

# 2.4 (5-27-2018)
- Tapping a tab button will take you to its initial screen (#55)
- Fix bug where the LeadTracker graph would not show overtime (#70)
- Player name column in a boxscore is now fixed; only stats are now scrollable (#72)
- Fixed bug where completed games were showing their tip-off time (#75)
- Add iPad support (#68)

# 2.3 (5-6-2018)

- Added a new screen that displays graphs for various player stats during a specific game (#49)
Expand Down
20 changes: 11 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<p align="center">
<img src="https://github.com/jbkuczma/NBAreact/blob/v2.0_rewrite/media/swish_app.png">
<img src="https://github.com/jbkuczma/NBAreact/blob/master/media/swish_app.png">
</p>

![](https://github.com/jbkuczma/NBAreact/blob/v2.0_rewrite/media/swish_github.png)
![](https://github.com/jbkuczma/NBAreact/blob/master/media/swish_github.png)

<p align="center">
<a href="">
Expand All @@ -21,18 +21,20 @@
# Swish
An iOS and Android NBA app created with React Native. If you would like to request a feature, find a bug, have a question, or would like to leave feedback, open an [issue](https://github.com/jbkuczma/NBAreact/issues)! ⭐️ this repo to show support!

# Download
## Download
- iOS - Download [here](https://itunes.apple.com/us/app/swish-basketball-stats/id1361567861)!
- Android - Coming soon!

## Features
- Scores for in-progress and completed games
- Scores and stats for in-progress and completed games
- Detailed play by play
- Full team and player stats
- Full team stats for a season
- Full player stats for a season and over their career
- Detailed player game stat graphs
- Conference rankings
- League leaders
- Videos and highlights (coming soon)
- Compare stats for two players (coming soon)
- Compare two players (coming soon)

## Libraries Used
[React Native](https://github.com/facebook/react-native)
Expand Down Expand Up @@ -70,8 +72,8 @@ An iOS and Android NBA app created with React Native. If you would like to reque

- Run

react-native run-ios
npm run start:ios

react-native run-ios --simulator="iPhone X"
npm run start:iphoneX

react-native run-android (an emulator must be running first)
npm run start:android (an emulator must be running first)
4 changes: 2 additions & 2 deletions ios/NBAreact.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -1312,7 +1312,7 @@
);
PRODUCT_BUNDLE_IDENTIFIER = com.jameskuczmarski.swish;
PRODUCT_NAME = NBAreact;
TARGETED_DEVICE_FAMILY = 1;
TARGETED_DEVICE_FAMILY = "1,2";
VERSIONING_SYSTEM = "apple-generic";
};
name = Debug;
Expand All @@ -1338,7 +1338,7 @@
);
PRODUCT_BUNDLE_IDENTIFIER = com.jameskuczmarski.swish;
PRODUCT_NAME = NBAreact;
TARGETED_DEVICE_FAMILY = 1;
TARGETED_DEVICE_FAMILY = "1,2";
VERSIONING_SYSTEM = "apple-generic";
};
name = Release;
Expand Down
10 changes: 8 additions & 2 deletions ios/NBAreact/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>2.3</string>
<string>2.4</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>6</string>
<string>6a</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>NSAppTransportSecurity</key>
Expand Down Expand Up @@ -49,6 +49,12 @@
<array>
<string>UIInterfaceOrientationPortrait</string>
</array>
<key>UISupportedInterfaceOrientations~ipad</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
<key>UIViewControllerBasedStatusBarAppearance</key>
<false/>
</dict>
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "NBAreact",
"version": "2.3.0",
"version": "2.4.0",
"private": true,
"scripts": {
"start": "node node_modules/react-native/local-cli/cli.js start",
Expand Down