Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: 유튜브 브랜딩 가이드에 따른 플레이리스트 추출 버튼 이미지 변경 #439

Merged
merged 6 commits into from
Nov 23, 2023
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.isSelected
)
}
} 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.isSelected
)
}

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 isSelected: Boolean
get() = _value.any { it.isSelected }

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

변수 이름이 조금 더 직관적이면 좋을 것 같아요. 예를 들면 isAnySelected 이런 식? 좋은 변수명인지는 모르겠네영ㅋㅋㅋ

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hasBeenSelected라는 변수명으로 수정했는데 더 좋은게 있을까요?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hasSelected 는 어떤가용 ( 선택된 걸 가지고 있냐? 느낌)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

오 좋네요~ 수정했습니다~

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