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

fixes #311 #315

Open
wants to merge 9 commits into
base: react-native-app-prototype
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
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
16 changes: 14 additions & 2 deletions mobile-app/src/screens/Team/Team.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,18 @@ export default class Team extends Component {
id === myTeam ? onUpdateProfileTeam({ team: '' }) : onUpdateProfileTeam({ team: id })
};

renderInfo = (icon, title, text, arrow, onPress) => (
renderInfo = (icon, title, text, arrow, onPress, counter) => (
<View style={{ marginTop: 15 }}>
<Text style={styles.infoTitle}>{title.toUpperCase()}</Text>
<TouchableOpacity style={styles.infoTextWrapper} onPress={onPress}>
{icon && <Image source={icon} style={styles.image} resizeMode="contain"/>}
<Text style={styles.text}>{text}</Text>
{arrow && <Image source={arrow} style={styles.arrow} resizeMode="contain"/>}
{!!(counter || counter === 0) &&
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can counter be non-numeric or why is this check needed?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Zero value will be treated as falsy and React will try to render it outside of Text tag, which will cause an error.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, but the check allows any truthy value or zero, only excluding null and undefined. If those values are not possible, the whole check is redundant.

<View style={styles.circle}>
<Text style={styles.circleText}>{counter}</Text>
</View>
}
</TouchableOpacity>
</View>
);
Expand Down Expand Up @@ -92,7 +97,14 @@ export default class Team extends Component {
{myTeam && myTeam !== team.id ? null : this.renderButton(btnText)}
{this.renderInfo(locationIcon, strings.label_team_location, location )}
{this.renderInfo(listIcon, strings.label_team_members, team.members )}
{this.renderInfo(trashIcon, strings.label_team_trashpoints, strings.label_team_trashpoints_tap, arrow, this.handleTrashpointsPress )}
{this.renderInfo(
trashIcon,
strings.label_team_trashpoints,
strings.label_team_trashpoints_tap,
arrow,
this.handleTrashpointsPress,
team.trashpoints
)}
{this.renderInfo(null, strings.label_team_description, team.teamDescription )}
</ScrollView>
);
Expand Down
16 changes: 16 additions & 0 deletions mobile-app/src/screens/Team/styles.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,22 @@ export default {
position: 'absolute',
right: 15,
},
circle: {
justifyContent: 'center',
alignItems: 'center',
width: 25,
height: 25,
position: 'absolute',
right: 40,
borderRadius: 12.5,
backgroundColor: '#DF1E83'
},
circleText: {
fontFamily,
color: 'white',
backgroundColor: 'rgba(0, 0, 0, 0)',
fontSize: 16,
},
text: {
fontFamily,
fontSize,
Expand Down