-
Notifications
You must be signed in to change notification settings - Fork 1
Fix #19: Implement complete notification screen with UI, API integration, and tests #22
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
Merged
Merged
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
7b958c6
Refactor notification domain: Rename packages and introduce Notificat…
theMr17 94c53f6
Implement notification feature: Add NotificationItem component, updat…
theMr17 2393ab3
Remove unused variable in NotificationUi.kt
theMr17 f68963e
Add isRead property to NotificationUi and NotificationItem, update UI…
theMr17 44b2024
Add loader on NotificationScreen
theMr17 64a9368
Add includeRead parameter to getNotifications method and update relat…
theMr17 508730b
Refactor toRelativeTimeString function for improved readability and a…
theMr17 42236c8
Add redirectUrl to NotificationUi and related components for improved…
theMr17 fff72e2
Merge branch 'main' into feat/notification-screen
theMr17 8efe331
Add discussion icon and update NotificationItem to display badge for …
theMr17 7a48034
Add discussion icon to NotificationScreen for enhanced visual represe…
theMr17 615d0fa
Add unit tests for toRelativeTimeString function to ensure accurate t…
theMr17 8843bba
Refactor Notification components for improved clarity and performance
theMr17 eea8979
Enhance Notification components with detailed documentation and impro…
theMr17 2418d17
Add green color resource and update icons to use it for consistent st…
theMr17 2ada9f0
Enhance NotificationViewModel with comprehensive documentation for be…
theMr17 ea83647
Enhance NotificationItem and NotificationScreen with detailed documen…
theMr17 8d68d67
Enhance code consistency by adding missing commas in parameter lists …
theMr17 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 hidden or 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 hidden or 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 hidden or 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
26 changes: 26 additions & 0 deletions
26
app/src/main/java/com/notifier/app/core/presentation/util/ZonedDateTimeToRelativeString.kt
This file contains hidden or 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,26 @@ | ||
| package com.notifier.app.core.presentation.util | ||
|
|
||
| import java.time.Duration | ||
| import java.time.ZonedDateTime | ||
| import kotlin.math.abs | ||
|
|
||
| fun ZonedDateTime.toRelativeTimeString(): String { | ||
| val now = ZonedDateTime.now() | ||
| val duration = Duration.between(this, now) | ||
| val seconds = duration.seconds | ||
|
|
||
| val absSeconds = abs(seconds) | ||
|
|
||
| val minute = 60 | ||
| val hour = 60 * minute | ||
| val day = 24 * hour | ||
| val week = 7 * day | ||
|
|
||
| return when { | ||
| absSeconds < minute -> "${absSeconds}s" | ||
| absSeconds < hour -> "${absSeconds / minute}m" | ||
| absSeconds < day -> "${absSeconds / hour}h" | ||
| absSeconds < week -> "${absSeconds / day}d" | ||
| else -> "${absSeconds / week}w" | ||
| } | ||
| } |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
2 changes: 1 addition & 1 deletion
2
...r/app/notification/domain/Notification.kt → ...notification/domain/model/Notification.kt
This file contains hidden or 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
2 changes: 1 addition & 1 deletion
2
...notifier/app/notification/domain/Owner.kt → ...er/app/notification/domain/model/Owner.kt
This file contains hidden or 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
2 changes: 1 addition & 1 deletion
2
...ier/app/notification/domain/Repository.kt → ...p/notification/domain/model/Repository.kt
This file contains hidden or 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
4 changes: 2 additions & 2 deletions
4
...tifier/app/notification/domain/Subject.kt → .../app/notification/domain/model/Subject.kt
This file contains hidden or 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
9 changes: 9 additions & 0 deletions
9
app/src/main/java/com/notifier/app/notification/presentation/NotificationAction.kt
This file contains hidden or 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,9 @@ | ||
| package com.notifier.app.notification.presentation | ||
|
|
||
| /** | ||
| * A sealed interface representing different user actions in the Notification screen. | ||
| * | ||
| * These actions are dispatched based on user interactions with the notification UI, | ||
| * such as clicking on a notification or performing bulk actions. | ||
| */ | ||
| sealed interface NotificationAction |
21 changes: 21 additions & 0 deletions
21
app/src/main/java/com/notifier/app/notification/presentation/NotificationEvent.kt
This file contains hidden or 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,21 @@ | ||
| package com.notifier.app.notification.presentation | ||
|
|
||
| import com.notifier.app.core.domain.util.NetworkError | ||
|
|
||
| /** | ||
| * A sealed interface representing different notification-related events. | ||
| * | ||
| * These events are used to trigger UI updates or error messages in response | ||
| * to state changes in the Notification screen. | ||
| */ | ||
| sealed interface NotificationEvent { | ||
| /** | ||
| * Event that triggers a toast or error message for a network-related error. | ||
| * | ||
| * This event is fired when a network error occurs while loading or interacting | ||
| * with notifications. | ||
| * | ||
| * @param error The network error that occurred. | ||
| */ | ||
| data class NetworkErrorEvent(val error: NetworkError) : NotificationEvent | ||
| } |
26 changes: 23 additions & 3 deletions
26
app/src/main/java/com/notifier/app/notification/presentation/NotificationRoute.kt
This file contains hidden or 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 |
|---|---|---|
| @@ -1,13 +1,33 @@ | ||
| package com.notifier.app.notification.presentation | ||
|
|
||
| import androidx.compose.runtime.Composable | ||
| import androidx.compose.runtime.getValue | ||
| import androidx.hilt.navigation.compose.hiltViewModel | ||
| import androidx.lifecycle.compose.collectAsStateWithLifecycle | ||
| import kotlinx.serialization.Serializable | ||
|
|
||
| /** | ||
| * Navigation route object for the Notification screen. | ||
| * | ||
| * This object is used for deep linking and navigation to the Notification screen within the app. | ||
| */ | ||
| @Serializable | ||
| data object NotificationScreen | ||
|
|
||
| /** | ||
| * The NotificationRoute Composable is the entry point to the Notification screen. | ||
| * | ||
| * It observes the notification state from the [NotificationViewModel] and renders | ||
| * the Notification screen with the latest state. | ||
| * | ||
| * @param viewModel The instance of [NotificationViewModel] used for managing notification logic | ||
| * and state. | ||
| */ | ||
| @Composable | ||
| fun NotificationRoute() { | ||
| NotificationScreen() | ||
| } | ||
| fun NotificationRoute( | ||
| viewModel: NotificationViewModel = hiltViewModel(), | ||
| ) { | ||
| val state by viewModel.state.collectAsStateWithLifecycle() | ||
|
|
||
| NotificationScreen(state) | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.