Skip to content

Commit

Permalink
[fix] #111 Rebase Conflict 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
JaesungLeee committed Jul 10, 2023
1 parent 732573d commit 5f88a34
Show file tree
Hide file tree
Showing 6 changed files with 57 additions and 40 deletions.
Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -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

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()
@HiltViewModel
class OnBoardingViewModel @Inject constructor(
private val saveOnboardingKeywordsUseCase: SaveOnboardingKeywordsUseCase
) : ViewModel() {
val uiState: MutableStateFlow<UiState> = MutableStateFlow(UiState.Editing(emptyList()))

fun saveKeywords(keywords: List<String>) {
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<String>) : UiState()
}
}
29 changes: 0 additions & 29 deletions presentation/src/main/res/navigation/graph_home.xml

This file was deleted.

8 changes: 0 additions & 8 deletions presentation/src/main/res/navigation/graph_navigation.xml

This file was deleted.

Empty file.

0 comments on commit 5f88a34

Please sign in to comment.