Updated on 2026-08-14
This commit is contained in:
parent
93117f441f
commit
e7d4125588
9 changed files with 29 additions and 29 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -13,6 +13,7 @@ local.properties
|
|||
.idea/caches/
|
||||
.idea/libraries/
|
||||
.idea/*.xml
|
||||
.idea/codeStyles
|
||||
|
||||
# OS-specific files
|
||||
.DS_Store
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ abstract class BaseItem<D>(
|
|||
viewModel.data = value
|
||||
}
|
||||
|
||||
fun restoreDefaultData(){
|
||||
fun restoreDefaultData() {
|
||||
setData(viewModel.defaultData)
|
||||
}
|
||||
}
|
||||
|
|
@ -16,4 +16,4 @@ class ListItem(override val id: Id, value: List<KeyValue>, selectedValue: Any?)
|
|||
: BaseItem<ListValueWrapper>(ListViewModel(ListValueWrapper(selectedValue, value))
|
||||
)
|
||||
|
||||
inline fun<reified T> BaseItem<T>.getData(): T? = viewModel.data
|
||||
inline fun <reified T> BaseItem<T>.getData(): T? = viewModel.data
|
||||
|
|
@ -22,7 +22,7 @@ interface ItemsChangeConsequence {
|
|||
fun affectChanges(payload: PayloadHolder, changedItem: Item, itemList: List<Item>): List<Item>?
|
||||
}
|
||||
|
||||
class SignScanConsequence: ItemsChangeConsequence {
|
||||
class SignScanConsequence : ItemsChangeConsequence {
|
||||
|
||||
override fun affectChanges(payload: PayloadHolder, changedItem: Item, itemList: List<Item>): List<Item>? {
|
||||
if (changedItem.id != TlvId.CardId) return null
|
||||
|
|
@ -35,7 +35,7 @@ class SignScanConsequence: ItemsChangeConsequence {
|
|||
postUI { (payload.get(PayloadKey.actionView) as? ActionView)?.enableActionFab(false) }
|
||||
} else {
|
||||
val dataForHashing = hashItem.getData() as? String ?: "Any data mother...s"
|
||||
val hashedData = when(card.curve) {
|
||||
val hashedData = when (card.curve) {
|
||||
EllipticCurve.Secp256k1 -> dataForHashing.calculateSha256()
|
||||
EllipticCurve.Ed25519 -> dataForHashing.calculateSha512()
|
||||
else -> return null
|
||||
|
|
|
|||
|
|
@ -57,7 +57,7 @@ class SigningMethodTypeAdapter : JsonSerializer<SigningMethod> {
|
|||
}
|
||||
}
|
||||
|
||||
class DateTypeAdapter: JsonSerializer<Date> {
|
||||
class DateTypeAdapter : JsonSerializer<Date> {
|
||||
override fun serialize(src: Date, typeOfSrc: Type, context: JsonSerializationContext): JsonElement {
|
||||
val formatter = DateFormat.getDateInstance(DateFormat.DEFAULT, Locale("en_US"))
|
||||
return JsonPrimitive(formatter.format(src).toString())
|
||||
|
|
|
|||
|
|
@ -3,8 +3,6 @@ package com.tangem.tangemtest.ucase.variants.personalize.ui
|
|||
import android.os.Bundle
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.LinearLayout
|
||||
import androidx.core.os.bundleOf
|
||||
import androidx.fragment.app.activityViewModels
|
||||
import androidx.fragment.app.viewModels
|
||||
import androidx.lifecycle.Observer
|
||||
|
|
@ -24,7 +22,6 @@ import com.tangem.tangemtest.ucase.tunnel.ActionView
|
|||
import com.tangem.tangemtest.ucase.tunnel.CardError
|
||||
import com.tangem.tangemtest.ucase.tunnel.ItemError
|
||||
import com.tangem.tangemtest.ucase.ui.ActionViewModelFactory
|
||||
import com.tangem.tangemtest.ucase.ui.BaseCardResponseFragment
|
||||
import com.tangem.tangemtest.ucase.ui.BaseFragment
|
||||
import com.tangem.tangemtest.ucase.ui.ParamsViewModel
|
||||
import com.tangem.tangemtest.ucase.variants.personalize.dto.PersonalizeConfig
|
||||
|
|
@ -36,19 +33,21 @@ import ru.dev.gbixahue.eu4d.lib.android.global.log.Log
|
|||
*/
|
||||
class PersonalizeFragment : BaseFragment(), ActionView {
|
||||
|
||||
private lateinit var itemContainer: ViewGroup
|
||||
private lateinit var actionFab: FloatingActionButton
|
||||
|
||||
private val mainActivityVM: MainViewModel by activityViewModels()
|
||||
private val personalizeVM: PersonalizeViewModel by viewModels { PersonalizeViewModelFactory(PersonalizeConfig()) }
|
||||
private val paramsVM: ParamsViewModel by viewModels() { ActionViewModelFactory(itemsManager) }
|
||||
|
||||
private val blockContainer: ViewGroup by lazy { mainView.findViewById<LinearLayout>(R.id.ll_container) }
|
||||
private val actionFab: FloatingActionButton by lazy { mainView.findViewById<FloatingActionButton>(R.id.fab_action) }
|
||||
|
||||
private val itemsManager: ItemsManager by lazy { ParamsManagerFactory.createFactory().get(ActionType.Personalize)!! }
|
||||
|
||||
override fun getLayoutId(): Int = R.layout.fg_personalize
|
||||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
itemContainer = mainView.findViewById(R.id.ll_container)
|
||||
actionFab = mainView.findViewById(R.id.fab_action)
|
||||
|
||||
paramsVM.setCardManager(CardManager.init(requireActivity()))
|
||||
paramsVM.attachToPayload(mutableMapOf(PayloadKey.actionView to this as ActionView))
|
||||
|
|
@ -58,16 +57,17 @@ class PersonalizeFragment : BaseFragment(), ActionView {
|
|||
}
|
||||
|
||||
private fun initFab() {
|
||||
enableActionFab(true)
|
||||
actionFab.setOnClickListener { paramsVM.invokeMainAction() }
|
||||
}
|
||||
|
||||
private fun createWidgets(widgetCreatedCallback: () -> Unit) {
|
||||
Log.d(this, "createWidgets")
|
||||
val blockList = mutableListOf<Item>()
|
||||
personalizeVM.ldBlockList.observe(viewLifecycleOwner, Observer { list ->
|
||||
Log.d(this, "ldBlockList size: ${list.size}")
|
||||
blockList.clear()
|
||||
blockList.addAll(list)
|
||||
blockList.forEach { WidgetBuilder(PersonalizeItemBuilder()).build(it, blockContainer) }
|
||||
blockList.forEach { WidgetBuilder(PersonalizeItemBuilder()).build(it, itemContainer) }
|
||||
paramsVM.attachToPayload(mutableMapOf(
|
||||
PayloadKey.actionView to this as ActionView,
|
||||
PayloadKey.itemList to blockList
|
||||
|
|
@ -76,25 +76,17 @@ class PersonalizeFragment : BaseFragment(), ActionView {
|
|||
})
|
||||
}
|
||||
|
||||
override fun enableActionFab(enable: Boolean) {
|
||||
if (enable) actionFab.show() else actionFab.hide()
|
||||
}
|
||||
|
||||
private fun subscribeToViewModelChanges() {
|
||||
Log.d(this, "subscribeToViewModelChanges")
|
||||
listenReadResponse()
|
||||
listenResponse()
|
||||
listenEvent()
|
||||
listenError()
|
||||
// listenChangedItems()
|
||||
listenDescriptionSwitchChanges()
|
||||
}
|
||||
|
||||
private fun listenReadResponse() {}
|
||||
|
||||
private fun listenResponse() {
|
||||
paramsVM.seResponse.observe(viewLifecycleOwner, Observer {
|
||||
navigateTo(R.id.action_nav_card_action_to_response_screen,
|
||||
bundleOf(Pair(BaseCardResponseFragment.response, it)))
|
||||
private fun listenEvent() {
|
||||
paramsVM.seResponseEvent.observe(viewLifecycleOwner, Observer {
|
||||
mainActivityVM.changeResponseEvent(it)
|
||||
navigateTo(R.id.action_nav_card_action_to_response_screen)
|
||||
})
|
||||
}
|
||||
|
||||
|
|
@ -109,6 +101,10 @@ class PersonalizeFragment : BaseFragment(), ActionView {
|
|||
})
|
||||
}
|
||||
|
||||
override fun enableActionFab(enable: Boolean) {
|
||||
if (enable) actionFab.show() else actionFab.hide()
|
||||
}
|
||||
|
||||
override fun showSnackbar(id: Id) {
|
||||
// MainResourceHolder.safeGet<>()
|
||||
when (id) {
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ import androidx.lifecycle.Observer
|
|||
import com.tangem.tangemtest.R
|
||||
import com.tangem.tangemtest.ucase.resources.ActionType
|
||||
import com.tangem.tangemtest.ucase.ui.BaseCardActionFragment
|
||||
import com.tangem.tangemtest.ucase.ui.BaseCardResponseFragment
|
||||
import com.tangem.tangemtest.ucase.ui.response.BaseCardResponseFragment
|
||||
|
||||
/**
|
||||
[REDACTED_AUTHOR]
|
||||
|
|
|
|||
|
|
@ -4,7 +4,10 @@
|
|||
android:id="@+id/root"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:padding="@dimen/def_indent">
|
||||
android:paddingStart="@dimen/def_indent"
|
||||
android:paddingTop="6dp"
|
||||
android:paddingEnd="@dimen/def_indent"
|
||||
android:paddingBottom="6dp">
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/container_field"
|
||||
|
|
|
|||
|
|
@ -127,7 +127,7 @@
|
|||
|
||||
<fragment
|
||||
android:id="@+id/nav_card_response"
|
||||
android:name="com.tangem.tangemtest.ucase.ui.BaseCardResponseFragment"
|
||||
android:name="com.tangem.tangemtest.ucase.ui.response.BaseCardResponseFragment"
|
||||
android:label="@string/unknown"
|
||||
tools:layout="@layout/fg_card_response" />
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue