-
Notifications
You must be signed in to change notification settings - Fork 105
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
[#157929923] add-badge-messages #979
Conversation
[#157929923] not completed. For the moment the badge is visible in all the tabs. Logic for badge is not implemented
Affected stories
Generated by 🚫 dangerJS |
@matgentili @cloudify We are using native-base as UI library and it also has a Badge component. I don't think we need to add another UI library like react-native-elements. |
@fpersico ok, i remove react-native-elements library and use native-base. |
@@ -71,7 +71,6 @@ class MessageListComponent extends React.Component<Props> { | |||
const refreshControl = ( | |||
<RefreshControl refreshing={refreshing} onRefresh={onRefresh} /> | |||
); | |||
|
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.
why this change?
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.
Sorry, i think i removed the line during implementing an other const that i removed later
ts/navigation/MainNavigator.tsx
Outdated
@@ -1,12 +1,6 @@ | |||
/** |
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.
why you removed the comment?
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.
Sorry, I didn't even notice it. Most likely I removed it while importing a library
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.
Still removed
[#157929923] not completed. Badge graphic is ok on Android, I must check it on iOS. The logic for the badge counter has not implemented yet.
Codecov Report
@@ Coverage Diff @@
## master #979 +/- ##
==========================================
- Coverage 46.5% 46.29% -0.21%
==========================================
Files 201 199 -2
Lines 4455 4378 -77
Branches 873 818 -55
==========================================
- Hits 2072 2027 -45
+ Misses 2376 2346 -30
+ Partials 7 5 -2 |
Codecov Report
@@ Coverage Diff @@
## master #979 +/- ##
=========================================
Coverage ? 45.21%
=========================================
Files ? 210
Lines ? 4837
Branches ? 948
=========================================
Hits ? 2187
Misses ? 2643
Partials ? 7 |
[#157929923] not completed. Badge graphic is ok on Android, I must check it on iOS. The logic for the badge counter has not implemented yet.
package.json
Outdated
@@ -99,6 +99,7 @@ | |||
"@types/react": "16.8.10", | |||
"@types/react-native": "0.57.42", | |||
"@types/react-native-background-timer": "^2.0.0", | |||
"@types/react-native-elements": "^0.18.0", |
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.
this need to be removed too
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.
Ok
@@ -12,7 +12,8 @@ import { MessageState } from "../../store/reducers/entities/messages/messagesByI | |||
import { PaymentByRptIdState } from "../../store/reducers/entities/payments"; | |||
import { ServicesByIdState } from "../../store/reducers/entities/services/servicesById"; | |||
import { MessageListItemComponent } from "./MessageListItemComponent"; | |||
|
|||
// tslint:disable-next-line: no-var-keyword | |||
var messagesToRead = 0; |
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.
don't use vars, the tslint rule is there for a reason :)
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.
Ok, can i use let?
const refreshControl = ( | ||
<RefreshControl refreshing={refreshing} onRefresh={onRefresh} /> | ||
); | ||
|
||
messagesToRead = messages.filter(obj => !obj.isRead).length; | ||
alert(messagesToRead); |
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.
what's this alert?
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.
It was only for tests and I forgot to remove it
yarn.lock
Outdated
@@ -1071,6 +1071,13 @@ | |||
version "2.0.0" |
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.
since you didn't add any package, yarn.lock
must not change
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.
Ok!
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.
@matgentili please check this.
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.
@fpersico Can i remove yarn.lock ? I don't add any package
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.
Just revert the changes.
[#157929923] add-badge-messages. Modified badge layout and added method for reading the number of messages. Tested on ios and android
ts/navigation/MainNavigator.tsx
Outdated
@@ -178,20 +180,27 @@ const navigation = createBottomTabNavigator( | |||
tabBarIcon: (options: { tintColor: string | null; focused: boolean }) => { | |||
const { routeName } = nav.state; | |||
const iconName: string = getIcon(routeName); | |||
const messagesToRead = MessageListComponent.prototype.getMessagesToRead(); |
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.
can you explain how this works?
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 take from the component that manages the list of messages the number of unread messages and save them in a constant which is then used to update the view. Do you think that could be fine?
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 don't think it could possibly work, did you tested it?
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.
Yes, I have tested it on ios simulator and on android device and when I open a message the badge number is updated correctly.
@matgentili you should create a custom component that subscribes to the redux store to get the list of messages |
@matgentili any update here? |
@cloudify I used Redux store as you suggested, now i'm testing it and soon I commit all ;) |
[#157929923]-add-badge-message-tab. Added store redux for badge
Completed badge implementation. It works correctly on ios and android.
fix - Now the badge number is retrieved using BadgeSelector instead of passing it during navigation
…m/teamdigitale/io-app into #157929923]-add-badge-message-tab
Fix implementation badge messages. Now I don't use reducer but i get the number for badge by list of messages
Added control if badge number is greater than 99
ts/components/MessagesTabIcon.tsx
Outdated
{messagesUnread > 0 ? ( | ||
Platform.OS === "ios" ? ( | ||
<Badge style={styles.badgeStyle}> | ||
<Text style={[styles.textBadgeStyle, { top: 0 }]}> |
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.
No inline style
ts/components/MessagesTabIcon.tsx
Outdated
/** | ||
* Filters the list of messages and returns the number of unread messages. | ||
*/ | ||
const getNumberMessagesUnread = ( |
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.
Convert this to a redux selector
ts/components/MessagesTabIcon.tsx
Outdated
|
||
const mapStateToProps = (state: GlobalState) => ({ | ||
messagesUnread: | ||
getNumberMessagesUnread(lexicallyOrderedMessagesStateSelector(state)) < 99 |
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.
You are calling the function twice!
ts/navigation/MainNavigator.tsx
Outdated
@@ -1,12 +1,6 @@ | |||
/** |
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.
Still removed
ts/navigation/MainNavigator.tsx
Outdated
@@ -87,6 +79,30 @@ const styles = StyleSheet.create({ | |||
shadowRadius: variables.footerShadowRadius, | |||
// Android shadow | |||
elevation: variables.footerElevation | |||
}, | |||
textBadgeStyle: { |
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.
Not used anymore?
@matgentili Please clean this PR because it contains unused stuff. |
Created selector for unread messages and improved the code
yarn.lock
Outdated
@@ -1071,6 +1071,13 @@ | |||
version "2.0.0" |
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.
@matgentili please check this.
Revert yarn.lock
Fix for prettier after merge
…m/teamdigitale/io-app into #157929923]-add-badge-message-tab
Now the badge's text is centered. I moved one pixel. To be added to [#157929923] add-badge-messages #979
Now the badge's text is centered. I moved one pixel. To be added to [#157929923] add-badge-messages #979
[#157929923] not completed. For the moment the badge is visible in all the tabs. Logic for badge is not implemented