Skip to content

Commit

Permalink
refactor: 유튜브 브랜딩 가이드에 따른 플레이리스트 추출 버튼 이미지 변경 (#439)
Browse files Browse the repository at this point in the history
* refactor: 플레이리스트 추출 아이콘 변경

* feat: 플레이리스트로 추출할 음악이 하나도 선택되어있지 않은 경우 플레이리스트 추출 버튼을 클릭할 수 없다.

* refactor: 변수명을 수정한다.

* refactor: 변수명을 수정한다.

* refactor: 선택된 적이 있다는 것을 나타내는 변수명으로 수정한다.

* refactor: 선택된 적이 있다는 것을 나타내는 변수명을 수정한다.
  • Loading branch information
boogi-woogi authored Nov 23, 2023
1 parent 9c9abd6 commit e953027
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,13 @@ class ScrapListActivity : AppCompatActivity() {
SocialLogin.Google.getIntent(this)
)

is ScrapUiState.Selection -> {
binding.scrapIbExtractPlaylist.isEnabled = it.isExtractionAvailable
binding.adapter?.submitList(
scrapViewModel.uiState.value?.rooms
)
}

else -> binding.adapter?.submitList(
scrapViewModel.uiState.value?.rooms
)
Expand All @@ -96,6 +103,7 @@ class ScrapListActivity : AppCompatActivity() {
it.expectedTime
)
is ScrapUiEvent.DisAllowedExtraction -> getString(R.string.scrap_disallowed_extracting_playlist)

is ScrapUiEvent.FailedSelection -> getString(R.string.scrap_maximum_selection).format(
it.maximum
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ sealed interface ScrapUiState {

data class Selection(
override val onSelect: (position: Int) -> Unit,
override val rooms: List<ScrappedRoomModel>
override val rooms: List<ScrappedRoomModel>,
val isExtractionAvailable: Boolean
) : ScrapUiState

data class PlaylistExtraction(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@ class ScrapViewModel @Keep constructor(
} else {
_uiState.value = ScrapUiState.Selection(
onSelect = ::switchSelection,
rooms = rooms.value.map { it.toModel(selectable = true) }
rooms = rooms.value.map { it.toModel(selectable = true) },
isExtractionAvailable = rooms.hasSelected
)
}
} else {
Expand All @@ -82,7 +83,8 @@ class ScrapViewModel @Keep constructor(
}
_uiState.value = ScrapUiState.Selection(
onSelect = ::switchSelection,
rooms = rooms.value.map { it.toModel(selectable = true) }
rooms = rooms.value.map { it.toModel(selectable = true) },
isExtractionAvailable = rooms.hasSelected
)
}

Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 0 additions & 5 deletions android/app/src/main/res/drawable/ic_extract_playlist.xml

This file was deleted.

8 changes: 4 additions & 4 deletions android/app/src/main/res/layout/activity_scrap.xml
Original file line number Diff line number Diff line change
Expand Up @@ -88,15 +88,15 @@

<ImageButton
android:id="@+id/scrap_ib_extract_playlist"
android:layout_width="60dp"
android:layout_height="60dp"
android:layout_width="100dp"
android:layout_height="100dp"
android:layout_marginEnd="20dp"
android:layout_marginBottom="20dp"
android:background="?attr/selectableItemBackground"
android:elevation="1dp"
android:onClick="@{() -> viewModel.startPlaylistExtraction()}"
android:scaleType="centerInside"
android:src="@drawable/ic_playlist"
android:scaleType="fitXY"
android:src="@drawable/ic_extract_playlist"
android:visibility="@{viewModel.uiState instanceof ScrapUiState.Selection ? View.VISIBLE : View.GONE}"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ class ScrappedRooms(
val value: List<ScrappedRoom>
get() = _value

val hasSelected: Boolean
get() = _value.any { it.isSelected }

val selectedId: List<String>
get() = _value.filter {
it.isSelected
Expand Down

0 comments on commit e953027

Please sign in to comment.