diff --git a/presentation/src/main/java/com/mashup/presentation/feature/guide/GuideFragment.kt b/presentation/src/main/java/com/mashup/presentation/feature/guide/GuideFragment.kt deleted file mode 100644 index e69de29bb..000000000 diff --git a/presentation/src/main/java/com/mashup/presentation/feature/onboarding/NotificationPermissionGuideFragment.kt b/presentation/src/main/java/com/mashup/presentation/feature/onboarding/NotificationPermissionGuideFragment.kt index c56840246..0955ca544 100644 --- a/presentation/src/main/java/com/mashup/presentation/feature/onboarding/NotificationPermissionGuideFragment.kt +++ b/presentation/src/main/java/com/mashup/presentation/feature/onboarding/NotificationPermissionGuideFragment.kt @@ -12,10 +12,9 @@ import androidx.core.content.ContextCompat import com.mashup.presentation.R import com.mashup.presentation.common.base.BaseFragment import com.mashup.presentation.common.extension.makeSnackBar -import com.mashup.presentation.databinding.FragmentNotificationPermissionGuideBinding -import com.mashup.presentation.ui.common.KeyLinkMintText import com.mashup.presentation.common.extension.setThemeContent import com.mashup.presentation.databinding.FragmentNotificationPermissionGuideComposeBinding +import com.mashup.presentation.onboarding.NotificationPermissionScreen import dagger.hilt.android.AndroidEntryPoint /** diff --git a/presentation/src/main/java/com/mashup/presentation/feature/onboarding/OnBoardingViewModel.kt b/presentation/src/main/java/com/mashup/presentation/feature/onboarding/OnBoardingViewModel.kt index f7e253e04..97bb52483 100644 --- a/presentation/src/main/java/com/mashup/presentation/feature/onboarding/OnBoardingViewModel.kt +++ b/presentation/src/main/java/com/mashup/presentation/feature/onboarding/OnBoardingViewModel.kt @@ -2,5 +2,60 @@ package com.mashup.presentation.feature.onboarding import androidx.lifecycle.ViewModel +import androidx.lifecycle.viewModelScope +import com.mashup.domain.usecase.SaveOnboardingKeywordsUseCase +import dagger.hilt.android.lifecycle.HiltViewModel +import kotlinx.coroutines.flow.MutableStateFlow +import kotlinx.coroutines.launch +import javax.inject.Inject -class OnBoardingViewModel: ViewModel() \ No newline at end of file +@HiltViewModel +class OnBoardingViewModel @Inject constructor( + private val saveOnboardingKeywordsUseCase: SaveOnboardingKeywordsUseCase +) : ViewModel() { + val uiState: MutableStateFlow = MutableStateFlow(UiState.Editing(emptyList())) + + fun saveKeywords(keywords: List) { + viewModelScope.launch { + uiState.emit(UiState.Loading) + saveOnboardingKeywordsUseCase.execute(keywords) + .onSuccess { + uiState.emit(UiState.SaveSuccess) + } + .onFailure { + it.message?.let { + uiState.emit(UiState.SaveFailed(it)) + } + } + } + } + + fun addKeyword(keyword: String) { + if (uiState.value is UiState.Editing) { + val keywords = (uiState.value as UiState.Editing).keywords.toMutableList() + + keywords.add(keyword) + viewModelScope.launch { + uiState.emit(UiState.Editing(keywords.toList())) + } + } + } + + fun removeKeyword(index: Int) { + if (uiState.value is UiState.Editing) { + val keywords = (uiState.value as UiState.Editing).keywords.toMutableList() + + keywords.removeAt(index) + viewModelScope.launch { + uiState.emit(UiState.Editing(keywords.toList())) + } + } + } + + sealed class UiState { + object Loading : UiState() + object SaveSuccess : UiState() + data class SaveFailed(val message: String) : UiState() + data class Editing(val keywords: List) : UiState() + } +} \ No newline at end of file diff --git a/presentation/src/main/res/navigation/graph_home.xml b/presentation/src/main/res/navigation/graph_home.xml deleted file mode 100644 index 2cd168236..000000000 --- a/presentation/src/main/res/navigation/graph_home.xml +++ /dev/null @@ -1,29 +0,0 @@ - - - - - - - - - - \ No newline at end of file diff --git a/presentation/src/main/res/navigation/graph_navigation.xml b/presentation/src/main/res/navigation/graph_navigation.xml deleted file mode 100644 index b042fc831..000000000 --- a/presentation/src/main/res/navigation/graph_navigation.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - \ No newline at end of file diff --git a/presentation/src/main/res/navigation/graph_signal.xml b/presentation/src/main/res/navigation/graph_signal.xml deleted file mode 100644 index e69de29bb..000000000