Skip to content

Commit

Permalink
attendee member info
Browse files Browse the repository at this point in the history
  • Loading branch information
jan-stanek committed Nov 12, 2023
1 parent 91ef550 commit 02e2376
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,27 @@ import kotlinx.serialization.Serializable

@Serializable
data class TicketCheckInfo(
/** Jméno účastníka. */
@SerialName("attendee_name") val attendeeName: String,

/** Věk účastníka. */
@SerialName("attendee_age") val attendeeAge: Int,

/** Odkaz na fotku účastníka. */
@SerialName("attendee_photo") val attendeePhoto: String? = null,

/** Má účastník propojený účet? */
@SerialName("attendee_member") val attendeeMember: Boolean,

/** Role účastníka. */
val roles: Array<String>,

/** Podakce účastníka. */
val subevents: Array<SubeventInfo>,

/** Má účastník podakci? */
@SerialName("has_subevent") val hasSubevent: Boolean,

/** Seznam časů kontroly vstupenky. */
@SerialName("subevent_checks") val subeventChecks: Array<Instant>,
)
Original file line number Diff line number Diff line change
Expand Up @@ -70,21 +70,32 @@ class TicketQrProcessor(context: FragmentActivity) : QrProcessor(context) {
val tvSubevents: TextView = dialogView.findViewById(R.id.dialog_ticket_tv_subevents_text)
val tvChecks: TextView = dialogView.findViewById(R.id.dialog_ticket_tv_checks_text)

val messages: MutableList<String> = mutableListOf()

if (!ticketInfo.hasSubevent) {
tvStatus.text = context.getString(R.string.dialog_ticket_status_invalid)
tvStatus.setTextColor(Color.RED)
tvMessage.text = context.getString(R.string.dialog_ticket_message_missing_subevent)
} else if (ticketInfo.subeventChecks.isNotEmpty()) {
tvStatus.text = context.getString(R.string.dialog_ticket_status_used)
tvStatus.setTextColor(COLOR_ORANGE.toInt())
tvMessage.text = context.getString(R.string.dialog_ticket_message_used)
messages.add(context.getString(R.string.dialog_ticket_message_missing_subevent))
} else {
tvStatus.text = context.getString(R.string.dialog_ticket_status_valid)
tvStatus.setTextColor(Color.GREEN)
tvMessage.text = null
if (ticketInfo.subeventChecks.isNotEmpty()) {
tvStatus.text = context.getString(R.string.dialog_ticket_status_used)
tvStatus.setTextColor(COLOR_ORANGE.toInt())
messages.add(context.getString(R.string.dialog_ticket_message_used))
} else {
tvStatus.text = context.getString(R.string.dialog_ticket_status_valid)
tvStatus.setTextColor(Color.GREEN)
}

if (!ticketInfo.attendeeMember) {
messages.add(context.getString(R.string.dialog_ticket_message_not_member))
}
if (ticketInfo.attendeeAge < 18) {
messages.add(context.getString(R.string.dialog_ticket_message_not_adult))
}
}

tvMessage.visibility = if (tvMessage.text == null) TextView.GONE else TextView.VISIBLE
tvMessage.text = messages.joinToString("\n")
tvMessage.visibility = if (messages.isEmpty()) TextView.GONE else TextView.VISIBLE

tvName.text = ticketInfo.attendeeName
tvAge.text = ticketInfo.attendeeAge.toString()
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
<string name="dialog_ticket_status_invalid">Neplatná</string>
<string name="dialog_ticket_message_used">Vstupenka již byla dříve načtena.</string>
<string name="dialog_ticket_message_missing_subevent">Účastník nemá kontrolovanou podakci.</string>
<string name="dialog_ticket_message_not_member">Účastník nemá propojený účet.</string>
<string name="dialog_ticket_message_not_adult">Účastník je mladší 18 let.</string>

<string name="dialog_error_title">Chyba</string>
<string name="dialog_error_message_invalid_ticket_qr">Neplatný QR kód vstupenky.</string>
Expand Down

0 comments on commit 02e2376

Please sign in to comment.