-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Added new marker Badge for Report unread messages #4603
Merged
Merged
Changes from 8 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
e6d33ee
added new marker
parasharrajat 885accf
refactor Styling
parasharrajat cf39af1
fix: style for new marker
parasharrajat 7b57f19
Merge Resolve Conflicts
parasharrajat b7b6794
revert extra changes
parasharrajat dd79836
code refactor to readability
parasharrajat cc630ed
fix: styling for markerbadge
parasharrajat 434f5dd
changes
parasharrajat fae11b0
translations
parasharrajat File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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,125 @@ | ||
import React, {PureComponent} from 'react'; | ||
import {Animated, Text, View} from 'react-native'; | ||
import PropTypes from 'prop-types'; | ||
import styles from '../../../styles/styles'; | ||
import Button from '../../../components/Button'; | ||
import Icon from '../../../components/Icon'; | ||
import {Close, DownArrow} from '../../../components/Icon/Expensicons'; | ||
import themeColors from '../../../styles/themes/default'; | ||
import withLocalize, {withLocalizePropTypes} from '../../../components/withLocalize'; | ||
|
||
const MARKER_NOT_ACTIVE_TRANSLATE_Y = -30; | ||
const MARKER_ACTIVE_TRANSLATE_Y = 10; | ||
const propTypes = { | ||
/** Count of new messages to show in the badge */ | ||
count: PropTypes.number, | ||
|
||
/** Whether the marker is active */ | ||
active: PropTypes.bool, | ||
|
||
/** Callback to be called when user closes the badge */ | ||
onClose: PropTypes.func, | ||
|
||
/** Callback to be called when user clicks the marker */ | ||
onClick: PropTypes.func, | ||
|
||
...withLocalizePropTypes, | ||
}; | ||
const defaultProps = { | ||
count: 0, | ||
active: false, | ||
onClose: () => {}, | ||
onClick: () => {}, | ||
}; | ||
class MarkerBadge extends PureComponent { | ||
constructor(props) { | ||
super(props); | ||
this.translateY = new Animated.Value(MARKER_NOT_ACTIVE_TRANSLATE_Y); | ||
this.show = this.show.bind(this); | ||
this.hide = this.hide.bind(this); | ||
} | ||
|
||
componentDidUpdate() { | ||
if (this.props.active && this.props.count > 0) { | ||
this.show(); | ||
} else { | ||
this.hide(); | ||
} | ||
} | ||
|
||
show() { | ||
Animated.spring(this.translateY, { | ||
toValue: MARKER_ACTIVE_TRANSLATE_Y, | ||
duration: 80, | ||
useNativeDriver: true, | ||
}).start(); | ||
} | ||
|
||
hide() { | ||
Animated.spring(this.translateY, { | ||
toValue: MARKER_NOT_ACTIVE_TRANSLATE_Y, | ||
duration: 80, | ||
useNativeDriver: true, | ||
}).start(); | ||
} | ||
|
||
render() { | ||
return ( | ||
<View style={styles.reportMarkerBadgeWrapper}> | ||
<Animated.View style={[ | ||
styles.reportMarkerBadge, | ||
styles.reportMarkerBadgeTransformation(this.translateY), | ||
]} | ||
> | ||
<View style={[ | ||
styles.flexRow, | ||
styles.justifyContentBetween, | ||
styles.alignItemsCenter, | ||
]} | ||
> | ||
<Button | ||
success | ||
small | ||
onPress={this.props.onClick} | ||
ContentComponent={() => ( | ||
<View style={[styles.flexRow]}> | ||
<Icon small src={DownArrow} fill={themeColors.textReversed} /> | ||
<Text | ||
selectable={false} | ||
style={[ | ||
styles.ml2, | ||
styles.buttonSmallText, | ||
styles.textWhite, | ||
]} | ||
> | ||
{this.props.translate( | ||
'reportActionsViewMarkerBadge.newMsg', | ||
{count: this.props.count}, | ||
)} | ||
</Text> | ||
</View> | ||
)} | ||
shouldRemoveRightBorderRadius | ||
/> | ||
<Button | ||
success | ||
small | ||
style={[styles.buttonDropdown]} | ||
onPress={this.props.onClose} | ||
shouldRemoveLeftBorderRadius | ||
ContentComponent={() => ( | ||
<Icon small src={Close} fill={themeColors.textReversed} /> | ||
)} | ||
/> | ||
</View> | ||
</Animated.View> | ||
</View> | ||
); | ||
} | ||
} | ||
|
||
MarkerBadge.propTypes = propTypes; | ||
MarkerBadge.defaultProps = defaultProps; | ||
MarkerBadge.displayName = 'MarkerBadge'; | ||
|
||
export default withLocalize(MarkerBadge); |
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 @@ | ||
export default visibility => ({visibility}); |
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 @@ | ||
export default () => ({}); |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe
nuevo
should come aftermensaje
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please tell me what is correct for new messages.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"# new messages" => # mensajes nuevos
"# new message" => # mensaje nuevo