Updated on 2026-08-14
This commit is contained in:
parent
adf0c5fd58
commit
5e4fba0405
2 changed files with 10 additions and 10 deletions
|
|
@ -12,14 +12,14 @@ import ru.dev.gbixahue.eu4d.lib.kotlin.stringOf
|
|||
[REDACTED_AUTHOR]
|
||||
*/
|
||||
open class MultiActionView<V : TextView>(
|
||||
stateList: MutableList<ButtonState>,
|
||||
stateActionList: MutableList<ViewAction>,
|
||||
val child: V
|
||||
) {
|
||||
|
||||
interface State {
|
||||
val id: Id
|
||||
|
||||
fun getAction(): StateButtonAction
|
||||
fun getAction(): SimpleFunction
|
||||
fun getResNameId(): Int
|
||||
}
|
||||
|
||||
|
|
@ -53,7 +53,7 @@ open class MultiActionView<V : TextView>(
|
|||
child.setText(value.getResNameId())
|
||||
}
|
||||
|
||||
protected val stateHolder: MutableMap<String, State> = stateList.associateBy { getKey(it.id) }.toMutableMap()
|
||||
protected val stateHolder: MutableMap<String, State> = stateActionList.associateBy { getKey(it.id) }.toMutableMap()
|
||||
|
||||
fun performAction(id: Id) {
|
||||
Log.d(this, "performAction ${getKey(id)}")
|
||||
|
|
@ -71,15 +71,15 @@ open class MultiActionView<V : TextView>(
|
|||
|
||||
enum class DefaultId : Id { default }
|
||||
|
||||
typealias StateButtonAction = () -> Unit
|
||||
typealias SimpleFunction = () -> Unit
|
||||
|
||||
class ButtonState(
|
||||
class ViewAction(
|
||||
override val id: Id,
|
||||
@StringRes val name: Int,
|
||||
private val action: StateButtonAction
|
||||
private val action: SimpleFunction
|
||||
) : MultiActionView.State {
|
||||
|
||||
override fun getAction(): StateButtonAction = action
|
||||
override fun getAction(): SimpleFunction = action
|
||||
|
||||
override fun getResNameId(): Int = name
|
||||
}
|
||||
|
|
@ -11,8 +11,8 @@ import com.tangem.tangemtest._arch.structure.Id
|
|||
import com.tangem.tangemtest._arch.structure.StringId
|
||||
import com.tangem.tangemtest._arch.structure.abstraction.Item
|
||||
import com.tangem.tangemtest._arch.widget.WidgetBuilder
|
||||
import com.tangem.tangemtest.commons.view.ButtonState
|
||||
import com.tangem.tangemtest.commons.view.MultiActionView
|
||||
import com.tangem.tangemtest.commons.view.ViewAction
|
||||
import com.tangem.tangemtest.ucase.domain.paramsManager.ItemsManager
|
||||
import com.tangem.tangemtest.ucase.domain.paramsManager.PayloadKey
|
||||
import com.tangem.tangemtest.ucase.domain.paramsManager.managers.PersonalizationItemsManager
|
||||
|
|
@ -48,8 +48,8 @@ class PersonalizationFragment : BaseCardActionFragment() {
|
|||
val show = StringId("show")
|
||||
val hide = StringId("hide")
|
||||
val multiAction = MultiActionView(mutableListOf(
|
||||
ButtonState(show, R.string.show_rare_fields) { actionVM.showFields(ActionType.Personalize) },
|
||||
ButtonState(hide, R.string.hide_rare_fields) { actionVM.hideFields(ActionType.Personalize) }
|
||||
ViewAction(show, R.string.show_rare_fields) { actionVM.showFields(ActionType.Personalize) },
|
||||
ViewAction(hide, R.string.hide_rare_fields) { actionVM.hideFields(ActionType.Personalize) }
|
||||
), btn)
|
||||
multiAction.afterAction = {
|
||||
multiAction.state = if (it == show) hide else show
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue