-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
🦡 [App Badges] Set badge count on activities tab bar item #694
🦡 [App Badges] Set badge count on activities tab bar item #694
Conversation
…e-icon-set-badge # Conflicts: # Kickstarter-iOS/ViewModels/RootViewModel.swift # Kickstarter-iOS/ViewModels/RootViewModelTests.swift
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.
@@ -375,3 +391,13 @@ extension TabBarItem: Equatable { | |||
} | |||
} | |||
} | |||
|
|||
func activitiesBadgeValue() -> String? { |
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.
private
?
@@ -4,7 +4,10 @@ import Prelude | |||
import ReactiveSwift | |||
import UIKit | |||
|
|||
public let maxBadgeValue = 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.
Since we're only using this constant from the function bellow does it still make sense to have it here (as oppose to inside the function)?
If you think it's better to have it as a global constant how about we extract this to Constants.swift
or something and maybe make it an enum?
|
||
guard count > 0 else { return nil } | ||
|
||
let plusSign = AppEnvironment.current.application.applicationIconBadgeNumber > maxBadgeValue ? "+" : "" |
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.
Also looks like we're repeating some code here..how about
private func activitiesBadgeValue() -> String? {
let applicationIconBadgeNumber = AppEnvironment.current.application.applicationIconBadgeNumber
let count = min(applicationIconBadgeNumber, maxBadgeValue)
guard count > 0 else { return nil }
let plusSign = applicationIconBadgeNumber > maxBadgeValue ? "+" : ""
return "\(count)\(plusSign)"
}
@@ -43,19 +43,3 @@ final class UIViewControllerURLTests: TestCase { | |||
} | |||
} | |||
} | |||
|
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.
Thanks for cleaning this up!
@dusi good point, will address a11y in a separate PR 👍 |
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.
Cheers
…e-icon-set-badge # Conflicts: # Library/UIViewController+URLTests.swift
* 🦡 [App Badges] Set badge count on activities tab bar item (#694) * Set badge value on app launch based on current applicationIconBadgeNumber * Add MockApplication.swift * Move constant to within function, improve coalescing * SwiftFormat * 🦡 [App Badges] Update badge value on push and lifecycle events (#698) * Update and clear unseen activity count on lifecycle events, push, user session * Update badge value on current user updated instead of session started, clear value on activities refresh * Fix tests * Only clear activity count when we know that one is set, set badge value while on activities tab, update user in environment * Remove redundant withEnvironment * Prevent infinite loop * Camel-case test functions * Do not update user in environment if logged out * Add logged out test * 🦡 [App Badges] Improve voice-over support for badge value (#706) * Add Strings.activities_badge_value_plus * Handle badge value correctly when voice over is enabled
📲 What
Sets the app's current badge count value on the activities tab bar item.
This is part of a larger body of work to bring badging to the app. Future PR's will include:
🤔 Why
We've allowed for badges in the app for some time now but work has recently been done to support this on the back-end. This brings additional functionality to allow us to display the amount of unread activities in the app and to mark them as read via GraphQL.
🛠 How
AppEnvironment.current.application.applicationIconBadgeNumber
which isUIApplication.shared.applicationIconBadgeNumber
via ourApplicationType
protocol onAppEnvironment
.99
and display a+
if this value exceeds that.0
or less.👀 See
✅ Acceptance criteria
UIApplication.shared.applicationIconBadgeNumber
on app launch.99+
is shown for an amount greater than99
.