Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* badge support added badge support * remove react-native-material-ui removed react-native-material-ui as dependency. implemented importing local badge component. * Added Badge.js Added Badge component to use instead of react-native-material-ui badge * updated prop types updated prop types * removed old prop type removed old prop type * documented badge changes documented badge changes * fixed isBadgeVisible documentation fixed isBadgeVisible documentation * Final changes final changes * final changes final changes * removed extra dependencies removed extra dependencies * android compatibility android compatibility * android compatibility android compatibility
- Loading branch information
1 parent
fe0547a
commit 689133d
Showing
3 changed files
with
116 additions
and
6 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
/** | ||
* Material badge for showing notifications, maybe more functionality in the future | ||
* @flow | ||
*/ | ||
|
||
import React, { Component } from 'react' | ||
import { | ||
View, | ||
Text, | ||
StyleSheet | ||
} from 'react-native'; | ||
|
||
type BProps = { | ||
text: string, | ||
size: number, | ||
children: Array<ReactElement<*>>, | ||
style: any, | ||
isVisible: boolean, | ||
} | ||
|
||
const defaultProps = { | ||
size: 20, | ||
isVisible: true, | ||
style: {}, | ||
} | ||
|
||
export default class Badge extends Component { | ||
static defaultProps: typeof defaultProps | ||
props: BProps | ||
static defaultProps = defaultProps | ||
|
||
createStyles() { | ||
const { size, style } = this.props; | ||
const container = Object.assign( | ||
{}, | ||
{ | ||
position: "absolute", | ||
width: size, | ||
height: size, | ||
borderRadius: size / 2, | ||
alignItems: "center", | ||
justifyContent: "center", | ||
backgroundColor: "#F50057", | ||
zIndex: 9999, | ||
bottom: 10, | ||
}, | ||
style.container | ||
); | ||
|
||
const text = Object.assign( | ||
{}, | ||
{ | ||
color: "#fff", | ||
fontWeight: "500", | ||
fontSize: 12, | ||
}, | ||
style.text | ||
) | ||
|
||
return StyleSheet.create({ | ||
container, | ||
text, | ||
}) | ||
} | ||
|
||
render() { | ||
const { children, text, isVisible } = this.props; | ||
const styles = this.createStyles(); | ||
if (!isVisible) { | ||
return null; | ||
} | ||
|
||
return ( | ||
<View> | ||
<View style={styles.container}> | ||
<Text style={styles.text}>{text}</Text> | ||
</View> | ||
</View> | ||
) | ||
} | ||
} |
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