-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
5 changed files
with
84 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
import React from 'react'; | ||
import { View, Text, StyleSheet } from 'react-native'; | ||
import Colors from '../../assets/colorConstants'; | ||
import { getUserLevel } from '../models/User'; | ||
import { type ExpProgressBarProps } from './types'; | ||
|
||
const ExpProgressBar: React.FC<ExpProgressBarProps> = ({ thisUser }) => { | ||
const lvl = getUserLevel(thisUser); | ||
// testing--const lvl = 7; | ||
const lvlThresh = [250, 500, 1000, 2000, 4000, 8000, 16000, 32000, 64000]; | ||
const maxExp = lvlThresh[lvl - 1]; | ||
|
||
const curr = thisUser.score; | ||
// testing--const curr = 14039; | ||
|
||
const progress = (curr / maxExp) * 100; | ||
|
||
return ( | ||
<View style={styles.container}> | ||
<View style={styles.progressBar}> | ||
<View style={[styles.currProgression, { width: `${progress}%` }]} /> | ||
</View> | ||
<View style={styles.textBox}> | ||
<View style={styles.levelContainer}> | ||
<Text style={styles.texts}> Level: {lvl}</Text> | ||
</View> | ||
<View style={styles.progContainer}> | ||
<Text style={styles.texts}> {`${curr}/${maxExp}`}</Text> | ||
</View> | ||
</View> | ||
</View> | ||
); | ||
}; | ||
|
||
const styles = StyleSheet.create({ | ||
container: { | ||
width: 250, | ||
marginVertical: 4, | ||
}, | ||
progressBar: { | ||
flexDirection: 'row', | ||
height: 5, | ||
backgroundColor: Colors.WHITE, | ||
borderRadius: 10, | ||
overflow: 'hidden', | ||
}, | ||
currProgression:{ | ||
backgroundColor: Colors.TEAL, | ||
height: '100%', | ||
|
||
}, | ||
levelContainer:{ | ||
flex: 1, | ||
justifyContent: 'flex-start', | ||
paddingLeft: 5, | ||
}, | ||
texts:{ | ||
marginTop: 5, | ||
color: Colors.WHITE, | ||
fontSize: 12, | ||
}, | ||
progContainer:{ | ||
justifyContent: 'flex-end', | ||
}, | ||
textBox:{ | ||
flexDirection: 'row' | ||
} | ||
}); | ||
|
||
export default ExpProgressBar; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters