-
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 #196 from TeamPINGLE/feat-list-view
[feat] 리스트뷰 구현
- Loading branch information
Showing
28 changed files
with
793 additions
and
198 deletions.
There are no files selected for viewing
11 changes: 11 additions & 0 deletions
11
app/src/main/java/org/sopt/pingle/presentation/type/MainListOrderType.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,11 @@ | ||
package org.sopt.pingle.presentation.type | ||
|
||
import androidx.annotation.StringRes | ||
import org.sopt.pingle.R | ||
|
||
enum class MainListOrderType( | ||
@StringRes val mainListOrderStringRes: Int | ||
) { | ||
NEW(mainListOrderStringRes = R.string.main_list_order_new), | ||
UPCOMING(mainListOrderStringRes = R.string.main_list_order_upcoming) | ||
} |
15 changes: 15 additions & 0 deletions
15
app/src/main/java/org/sopt/pingle/presentation/type/PingleCardType.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,15 @@ | ||
package org.sopt.pingle.presentation.type | ||
|
||
import androidx.annotation.ColorRes | ||
import org.sopt.pingle.R | ||
|
||
enum class PingleCardType( | ||
@ColorRes val participationStatusColorRes: Int | ||
) { | ||
MAP( | ||
participationStatusColorRes = R.color.g_10 | ||
), | ||
MAINLIST( | ||
participationStatusColorRes = R.color.g_09 | ||
) | ||
} |
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
40 changes: 40 additions & 0 deletions
40
app/src/main/java/org/sopt/pingle/presentation/ui/main/home/mainlist/MainListAdapter.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,40 @@ | ||
package org.sopt.pingle.presentation.ui.main.home.mainlist | ||
|
||
import android.view.LayoutInflater | ||
import android.view.ViewGroup | ||
import androidx.recyclerview.widget.ListAdapter | ||
import org.sopt.pingle.databinding.ItemMainListPingleCardBinding | ||
import org.sopt.pingle.domain.model.PingleEntity | ||
import org.sopt.pingle.util.view.ItemDiffCallback | ||
|
||
class MainListAdapter( | ||
private val navigateToParticipant: (Long) -> Unit, | ||
private val navigateToWebViewWithChatLink: (String) -> Unit, | ||
private val showPingleJoinModalDialogFragment: (PingleEntity) -> Unit, | ||
private val showPingleCancelModalDialogFragment: (PingleEntity) -> Unit, | ||
private val showPingleDeleteModalDialogFragment: (PingleEntity) -> Unit | ||
) : ListAdapter<PingleEntity, MainListViewHolder>( | ||
ItemDiffCallback<PingleEntity>( | ||
onContentsTheSame = { old, new -> old == new }, | ||
onItemsTheSame = { old, new -> old.id == new.id } | ||
) | ||
) { | ||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): MainListViewHolder = | ||
MainListViewHolder( | ||
binding = ItemMainListPingleCardBinding.inflate( | ||
LayoutInflater.from(parent.context), | ||
parent, | ||
false | ||
), | ||
context = parent.context, | ||
navigateToParticipant = navigateToParticipant, | ||
navigateToWebViewWithChatLink = navigateToWebViewWithChatLink, | ||
showPingleJoinModalDialogFragment = showPingleJoinModalDialogFragment, | ||
showPingleCancelModalDialogFragment = showPingleCancelModalDialogFragment, | ||
showPingleDeleteModalDialogFragment = showPingleDeleteModalDialogFragment | ||
) | ||
|
||
override fun onBindViewHolder(holder: MainListViewHolder, position: Int) { | ||
holder.onBind(pingleEntity = currentList[position]) | ||
} | ||
} |
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
70 changes: 70 additions & 0 deletions
70
app/src/main/java/org/sopt/pingle/presentation/ui/main/home/mainlist/MainListViewHolder.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,70 @@ | ||
package org.sopt.pingle.presentation.ui.main.home.mainlist | ||
|
||
import android.content.Context | ||
import android.view.View | ||
import androidx.appcompat.content.res.AppCompatResources | ||
import androidx.recyclerview.widget.RecyclerView | ||
import org.sopt.pingle.R | ||
import org.sopt.pingle.databinding.ItemMainListPingleCardBinding | ||
import org.sopt.pingle.domain.model.PingleEntity | ||
import org.sopt.pingle.presentation.type.PingleCardType | ||
|
||
class MainListViewHolder( | ||
private val binding: ItemMainListPingleCardBinding, | ||
private val context: Context, | ||
private val navigateToParticipant: (Long) -> Unit, | ||
private val navigateToWebViewWithChatLink: (String) -> Unit, | ||
private val showPingleJoinModalDialogFragment: (PingleEntity) -> Unit, | ||
private val showPingleCancelModalDialogFragment: (PingleEntity) -> Unit, | ||
private val showPingleDeleteModalDialogFragment: (PingleEntity) -> Unit | ||
) : RecyclerView.ViewHolder(binding.root) { | ||
init { | ||
with(binding) { | ||
ivMainListPingleCardBottomArrowUp.setOnClickListener { | ||
setCardExpandable(isExpanded = false) | ||
} | ||
|
||
ivMainListPingleCardBottomArrowDown.setOnClickListener { | ||
setCardExpandable(isExpanded = true) | ||
} | ||
} | ||
} | ||
|
||
private fun setCardExpandable(isExpanded: Boolean) { | ||
with(binding) { | ||
ivMainListPingleCardBottomArrowUp.visibility = | ||
if (isExpanded) View.VISIBLE else View.GONE | ||
pingleCardBottomMainListPingleCard.visibility = | ||
if (isExpanded) View.VISIBLE else View.GONE | ||
ivMainListPingleCardBottomArrowDown.visibility = | ||
if (isExpanded) View.GONE else View.VISIBLE | ||
layoutMainListPingleCardBottom.background = AppCompatResources.getDrawable( | ||
context, | ||
if (isExpanded) R.drawable.shape_border_radius_15 else R.drawable.shape_border_radius_8 | ||
) | ||
} | ||
} | ||
|
||
fun onBind(pingleEntity: PingleEntity) { | ||
with(binding.pingleCardTopMainListPingleCard) { | ||
initLayout(pingleEntity = pingleEntity, pingleCardType = PingleCardType.MAINLIST) | ||
setOnParticipationStatusLayoutClick { | ||
navigateToParticipant(pingleEntity.id) | ||
} | ||
} | ||
|
||
with(binding.pingleCardBottomMainListPingleCard) { | ||
initLayout(pingleEntity) | ||
setOnChatButtonClick { | ||
navigateToWebViewWithChatLink(pingleEntity.chatLink) | ||
} | ||
setOnParticipateButtonClick { | ||
when { | ||
pingleEntity.isOwner -> showPingleDeleteModalDialogFragment(pingleEntity) | ||
pingleEntity.isParticipating -> showPingleCancelModalDialogFragment(pingleEntity) | ||
else -> showPingleJoinModalDialogFragment(pingleEntity) | ||
} | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.