Skip to content

Commit

Permalink
[mod] #130 modify to immutable list
Browse files Browse the repository at this point in the history
  • Loading branch information
seohee0925 committed Oct 14, 2024
1 parent 70001b8 commit dedd313
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.record.search

data class Exhibition(
data class ExhibitionData(
val exhibitionName: String,
val location: String,
val venue: String,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ fun SearchScreen(
modifier: Modifier,
query: String,
onQueryChange: (String) -> Unit,
items: List<Exhibition>,
items: List<ExhibitionData>,
) {
val keyboardController = LocalSoftwareKeyboardController.current

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@ package com.record.search

import com.record.ui.base.SideEffect
import com.record.ui.base.UiState
import kotlinx.collections.immutable.ImmutableList
import kotlinx.collections.immutable.toImmutableList

data class SearchState(
val query: String = "",
val filteredItems: List<Exhibition> = emptyList(),
val filteredItems: ImmutableList<ExhibitionData> = emptyList<ExhibitionData>().toImmutableList(),
) : UiState

sealed interface SearchSideEffect : SideEffect
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,17 @@ package com.record.search

import androidx.lifecycle.viewModelScope
import com.record.ui.base.BaseViewModel
import kotlinx.collections.immutable.toImmutableList
import kotlinx.coroutines.launch

class SearchViewModel : BaseViewModel<SearchState, SearchSideEffect>(
initialState = SearchState(),
) {
private val items = listOf(
Exhibition("국립현대미술관", "서울 종로구", "전시회장", listOf("미술전시회1", "전시회2", "전시회3")),
Exhibition("국으로 시작하는 단어", "서울 종로구", "전시회장", listOf("미술", "현대미술")),
Exhibition("서울 예술의 전당", "서울 서초구", "전시회장", listOf("음악")),
Exhibition("D Museum", "서울 용산구", "미술관", listOf("사진", "디자인")),
ExhibitionData("국립현대미술관", "서울 종로구", "전시회장", listOf("미술전시회1", "전시회2", "전시회3")),
ExhibitionData("국으로 시작하는 단어", "서울 종로구", "전시회장", listOf("미술", "현대미술")),
ExhibitionData("서울 예술의 전당", "서울 서초구", "전시회장", listOf("음악")),
ExhibitionData("D Museum", "서울 용산구", "미술관", listOf("사진", "디자인")),
)

fun onQueryChanged(newQuery: String) {
Expand All @@ -33,7 +34,7 @@ class SearchViewModel : BaseViewModel<SearchState, SearchSideEffect>(
}
}
intent {
copy(filteredItems = result)
copy(filteredItems = result.toImmutableList())
}
}
}
Expand Down

0 comments on commit dedd313

Please sign in to comment.