-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #300 from tinkoff-mobile-tech/EACQAPW-5611-bugfix-…
…main-screen-cvc-input-focus EACQAPW-5611 Изменена логика поведения CVC поля на главной форме оплаты, при клике фокусируется
- Loading branch information
Showing
8 changed files
with
127 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
...java/ru/tinkoff/acquiring/sdk/redesign/common/carddatainput/FocusDecoratorCvcComponent.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
package ru.tinkoff.acquiring.sdk.redesign.common.carddatainput | ||
|
||
import android.view.View | ||
import android.view.ViewGroup | ||
import kotlinx.android.synthetic.main.acq_fragment_cvc_input.view.cvc_input | ||
import ru.tinkoff.acquiring.sdk.ui.component.UiComponent | ||
|
||
interface CvcUIComponent : UiComponent<String?> { | ||
fun clearCvc() | ||
fun enableCvc(isEnabled: Boolean) | ||
} | ||
|
||
class FocusDecoratorCvcComponent( | ||
private val root: ViewGroup, | ||
private val initingFocusAndKeyboard: Boolean, | ||
private val onFocusCvc: View.() -> Unit, | ||
onInputComplete: (String) -> Unit, | ||
onDataChange: (Boolean, String) -> Unit | ||
) : CvcUIComponent { | ||
|
||
private val cvcComponent: CvcComponent = CvcComponent( | ||
root, | ||
initingFocusAndKeyboard, | ||
onInputComplete, | ||
onDataChange, | ||
onInitScreen = { _, function -> | ||
if(initingFocusAndKeyboard){ | ||
onFocusCvc(root.cvc_input.editText.apply(function)) | ||
} | ||
} | ||
) | ||
|
||
override fun clearCvc() { | ||
cvcComponent.render(null) | ||
} | ||
|
||
override fun enableCvc(isEnabled: Boolean) = cvcComponent.enable(isEnabled) | ||
|
||
fun enable(isEnable: Boolean) = with(cvcComponent.cvcInput) { | ||
isEnabled = isEnable | ||
editable = isEnable | ||
if (isEnable.not()) { | ||
hideKeyboard() | ||
} | ||
} | ||
|
||
override fun render(state: String?) = cvcComponent.render(state) | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters