ux tweak on poll result

This commit is contained in:
Valere 2020-01-05 11:48:25 +01:00 committed by Benoit Marty
parent 3dae220501
commit 0cea26ec77
3 changed files with 56 additions and 46 deletions

View file

@ -17,6 +17,7 @@
package im.vector.riotx.features.home.room.detail.timeline.item
import android.view.View
import android.view.ViewGroup
import android.widget.Button
import android.widget.TextView
import androidx.core.view.isVisible
@ -70,6 +71,7 @@ abstract class MessagePollItem : AbsMessageItem<MessagePollItem.Holder>() {
if (!iHaveVoted) {
// Show buttons if i have not voted
holder.resultWrapper.isVisible = false
optionsContent?.options?.forEachIndexed { index, item ->
if (index < buttons.size) {
buttons[index].let {
@ -79,6 +81,7 @@ abstract class MessagePollItem : AbsMessageItem<MessagePollItem.Holder>() {
}
}
} else {
holder.resultWrapper.isVisible = true
val maxCount = votes?.maxBy { it.value }?.value ?: 0
optionsContent?.options?.forEachIndexed { index, item ->
if (index < resultLines.size) {
@ -131,6 +134,8 @@ abstract class MessagePollItem : AbsMessageItem<MessagePollItem.Holder>() {
val labelText by bind<TextView>(R.id.pollLabelText)
val infoText by bind<TextView>(R.id.pollInfosText)
val resultWrapper by bind<ViewGroup>(R.id.pollResultsWrapper)
override fun bindView(itemView: View) {
super.bindView(itemView)
val buttons = listOf(button1, button2, button3, button4, button5)

View file

@ -8,14 +8,14 @@
<ImageView
android:id="@+id/pollResultItemSelectedIcon"
android:layout_width="30dp"
android:layout_width="24dp"
android:layout_height="wrap_content"
android:paddingStart="2dp"
android:layout_gravity="center_vertical"
android:contentDescription="@string/poll_item_selected_aria"
android:paddingStart="2dp"
android:paddingEnd="2dp"
android:src="@drawable/ic_check_white_24dp"
android:tint="?riotx_text_secondary"
android:contentDescription="@string/poll_item_selected_aria" />
android:tint="?riotx_text_secondary" />
<TextView
android:id="@+id/pollResultItemLabel"

View file

@ -3,7 +3,6 @@
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical">
<TextView
@ -52,57 +51,63 @@
android:visibility="gone"
tools:text="Option 5" />
<im.vector.riotx.features.home.room.detail.timeline.item.PollResultLineView
android:id="@+id/pollResult1"
<LinearLayout
android:id="@+id/pollResultsWrapper"
android:layout_width="match_parent"
android:layout_height="40dp"
tools:optionName="Create Github issue"
tools:optionCount="40%"
tools:optionSelected="true"
/>
<im.vector.riotx.features.home.room.detail.timeline.item.PollResultLineView
android:id="@+id/pollResult2"
android:layout_width="match_parent"
android:layout_height="40dp"
tools:optionName="Search Github"
tools:optionCount="60%"
tools:optionSelected="false"
tools:optionIsWinner="true"
/>
android:layout_height="wrap_content"
android:background="@drawable/bg_attachment_type_selector"
android:orientation="vertical"
android:paddingStart="8dp"
android:paddingEnd="8dp">
<im.vector.riotx.features.home.room.detail.timeline.item.PollResultLineView
android:id="@+id/pollResult3"
android:layout_width="match_parent"
android:layout_height="40dp"
tools:optionName="Logout"
tools:optionCount="0%"
tools:optionSelected="false"
/>
<im.vector.riotx.features.home.room.detail.timeline.item.PollResultLineView
android:id="@+id/pollResult1"
android:layout_width="match_parent"
android:layout_height="40dp"
tools:optionCount="40%"
tools:optionName="Create Github issue"
tools:optionSelected="true" />
<im.vector.riotx.features.home.room.detail.timeline.item.PollResultLineView
android:id="@+id/pollResult4"
android:layout_width="match_parent"
android:layout_height="40dp"
tools:optionName="Option 4"
tools:optionCount="0%"
tools:optionSelected="false"
/>
<im.vector.riotx.features.home.room.detail.timeline.item.PollResultLineView
android:id="@+id/pollResult2"
android:layout_width="match_parent"
android:layout_height="40dp"
tools:optionCount="60%"
tools:optionIsWinner="true"
tools:optionName="Search Github"
tools:optionSelected="false" />
<im.vector.riotx.features.home.room.detail.timeline.item.PollResultLineView
android:id="@+id/pollResult5"
android:layout_width="match_parent"
android:layout_height="40dp"
tools:optionName="Option 5"
tools:optionCount="0%"
tools:optionSelected="false"
/>
<im.vector.riotx.features.home.room.detail.timeline.item.PollResultLineView
android:id="@+id/pollResult3"
android:layout_width="match_parent"
android:layout_height="40dp"
tools:optionCount="0%"
tools:optionName="Logout"
tools:optionSelected="false" />
<im.vector.riotx.features.home.room.detail.timeline.item.PollResultLineView
android:id="@+id/pollResult4"
android:layout_width="match_parent"
android:layout_height="40dp"
tools:optionCount="0%"
tools:optionName="Option 4"
tools:optionSelected="false" />
<im.vector.riotx.features.home.room.detail.timeline.item.PollResultLineView
android:id="@+id/pollResult5"
android:layout_width="match_parent"
android:layout_height="40dp"
tools:optionCount="0%"
tools:optionName="Option 5"
tools:optionSelected="false" />
</LinearLayout>
<TextView
android:id="@+id/pollInfosText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="?riotx_text_secondary"
android:gravity="start"
android:textColor="?riotx_text_secondary"
android:textSize="12sp"
tools:text="12 votes - Final Results" />