Skip to content
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

chore: Notifications Inbox Screen Implementation #113

Open
wants to merge 1 commit into
base: 2U/develop
Choose a base branch
from

Conversation

shafqat-muneer
Copy link

@shafqat-muneer shafqat-muneer commented Jan 9, 2025

LEARNER-10288: Notifications Inbox Screen Implementation

Description:

We need to implement a Notifications screen in the edX mobile app. This screen will display notifications fetched from the notifications table, allowing learners to stay updated on relevant discussions and interactions.

Design cases:

  • Empty screen when there are no notifications to show {It will be covered in separate ticket}
  • Distinguishable read and unread notifications
  • Grouping based on how recent the notification is (i.e. today/recent, last week, older)?

Design UI for the notifications screen. Main components include:

  • Icon for notification type (Discussions, Learning Reminder, Promotion) {Currently, just Discussions notifications implemented, so we are just showing discussions icon}
  • Ability to distinguish read and unread notifications (Unread indicator)
  • Course Name
  • Time elapsed
  • Group notifications based on recency (Today/Recent, This Week, Older)
  • Ability to mark all notifications as read {It's dependent on this PR. API integrated there. We will handle this point in separate PR}

Tasks:
Notifications Screen UI:

  • We need to design and implement the layout for the Notifications screen which is the list view for displaying individual notifications. Ensure the UI is user-friendly, visually aligned with the app’s design standards, and optimized for different screen sizes.
  • The UI will include notification groups based on recency. The following is the logic to be implemented for these groups:
    • Recent: within the last 24 hours
    • This Week: greater than 24 hours but not more than 7 day old
    • Older: more than 7 day old
  • The notifications also show the time elapsed on each notification since it was received. We need the time elapse to be human-readable similar to the dates tab. i.e. 5 minutes, 2 days, 1 week, 1 month, etc.
  • Icons on notifications depend on the notification category.

Acceptance Criteria:

A functional Notifications screen is implemented, displaying notifications from the notifications table in an organized list.

Screenshots:

Light Mode Dark Mode
Simulator Screenshot - iPhone 16 - 2025-01-09 at 13 16 40 Simulator Screenshot - iPhone 16 - 2025-01-09 at 13 16 34

Demo:

Light Mode Dark Mode
Simulator.Screen.Recording.-.iPhone.16.-.2025-01-09.at.13.16.16.mp4
Simulator.Screen.Recording.-.iPhone.16.-.2025-01-09.at.13.16.32.mp4

Figma:

Mobile Notifications UI Screen

@shafqat-muneer shafqat-muneer requested review from rnr and mta452 January 9, 2025 09:06
@rnr
Copy link
Collaborator

rnr commented Jan 9, 2025

@shafqat-muneer I don't have access to the ticket and I don't know what the task is exactly. Could you briefly describe what this "implementation" is supposed to do? Just show a list of notifications, or maybe open/redirect notifications, edit/delete notifications in the list, make them read/unread, have a pool-to-refresh feature, etc.
Thank you

@rnr
Copy link
Collaborator

rnr commented Jan 9, 2025

I think the Notifications Lists should respect readable content size on iPad as other lists do.

Settings for example:

}
.padding(.horizontal, isHorizontal ? 48 : 0)
} else {
// Handle empty or error screens
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@shafqat-muneer Needs to implement Empty state here

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and error/offline too I think

}
}

struct SingleNotificationView: View {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@shafqat-muneer Maybe it should be a separate View file with the Preview?

var router: NotificationsRouter
var errorMessage: String? {
didSet {
withAnimation {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We are trying to avoid to use withAnimation inside view models. openedx#277
Please move to view. Thank you

Comment on lines +28 to +30
.get
case .getAllNotifications:
.get
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please fix indentations here

@@ -0,0 +1,73 @@
import SwiftUI
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@shafqat-muneer How about move AttributedText and parser to other Base Views in Core target? It looks like reusable.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And also why didn't add this as dependency to this target? As I see it's from here https://github.com/Iaenhaall/AttributedText ?
Or you made some changes with this AttributedText?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What problems do you see compared to just using NSAttributedString(AttributedString) to parse html?

.offset(y: 10)

.padding(.leading, isHorizontal ? 48 : 10)
.accessibilityIdentifier("back_button")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This accessibilityIdentifier is already inside BackNavigationButton`

}

public enum NotificationGroup: String, CaseIterable {
case recent = "Recent"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't we place these in Localization?

outputFileListPaths = (
);
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "\"${BUILD_DIR%Build/*}/SourcePackages/artifacts/fullstory-swift-package-ios/fullstory/tools/FullStoryCommandLine\" \"${CONFIGURATION_BUILD_DIR}/${WRAPPER_NAME}\"\n";
shellScript = "#\"${BUILD_DIR%Build/*}/SourcePackages/artifacts/fullstory-swift-package-ios/fullstory/tools/FullStoryCommandLine\" \"${CONFIGURATION_BUILD_DIR}/${WRAPPER_NAME}\"\n";
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are these changes intentionally committed?

.padding()
```
*/
public struct AttributedText: View {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have we considered implementing it based on the built in HTML support of NSAttributedString as a simple solution?

}

/// Starts the text parsing process. The results of this method will be placed in the `formattedText` variable.
internal func parse() {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have we considered implementing this logic based on XMLParser instead of writing our own?

if totalPages > 1 {
if index == flatNotifications.count - 3 {
if totalPages != 1 {
if nextPage <= totalPages {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can be simplified to a single condition without nesting.

@shafqat-muneer
Copy link
Author

@shafqat-muneer I don't have access to the ticket and I don't know what the task is exactly. Could you briefly describe what this "implementation" is supposed to do? Just show a list of notifications, or maybe open/redirect notifications, edit/delete notifications in the list, make them read/unread, have a pool-to-refresh feature, etc. Thank you

@rnr I’ve updated the ticket details.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants