-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
13 changed files
with
384 additions
and
5 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
38 changes: 38 additions & 0 deletions
38
presentation/src/main/java/co/orange/presentation/detail/OptionAdapter.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,38 @@ | ||
package co.orange.presentation.detail | ||
|
||
import android.view.LayoutInflater | ||
import android.view.ViewGroup | ||
import androidx.recyclerview.widget.ListAdapter | ||
import co.orange.domain.entity.response.OptionModel | ||
import kr.genti.core.util.ItemDiffCallback | ||
import kr.genti.presentation.databinding.ItemOptionBinding | ||
|
||
class OptionAdapter( | ||
private val itemClick: (Int, Long) -> Unit, | ||
) : ListAdapter<OptionModel, OptionViewHolder>(diffUtil) { | ||
|
||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): OptionViewHolder { | ||
val inflater by lazy { LayoutInflater.from(parent.context) } | ||
val binding: ItemOptionBinding = | ||
ItemOptionBinding.inflate(inflater, parent, false) | ||
return OptionViewHolder(binding, itemClick) | ||
} | ||
|
||
override fun onBindViewHolder(holder: OptionViewHolder, position: Int) { | ||
val item = getItem(position) ?: return | ||
holder.onBind(item, position) | ||
} | ||
|
||
fun addList(newItems: List<OptionModel>) { | ||
val currentItems = currentList.toMutableList() | ||
currentItems.addAll(newItems) | ||
submitList(currentItems) | ||
} | ||
|
||
companion object { | ||
private val diffUtil = ItemDiffCallback<OptionModel>( | ||
onItemsTheSame = { old, new -> old.optionId == new.optionId }, | ||
onContentsTheSame = { old, new -> old == new }, | ||
) | ||
} | ||
} |
67 changes: 67 additions & 0 deletions
67
presentation/src/main/java/co/orange/presentation/detail/OptionBottomSheet.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,67 @@ | ||
package co.orange.presentation.detail | ||
|
||
import android.content.Intent | ||
import android.net.Uri | ||
import android.os.Bundle | ||
import android.view.View | ||
import androidx.fragment.app.activityViewModels | ||
import co.orange.presentation.main.home.HomeProductViewHolder.Companion.OVER_999 | ||
import kr.genti.core.base.BaseBottomSheet | ||
import kr.genti.core.extension.setOnSingleClickListener | ||
import kr.genti.presentation.R | ||
import kr.genti.presentation.databinding.BottomSheetOptionBinding | ||
|
||
class OptionBottomSheet : | ||
BaseBottomSheet<BottomSheetOptionBinding>(R.layout.bottom_sheet_option) { | ||
|
||
private val viewModel by activityViewModels<DetailViewModel>() | ||
|
||
private var _adapter: OptionAdapter? = null | ||
private val adapter | ||
get() = requireNotNull(_adapter) { getString(R.string.adapter_not_initialized_error_msg) } | ||
|
||
override fun onStart() { | ||
super.onStart() | ||
dialog?.window?.setBackgroundDrawableResource(R.color.transparent) | ||
} | ||
|
||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { | ||
super.onViewCreated(view, savedInstanceState) | ||
|
||
initDetailViewBtnListener() | ||
initAdapter() | ||
setInterestCount() | ||
setOptionData() | ||
} | ||
|
||
private fun initDetailViewBtnListener() { | ||
binding.btnDetailView.setOnSingleClickListener { | ||
if (viewModel.mockProduct.infoUrl.isNotEmpty()) { | ||
startActivity(Intent(Intent.ACTION_VIEW, Uri.parse(viewModel.mockProduct.infoUrl))) | ||
} | ||
} | ||
} | ||
|
||
private fun initAdapter() { | ||
_adapter = OptionAdapter( | ||
itemClick = ::initItemClickListener, | ||
) | ||
binding.rvOption.adapter = adapter | ||
} | ||
|
||
private fun initItemClickListener(position: Int, optionId: Long) { | ||
// TODO | ||
} | ||
|
||
private fun setInterestCount() { | ||
binding.tvOptionLike.text = if (viewModel.mockProduct.interestCount < 1000) { | ||
viewModel.mockProduct.interestCount.toString() | ||
} else { | ||
OVER_999 | ||
} | ||
} | ||
|
||
private fun setOptionData() { | ||
adapter.addList(viewModel.mockProduct.optionList) | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
presentation/src/main/java/co/orange/presentation/detail/OptionViewHolder.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,22 @@ | ||
package co.orange.presentation.detail | ||
|
||
import androidx.recyclerview.widget.RecyclerView | ||
import co.orange.domain.entity.response.OptionModel | ||
import kr.genti.core.extension.setOnSingleClickListener | ||
import kr.genti.presentation.databinding.ItemOptionBinding | ||
|
||
class OptionViewHolder( | ||
val binding: ItemOptionBinding, | ||
private val itemClick: (Int, Long) -> Unit, | ||
) : RecyclerView.ViewHolder(binding.root) { | ||
|
||
fun onBind(item: OptionModel, position: Int) { | ||
// TODO: 수정된 UI 대응 | ||
with(binding) { | ||
tvOptionItemTitle.text = item.type | ||
root.setOnSingleClickListener { | ||
itemClick(position, item.optionId) | ||
} | ||
} | ||
} | ||
} |
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,9 @@ | ||
<vector xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:width="21dp" | ||
android:height="21dp" | ||
android:viewportWidth="21" | ||
android:viewportHeight="21"> | ||
<path | ||
android:pathData="M10.748,20.988C5.287,20.988 0.748,16.449 0.748,10.988C0.748,5.518 5.277,0.988 10.738,0.988C16.209,0.988 20.748,5.518 20.748,10.988C20.748,16.449 16.219,20.988 10.748,20.988ZM10.748,19.322C15.375,19.322 19.081,15.616 19.081,10.988C19.081,6.361 15.366,2.655 10.738,2.655C6.111,2.655 2.425,6.361 2.425,10.988C2.425,15.616 6.121,19.322 10.748,19.322ZM9.67,15.645C9.346,15.645 9.081,15.508 8.836,15.184L6.444,12.243C6.307,12.057 6.219,11.851 6.219,11.635C6.219,11.204 6.552,10.861 6.974,10.861C7.248,10.861 7.464,10.939 7.699,11.253L9.63,13.753L13.699,7.224C13.885,6.939 14.13,6.782 14.375,6.782C14.787,6.782 15.179,7.067 15.179,7.508C15.179,7.724 15.052,7.939 14.944,8.135L10.464,15.184C10.268,15.488 9.993,15.645 9.67,15.645Z" | ||
android:fillColor="#000000"/> | ||
</vector> |
6 changes: 6 additions & 0 deletions
6
presentation/src/main/res/drawable/shape_gray4_fill_100_rect.xml
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,6 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<shape xmlns:android="http://schemas.android.com/apk/res/android"> | ||
<solid android:color="@color/gray_4" /> | ||
<corners | ||
android:radius="100dp" /> | ||
</shape> |
7 changes: 7 additions & 0 deletions
7
presentation/src/main/res/drawable/shape_white_fill_top20_rect.xml
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,7 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<shape xmlns:android="http://schemas.android.com/apk/res/android"> | ||
<solid android:color="@color/white" /> | ||
<corners | ||
android:topLeftRadius="20dp" | ||
android:topRightRadius="20dp" /> | ||
</shape> |
Oops, something went wrong.