-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
94 additions
and
31 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
38 changes: 38 additions & 0 deletions
38
feature/src/main/java/com/terning/feature/intern/InternViewModel.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 |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package com.terning.feature.intern | ||
|
||
import androidx.compose.ui.graphics.Color | ||
import androidx.lifecycle.ViewModel | ||
import com.terning.feature.intern.model.InternScrapState | ||
import dagger.hilt.android.lifecycle.HiltViewModel | ||
import kotlinx.coroutines.flow.MutableStateFlow | ||
import kotlinx.coroutines.flow.StateFlow | ||
import javax.inject.Inject | ||
|
||
@HiltViewModel | ||
class InternViewModel @Inject constructor() : ViewModel() { | ||
private val _state: MutableStateFlow<InternScrapState> = | ||
MutableStateFlow(InternScrapState()) | ||
|
||
val state: StateFlow<InternScrapState> get() = _state | ||
|
||
fun updateScrap(newScrap: Boolean) { | ||
_state.value = _state.value.copy(isScrap = newScrap) | ||
} | ||
|
||
fun updateSelectColor(newColor: Color) { | ||
_state.value = _state.value.copy(selectedColor = newColor) | ||
} | ||
|
||
fun updateScrapDialogVisible(visible: Boolean) { | ||
_state.value = _state.value.copy(isScrapDialogVisible = visible) | ||
} | ||
|
||
fun updateScrapped(scrapped: Boolean) { | ||
_state.value = _state.value.copy(isScrapped = scrapped) | ||
} | ||
|
||
fun updateColorChange(change: Boolean) { | ||
_state.value = _state.value.copy(isColorChange = change) | ||
} | ||
|
||
} |
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
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
13 changes: 13 additions & 0 deletions
13
feature/src/main/java/com/terning/feature/intern/model/InternScrapState.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 |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package com.terning.feature.intern.model | ||
|
||
import androidx.compose.ui.graphics.Color | ||
import com.terning.core.designsystem.theme.CalRed | ||
|
||
data class InternScrapState( | ||
val isScrap: Boolean = false, | ||
val isColorChange: Boolean = false, | ||
val selectedColor: Color = CalRed, | ||
val isScrapDialogVisible: Boolean = false, | ||
val isScrapped: Boolean = false, | ||
val viewCount: Int = 0, | ||
) |