-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #185 from TeamPINGLE/refactor-map-card
[refactor] 핑글 카드 커스텀 뷰 분리 및 지도 ViewPager Item 재구현
- Loading branch information
Showing
13 changed files
with
501 additions
and
452 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
116 changes: 0 additions & 116 deletions
116
app/src/main/java/org/sopt/pingle/util/component/PingleCard.kt
This file was deleted.
Oops, something went wrong.
77 changes: 77 additions & 0 deletions
77
app/src/main/java/org/sopt/pingle/util/component/PingleCardBottom.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
package org.sopt.pingle.util.component | ||
|
||
import android.annotation.SuppressLint | ||
import android.content.Context | ||
import android.util.AttributeSet | ||
import android.view.LayoutInflater | ||
import androidx.constraintlayout.widget.ConstraintLayout | ||
import org.sopt.pingle.R | ||
import org.sopt.pingle.databinding.BottomCardPingleBinding | ||
import org.sopt.pingle.domain.model.PingleEntity | ||
import org.sopt.pingle.presentation.mapper.isCompleted | ||
import org.sopt.pingle.util.convertToCalenderDetailWithNewLine | ||
import org.sopt.pingle.util.view.stringOf | ||
|
||
@SuppressLint("CustomViewStyleable") | ||
class PingleCardBottom @JvmOverloads constructor( | ||
context: Context, | ||
attrs: AttributeSet? = null, | ||
defStyleAttr: Int = 0 | ||
) : ConstraintLayout(context, attrs, defStyleAttr) { | ||
private val binding: BottomCardPingleBinding | ||
private var onChatButtonClick: () -> Unit = {} | ||
private var onParticipateButtonClick: (Long?) -> Unit = {} | ||
private var _pinId: Long? = null | ||
val pinId get() = _pinId | ||
|
||
init { | ||
binding = BottomCardPingleBinding.inflate(LayoutInflater.from(context), this, true) | ||
|
||
addListeners() | ||
} | ||
|
||
private fun addListeners() { | ||
binding.btnCardBottomMapChat.setOnClickListener { | ||
onChatButtonClick() | ||
} | ||
|
||
binding.btnCardBottomMapParticipate.setOnClickListener { | ||
onParticipateButtonClick(pinId) | ||
} | ||
} | ||
|
||
fun initLayout(pingleEntity: PingleEntity) { | ||
with(binding) { | ||
tvCardBottomCalenderDetail.text = convertToCalenderDetailWithNewLine( | ||
date = pingleEntity.date, | ||
startAt = pingleEntity.startAt, | ||
endAt = pingleEntity.endAt | ||
) | ||
tvCardBottomMapDetail.text = pingleEntity.location | ||
btnCardBottomMapChat.isEnabled = pingleEntity.isParticipating | ||
btnCardBottomMapParticipate.isEnabled = when { | ||
pingleEntity.isOwner -> true | ||
else -> pingleEntity.isParticipating || !pingleEntity.isCompleted() | ||
} | ||
|
||
btnCardBottomMapParticipate.text = | ||
when { | ||
pingleEntity.isOwner -> stringOf(R.string.pingle_card_delete) | ||
pingleEntity.isParticipating -> stringOf(R.string.pingle_card_cancel) | ||
else -> stringOf(R.string.pingle_card_participate) | ||
} | ||
} | ||
} | ||
|
||
fun setPinId(pinId: Long) { | ||
_pinId = pinId | ||
} | ||
|
||
fun setOnChatButtonClick(chatButtonClickListener: () -> Unit) { | ||
onChatButtonClick = chatButtonClickListener | ||
} | ||
|
||
fun setOnParticipateButtonClick(participateButtonClickListener: (Long?) -> Unit) { | ||
onParticipateButtonClick = participateButtonClickListener | ||
} | ||
} |
65 changes: 65 additions & 0 deletions
65
app/src/main/java/org/sopt/pingle/util/component/PingleCardTop.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
package org.sopt.pingle.util.component | ||
|
||
import android.annotation.SuppressLint | ||
import android.content.Context | ||
import android.util.AttributeSet | ||
import android.view.LayoutInflater | ||
import android.view.View | ||
import androidx.constraintlayout.widget.ConstraintLayout | ||
import org.sopt.pingle.databinding.TopCardPingleBinding | ||
import org.sopt.pingle.domain.model.PingleEntity | ||
import org.sopt.pingle.presentation.mapper.isCompleted | ||
import org.sopt.pingle.presentation.type.CategoryType | ||
import org.sopt.pingle.util.view.colorOf | ||
|
||
@SuppressLint("CustomViewStyleable") | ||
class PingleCardTop @JvmOverloads constructor( | ||
context: Context, | ||
attrs: AttributeSet? = null, | ||
defStyleAttr: Int = 0 | ||
) : ConstraintLayout(context, attrs, defStyleAttr) { | ||
private val binding: TopCardPingleBinding | ||
private var onParticipationStatusLayoutClick: (Long) -> Unit = {} | ||
|
||
init { | ||
binding = TopCardPingleBinding.inflate(LayoutInflater.from(context), this, true) | ||
} | ||
|
||
fun initLayout(pingleEntity: PingleEntity) { | ||
with(binding) { | ||
(CategoryType.fromString(pingleEntity.category)).let { category -> | ||
badgeCardTopInfo.setBadgeCategoryType(category) | ||
tvCardTopInfoParticipationStatusCurrentParticipants.setTextColor(colorOf(category.textColor)) | ||
tvCardTopInfoName.setTextColor(colorOf(category.textColor)) | ||
} | ||
tvCardTopInfoName.text = pingleEntity.name | ||
tvCardTopInfoOwnerName.text = pingleEntity.ownerName | ||
|
||
(pingleEntity.isCompleted()).let { isCompleted -> | ||
tvCardTopInfoParticipationStatusSlash.visibility = | ||
if (isCompleted) View.INVISIBLE else View.VISIBLE | ||
tvCardTopInfoParticipationStatusCurrentParticipants.visibility = | ||
if (isCompleted) View.INVISIBLE else View.VISIBLE | ||
tvCardTopInfoParticipationStatusMaxParticipants.visibility = | ||
if (isCompleted) View.INVISIBLE else View.VISIBLE | ||
tvCardTopInfoParticipationCompleted.visibility = | ||
if (isCompleted) View.VISIBLE else View.INVISIBLE | ||
|
||
if (!isCompleted) { | ||
tvCardTopInfoParticipationStatusCurrentParticipants.text = | ||
pingleEntity.curParticipants.toString() | ||
tvCardTopInfoParticipationStatusMaxParticipants.text = | ||
pingleEntity.maxParticipants.toString() | ||
} | ||
} | ||
|
||
layoutCardTopParticipationStatus.setOnClickListener { | ||
onParticipationStatusLayoutClick(pingleEntity.id) | ||
} | ||
} | ||
} | ||
|
||
fun setOnParticipationStatusLayoutClick(participationStatusLayoutClickListener: (Long) -> Unit) { | ||
onParticipationStatusLayoutClick = participationStatusLayoutClickListener | ||
} | ||
} |
Oops, something went wrong.