fun bind(state: CreditCardEditorState) { if (state.isEditing) { binding.deleteButton.apply { visibility = View.VISIBLE setOnClickListener { interactor.onDeleteCardButtonClicked(state.guid) } } } binding.cancelButton.setOnClickListener { interactor.onCancelButtonClicked() } binding.saveButton.setOnClickListener { saveCreditCard(state) } binding.cardNumberInput.text = state.cardNumber.toEditable() binding.nameOnCardInput.text = state.billingName.toEditable() binding.cardNumberLayout.setErrorTextColor( ColorStateList.valueOf( binding.root.context.getColorFromAttr(R.attr.textWarning), ), ) binding.nameOnCardLayout.setErrorTextColor( ColorStateList.valueOf( binding.root.context.getColorFromAttr(R.attr.textWarning), ), ) bindExpiryMonthDropDown(state.expiryMonth) bindExpiryYearDropDown(state.expiryYears) }
Binds the given [CreditCardEditorState] in the [CreditCardEditorFragment].