29 lines
1007 B
Kotlin
29 lines
1007 B
Kotlin
package com.keylesspalace.tusky.components.compose.view
|
|
|
|
import android.content.Context
|
|
import android.util.AttributeSet
|
|
import android.view.LayoutInflater
|
|
import androidx.constraintlayout.widget.ConstraintLayout
|
|
import androidx.core.widget.doAfterTextChanged
|
|
import com.keylesspalace.tusky.databinding.ViewComposeAppendTextBinding
|
|
|
|
class ComposeAppendTextView @JvmOverloads constructor(
|
|
context: Context,
|
|
attrs: AttributeSet? = null,
|
|
defStyleAttr: Int = 0
|
|
) : ConstraintLayout(context, attrs, defStyleAttr) {
|
|
|
|
private val binding = ViewComposeAppendTextBinding.inflate(
|
|
(context.getSystemService(Context.LAYOUT_INFLATER_SERVICE) as LayoutInflater),
|
|
this,
|
|
)
|
|
|
|
val onEnabledChange = binding.switchAppendText::setOnCheckedChangeListener
|
|
val onTextChange = binding.editAppendText::doAfterTextChanged
|
|
|
|
fun setup(enabled: Boolean, appendText: String) {
|
|
binding.switchAppendText.isChecked = enabled
|
|
binding.editAppendText.setText(appendText)
|
|
}
|
|
}
|