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

feat(EventResponse): 서버에서 주는 형식에 맞게 Response 형식 변경 및 매퍼 로직 변경, 행사 태그를… #907

Merged
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 @@ -28,7 +28,7 @@ data class EventResponse(
@SerialName("location")
val location: String,
@SerialName("tags")
val tags: List<String>,
val tags: List<EventTagResponse>,
@SerialName("thumbnailUrl")
val thumbnailUrl: String?,
@SerialName("type")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ fun EventResponse.toData(): Event = Event(
applyingStartDate = applyStartDate,
applyingEndDate = applyEndDate,
location = location,
tags = tags,
tags = tags.toData(),
posterImageUrl = thumbnailUrl?.let { BuildConfig.IMAGE_URL_PREFIX + it } ?: "",
type = type,
paymentType = paymentType.toPaymentType(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ data class Event(
val applyingStartDate: LocalDateTime = DEFAULT_LOCAL_DATE_TIME,
val applyingEndDate: LocalDateTime = DEFAULT_LOCAL_DATE_TIME,
val location: String = "",
val tags: List<String> = emptyList(),
val tags: List<EventTag> = emptyList(),
val posterImageUrl: String? = "",
val paymentType: PaymentType = DEFAULT_PAYMENT_TYPE,
val onOfflineMode: OnOfflineMode = DEFAULT_ON_OFFLINE_MODE,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
package com.emmsale.presentation.common.bindingadapter

import androidx.databinding.BindingAdapter
import com.emmsale.data.model.EventTag
import com.emmsale.presentation.common.views.EventTagChip
import com.google.android.material.chip.ChipGroup

@BindingAdapter("app:eventChips")
fun ChipGroup.setEventChips(tags: List<String>?) {
fun ChipGroup.setEventChips(tags: List<EventTag>?) {
removeAllViews()
addEventTags(tags ?: emptyList())
}

private fun ChipGroup.addEventTags(tags: List<String>) {
private fun ChipGroup.addEventTags(tags: List<EventTag>) {
tags.forEach { addView(createEventTag(it)) }
}

private fun ChipGroup.createEventTag(tag: String) = EventTagChip(this.context).apply {
text = tag
private fun ChipGroup.createEventTag(tag: EventTag) = EventTagChip(this.context).apply {
text = tag.name
}
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
package com.emmsale.presentation.ui.competitionList.recyclerView

import android.content.Context
import android.view.LayoutInflater
import android.view.ViewGroup
import androidx.recyclerview.widget.RecyclerView.ViewHolder
import com.emmsale.R
import com.emmsale.data.model.Event
import com.emmsale.databinding.ItemCompetitionBinding
import com.emmsale.presentation.common.views.EventTagChip
import com.emmsale.presentation.common.views.eventChipOf

class CompetitionViewHolder(
parent: ViewGroup,
Expand All @@ -24,18 +21,5 @@ class CompetitionViewHolder(

fun bind(event: Event) {
binding.event = event
binding.cgEventTags.removeAllViews()
event.tags.forEach(::addEventChip)
}

private fun addEventChip(tagName: String) {
binding.cgEventTags.addView(createEventChip(itemView.context, tagName))
}

private fun createEventChip(
context: Context,
tagName: String,
): EventTagChip = context.eventChipOf {
text = tagName
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@
android:layout_height="wrap_content"
android:layout_marginTop="24dp"
android:layout_marginBottom="10dp"
app:eventChips="@{event.tags}"
app:layout_constraintEnd_toEndOf="@+id/iv_event_poster"
app:layout_constraintStart_toStartOf="@+id/iv_event_poster"
app:layout_constraintTop_toBottomOf="@+id/tv_is_online" />
Expand Down
Loading