Skip to content

Commit

Permalink
feat : dummy data binding 및 UI 개선
Browse files Browse the repository at this point in the history
  • Loading branch information
2taezeat committed Nov 21, 2023
1 parent 7f27e7e commit caa872d
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
2 changes: 2 additions & 0 deletions android/core/ui/src/main/res/layout/item_music_horizontal.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/small"
android:text="@{music.title}"
android:textColor="@color/on_surface"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
Expand All @@ -42,6 +43,7 @@
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/extra_small"
android:text="@{music.artist}"
android:textColor="@color/on_surface_variant"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package com.ohdodok.catchytape.feature.home

import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import com.ohdodok.catchytape.core.domain.model.Music
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.StateFlow
Expand All @@ -12,13 +13,21 @@ import kotlinx.coroutines.flow.onEach
import kotlinx.coroutines.flow.update

data class HomeUiState(
val recentlyUploadedMusics: List<Unit> = emptyList()
val recentlyUploadedMusics: List<Music> = emptyList()
)

class HomeViewModel constructor(
// todo : DI로 주입하는 코드로 변경
private val getMusicUseCase: GetMusicUseCase = GetMusicUseCase {
flow { emit(listOf()) }
flow {
emit(
listOf(
Music("1", "title1", "artist1", ""),
Music("2", "title2", "artist2", ""),
Music("3", "title3", "artist3", "")
) // 화면 확인용 Dummy data 입니다.
)
}
},
) : ViewModel() {

Expand All @@ -44,5 +53,5 @@ class HomeViewModel constructor(

// todo : domain layer로 이동
fun interface GetMusicUseCase {
operator fun invoke(): Flow<List<Unit>>
operator fun invoke(): Flow<List<Music>>
}
2 changes: 2 additions & 0 deletions android/feature/home/src/main/res/layout/fragment_home.xml
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,13 @@
android:id="@+id/rv_recently_added_song"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/small"
android:orientation="horizontal"
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
app:layout_constraintEnd_toEndOf="@id/tv_recently_added_song"
app:layout_constraintStart_toStartOf="@id/tv_recently_added_song"
app:layout_constraintTop_toBottomOf="@id/tv_recently_added_song"
app:submitData="@{viewModel.uiState.recentlyUploadedMusics}"
tools:listitem="@layout/item_music_horizontal" />

</androidx.constraintlayout.widget.ConstraintLayout>
Expand Down

0 comments on commit caa872d

Please sign in to comment.