-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Asking notification permission at the beginning of the home screen la…
…unch
- Loading branch information
Showing
3 changed files
with
47 additions
and
2 deletions.
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
16 changes: 15 additions & 1 deletion
16
app/src/main/kotlin/com/naveenapps/expensemanager/ui/HomeViewModel.kt
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 |
---|---|---|
@@ -1,18 +1,32 @@ | ||
package com.naveenapps.expensemanager.ui | ||
|
||
import androidx.lifecycle.ViewModel | ||
import androidx.lifecycle.viewModelScope | ||
import com.naveenapps.expensemanager.core.domain.usecase.settings.reminder.UpdateReminderStatusUseCase | ||
import com.naveenapps.expensemanager.core.notification.NotificationScheduler | ||
import dagger.hilt.android.lifecycle.HiltViewModel | ||
import kotlinx.coroutines.flow.MutableStateFlow | ||
import kotlinx.coroutines.flow.asStateFlow | ||
import kotlinx.coroutines.launch | ||
import javax.inject.Inject | ||
|
||
@HiltViewModel | ||
class HomeViewModel @Inject constructor() : ViewModel() { | ||
class HomeViewModel @Inject constructor( | ||
private val updateReminderStatusUseCase: UpdateReminderStatusUseCase, | ||
private val notificationScheduler: NotificationScheduler | ||
) : ViewModel() { | ||
|
||
private val _homeScreenBottomBarItems = MutableStateFlow(HomeScreenBottomBarItems.Home) | ||
val homeScreenBottomBarItems = _homeScreenBottomBarItems.asStateFlow() | ||
|
||
fun setUISystem(homeScreenBottomBarItems: HomeScreenBottomBarItems) { | ||
_homeScreenBottomBarItems.value = homeScreenBottomBarItems | ||
} | ||
|
||
fun turnOnNotification() { | ||
viewModelScope.launch { | ||
updateReminderStatusUseCase.invoke(true) | ||
notificationScheduler.checkAndRestartReminder() | ||
} | ||
} | ||
} |
3 changes: 2 additions & 1 deletion
3
...napps/expensemanager/core/domain/usecase/settings/reminder/UpdateReminderStatusUseCase.kt
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