Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Event time, price and UI for tickets #2145

Merged
merged 1 commit into from
Jul 20, 2019
Merged
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 @@ -800,35 +800,18 @@ class AttendeeFragment : Fragment(), ComplexBackPressFragment {
}

private fun loadEventDetailsUI(event: Event) {
val dateString = StringBuilder()
val startsAt = EventUtils.getEventDateTime(event.startsAt, event.timezone)
val endsAt = EventUtils.getEventDateTime(event.endsAt, event.timezone)

attendeeViewModel.paymentCurrency = Currency.getInstance(event.paymentCurrency).symbol
ticketsRecyclerAdapter.setCurrency(attendeeViewModel.paymentCurrency)

rootView.eventName.text = event.name
val total = if (safeArgs.amount > 0) "${attendeeViewModel.paymentCurrency}${safeArgs.amount}"
val total = if (safeArgs.amount > 0) "${attendeeViewModel.paymentCurrency} ${"%.2f".format(safeArgs.amount)}"
else getString(R.string.free)
rootView.amount.text = "Total: $total"

val startDate = EventUtils.getFormattedDate(startsAt)
val endDate = EventUtils.getFormattedDate(endsAt)
dateString.append(startDate)
if (startDate == endDate) {
dateString.append(" • ")
.append(EventUtils.getFormattedTime(startsAt))
.append(" - ")
.append(EventUtils.getFormattedTime(endsAt))
} else {
dateString.append(" - ")
.append(EventUtils.getFormattedTime(startsAt))
.append(" • ")
.append(endDate)
.append(" - ")
.append(EventUtils.getFormattedTime(endsAt))
}
rootView.time.text = dateString
rootView.time.text = EventUtils.getFormattedDateTimeRangeDetailed(startsAt, endsAt)
}

private fun loadUserUI(user: User) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -307,20 +307,20 @@ class EventDetailsViewModel(
else {
range.append(paymentCurrency)
range.append(" ")
range.append(minPrice)
range.append("%.2f".format(minPrice))
}
} else {
if (minPrice == 0f)
range.append("Free")
else {
range.append(paymentCurrency)
range.append(" ")
range.append(minPrice)
range.append("%.2f".format(minPrice))
}
range.append(" - ")
range.append(paymentCurrency)
range.append(" ")
range.append(maxPrice)
range.append("%.2f".format(maxPrice))
}
mutablePriceRange.value = range.toString()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,16 @@ class TicketDetailsViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView
when (ticket.type) {
TICKET_TYPE_DONATION -> {
itemView.price.text = resource.getString(R.string.donation)
itemView.subTotal.text = "$eventCurrency$donationAmount"
itemView.subTotal.text = "$eventCurrency${"%2.f".format(donationAmount)}"
}
TICKET_TYPE_FREE -> {
itemView.price.text = resource.getString(R.string.free)
itemView.subTotal.text = "${eventCurrency}0.00"
}
TICKET_TYPE_PAID -> {
itemView.price.text = "$eventCurrency${ticket.price}"
itemView.price.text = "$eventCurrency${"%.2f".format(ticket.price)}"
val subTotal: Float? = ticket.price.times(ticketQuantity)
itemView.subTotal.text = "$eventCurrency$subTotal"
itemView.subTotal.text = "$eventCurrency${"%.2f".format(subTotal)}"
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ class TicketViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
itemView.donationInput.isVisible = false
}
TICKET_TYPE_PAID -> {
itemView.price.text = "$eventCurrency${ticket.price}"
itemView.price.text = "$eventCurrency${"%.2f".format(ticket.price)}"
itemView.priceSection.isVisible = true
itemView.donationInput.isVisible = false
}
Expand All @@ -107,12 +107,12 @@ class TicketViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
itemView.description.text = ticket.description
}

if (discountCode?.value != null && ticket.price != null && ticket.price != 0.toFloat()) {
if (discountCode?.value != null && ticket.price != 0.toFloat()) {
itemView.discountPrice.visibility = View.VISIBLE
itemView.price.paintFlags = Paint.STRIKE_THRU_TEXT_FLAG
itemView.discountPrice.text =
if (discountCode.type == AMOUNT) "$eventCurrency${ticket.price - discountCode.value}"
else "$eventCurrency${ticket.price - (ticket.price * discountCode.value / 100)}"
else "$eventCurrency${"%.2f".format(ticket.price - (ticket.price * discountCode.value / 100))}"
}
}

Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/layout/item_ticket.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
android:orientation="vertical">
<TextView
android:id="@+id/ticketName"
android:paddingEnd="@dimen/padding_medium"
android:layout_width="match_parent"
android:layout_height="wrap_content"
tools:text="Google I/O" />
Expand Down
4 changes: 3 additions & 1 deletion app/src/main/res/layout/item_ticket_details.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
<TextView
android:id="@+id/ticketName"
android:layout_width="@dimen/layout_margin_none"
android:paddingEnd="@dimen/padding_medium"
android:layout_height="wrap_content"
android:layout_weight="2"
tools:text="Google I/O" />
Expand All @@ -20,12 +21,13 @@
android:layout_width="@dimen/layout_margin_none"
android:layout_height="wrap_content"
android:layout_weight="1"
android:maxLines="1"
android:maxLines="2"
android:ellipsize="end"
tools:text="$25" />

<TextView
android:id="@+id/qty"
android:paddingStart="@dimen/padding_medium"
android:layout_width="@dimen/layout_margin_none"
android:layout_height="wrap_content"
android:layout_weight="1"
Expand Down