More click listener...
This commit is contained in:
parent
316e685690
commit
6dd1bc3385
|
@ -24,6 +24,8 @@ import android.widget.FrameLayout
|
|||
import androidx.core.view.isInvisible
|
||||
import androidx.core.view.isVisible
|
||||
import im.vector.app.R
|
||||
import im.vector.app.core.epoxy.ClickListener
|
||||
import im.vector.app.core.epoxy.onClick
|
||||
import im.vector.app.databinding.ViewButtonStateBinding
|
||||
|
||||
class ButtonStateView @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null, defStyle: Int = 0)
|
||||
|
@ -36,12 +38,9 @@ class ButtonStateView @JvmOverloads constructor(context: Context, attrs: Attribu
|
|||
object Error : State()
|
||||
}
|
||||
|
||||
var callback: Callback? = null
|
||||
|
||||
interface Callback {
|
||||
fun onButtonClicked()
|
||||
fun onRetryClicked()
|
||||
}
|
||||
var commonClicked: ClickListener? = null
|
||||
var buttonClicked: ClickListener? = null
|
||||
var retryClicked: ClickListener? = null
|
||||
|
||||
// Big or Flat button
|
||||
var button: Button
|
||||
|
@ -54,8 +53,9 @@ class ButtonStateView @JvmOverloads constructor(context: Context, attrs: Attribu
|
|||
|
||||
layoutParams = LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT)
|
||||
|
||||
views.buttonStateRetry.setOnClickListener {
|
||||
callback?.onRetryClicked()
|
||||
views.buttonStateRetry.onClick {
|
||||
commonClicked?.invoke(it)
|
||||
retryClicked?.invoke(it)
|
||||
}
|
||||
|
||||
// Read attributes
|
||||
|
@ -80,8 +80,9 @@ class ButtonStateView @JvmOverloads constructor(context: Context, attrs: Attribu
|
|||
}
|
||||
}
|
||||
|
||||
button.setOnClickListener {
|
||||
callback?.onButtonClicked()
|
||||
button.onClick {
|
||||
commonClicked?.invoke(it)
|
||||
buttonClicked?.invoke(it)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -23,8 +23,10 @@ import androidx.core.graphics.drawable.DrawableCompat
|
|||
import com.airbnb.epoxy.EpoxyAttribute
|
||||
import com.airbnb.epoxy.EpoxyModelClass
|
||||
import im.vector.app.R
|
||||
import im.vector.app.core.epoxy.ClickListener
|
||||
import im.vector.app.core.epoxy.VectorEpoxyHolder
|
||||
import im.vector.app.core.epoxy.VectorEpoxyModel
|
||||
import im.vector.app.core.epoxy.onClick
|
||||
import im.vector.app.features.themes.ThemeUtils
|
||||
|
||||
@EpoxyModelClass(layout = R.layout.item_room_category)
|
||||
|
@ -34,7 +36,7 @@ abstract class RoomCategoryItem : VectorEpoxyModel<RoomCategoryItem.Holder>() {
|
|||
@EpoxyAttribute var expanded: Boolean = false
|
||||
@EpoxyAttribute var unreadNotificationCount: Int = 0
|
||||
@EpoxyAttribute var showHighlighted: Boolean = false
|
||||
@EpoxyAttribute var listener: (() -> Unit)? = null
|
||||
@EpoxyAttribute(EpoxyAttribute.Option.DoNotHash) var listener: ClickListener? = null
|
||||
|
||||
override fun bind(holder: Holder) {
|
||||
super.bind(holder)
|
||||
|
@ -46,7 +48,7 @@ abstract class RoomCategoryItem : VectorEpoxyModel<RoomCategoryItem.Holder>() {
|
|||
holder.unreadCounterBadgeView.render(UnreadCounterBadgeView.State(unreadNotificationCount, showHighlighted))
|
||||
holder.titleView.setCompoundDrawablesWithIntrinsicBounds(null, null, expandedArrowDrawable, null)
|
||||
holder.titleView.text = title
|
||||
holder.rootView.setOnClickListener { listener?.invoke() }
|
||||
holder.rootView.onClick(listener)
|
||||
}
|
||||
|
||||
class Holder : VectorEpoxyHolder() {
|
||||
|
|
|
@ -22,8 +22,10 @@ import android.widget.TextView
|
|||
import com.airbnb.epoxy.EpoxyAttribute
|
||||
import com.airbnb.epoxy.EpoxyModelClass
|
||||
import im.vector.app.R
|
||||
import im.vector.app.core.epoxy.ClickListener
|
||||
import im.vector.app.core.epoxy.VectorEpoxyHolder
|
||||
import im.vector.app.core.epoxy.VectorEpoxyModel
|
||||
import im.vector.app.core.epoxy.onClick
|
||||
import im.vector.app.core.extensions.setTextOrHide
|
||||
import im.vector.app.core.platform.ButtonStateView
|
||||
import im.vector.app.features.home.AvatarRenderer
|
||||
|
@ -37,36 +39,16 @@ abstract class RoomInvitationItem : VectorEpoxyModel<RoomInvitationItem.Holder>(
|
|||
@EpoxyAttribute lateinit var avatarRenderer: AvatarRenderer
|
||||
@EpoxyAttribute lateinit var matrixItem: MatrixItem
|
||||
@EpoxyAttribute var secondLine: CharSequence? = null
|
||||
@EpoxyAttribute var listener: (() -> Unit)? = null
|
||||
@EpoxyAttribute(EpoxyAttribute.Option.DoNotHash) var listener: ClickListener? = null
|
||||
@EpoxyAttribute lateinit var changeMembershipState: ChangeMembershipState
|
||||
@EpoxyAttribute var acceptListener: (() -> Unit)? = null
|
||||
@EpoxyAttribute var rejectListener: (() -> Unit)? = null
|
||||
|
||||
private val acceptCallback = object : ButtonStateView.Callback {
|
||||
override fun onButtonClicked() {
|
||||
acceptListener?.invoke()
|
||||
}
|
||||
|
||||
override fun onRetryClicked() {
|
||||
acceptListener?.invoke()
|
||||
}
|
||||
}
|
||||
|
||||
private val rejectCallback = object : ButtonStateView.Callback {
|
||||
override fun onButtonClicked() {
|
||||
rejectListener?.invoke()
|
||||
}
|
||||
|
||||
override fun onRetryClicked() {
|
||||
rejectListener?.invoke()
|
||||
}
|
||||
}
|
||||
@EpoxyAttribute(EpoxyAttribute.Option.DoNotHash) var acceptListener: ClickListener? = null
|
||||
@EpoxyAttribute(EpoxyAttribute.Option.DoNotHash) var rejectListener: ClickListener? = null
|
||||
|
||||
override fun bind(holder: Holder) {
|
||||
super.bind(holder)
|
||||
holder.rootView.setOnClickListener { listener?.invoke() }
|
||||
holder.acceptView.callback = acceptCallback
|
||||
holder.rejectView.callback = rejectCallback
|
||||
holder.rootView.onClick(listener)
|
||||
holder.acceptView.commonClicked = acceptListener
|
||||
holder.rejectView.commonClicked = rejectListener
|
||||
InviteButtonStateBinder.bind(holder.acceptView, holder.rejectView, changeMembershipState)
|
||||
holder.titleView.text = matrixItem.getBestName()
|
||||
holder.subtitleView.setTextOrHide(secondLine)
|
||||
|
|
|
@ -23,10 +23,8 @@ import androidx.constraintlayout.widget.ConstraintLayout
|
|||
import androidx.core.view.updateLayoutParams
|
||||
import im.vector.app.R
|
||||
import im.vector.app.core.di.HasScreenInjector
|
||||
import im.vector.app.core.platform.ButtonStateView
|
||||
import im.vector.app.databinding.VectorInviteViewBinding
|
||||
import im.vector.app.features.home.AvatarRenderer
|
||||
|
||||
import org.matrix.android.sdk.api.session.room.members.ChangeMembershipState
|
||||
import org.matrix.android.sdk.api.session.room.model.RoomMemberSummary
|
||||
import org.matrix.android.sdk.api.util.toMatrixItem
|
||||
|
@ -56,25 +54,8 @@ class VectorInviteView @JvmOverloads constructor(context: Context, attrs: Attrib
|
|||
}
|
||||
inflate(context, R.layout.vector_invite_view, this)
|
||||
views = VectorInviteViewBinding.bind(this)
|
||||
views.inviteAcceptView.callback = object : ButtonStateView.Callback {
|
||||
override fun onButtonClicked() {
|
||||
callback?.onAcceptInvite()
|
||||
}
|
||||
|
||||
override fun onRetryClicked() {
|
||||
callback?.onAcceptInvite()
|
||||
}
|
||||
}
|
||||
|
||||
views.inviteRejectView.callback = object : ButtonStateView.Callback {
|
||||
override fun onButtonClicked() {
|
||||
callback?.onRejectInvite()
|
||||
}
|
||||
|
||||
override fun onRetryClicked() {
|
||||
callback?.onRejectInvite()
|
||||
}
|
||||
}
|
||||
views.inviteAcceptView.commonClicked = { callback?.onAcceptInvite() }
|
||||
views.inviteRejectView.commonClicked = { callback?.onRejectInvite() }
|
||||
}
|
||||
|
||||
fun render(sender: RoomMemberSummary, mode: Mode = Mode.LARGE, changeMembershipState: ChangeMembershipState) {
|
||||
|
|
|
@ -51,19 +51,8 @@ class MatrixToRoomSpaceFragment @Inject constructor(
|
|||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
views.matrixToCardMainButton.callback = object : ButtonStateView.Callback {
|
||||
override fun onButtonClicked() {
|
||||
mainButtonClicked()
|
||||
}
|
||||
|
||||
override fun onRetryClicked() = onButtonClicked()
|
||||
}
|
||||
views.matrixToCardSecondaryButton.callback = object : ButtonStateView.Callback {
|
||||
override fun onButtonClicked() {
|
||||
secondaryButtonClicked()
|
||||
}
|
||||
override fun onRetryClicked() = onButtonClicked()
|
||||
}
|
||||
views.matrixToCardMainButton.commonClicked = { mainButtonClicked() }
|
||||
views.matrixToCardSecondaryButton.commonClicked = { secondaryButtonClicked() }
|
||||
}
|
||||
|
||||
override fun invalidate() = withState(sharedViewModel) { state ->
|
||||
|
|
|
@ -22,8 +22,10 @@ import android.widget.TextView
|
|||
import com.airbnb.epoxy.EpoxyAttribute
|
||||
import com.airbnb.epoxy.EpoxyModelClass
|
||||
import im.vector.app.R
|
||||
import im.vector.app.core.epoxy.ClickListener
|
||||
import im.vector.app.core.epoxy.VectorEpoxyHolder
|
||||
import im.vector.app.core.epoxy.VectorEpoxyModel
|
||||
import im.vector.app.core.epoxy.onClick
|
||||
import im.vector.app.core.extensions.setTextOrHide
|
||||
import im.vector.app.core.platform.ButtonStateView
|
||||
import im.vector.app.features.home.AvatarRenderer
|
||||
|
@ -50,15 +52,15 @@ abstract class PublicRoomItem : VectorEpoxyModel<PublicRoomItem.Holder>() {
|
|||
@EpoxyAttribute
|
||||
var joinState: JoinState = JoinState.NOT_JOINED
|
||||
|
||||
@EpoxyAttribute
|
||||
var globalListener: (() -> Unit)? = null
|
||||
@EpoxyAttribute(EpoxyAttribute.Option.DoNotHash)
|
||||
var globalListener: ClickListener? = null
|
||||
|
||||
@EpoxyAttribute
|
||||
var joinListener: (() -> Unit)? = null
|
||||
@EpoxyAttribute(EpoxyAttribute.Option.DoNotHash)
|
||||
var joinListener: ClickListener? = null
|
||||
|
||||
override fun bind(holder: Holder) {
|
||||
super.bind(holder)
|
||||
holder.rootView.setOnClickListener { globalListener?.invoke() }
|
||||
holder.rootView.onClick(globalListener)
|
||||
|
||||
avatarRenderer.render(matrixItem, holder.avatarView)
|
||||
holder.nameView.text = matrixItem.displayName
|
||||
|
@ -76,16 +78,7 @@ abstract class PublicRoomItem : VectorEpoxyModel<PublicRoomItem.Holder>() {
|
|||
}
|
||||
)
|
||||
|
||||
holder.buttonState.callback = object : ButtonStateView.Callback {
|
||||
override fun onButtonClicked() {
|
||||
joinListener?.invoke()
|
||||
}
|
||||
|
||||
override fun onRetryClicked() {
|
||||
// Same action
|
||||
onButtonClicked()
|
||||
}
|
||||
}
|
||||
holder.buttonState.commonClicked = { joinListener?.invoke(it) }
|
||||
}
|
||||
|
||||
class Holder : VectorEpoxyHolder() {
|
||||
|
|
|
@ -22,8 +22,10 @@ import android.widget.TextView
|
|||
import com.airbnb.epoxy.EpoxyAttribute
|
||||
import com.airbnb.epoxy.EpoxyModelClass
|
||||
import im.vector.app.R
|
||||
import im.vector.app.core.epoxy.ClickListener
|
||||
import im.vector.app.core.epoxy.VectorEpoxyHolder
|
||||
import im.vector.app.core.epoxy.VectorEpoxyModel
|
||||
import im.vector.app.core.epoxy.onClick
|
||||
import im.vector.app.features.home.AvatarRenderer
|
||||
import org.matrix.android.sdk.api.util.MatrixItem
|
||||
|
||||
|
@ -36,12 +38,12 @@ abstract class UnknownRoomItem : VectorEpoxyModel<UnknownRoomItem.Holder>() {
|
|||
@EpoxyAttribute
|
||||
lateinit var matrixItem: MatrixItem
|
||||
|
||||
@EpoxyAttribute
|
||||
var globalListener: (() -> Unit)? = null
|
||||
@EpoxyAttribute(EpoxyAttribute.Option.DoNotHash)
|
||||
var globalListener: ClickListener? = null
|
||||
|
||||
override fun bind(holder: Holder) {
|
||||
super.bind(holder)
|
||||
holder.rootView.setOnClickListener { globalListener?.invoke() }
|
||||
holder.rootView.onClick(globalListener)
|
||||
avatarRenderer.render(matrixItem, holder.avatarView)
|
||||
holder.nameView.text = matrixItem.displayName
|
||||
}
|
||||
|
|
|
@ -25,8 +25,10 @@ import androidx.core.view.isVisible
|
|||
import com.airbnb.epoxy.EpoxyAttribute
|
||||
import com.airbnb.epoxy.EpoxyModelClass
|
||||
import im.vector.app.R
|
||||
import im.vector.app.core.epoxy.ClickListener
|
||||
import im.vector.app.core.epoxy.VectorEpoxyHolder
|
||||
import im.vector.app.core.epoxy.VectorEpoxyModel
|
||||
import im.vector.app.core.epoxy.onClick
|
||||
import im.vector.app.core.extensions.setTextOrHide
|
||||
import im.vector.app.core.glide.GlideApp
|
||||
|
||||
|
@ -48,12 +50,12 @@ abstract class RoomDirectoryItem : VectorEpoxyModel<RoomDirectoryItem.Holder>()
|
|||
@EpoxyAttribute
|
||||
var checked: Boolean = false
|
||||
|
||||
@EpoxyAttribute
|
||||
var globalListener: (() -> Unit)? = null
|
||||
@EpoxyAttribute(EpoxyAttribute.Option.DoNotHash)
|
||||
var globalListener: ClickListener? = null
|
||||
|
||||
override fun bind(holder: Holder) {
|
||||
super.bind(holder)
|
||||
holder.rootView.setOnClickListener { globalListener?.invoke() }
|
||||
holder.rootView.onClick(globalListener)
|
||||
|
||||
// Avatar
|
||||
GlideApp.with(holder.avatarView)
|
||||
|
|
|
@ -57,16 +57,7 @@ class RoomPreviewNoPreviewFragment @Inject constructor(
|
|||
super.onViewCreated(view, savedInstanceState)
|
||||
setupToolbar(views.roomPreviewNoPreviewToolbar)
|
||||
|
||||
views.roomPreviewNoPreviewJoin.callback = object : ButtonStateView.Callback {
|
||||
override fun onButtonClicked() {
|
||||
roomPreviewViewModel.handle(RoomPreviewAction.Join)
|
||||
}
|
||||
|
||||
override fun onRetryClicked() {
|
||||
// Same action
|
||||
onButtonClicked()
|
||||
}
|
||||
}
|
||||
views.roomPreviewNoPreviewJoin.commonClicked = { roomPreviewViewModel.handle(RoomPreviewAction.Join) }
|
||||
}
|
||||
|
||||
override fun invalidate() = withState(roomPreviewViewModel) { state ->
|
||||
|
|
|
@ -23,8 +23,10 @@ import androidx.core.view.isVisible
|
|||
import com.airbnb.epoxy.EpoxyAttribute
|
||||
import com.airbnb.epoxy.EpoxyModelClass
|
||||
import im.vector.app.R
|
||||
import im.vector.app.core.epoxy.ClickListener
|
||||
import im.vector.app.core.epoxy.VectorEpoxyHolder
|
||||
import im.vector.app.core.epoxy.VectorEpoxyModel
|
||||
import im.vector.app.core.epoxy.onClick
|
||||
import im.vector.app.core.resources.ColorProvider
|
||||
import im.vector.app.core.ui.views.ShieldImageView
|
||||
import im.vector.app.core.utils.DimensionConverter
|
||||
|
@ -47,8 +49,8 @@ abstract class DeviceItem : VectorEpoxyModel<DeviceItem.Holder>() {
|
|||
@EpoxyAttribute
|
||||
var currentDevice = false
|
||||
|
||||
@EpoxyAttribute
|
||||
var itemClickAction: (() -> Unit)? = null
|
||||
@EpoxyAttribute(EpoxyAttribute.Option.DoNotHash)
|
||||
var itemClickAction: ClickListener? = null
|
||||
|
||||
@EpoxyAttribute
|
||||
var detailedMode = false
|
||||
|
@ -73,7 +75,7 @@ abstract class DeviceItem : VectorEpoxyModel<DeviceItem.Holder>() {
|
|||
|
||||
override fun bind(holder: Holder) {
|
||||
super.bind(holder)
|
||||
holder.root.setOnClickListener { itemClickAction?.invoke() }
|
||||
holder.root.onClick(itemClickAction)
|
||||
|
||||
if (e2eCapable) {
|
||||
val shield = TrustUtils.shieldForTrust(
|
||||
|
|
|
@ -21,8 +21,10 @@ import android.widget.TextView
|
|||
import com.airbnb.epoxy.EpoxyAttribute
|
||||
import com.airbnb.epoxy.EpoxyModelClass
|
||||
import im.vector.app.R
|
||||
import im.vector.app.core.epoxy.ClickListener
|
||||
import im.vector.app.core.epoxy.VectorEpoxyHolder
|
||||
import im.vector.app.core.epoxy.VectorEpoxyModel
|
||||
import im.vector.app.core.epoxy.onClick
|
||||
import im.vector.app.core.extensions.setTextOrHide
|
||||
import im.vector.app.features.home.AvatarRenderer
|
||||
import org.matrix.android.sdk.api.util.MatrixItem
|
||||
|
@ -39,12 +41,12 @@ abstract class UserItem : VectorEpoxyModel<UserItem.Holder>() {
|
|||
@EpoxyAttribute
|
||||
lateinit var matrixItem: MatrixItem
|
||||
|
||||
@EpoxyAttribute
|
||||
var itemClickAction: (() -> Unit)? = null
|
||||
@EpoxyAttribute(EpoxyAttribute.Option.DoNotHash)
|
||||
var itemClickAction: ClickListener? = null
|
||||
|
||||
override fun bind(holder: Holder) {
|
||||
super.bind(holder)
|
||||
holder.root.setOnClickListener { itemClickAction?.invoke() }
|
||||
holder.root.onClick(itemClickAction)
|
||||
|
||||
avatarRenderer.render(matrixItem, holder.avatarImage)
|
||||
holder.userIdText.setTextOrHide(matrixItem.id)
|
||||
|
|
|
@ -20,23 +20,23 @@ import android.widget.Button
|
|||
import com.airbnb.epoxy.EpoxyAttribute
|
||||
import com.airbnb.epoxy.EpoxyModelClass
|
||||
import im.vector.app.R
|
||||
import im.vector.app.core.epoxy.ClickListener
|
||||
import im.vector.app.core.epoxy.VectorEpoxyHolder
|
||||
import im.vector.app.core.epoxy.VectorEpoxyModel
|
||||
import im.vector.app.core.epoxy.onClick
|
||||
import im.vector.app.core.extensions.setTextOrHide
|
||||
|
||||
@EpoxyModelClass(layout = R.layout.item_login_centered_button)
|
||||
abstract class LoginCenterButtonItem : VectorEpoxyModel<LoginCenterButtonItem.Holder>() {
|
||||
|
||||
@EpoxyAttribute var text: String? = null
|
||||
@EpoxyAttribute var listener: (() -> Unit)? = null
|
||||
@EpoxyAttribute(EpoxyAttribute.Option.DoNotHash) var listener: ClickListener? = null
|
||||
|
||||
override fun bind(holder: Holder) {
|
||||
super.bind(holder)
|
||||
|
||||
holder.button.setTextOrHide(text)
|
||||
holder.button.setOnClickListener {
|
||||
listener?.invoke()
|
||||
}
|
||||
holder.button.onClick(listener)
|
||||
}
|
||||
|
||||
class Holder : VectorEpoxyHolder() {
|
||||
|
|
|
@ -21,8 +21,10 @@ import android.widget.TextView
|
|||
import com.airbnb.epoxy.EpoxyAttribute
|
||||
import com.airbnb.epoxy.EpoxyModelClass
|
||||
import im.vector.app.R
|
||||
import im.vector.app.core.epoxy.ClickListener
|
||||
import im.vector.app.core.epoxy.VectorEpoxyHolder
|
||||
import im.vector.app.core.epoxy.VectorEpoxyModel
|
||||
import im.vector.app.core.epoxy.onClick
|
||||
|
||||
@EpoxyModelClass(layout = R.layout.item_login_error_retry)
|
||||
abstract class LoginErrorWithRetryItem : VectorEpoxyModel<LoginErrorWithRetryItem.Holder>() {
|
||||
|
@ -30,13 +32,13 @@ abstract class LoginErrorWithRetryItem : VectorEpoxyModel<LoginErrorWithRetryIte
|
|||
@EpoxyAttribute
|
||||
var text: String? = null
|
||||
|
||||
@EpoxyAttribute
|
||||
var listener: (() -> Unit)? = null
|
||||
@EpoxyAttribute(EpoxyAttribute.Option.DoNotHash)
|
||||
var listener: ClickListener? = null
|
||||
|
||||
override fun bind(holder: Holder) {
|
||||
super.bind(holder)
|
||||
holder.textView.text = text
|
||||
holder.buttonView.setOnClickListener { listener?.invoke() }
|
||||
holder.buttonView.onClick(listener)
|
||||
}
|
||||
|
||||
class Holder : VectorEpoxyHolder() {
|
||||
|
|
|
@ -25,9 +25,11 @@ import com.airbnb.epoxy.EpoxyModelClass
|
|||
import com.google.android.material.textfield.TextInputEditText
|
||||
import com.google.android.material.textfield.TextInputLayout
|
||||
import im.vector.app.R
|
||||
import im.vector.app.core.epoxy.ClickListener
|
||||
import im.vector.app.core.epoxy.VectorEpoxyHolder
|
||||
import im.vector.app.core.epoxy.VectorEpoxyModel
|
||||
import im.vector.app.core.epoxy.addTextChangedListenerOnce
|
||||
import im.vector.app.core.epoxy.onClick
|
||||
import im.vector.app.core.extensions.showPassword
|
||||
import im.vector.app.core.platform.SimpleTextWatcher
|
||||
import im.vector.app.core.resources.StringProvider
|
||||
|
@ -40,8 +42,8 @@ abstract class LoginPasswordFormItem : VectorEpoxyModel<LoginPasswordFormItem.Ho
|
|||
@EpoxyAttribute var submitEnabled: Boolean = false
|
||||
@EpoxyAttribute var errorText: String? = null
|
||||
@EpoxyAttribute lateinit var stringProvider: StringProvider
|
||||
@EpoxyAttribute var passwordRevealClickListener: (() -> Unit)? = null
|
||||
@EpoxyAttribute var forgetPasswordClickListener: (() -> Unit)? = null
|
||||
@EpoxyAttribute(EpoxyAttribute.Option.DoNotHash) var passwordRevealClickListener: ClickListener? = null
|
||||
@EpoxyAttribute(EpoxyAttribute.Option.DoNotHash) var forgetPasswordClickListener: ClickListener? = null
|
||||
@EpoxyAttribute var submitClickListener: ((String) -> Unit)? = null
|
||||
@EpoxyAttribute(EpoxyAttribute.Option.DoNotHash) var onPasswordEdited: ((String) -> Unit)? = null
|
||||
|
||||
|
@ -57,8 +59,8 @@ abstract class LoginPasswordFormItem : VectorEpoxyModel<LoginPasswordFormItem.Ho
|
|||
setupAutoFill(holder)
|
||||
holder.passwordFieldTil.error = errorText
|
||||
renderPasswordField(holder)
|
||||
holder.passwordReveal.setOnClickListener { passwordRevealClickListener?.invoke() }
|
||||
holder.forgetPassword.setOnClickListener { forgetPasswordClickListener?.invoke() }
|
||||
holder.passwordReveal.onClick(passwordRevealClickListener)
|
||||
holder.forgetPassword.onClick(forgetPasswordClickListener)
|
||||
holder.submit.isEnabled = submitEnabled
|
||||
holder.submit.setOnClickListener { submitClickListener?.invoke(holder.passwordField.text.toString()) }
|
||||
holder.passwordField.addTextChangedListenerOnce(textChangeListener)
|
||||
|
|
|
@ -20,23 +20,23 @@ import android.widget.Button
|
|||
import com.airbnb.epoxy.EpoxyAttribute
|
||||
import com.airbnb.epoxy.EpoxyModelClass
|
||||
import im.vector.app.R
|
||||
import im.vector.app.core.epoxy.ClickListener
|
||||
import im.vector.app.core.epoxy.VectorEpoxyHolder
|
||||
import im.vector.app.core.epoxy.VectorEpoxyModel
|
||||
import im.vector.app.core.epoxy.onClick
|
||||
import im.vector.app.core.extensions.setTextOrHide
|
||||
|
||||
@EpoxyModelClass(layout = R.layout.item_login_red_button)
|
||||
abstract class LoginRedButtonItem : VectorEpoxyModel<LoginRedButtonItem.Holder>() {
|
||||
|
||||
@EpoxyAttribute var text: String? = null
|
||||
@EpoxyAttribute var listener: (() -> Unit)? = null
|
||||
@EpoxyAttribute(EpoxyAttribute.Option.DoNotHash) var listener: ClickListener? = null
|
||||
|
||||
override fun bind(holder: Holder) {
|
||||
super.bind(holder)
|
||||
|
||||
holder.button.setTextOrHide(text)
|
||||
holder.button.setOnClickListener {
|
||||
listener?.invoke()
|
||||
}
|
||||
holder.button.onClick(listener)
|
||||
}
|
||||
|
||||
class Holder : VectorEpoxyHolder() {
|
||||
|
|
|
@ -79,24 +79,16 @@ class SpaceInviteBottomSheet : VectorBaseBottomSheetDialogFragment<BottomSheetIn
|
|||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
|
||||
views.spaceCard.matrixToCardMainButton.callback = object : ButtonStateView.Callback {
|
||||
override fun onButtonClicked() {
|
||||
// quick local echo
|
||||
views.spaceCard.matrixToCardMainButton.render(ButtonStateView.State.Loading)
|
||||
views.spaceCard.matrixToCardSecondaryButton.button.isEnabled = false
|
||||
viewModel.handle(SpaceInviteBottomSheetAction.DoJoin)
|
||||
}
|
||||
|
||||
override fun onRetryClicked() = onButtonClicked()
|
||||
views.spaceCard.matrixToCardMainButton.commonClicked = {
|
||||
// quick local echo
|
||||
views.spaceCard.matrixToCardMainButton.render(ButtonStateView.State.Loading)
|
||||
views.spaceCard.matrixToCardSecondaryButton.button.isEnabled = false
|
||||
viewModel.handle(SpaceInviteBottomSheetAction.DoJoin)
|
||||
}
|
||||
views.spaceCard.matrixToCardSecondaryButton.callback = object : ButtonStateView.Callback {
|
||||
override fun onButtonClicked() {
|
||||
views.spaceCard.matrixToCardMainButton.button.isEnabled = false
|
||||
views.spaceCard.matrixToCardSecondaryButton.render(ButtonStateView.State.Loading)
|
||||
viewModel.handle(SpaceInviteBottomSheetAction.DoReject)
|
||||
}
|
||||
|
||||
override fun onRetryClicked() = onButtonClicked()
|
||||
views.spaceCard.matrixToCardSecondaryButton.commonClicked = {
|
||||
views.spaceCard.matrixToCardMainButton.button.isEnabled = false
|
||||
views.spaceCard.matrixToCardSecondaryButton.render(ButtonStateView.State.Loading)
|
||||
viewModel.handle(SpaceInviteBottomSheetAction.DoReject)
|
||||
}
|
||||
|
||||
viewModel.observeViewEvents {
|
||||
|
@ -144,15 +136,15 @@ class SpaceInviteBottomSheet : VectorBaseBottomSheetDialogFragment<BottomSheetIn
|
|||
Uninitialized -> {
|
||||
views.spaceCard.matrixToCardMainButton.render(ButtonStateView.State.Button)
|
||||
}
|
||||
is Loading -> {
|
||||
is Loading -> {
|
||||
views.spaceCard.matrixToCardMainButton.render(ButtonStateView.State.Loading)
|
||||
views.spaceCard.matrixToCardSecondaryButton.button.isEnabled = false
|
||||
}
|
||||
is Success -> {
|
||||
is Success -> {
|
||||
interactionListener?.spaceInviteBottomSheetOnAccept(inviteArgs.spaceId)
|
||||
dismiss()
|
||||
}
|
||||
is Fail -> {
|
||||
is Fail -> {
|
||||
views.spaceCard.matrixToCardMainButton.render(ButtonStateView.State.Error)
|
||||
views.spaceCard.matrixToCardSecondaryButton.button.isEnabled = true
|
||||
}
|
||||
|
@ -162,15 +154,15 @@ class SpaceInviteBottomSheet : VectorBaseBottomSheetDialogFragment<BottomSheetIn
|
|||
Uninitialized -> {
|
||||
views.spaceCard.matrixToCardSecondaryButton.render(ButtonStateView.State.Button)
|
||||
}
|
||||
is Loading -> {
|
||||
is Loading -> {
|
||||
views.spaceCard.matrixToCardSecondaryButton.render(ButtonStateView.State.Loading)
|
||||
views.spaceCard.matrixToCardMainButton.button.isEnabled = false
|
||||
}
|
||||
is Success -> {
|
||||
is Success -> {
|
||||
interactionListener?.spaceInviteBottomSheetOnDecline(inviteArgs.spaceId)
|
||||
dismiss()
|
||||
}
|
||||
is Fail -> {
|
||||
is Fail -> {
|
||||
views.spaceCard.matrixToCardSecondaryButton.render(ButtonStateView.State.Error)
|
||||
views.spaceCard.matrixToCardSecondaryButton.button.isEnabled = true
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue