Updated on 2026-08-14
This commit is contained in:
parent
14ea1d3807
commit
bdce71a2b1
26 changed files with 69 additions and 6 deletions
|
|
@ -3,13 +3,15 @@ package com.tangem.tangemtest._arch.structure.impl
|
|||
import com.tangem.tangemtest._arch.structure.Id
|
||||
import com.tangem.tangemtest._arch.structure.abstraction.BaseItem
|
||||
|
||||
|
||||
/**
|
||||
[REDACTED_AUTHOR]
|
||||
*/
|
||||
class AnyItem(override val id: Id, value: Any? = null) : BaseItem<Any>(AnyViewModel(value))
|
||||
class TextItem(override val id: Id, value: String? = null) : BaseItem<String>(StringViewModel(value))
|
||||
class EditTextItem(override val id: Id, value: String? = null) : BaseItem<String>(StringViewModel(value))
|
||||
class NumberItem(override val id: Id, value: Number? = null) : BaseItem<Number>(NumberViewModel(value))
|
||||
class BoolItem(override val id: Id, value: Boolean? = null) : BaseItem<Boolean>(BoolViewModel(value))
|
||||
|
||||
class ListItem(override val id: Id, value: List<KeyValue>, selectedValue: Any)
|
||||
class ListItem(override val id: Id, value: List<KeyValue>, selectedValue: Any?)
|
||||
: BaseItem<ListValueWrapper>(ListViewModel(ListValueWrapper(selectedValue, value))
|
||||
)
|
||||
|
|
@ -27,4 +27,4 @@ class ListViewModel(value: ListValueWrapper? = null) : TransitiveViewModel<ListV
|
|||
}
|
||||
|
||||
class KeyValue(val key: String, val value: Any)
|
||||
class ListValueWrapper(var selectedItem: Any, val itemList: List<KeyValue>)
|
||||
class ListValueWrapper(var selectedItem: Any?, val itemList: List<KeyValue>)
|
||||
|
|
@ -16,7 +16,7 @@ import androidx.navigation.ui.setupActionBarWithNavController
|
|||
import com.tangem.tangemtest.R
|
||||
|
||||
/**
|
||||
* A simple activity demonstrating use of a NavHostFragment with a navigation drawer.
|
||||
[REDACTED_AUTHOR]
|
||||
*/
|
||||
class MainActivity : AppCompatActivity() {
|
||||
|
||||
|
|
|
|||
|
|
@ -7,7 +7,6 @@ import com.tangem.tangemtest.R
|
|||
/**
|
||||
[REDACTED_AUTHOR]
|
||||
*/
|
||||
|
||||
fun getDefaultNavigationOptions(): NavOptions {
|
||||
return navOptions {
|
||||
anim {
|
||||
|
|
|
|||
|
|
@ -4,6 +4,9 @@ import com.tangem.common.tlv.TlvTag
|
|||
import com.tangem.tangemtest.ucase.domain.paramsManager.ActionCallback
|
||||
import com.tangem.tangemtest.ucase.domain.paramsManager.findParameter
|
||||
|
||||
/**
|
||||
[REDACTED_AUTHOR]
|
||||
*/
|
||||
class DepesonalizeAction : BaseCardAction() {
|
||||
override fun executeMainAction(attrs: AttrForAction, callback: ActionCallback) {
|
||||
val cardId = attrs.paramsList.findParameter(TlvTag.CardId)?.data as? String ?: return
|
||||
|
|
|
|||
|
|
@ -7,6 +7,9 @@ import com.tangem.tangemtest.ucase.domain.paramsManager.ActionCallback
|
|||
import com.tangem.tasks.ScanEvent
|
||||
import com.tangem.tasks.TaskEvent
|
||||
|
||||
/**
|
||||
[REDACTED_AUTHOR]
|
||||
*/
|
||||
class PersonalizeAction : BaseCardAction() {
|
||||
override fun executeMainAction(attrs: AttrForAction, callback: ActionCallback) {
|
||||
ScanAction().executeMainAction(attrs) { response, b ->
|
||||
|
|
|
|||
|
|
@ -3,6 +3,9 @@ package com.tangem.tangemtest.ucase.domain.actions
|
|||
import com.tangem.tangemtest.ucase.domain.paramsManager.ActionCallback
|
||||
import com.tangem.tangemtest.ucase.domain.paramsManager.triggers.afterAction.AfterScanModifier
|
||||
|
||||
/**
|
||||
[REDACTED_AUTHOR]
|
||||
*/
|
||||
class ScanAction : BaseCardAction() {
|
||||
override fun executeMainAction(attrs: AttrForAction, callback: ActionCallback) {
|
||||
attrs.cardManager.scanCard { handleResponse(it, AfterScanModifier(), attrs, callback) }
|
||||
|
|
|
|||
|
|
@ -5,6 +5,9 @@ import com.tangem.tangemtest.ucase.domain.paramsManager.ActionCallback
|
|||
import com.tangem.tangemtest.ucase.domain.paramsManager.findParameter
|
||||
import ru.dev.gbixahue.eu4d.lib.kotlin.stringOf
|
||||
|
||||
/**
|
||||
[REDACTED_AUTHOR]
|
||||
*/
|
||||
class SignAction : BaseCardAction() {
|
||||
override fun executeMainAction(attrs: AttrForAction, callback: ActionCallback) {
|
||||
val dataForHashing = attrs.paramsList.findParameter(TlvTag.TransactionOutHash) ?: return
|
||||
|
|
|
|||
|
|
@ -9,6 +9,9 @@ typealias AffectedList = List<IncomingParameter>
|
|||
typealias AffectedParamsCallback = (AffectedList) -> Unit
|
||||
typealias ActionCallback = (ActionResponse, AffectedList) -> Unit
|
||||
|
||||
/**
|
||||
[REDACTED_AUTHOR]
|
||||
*/
|
||||
interface ParamsManager {
|
||||
|
||||
fun parameterChanged(tag: TlvTag, value: Any?, callback: AffectedParamsCallback? = null)
|
||||
|
|
|
|||
|
|
@ -7,6 +7,9 @@ import com.tangem.tangemtest.ucase.domain.actions.CardAction
|
|||
import com.tangem.tangemtest.ucase.domain.paramsManager.*
|
||||
import com.tangem.tangemtest.ucase.domain.paramsManager.triggers.changeConsequence.ParamsChangeConsequence
|
||||
|
||||
/**
|
||||
[REDACTED_AUTHOR]
|
||||
*/
|
||||
abstract class BaseParamsManager(protected val action: CardAction) : ParamsManager {
|
||||
|
||||
protected val paramsList: List<IncomingParameter> by lazy { createParamsList() }
|
||||
|
|
|
|||
|
|
@ -6,6 +6,9 @@ import com.tangem.tangemtest.ucase.domain.actions.DepesonalizeAction
|
|||
import com.tangem.tangemtest.ucase.domain.paramsManager.ActionCallback
|
||||
import com.tangem.tangemtest.ucase.domain.paramsManager.IncomingParameter
|
||||
|
||||
/**
|
||||
[REDACTED_AUTHOR]
|
||||
*/
|
||||
class DepersonalizeParamsManager : BaseParamsManager(DepesonalizeAction()) {
|
||||
override fun createParamsList(): List<IncomingParameter> {
|
||||
return listOf(IncomingParameter(TlvTag.CardId, null))
|
||||
|
|
|
|||
|
|
@ -5,6 +5,9 @@ import com.tangem.tangemtest.ucase.domain.actions.PersonalizeAction
|
|||
import com.tangem.tangemtest.ucase.domain.paramsManager.ActionCallback
|
||||
import com.tangem.tangemtest.ucase.domain.paramsManager.IncomingParameter
|
||||
|
||||
/**
|
||||
[REDACTED_AUTHOR]
|
||||
*/
|
||||
class PersonalizeParamsManager : BaseParamsManager(PersonalizeAction()) {
|
||||
override fun createParamsList(): List<IncomingParameter> {
|
||||
return listOf()
|
||||
|
|
|
|||
|
|
@ -6,6 +6,9 @@ import com.tangem.tangemtest.ucase.domain.actions.ScanAction
|
|||
import com.tangem.tangemtest.ucase.domain.paramsManager.ActionCallback
|
||||
import com.tangem.tangemtest.ucase.domain.paramsManager.IncomingParameter
|
||||
|
||||
/**
|
||||
[REDACTED_AUTHOR]
|
||||
*/
|
||||
class ScanParamsManager : BaseParamsManager(ScanAction()) {
|
||||
override fun createParamsList(): List<IncomingParameter> {
|
||||
return listOf(IncomingParameter(TlvTag.CardId, null))
|
||||
|
|
|
|||
|
|
@ -6,6 +6,9 @@ import com.tangem.tangemtest.ucase.domain.actions.SignAction
|
|||
import com.tangem.tangemtest.ucase.domain.paramsManager.ActionCallback
|
||||
import com.tangem.tangemtest.ucase.domain.paramsManager.IncomingParameter
|
||||
|
||||
/**
|
||||
[REDACTED_AUTHOR]
|
||||
*/
|
||||
class SignParamsManager : BaseParamsManager(SignAction()) {
|
||||
override fun createParamsList(): List<IncomingParameter> {
|
||||
return listOf(
|
||||
|
|
|
|||
|
|
@ -6,6 +6,9 @@ import com.tangem.tangemtest.ucase.domain.paramsManager.findParameter
|
|||
import com.tangem.tasks.ScanEvent
|
||||
import com.tangem.tasks.TaskEvent
|
||||
|
||||
/**
|
||||
[REDACTED_AUTHOR]
|
||||
*/
|
||||
class AfterScanModifier : AfterActionModification {
|
||||
override fun modify(taskEvent: TaskEvent<*>, paramsList: List<IncomingParameter>): List<IncomingParameter> {
|
||||
val parameter = paramsList.findParameter(TlvTag.CardId) ?: return listOf()
|
||||
|
|
|
|||
|
|
@ -6,6 +6,9 @@ import com.tangem.tangemtest.ucase.resources.ResourceHolder
|
|||
import com.tangem.tangemtest.ucase.resources.Resources
|
||||
import ru.dev.gbixahue.eu4d.lib.kotlin.common.TypedHolder
|
||||
|
||||
/**
|
||||
[REDACTED_AUTHOR]
|
||||
*/
|
||||
class PersonalizeResources() {
|
||||
fun init(holder: ResourceHolder<Id>) {
|
||||
initBlock(holder)
|
||||
|
|
|
|||
|
|
@ -19,7 +19,6 @@ import com.tangem.tasks.TaskEvent
|
|||
/**
|
||||
[REDACTED_AUTHOR]
|
||||
*/
|
||||
|
||||
class ActionViewModelFactory(private val manager: ParamsManager) : ViewModelProvider.NewInstanceFactory() {
|
||||
override fun <T : ViewModel?> create(modelClass: Class<T>): T = ParamsViewModel(manager) as T
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,6 +4,9 @@ import com.tangem.tangemtest._arch.structure.abstraction.Block
|
|||
import com.tangem.tangemtest.ucase.variants.personalize.dto.TestJsonDto
|
||||
import ru.dev.gbixahue.eu4d.lib.kotlin.common.Converter
|
||||
|
||||
/**
|
||||
[REDACTED_AUTHOR]
|
||||
*/
|
||||
class BlockToJsonConverter : Converter<List<Block>, TestJsonDto> {
|
||||
override fun convert(from: List<Block>): TestJsonDto = TestJsonDto()
|
||||
}
|
||||
|
|
@ -1,5 +1,8 @@
|
|||
package com.tangem.tangemtest.ucase.variants.personalize.dto
|
||||
|
||||
/**
|
||||
[REDACTED_AUTHOR]
|
||||
*/
|
||||
class TestJsonDto {
|
||||
|
||||
// Card number
|
||||
|
|
|
|||
|
|
@ -11,6 +11,9 @@ import com.tangem.tangemtest.ucase.variants.personalize.ui.widgets.impl.StubWidg
|
|||
import com.tangem.tangemtest.ucase.variants.personalize.ui.widgets.impl.block.LinearBlockWidget
|
||||
import com.tangem.tangemtest.ucase.variants.personalize.ui.widgets.impl.item.*
|
||||
|
||||
/**
|
||||
[REDACTED_AUTHOR]
|
||||
*/
|
||||
class WidgetBuilder {
|
||||
|
||||
fun build(item: Item, parent: ViewGroup): ViewWidget? {
|
||||
|
|
|
|||
|
|
@ -5,6 +5,9 @@ import com.tangem.tangemtest.R
|
|||
import com.tangem.tangemtest._arch.structure.abstraction.ItemViewModel
|
||||
import com.tangem.tangemtest.ucase.variants.personalize.ui.widgets.abstraction.BaseBlockWidget
|
||||
|
||||
/**
|
||||
[REDACTED_AUTHOR]
|
||||
*/
|
||||
class StubWidget(parent: ViewGroup) : BaseBlockWidget(parent) {
|
||||
override fun getLayoutId(): Int = R.layout.w_empty
|
||||
override var viewModel: List<ItemViewModel<*>> = listOf()
|
||||
|
|
|
|||
|
|
@ -10,6 +10,9 @@ import com.tangem.tangemtest._arch.structure.impl.EditTextItem
|
|||
import com.tangem.tangemtest.ucase.variants.personalize.ui.widgets.abstraction.getResNameId
|
||||
import ru.dev.gbixahue.eu4d.lib.kotlin.stringOf
|
||||
|
||||
/**
|
||||
[REDACTED_AUTHOR]
|
||||
*/
|
||||
class EditTextWidget(parent: ViewGroup, data: EditTextItem) : DescriptionWidget<String>(parent, data) {
|
||||
override fun getLayoutId(): Int = R.layout.w_personalize_item_edit_text
|
||||
|
||||
|
|
|
|||
|
|
@ -10,6 +10,9 @@ import com.tangem.tangemtest._arch.structure.impl.NumberItem
|
|||
import com.tangem.tangemtest.ucase.variants.personalize.ui.widgets.abstraction.getResNameId
|
||||
import ru.dev.gbixahue.eu4d.lib.kotlin.stringOf
|
||||
|
||||
/**
|
||||
[REDACTED_AUTHOR]
|
||||
*/
|
||||
class NumberWidget(parent: ViewGroup, data: NumberItem) : DescriptionWidget<Number>(parent, data) {
|
||||
override fun getLayoutId(): Int = R.layout.w_personalize_item_number
|
||||
|
||||
|
|
|
|||
|
|
@ -14,6 +14,9 @@ import com.tangem.tangemtest.ucase.variants.personalize.ui.widgets.abstraction.g
|
|||
import ru.dev.gbixahue.eu4d.lib.android._android.views.inflate
|
||||
import ru.dev.gbixahue.eu4d.lib.kotlin.stringOf
|
||||
|
||||
/**
|
||||
[REDACTED_AUTHOR]
|
||||
*/
|
||||
class SpinnerWidget(parent: ViewGroup, data: ListItem) : DescriptionWidget<ListValueWrapper>(parent, data) {
|
||||
override fun getLayoutId(): Int = R.layout.w_personalize_item_spinner
|
||||
|
||||
|
|
|
|||
|
|
@ -7,6 +7,9 @@ import com.tangem.tangemtest.R
|
|||
import com.tangem.tangemtest._arch.structure.impl.BoolItem
|
||||
import com.tangem.tangemtest.ucase.variants.personalize.ui.widgets.abstraction.getResNameId
|
||||
|
||||
/**
|
||||
[REDACTED_AUTHOR]
|
||||
*/
|
||||
class SwitchWidget(parent: ViewGroup, data: BoolItem) : DescriptionWidget<Boolean>(parent, data) {
|
||||
override fun getLayoutId(): Int = R.layout.w_personalize_item_switch
|
||||
|
||||
|
|
|
|||
|
|
@ -6,6 +6,9 @@ import com.tangem.tangemtest.R
|
|||
import com.tangem.tangemtest._arch.structure.impl.TextItem
|
||||
import com.tangem.tangemtest.ucase.variants.personalize.ui.widgets.abstraction.getResNameId
|
||||
|
||||
/**
|
||||
[REDACTED_AUTHOR]
|
||||
*/
|
||||
class TextWidget(parent: ViewGroup, data: TextItem) : DescriptionWidget<String>(parent, data) {
|
||||
override fun getLayoutId(): Int = R.layout.w_personalize_item_text
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue