1
0
Fork 0

For #2898 - Adds Deselect All in Collection Creation Select Tabs Step

master
Emily Kager 2019-05-28 13:50:15 -07:00 committed by Sawyer Blatz
parent e0ceb195ff
commit a6a72885d2
4 changed files with 22 additions and 4 deletions

View File

@ -36,6 +36,7 @@ data class CollectionCreationState(
sealed class CollectionCreationChange : Change {
data class TabListChange(val tabs: List<Tab>) : CollectionCreationChange()
object AddAllTabs : CollectionCreationChange()
object RemoveAllTabs : CollectionCreationChange()
data class TabAdded(val tab: Tab) : CollectionCreationChange()
data class TabRemoved(val tab: Tab) : CollectionCreationChange()
data class StepChanged(val saveCollectionStep: SaveCollectionStep) : CollectionCreationChange()
@ -45,6 +46,7 @@ sealed class CollectionCreationChange : Change {
sealed class CollectionCreationAction : Action {
object Close : CollectionCreationAction()
object SelectAllTapped : CollectionCreationAction()
object DeselectAllTapped : CollectionCreationAction()
object AddNewCollection : CollectionCreationAction()
data class AddTabToSelection(val tab: Tab) : CollectionCreationAction()
data class RemoveTabFromSelection(val tab: Tab) : CollectionCreationAction()
@ -95,6 +97,7 @@ class CollectionCreationViewModel(
{ state, change ->
when (change) {
is CollectionCreationChange.AddAllTabs -> state.copy(selectedTabs = state.tabs.toSet())
is CollectionCreationChange.RemoveAllTabs -> state.copy(selectedTabs = setOf())
is CollectionCreationChange.TabListChange -> state.copy(tabs = change.tabs)
is CollectionCreationChange.TabAdded -> {
val selectedTabs = state.selectedTabs + setOf(change.tab)

View File

@ -67,10 +67,6 @@ class CollectionCreationUIView(
R.layout.component_collection_creation_name_collection
)
view.select_all_button.setOnClickListener {
actionEmitter.onNext(CollectionCreationAction.SelectAllTapped)
}
view.close_icon.apply {
increaseTapArea(increaseButtonByDps)
setOnClickListener {
@ -128,6 +124,19 @@ class CollectionCreationUIView(
back_button.setOnClickListener {
actionEmitter.onNext(CollectionCreationAction.BackPressed(SaveCollectionStep.SelectTabs))
}
val allSelected = it.selectedTabs.size == it.tabs.size
select_all_button.text =
if (allSelected)
view.context.getString(R.string.create_collection_deselect_all) else
view.context.getString(R.string.create_collection_select_all)
view.select_all_button.setOnClickListener {
if (allSelected) {
actionEmitter.onNext(CollectionCreationAction.DeselectAllTapped)
} else {
actionEmitter.onNext(CollectionCreationAction.SelectAllTapped)
}
}
TransitionManager.beginDelayedTransition(
view.collection_constraint_layout,
transition

View File

@ -114,6 +114,10 @@ class CreateCollectionFragment : DialogFragment(), CoroutineScope {
getManagedEmitter<CollectionCreationChange>()
.onNext(CollectionCreationChange.AddAllTabs)
}
is CollectionCreationAction.DeselectAllTapped -> {
getManagedEmitter<CollectionCreationChange>()
.onNext(CollectionCreationChange.RemoveAllTabs)
}
is CollectionCreationAction.AddNewCollection -> getManagedEmitter<CollectionCreationChange>().onNext(
CollectionCreationChange.StepChanged(SaveCollectionStep.NameCollection)
)

View File

@ -489,6 +489,8 @@
<string name="create_collection_add_new_collection">Add new collection</string>
<!-- Button to select all tabs in the "select tabs" step of the collection creator -->
<string name="create_collection_select_all">Select All</string>
<!-- Button to deselect all tabs in the "select tabs" step of the collection creator -->
<string name="create_collection_deselect_all">Deselect All</string>
<!-- Text to prompt users to select the tabs to save in the "select tabs" step of the collection creator -->
<string name="create_collection_save_to_collection_empty">Select tabs to save</string>
<!-- Text to show users how many tabs they have selected in the "select tabs" step of the collection creator.