mirror of
https://github.com/SchildiChat/SchildiChat-android.git
synced 2024-11-26 11:26:01 +03:00
dynamically setting the terms item padding
This commit is contained in:
parent
06147967a4
commit
f45de34db4
6 changed files with 29 additions and 14 deletions
|
@ -24,6 +24,7 @@ class PolicyController @Inject constructor() : TypedEpoxyController<List<Localiz
|
||||||
|
|
||||||
var listener: PolicyControllerListener? = null
|
var listener: PolicyControllerListener? = null
|
||||||
|
|
||||||
|
var horizontalPadding: Int? = null
|
||||||
var homeServer: String? = null
|
var homeServer: String? = null
|
||||||
|
|
||||||
override fun buildModels(data: List<LocalizedFlowDataLoginTermsChecked>) {
|
override fun buildModels(data: List<LocalizedFlowDataLoginTermsChecked>) {
|
||||||
|
@ -32,6 +33,7 @@ class PolicyController @Inject constructor() : TypedEpoxyController<List<Localiz
|
||||||
policyItem {
|
policyItem {
|
||||||
id(entry.localizedFlowDataLoginTerms.policyName)
|
id(entry.localizedFlowDataLoginTerms.policyName)
|
||||||
checked(entry.checked)
|
checked(entry.checked)
|
||||||
|
horizontalPadding(host.horizontalPadding)
|
||||||
title(entry.localizedFlowDataLoginTerms.localizedName)
|
title(entry.localizedFlowDataLoginTerms.localizedName)
|
||||||
subtitle(host.homeServer)
|
subtitle(host.homeServer)
|
||||||
clickListener { host.listener?.openPolicy(entry.localizedFlowDataLoginTerms) }
|
clickListener { host.listener?.openPolicy(entry.localizedFlowDataLoginTerms) }
|
||||||
|
|
|
@ -38,6 +38,9 @@ abstract class PolicyItem : EpoxyModelWithHolder<PolicyItem.Holder>() {
|
||||||
@EpoxyAttribute
|
@EpoxyAttribute
|
||||||
var subtitle: String? = null
|
var subtitle: String? = null
|
||||||
|
|
||||||
|
@EpoxyAttribute
|
||||||
|
var horizontalPadding: Int? = null
|
||||||
|
|
||||||
@EpoxyAttribute(EpoxyAttribute.Option.DoNotHash)
|
@EpoxyAttribute(EpoxyAttribute.Option.DoNotHash)
|
||||||
var checkChangeListener: CompoundButton.OnCheckedChangeListener? = null
|
var checkChangeListener: CompoundButton.OnCheckedChangeListener? = null
|
||||||
|
|
||||||
|
@ -47,6 +50,12 @@ abstract class PolicyItem : EpoxyModelWithHolder<PolicyItem.Holder>() {
|
||||||
override fun bind(holder: Holder) {
|
override fun bind(holder: Holder) {
|
||||||
super.bind(holder)
|
super.bind(holder)
|
||||||
holder.let {
|
holder.let {
|
||||||
|
it.view.setPadding(
|
||||||
|
horizontalPadding ?: it.view.paddingLeft,
|
||||||
|
it.view.paddingTop,
|
||||||
|
horizontalPadding ?: it.view.paddingRight,
|
||||||
|
it.view.paddingBottom
|
||||||
|
)
|
||||||
it.checkbox.isChecked = checked
|
it.checkbox.isChecked = checked
|
||||||
it.checkbox.setOnCheckedChangeListener(checkChangeListener)
|
it.checkbox.setOnCheckedChangeListener(checkChangeListener)
|
||||||
it.title.text = title
|
it.title.text = title
|
||||||
|
|
|
@ -20,7 +20,10 @@ import android.os.Bundle
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
|
import androidx.constraintlayout.widget.ConstraintLayout
|
||||||
|
import androidx.core.view.doOnLayout
|
||||||
import com.airbnb.mvrx.args
|
import com.airbnb.mvrx.args
|
||||||
|
import im.vector.app.R
|
||||||
import im.vector.app.core.extensions.cleanup
|
import im.vector.app.core.extensions.cleanup
|
||||||
import im.vector.app.core.extensions.configureWith
|
import im.vector.app.core.extensions.configureWith
|
||||||
import im.vector.app.core.extensions.toReducedUrl
|
import im.vector.app.core.extensions.toReducedUrl
|
||||||
|
@ -35,6 +38,7 @@ import im.vector.app.features.onboarding.RegisterAction
|
||||||
import im.vector.app.features.onboarding.ftueauth.AbstractFtueAuthFragment
|
import im.vector.app.features.onboarding.ftueauth.AbstractFtueAuthFragment
|
||||||
import org.matrix.android.sdk.internal.auth.registration.LocalizedFlowDataLoginTerms
|
import org.matrix.android.sdk.internal.auth.registration.LocalizedFlowDataLoginTerms
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
import kotlin.math.roundToInt
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* LoginTermsFragment displays the list of policies the user has to accept
|
* LoginTermsFragment displays the list of policies the user has to accept
|
||||||
|
@ -54,24 +58,24 @@ class FtueAuthTermsFragment @Inject constructor(
|
||||||
|
|
||||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||||
super.onViewCreated(view, savedInstanceState)
|
super.onViewCreated(view, savedInstanceState)
|
||||||
|
|
||||||
setupViews()
|
setupViews()
|
||||||
views.loginTermsPolicyList.configureWith(policyController, hasFixedSize = false)
|
|
||||||
policyController.listener = this
|
|
||||||
|
|
||||||
val list = ArrayList<LocalizedFlowDataLoginTermsChecked>()
|
val list = ArrayList<LocalizedFlowDataLoginTermsChecked>()
|
||||||
|
|
||||||
params.localizedFlowDataLoginTerms
|
params.localizedFlowDataLoginTerms
|
||||||
.forEach {
|
.forEach {
|
||||||
list.add(LocalizedFlowDataLoginTermsChecked(it))
|
list.add(LocalizedFlowDataLoginTermsChecked(it))
|
||||||
}
|
}
|
||||||
|
|
||||||
loginTermsViewState = LoginTermsViewState(list)
|
loginTermsViewState = LoginTermsViewState(list)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setupViews() {
|
private fun setupViews() {
|
||||||
views.displayNameSubmit.setOnClickListener { submit() }
|
views.displayNameSubmit.setOnClickListener { submit() }
|
||||||
views.loginTermsPolicyList.setHasFixedSize(false)
|
views.loginTermsPolicyList.setHasFixedSize(false)
|
||||||
|
views.loginTermsPolicyList.configureWith(policyController, hasFixedSize = false, dividerDrawable = R.drawable.divider_horizontal)
|
||||||
|
views.displayNameGutterStart.doOnLayout {
|
||||||
|
val gutterSize = views.contentRoot.width * (views.displayNameGutterStart.layoutParams as ConstraintLayout.LayoutParams).guidePercent
|
||||||
|
policyController.horizontalPadding = gutterSize.roundToInt()
|
||||||
|
}
|
||||||
|
policyController.listener = this
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onDestroyView() {
|
override fun onDestroyView() {
|
||||||
|
|
|
@ -48,6 +48,8 @@
|
||||||
android:layout_height="0dp"
|
android:layout_height="0dp"
|
||||||
android:layout_marginTop="10dp"
|
android:layout_marginTop="10dp"
|
||||||
android:layout_marginBottom="16dp"
|
android:layout_marginBottom="16dp"
|
||||||
|
android:paddingStart="16dp"
|
||||||
|
android:paddingEnd="16dp"
|
||||||
app:layout_constraintBottom_toTopOf="@id/loginTermsSubmit"
|
app:layout_constraintBottom_toTopOf="@id/loginTermsSubmit"
|
||||||
app:layout_constraintTop_toBottomOf="@id/loginTermsNotice"
|
app:layout_constraintTop_toBottomOf="@id/loginTermsNotice"
|
||||||
tools:listitem="@layout/item_policy" />
|
tools:listitem="@layout/item_policy" />
|
||||||
|
|
|
@ -52,6 +52,8 @@
|
||||||
android:layout_height="0dp"
|
android:layout_height="0dp"
|
||||||
android:layout_marginTop="10dp"
|
android:layout_marginTop="10dp"
|
||||||
android:layout_marginBottom="16dp"
|
android:layout_marginBottom="16dp"
|
||||||
|
android:paddingStart="16dp"
|
||||||
|
android:paddingEnd="16dp"
|
||||||
app:layout_constraintBottom_toTopOf="@id/loginTermsSubmit"
|
app:layout_constraintBottom_toTopOf="@id/loginTermsSubmit"
|
||||||
app:layout_constraintTop_toBottomOf="@id/loginTermsNotice"
|
app:layout_constraintTop_toBottomOf="@id/loginTermsNotice"
|
||||||
tools:listitem="@layout/item_policy" />
|
tools:listitem="@layout/item_policy" />
|
||||||
|
|
|
@ -6,8 +6,6 @@
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:foreground="?attr/selectableItemBackground"
|
android:foreground="?attr/selectableItemBackground"
|
||||||
android:minHeight="72dp"
|
android:minHeight="72dp"
|
||||||
android:paddingStart="16dp"
|
|
||||||
android:paddingEnd="16dp"
|
|
||||||
tools:viewBindingIgnore="true">
|
tools:viewBindingIgnore="true">
|
||||||
|
|
||||||
<CheckBox
|
<CheckBox
|
||||||
|
@ -20,10 +18,9 @@
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/adapter_item_policy_title"
|
android:id="@+id/adapter_item_policy_title"
|
||||||
style="@style/Widget.Vector.TextView.Body"
|
style="@style/Widget.Vector.TextView.Subtitle"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:drawablePadding="8dp"
|
|
||||||
android:textColor="?vctr_content_primary"
|
android:textColor="?vctr_content_primary"
|
||||||
app:layout_constraintBottom_toTopOf="@id/adapter_item_policy_subtitle"
|
app:layout_constraintBottom_toTopOf="@id/adapter_item_policy_subtitle"
|
||||||
app:layout_constraintEnd_toStartOf="@id/adapter_item_policy_arrow"
|
app:layout_constraintEnd_toStartOf="@id/adapter_item_policy_arrow"
|
||||||
|
@ -50,16 +47,15 @@
|
||||||
<ImageView
|
<ImageView
|
||||||
android:id="@+id/adapter_item_policy_arrow"
|
android:id="@+id/adapter_item_policy_arrow"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="22dp"
|
||||||
android:importantForAccessibility="no"
|
android:importantForAccessibility="no"
|
||||||
android:paddingStart="8dp"
|
android:adjustViewBounds="true"
|
||||||
android:paddingEnd="0dp"
|
|
||||||
android:rotationY="@integer/rtl_mirror_flip"
|
android:rotationY="@integer/rtl_mirror_flip"
|
||||||
android:src="@drawable/ic_arrow_right"
|
android:src="@drawable/ic_arrow_right"
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
app:layout_constraintTop_toTopOf="parent"
|
app:layout_constraintTop_toTopOf="parent"
|
||||||
app:tint="?vctr_content_secondary"
|
app:tint="?vctr_content_tertiary"
|
||||||
tools:ignore="MissingPrefix" />
|
tools:ignore="MissingPrefix" />
|
||||||
|
|
||||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
Loading…
Reference in a new issue