Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@
android:visibility="gone"
app:inputHint="Number of elements"
app:inputText="4"
app:inputType="number"
tools:visibility="visible" />

<LinearLayout
Expand Down
15 changes: 2 additions & 13 deletions library/src/main/java/com/telefonica/mistica/sheet/Sheet.kt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.LinearLayout
import android.widget.Space
import android.widget.TextView
import androidx.coordinatorlayout.widget.CoordinatorLayout
import androidx.core.view.ViewCompat
Expand Down Expand Up @@ -89,20 +88,18 @@ open class SheetView(
root: View,
sheetModel: SheetModel,
) {
val handler = root.findViewById<View>(R.id.handler)
val closeButton = root.findViewById<View>(R.id.close_button)
val title = root.findViewById<TextView>(R.id.title)
val subtitle = root.findViewById<TextView>(R.id.subtitle)
val description = root.findViewById<TextView>(R.id.description)
val titleSpace = root.findViewById<Space>(R.id.title_space)

val titleText = sheetModel.header.title
val subtitleText = sheetModel.header.subtitle
val descriptionText = sheetModel.header.description

handler.setOnClickListener { cancel() }
closeButton.setOnClickListener { cancel() }
title.setTextOrHide(titleText)
ViewCompat.setAccessibilityHeading(title, true)
titleSpace.setSpaceOrGone(titleText)
subtitle.setTextOrHide(subtitleText)
description.setTextOrHide(descriptionText)
}
Expand Down Expand Up @@ -295,11 +292,3 @@ private fun TextView.setTextOrHide(text: String?) {
this.text = text
}
}

private fun Space.setSpaceOrGone(text: String?) {
if (text.isNullOrEmpty()) {
this.visibility = View.VISIBLE
} else {
this.visibility = View.GONE
}
}
73 changes: 42 additions & 31 deletions library/src/main/res/layout/sheet_layout.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,36 +13,51 @@
android:id="@+id/handler"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:importantForAccessibility="no"
android:padding="8dp"
android:contentDescription="@string/close_button_content_description"
android:clickable="true"
android:focusable="true"
android:layout_gravity="center"
app:srcCompat="@drawable/sheet_handler"
/>

<TextView
android:id="@+id/title"
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingStart="16dp"
android:paddingTop="12dp"
android:paddingBottom="8dp"
tools:ignore="RtlSymmetry"
tools:text="Title"
android:textAppearance="@style/AppTheme.TextAppearance.Preset5"
/>
>

<Space
android:id="@+id/title_space"
android:layout_width="match_parent"
android:layout_height="24dp"
android:visibility="gone"
/>
<TextView
android:id="@+id/title"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:paddingStart="16dp"
android:paddingTop="12dp"
android:paddingBottom="8dp"
tools:ignore="RtlSymmetry"
tools:text="Title"
android:textAppearance="@style/AppTheme.TextAppearance.Preset5"
app:layout_constraintEnd_toStartOf="@+id/close_button"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
/>

<ImageButton
android:id="@+id/close_button"
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have an important question. Previously, the A11Y navigated as follows:

  • Handler: As a button to close the sheet
  • Title

Now, according to the spec, it's the opposite. I understand that this is expected, although personally, as a user, I find it strange that the order has been changed. And I don't know if this might give the user the impression that there's no more information and by that the user could close the Sheet.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know how the user usually navigates but I think that if you are not able to see and read the full screen, you will navigate through the screen before taking an action.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, that's the dilemma I had. I'd wait until design double check that is intended/expected.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point! The WCAG guidelines don't strictly define an ideal focus order, but rather recommend that it be logical and coherent with the content being presented, leaving some flexibility in how it's implemented.

Imho, the key point here is to ensure that this focus order is intentional and considered the best option for this scenario. @aawell, just to confirm this matches the intended a11y behavior.

Focus order is something that may be reviewed by the OB (like Vivo) or during accessibility audits, so having a clear and defensible rationale for this choice is important.

android:layout_width="48dp"
android:layout_height="48dp"
android:layout_marginEnd="8dp"
android:background="@android:color/transparent"
android:contentDescription="@string/close_button_content_description"
android:src="@drawable/icn_cross"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
/>

</androidx.constraintlayout.widget.ConstraintLayout>

<androidx.core.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">
android:layout_height="match_parent"
>

<LinearLayout
android:id="@+id/container_outer"
android:layout_width="match_parent"
Expand All @@ -55,7 +70,8 @@
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@+id/title">
app:layout_constraintTop_toBottomOf="@+id/title"
>


<TextView
Expand All @@ -79,20 +95,15 @@
android:textAppearance="@style/AppTheme.TextAppearance.Preset2"
android:textColor="?colorTextSecondary"
/>
<androidx.core.widget.NestedScrollView
android:paddingTop="8dp"

<LinearLayout
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fillViewport="true"
android:orientation="vertical"
android:paddingTop="8dp"
android:paddingBottom="16dp"
>
<LinearLayout
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"/>

</androidx.core.widget.NestedScrollView>
/>

</LinearLayout>
</androidx.core.widget.NestedScrollView>
Expand Down
Loading