Renaming field to votesStatus
This commit is contained in:
parent
55bb6fa21a
commit
26aaf84806
|
@ -244,7 +244,7 @@ class MessageItemFactory @Inject constructor(
|
|||
.eventId(informationData.eventId)
|
||||
.pollQuestion(createPollQuestion(informationData, pollViewState.question, callback))
|
||||
.canVote(pollViewState.canVote)
|
||||
.totalVotesText(pollViewState.totalVotes)
|
||||
.votesStatus(pollViewState.votesStatus)
|
||||
.optionViewStates(pollViewState.optionViewStates)
|
||||
.edited(informationData.hasBeenEdited)
|
||||
.highlighted(highlight)
|
||||
|
|
|
@ -65,7 +65,7 @@ class PollItemViewStateFactory @Inject constructor(
|
|||
private fun createSendingPollViewState(question: String, pollCreationInfo: PollCreationInfo?): PollViewState {
|
||||
return PollViewState(
|
||||
question = question,
|
||||
totalVotes = stringProvider.getString(R.string.poll_no_votes_cast),
|
||||
votesStatus = stringProvider.getString(R.string.poll_no_votes_cast),
|
||||
canVote = false,
|
||||
optionViewStates = pollCreationInfo?.answers?.map { answer ->
|
||||
PollOptionViewState.PollSending(
|
||||
|
@ -85,7 +85,7 @@ class PollItemViewStateFactory @Inject constructor(
|
|||
): PollViewState {
|
||||
return PollViewState(
|
||||
question = question,
|
||||
totalVotes = stringProvider.getQuantityString(R.plurals.poll_total_vote_count_after_ended, totalVotes, totalVotes),
|
||||
votesStatus = stringProvider.getQuantityString(R.plurals.poll_total_vote_count_after_ended, totalVotes, totalVotes),
|
||||
canVote = false,
|
||||
optionViewStates = pollCreationInfo?.answers?.map { answer ->
|
||||
val voteSummary = pollResponseSummary?.getVoteSummaryOfAnOption(answer.id ?: "")
|
||||
|
@ -107,7 +107,7 @@ class PollItemViewStateFactory @Inject constructor(
|
|||
): PollViewState {
|
||||
return PollViewState(
|
||||
question = question,
|
||||
totalVotes = stringProvider.getString(R.string.poll_undisclosed_not_ended),
|
||||
votesStatus = stringProvider.getString(R.string.poll_undisclosed_not_ended),
|
||||
canVote = true,
|
||||
optionViewStates = pollCreationInfo?.answers?.map { answer ->
|
||||
val isMyVote = pollResponseSummary?.myVote == answer.id
|
||||
|
@ -128,7 +128,7 @@ class PollItemViewStateFactory @Inject constructor(
|
|||
): PollViewState {
|
||||
return PollViewState(
|
||||
question = question,
|
||||
totalVotes = stringProvider.getQuantityString(R.plurals.poll_total_vote_count_before_ended_and_voted, totalVotes, totalVotes),
|
||||
votesStatus = stringProvider.getQuantityString(R.plurals.poll_total_vote_count_before_ended_and_voted, totalVotes, totalVotes),
|
||||
canVote = true,
|
||||
optionViewStates = pollCreationInfo?.answers?.map { answer ->
|
||||
val isMyVote = pollResponseSummary?.myVote == answer.id
|
||||
|
@ -152,7 +152,7 @@ class PollItemViewStateFactory @Inject constructor(
|
|||
}
|
||||
return PollViewState(
|
||||
question = question,
|
||||
totalVotes = totalVotesText,
|
||||
votesStatus = totalVotesText,
|
||||
canVote = true,
|
||||
optionViewStates = pollCreationInfo?.answers?.map { answer ->
|
||||
PollOptionViewState.PollReady(
|
||||
|
|
|
@ -42,7 +42,7 @@ abstract class PollItem : AbsMessageItem<PollItem.Holder>() {
|
|||
var canVote: Boolean = false
|
||||
|
||||
@EpoxyAttribute
|
||||
var totalVotesText: String? = null
|
||||
var votesStatus: String? = null
|
||||
|
||||
@EpoxyAttribute
|
||||
var edited: Boolean = false
|
||||
|
@ -58,7 +58,7 @@ abstract class PollItem : AbsMessageItem<PollItem.Holder>() {
|
|||
renderSendState(holder.view, holder.questionTextView)
|
||||
|
||||
holder.questionTextView.text = pollQuestion?.charSequence
|
||||
holder.totalVotesTextView.text = totalVotesText
|
||||
holder.votesStatusTextView.text = votesStatus
|
||||
|
||||
while (holder.optionsContainer.childCount < optionViewStates.size) {
|
||||
holder.optionsContainer.addView(PollOptionView(holder.view.context))
|
||||
|
@ -88,7 +88,7 @@ abstract class PollItem : AbsMessageItem<PollItem.Holder>() {
|
|||
class Holder : AbsMessageItem.Holder(STUB_ID) {
|
||||
val questionTextView by bind<TextView>(R.id.questionTextView)
|
||||
val optionsContainer by bind<LinearLayout>(R.id.optionsContainer)
|
||||
val totalVotesTextView by bind<TextView>(R.id.optionsTotalVotesTextView)
|
||||
val votesStatusTextView by bind<TextView>(R.id.optionsVotesStatusTextView)
|
||||
}
|
||||
|
||||
companion object {
|
||||
|
|
|
@ -19,8 +19,8 @@ package im.vector.app.features.poll
|
|||
import im.vector.app.features.home.room.detail.timeline.item.PollOptionViewState
|
||||
|
||||
data class PollViewState(
|
||||
val question: String,
|
||||
val totalVotes: String,
|
||||
val canVote: Boolean,
|
||||
val optionViewStates: List<PollOptionViewState>?,
|
||||
val question: String,
|
||||
val votesStatus: String,
|
||||
val canVote: Boolean,
|
||||
val optionViewStates: List<PollOptionViewState>?,
|
||||
)
|
||||
|
|
|
@ -33,7 +33,7 @@
|
|||
app:layout_constraintTop_toBottomOf="@id/questionTextView" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/optionsTotalVotesTextView"
|
||||
android:id="@+id/optionsVotesStatusTextView"
|
||||
style="@style/Widget.Vector.TextView.Caption"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
|
@ -42,4 +42,4 @@
|
|||
app:layout_constraintTop_toBottomOf="@id/optionsContainer"
|
||||
tools:text="@sample/poll.json/totalVotes" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
|
|
@ -91,7 +91,7 @@ class PollItemViewStateFactoryTest {
|
|||
|
||||
pollViewState shouldBeEqualTo PollViewState(
|
||||
question = A_POLL_CONTENT.getBestPollCreationInfo()?.question?.getBestQuestion() ?: "",
|
||||
totalVotes = stringProvider.instance.getString(R.string.poll_no_votes_cast),
|
||||
votesStatus = stringProvider.instance.getString(R.string.poll_no_votes_cast),
|
||||
canVote = false,
|
||||
optionViewStates = A_POLL_CONTENT.getBestPollCreationInfo()?.answers?.map { answer ->
|
||||
PollOptionViewState.PollSending(
|
||||
|
@ -117,7 +117,7 @@ class PollItemViewStateFactoryTest {
|
|||
|
||||
pollViewState shouldBeEqualTo PollViewState(
|
||||
question = A_POLL_CONTENT.getBestPollCreationInfo()?.question?.getBestQuestion() ?: "",
|
||||
totalVotes = stringProvider.instance.getQuantityString(R.plurals.poll_total_vote_count_after_ended, 0, 0),
|
||||
votesStatus = stringProvider.instance.getQuantityString(R.plurals.poll_total_vote_count_after_ended, 0, 0),
|
||||
canVote = false,
|
||||
optionViewStates = A_POLL_CONTENT.getBestPollCreationInfo()?.answers?.map { answer ->
|
||||
PollOptionViewState.PollEnded(
|
||||
|
@ -143,7 +143,7 @@ class PollItemViewStateFactoryTest {
|
|||
|
||||
pollViewState shouldBeEqualTo PollViewState(
|
||||
question = A_POLL_CONTENT.getBestPollCreationInfo()?.question?.getBestQuestion() ?: "",
|
||||
totalVotes = stringProvider.instance.getString(R.string.poll_undisclosed_not_ended),
|
||||
votesStatus = stringProvider.instance.getString(R.string.poll_undisclosed_not_ended),
|
||||
canVote = true,
|
||||
optionViewStates = A_POLL_CONTENT.getBestPollCreationInfo()?.answers?.map { answer ->
|
||||
PollOptionViewState.PollUndisclosed(
|
||||
|
@ -179,7 +179,7 @@ class PollItemViewStateFactoryTest {
|
|||
|
||||
pollViewState shouldBeEqualTo PollViewState(
|
||||
question = A_POLL_CONTENT.getBestPollCreationInfo()?.question?.getBestQuestion() ?: "",
|
||||
totalVotes = stringProvider.instance.getQuantityString(R.plurals.poll_total_vote_count_before_ended_and_voted, 1, 1),
|
||||
votesStatus = stringProvider.instance.getQuantityString(R.plurals.poll_total_vote_count_before_ended_and_voted, 1, 1),
|
||||
canVote = true,
|
||||
optionViewStates = A_POLL_CONTENT.getBestPollCreationInfo()?.answers?.mapIndexed { index, answer ->
|
||||
PollOptionViewState.PollVoted(
|
||||
|
@ -210,7 +210,7 @@ class PollItemViewStateFactoryTest {
|
|||
|
||||
pollViewState shouldBeEqualTo PollViewState(
|
||||
question = A_POLL_CONTENT.getBestPollCreationInfo()?.question?.getBestQuestion() ?: "",
|
||||
totalVotes = stringProvider.instance.getString(R.string.poll_no_votes_cast),
|
||||
votesStatus = stringProvider.instance.getString(R.string.poll_no_votes_cast),
|
||||
canVote = true,
|
||||
optionViewStates = A_POLL_CONTENT.getBestPollCreationInfo()?.answers?.map { answer ->
|
||||
PollOptionViewState.PollReady(
|
||||
|
|
Loading…
Reference in New Issue