Skip to content

Commit

Permalink
Merge pull request #28 from DOSOPT-CDS-TABLING/feat-view-connection
Browse files Browse the repository at this point in the history
[feat] 뷰 연결 및 자잘한 오류 수정
  • Loading branch information
jihyunniiii authored Dec 1, 2023
2 parents 56865e3 + ec1c618 commit a648331
Show file tree
Hide file tree
Showing 34 changed files with 832 additions and 245 deletions.
55 changes: 54 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,54 @@
# Tabling-AOS
# 🍴 Tabling-Android 🍴
> DO SOPT 33RD 합동 세미나 앱 9조 Android팀 <br>
23.11.18 - 23.12.01

![image](https://github.com/DOSOPT-CDS-TABLING/Tabling-Android/assets/103172971/81033c2b-f9d7-4fea-9b8e-a1e51e4ee9be)

## 🍽️ *****Contributors*****
| 배지현 <br> [@jihyunniiii](https://github.com/jihyunniiii) | 김민우 <br> [@DoReMinWoo](https://github.com/DoReMinWoo) | 하지은 <br>[@HAJIEUN02](https://github.com/HAJIEUN02) |
|:---:| :---: | :---: |
| <img width="250" src="https://avatars.githubusercontent.com/u/103172971?v=4"/> |<img width="250" src="https://avatars.githubusercontent.com/u/86788873?v=4"/>|<img width="250" src="https://avatars.githubusercontent.com/u/83916472?v=4"/>|
| `매장 상세`, `방문 인원 모달` |`매장 검색_검색 결과`, `대기 상세`|`대기 신청 완료 팝업`, `이용예정/완료`|

## 📗 *****Convention*****
[📕 Git Convention & Branch Strategy](https://jihyunniiii.notion.site/Git-Convention-Branch-Strategy-ef6552f59ca5439d831eb3a9c306d6ae?pvs=4)
<br>
[📘 Android Coding Convention](https://jihyunniiii.notion.site/Android-Coding-Convention-5732cddbd1b04c62b36de8bdd8870a22?pvs=4)
<br>
[📒 Package Convention](https://jihyunniiii.notion.site/Package-Convention-4a4895944f484883a2d59b044f85890d?pvs=4)

## 📷 *****ScreenShot*****
### 🥄 매장 검색_검색 결과, 매장 상세, 방문인원 모달, 대기 신청 완료 팝업
https://github.com/DOSOPT-CDS-TABLING/Tabling-Android/assets/103172971/de5a1669-4d4f-4f5b-8aff-6c6d1216a2e2

### 🧂 이용예정/완료, 대기 상세
https://github.com/DOSOPT-CDS-TABLING/Tabling-Android/assets/103172971/e080dd36-af61-4b53-b007-2d3d3ee88ced

## 📁 *****Foldering*****

```
📂 org.sopt.tabling
┣ 📂 data
┃ ┣ 📂 datasource
┃ ┃ ┣ 📂 remote
┃ ┣ 📂 model
┃ ┃ ┣ 📂 request
┃ ┃ ┣ 📂 response
┃ ┣ 📂 repository
┃ ┣ 📂 service
┣ 📂 di
┣ 📂 domain
┃ ┣ 📂 model
┃ ┣ 📂 repository
┣ 📂 presentation
┃ ┣ 📂 common
┃ ┣ 📂 queue
┃ ┣ 📂 reserve
┃ ┣ 📂 shopDetail
┃ ┣ 📂 store
┃ ┣ 📂 type
┃ ┣ 📂 waiting
┣ 📂 util
┃ ┣ 📂 binding
┃ ┣ 📂 extension
```
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ import retrofit2.http.Path

interface WaitingDetailService {
@GET("/orders/{order_id}")
suspend fun getWaitingDetail(@Path("order_id") orderId: Int): ResponseWaitingDetailDto
suspend fun getWaitingDetail(@Path("order_id") orderId: Long): ResponseWaitingDetailDto
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import android.view.View
import org.sopt.tabling.R
import org.sopt.tabling.databinding.DialogReserveBinding
import org.sopt.tabling.domain.model.Reserve
import org.sopt.tabling.presentation.store.PopularStoreActivity
import org.sopt.tabling.presentation.queue.QueueDetailsActivity
import org.sopt.tabling.util.binding.BindingDialogFragment

class ReserveDialog(
Expand All @@ -31,7 +31,7 @@ class ReserveDialog(

private fun addListeners() {
binding.btnDialogConfirm.setOnClickListener {
startActivity(Intent(requireContext(), PopularStoreActivity::class.java))
startActivity(Intent(requireContext(), QueueDetailsActivity::class.java))
}

binding.ivIcExit24.setOnClickListener {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,13 @@ class QueueDetailsActivity :
.add(R.id.fcv_reservation, QueueReservationFragment())
.commit()
}

addListeners()
}

private fun addListeners() {
binding.ivQueueDetailBack.setOnClickListener {
finish()
}
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.sopt.tabling.presentation.queue

import android.content.Intent
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
Expand All @@ -10,6 +11,7 @@ import org.sopt.tabling.data.model.request.RequestApplyCodeDto
import org.sopt.tabling.data.model.response.ResponseApplyCodeDto
import org.sopt.tabling.data.model.response.ResponseReservationDto
import org.sopt.tabling.databinding.FragmentQueueReservationBinding
import org.sopt.tabling.presentation.waiting.WaitingDetailActivity
import org.sopt.tabling.util.extension.showToast
import retrofit2.Call
import retrofit2.Response
Expand Down Expand Up @@ -62,7 +64,8 @@ class QueueReservationFragment : Fragment() {
}

private fun setReservationAdapter(reserveList: List<ResponseReservationDto.Reservation>) {
val reservationAdapter = ReservationAdapter(requireContext(), ::patchApplyCode)
val reservationAdapter =
ReservationAdapter(requireContext(), ::patchApplyCode, ::moveToWaiting)
reservationAdapter.setReservationList(reserveList)
binding.rvReservationItems.adapter = reservationAdapter
}
Expand All @@ -83,7 +86,6 @@ class QueueReservationFragment : Fragment() {
} else if (response.code() == 500) {
context!!.showToast("서버 에러 발생")
} else {
context!!.showToast("변경이 완료되었습니다.")
setReservationList()
}
}
Expand All @@ -94,4 +96,15 @@ class QueueReservationFragment : Fragment() {
}
})
}

private fun moveToWaiting(orderId: Long) {
Intent(requireContext(), WaitingDetailActivity::class.java).apply {
putExtra(ORDER_ID, orderId)
startActivity(this)
}
}

companion object {
const val ORDER_ID = "orderId"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import org.sopt.tabling.databinding.ItemReservationBinding
class ReservationAdapter(
context: Context,
private val patchOnClick: (Int) -> Unit,
private val moveToWaiting: (Long) -> Unit
) : RecyclerView.Adapter<RecyclerView.ViewHolder>() {
private val inflater by lazy { LayoutInflater.from(context) }

Expand All @@ -22,14 +23,17 @@ class ReservationAdapter(
1 -> ReservationViewHolder(
ItemReservationBinding.inflate(inflater, parent, false),
patchOnClick,
moveToWaiting
)

2 -> ReservationDoneViewHolder(
ItemDoneReservationBinding.inflate(inflater, parent, false),
moveToWaiting
)

3 -> ReservationNoneViewHolder(
ItemNoneReservationBinding.inflate(inflater, parent, false),
moveToWaiting
)

else -> throw RuntimeException()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,20 @@ import androidx.recyclerview.widget.RecyclerView
import org.sopt.tabling.data.model.response.ResponseReservationDto
import org.sopt.tabling.databinding.ItemDoneReservationBinding

class ReservationDoneViewHolder(private val binding: ItemDoneReservationBinding) :
class ReservationDoneViewHolder(
private val binding: ItemDoneReservationBinding,
private val moveToWaiting: (Long) -> Unit
) :
RecyclerView.ViewHolder(binding.root) {
fun onBind(item: ResponseReservationDto.Reservation) {
binding.chipReservationWait.text = item.orderStatus
binding.tvReservationDate.text = item.orderDate
binding.tvReservationPeople.text = item.personCount.toString() + ""
binding.tvStoreName.text = item.shopName
binding.tvRemainReviewNum.text = item.remainingReviewPeriod.toString() + ""

binding.tvShowDetail.setOnClickListener {
moveToWaiting(item.orderId.toLong())
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,19 @@ import androidx.recyclerview.widget.RecyclerView
import org.sopt.tabling.data.model.response.ResponseReservationDto
import org.sopt.tabling.databinding.ItemNoneReservationBinding

class ReservationNoneViewHolder(private val binding: ItemNoneReservationBinding) :
class ReservationNoneViewHolder(
private val binding: ItemNoneReservationBinding,
private val moveToWaiting: (Long) -> Unit
) :
RecyclerView.ViewHolder(binding.root) {
fun onBind(item: ResponseReservationDto.Reservation) {
binding.chipReservationWait.text = item.orderStatus
binding.tvReservationDate.text = item.orderDate
binding.tvReservationPeople.text = item.personCount.toString() + ""
binding.tvStoreName.text = item.shopName

binding.tvShowDetail.setOnClickListener {
moveToWaiting(item.orderId.toLong())
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import org.sopt.tabling.databinding.ItemReservationBinding
class ReservationViewHolder(
private val binding: ItemReservationBinding,
private val patchOnClick: (Int) -> Unit,
private val moveToWaiting: (Long) -> Unit
) :
RecyclerView.ViewHolder(binding.root) {
fun onBind(item: ResponseReservationDto.Reservation) {
Expand All @@ -20,5 +21,9 @@ class ReservationViewHolder(
binding.btnCode.setOnClickListener {
patchOnClick(item.orderId)
}

binding.tvShowDetail.setOnClickListener {
moveToWaiting(item.orderId.toLong())
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,10 @@ import org.sopt.tabling.R
import org.sopt.tabling.databinding.ActivityShopDetailBinding
import org.sopt.tabling.domain.model.Reserve
import org.sopt.tabling.domain.model.ShopDetail
import org.sopt.tabling.presentation.common.ViewModelFactory
import org.sopt.tabling.presentation.reserve.ReserveBottomSheetDialogFragment
import org.sopt.tabling.presentation.reserve.ReserveDialog
import org.sopt.tabling.presentation.common.ViewModelFactory
import org.sopt.tabling.presentation.store.PopularStoreActivity.Companion.SHOP_ID
import org.sopt.tabling.presentation.type.StarType
import org.sopt.tabling.util.UiState
import org.sopt.tabling.util.binding.BindingActivity
Expand All @@ -34,12 +35,16 @@ class ShopDetailActivity :
private lateinit var shopDetailShopImgAdapter: ShopDetailShopImgAdapter
private lateinit var shopDetailMenuListAdapter: ShopDetailMenuListAdapter
private lateinit var shopDetailRecentReviewAdapter: ShopDetailRecentReviewAdapter
private var shopId: Long = -1

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
binding.shopDetailViewModel = shopDetailViewModel

shopId = intent.getLongExtra(SHOP_ID, -1)

initLayout()
addListeners()
collectData()
}

Expand All @@ -54,11 +59,19 @@ class ShopDetailActivity :
}

private fun initLayout() {
shopDetailViewModel.getShopDetail(shopId)

initAppBar()
initTabLayout()
initNestedScrollView()
}

private fun addListeners() {
binding.ivShopDetailBack.setOnClickListener {
finish()
}
}

private fun collectData() {
shopDetailViewModel.getShopDetailState.flowWithLifecycle(lifecycle).onEach { uiState ->
when (uiState) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,7 @@ class ShopDetailViewModel(
private val _getShopDetailState = MutableStateFlow<UiState<ShopDetail?>>(UiState.Empty)
val getShopDetailState = _getShopDetailState.asStateFlow()

init {
getShopDetail()
}

private fun getShopDetail(shopId: Long = 2) {
fun getShopDetail(shopId: Long) {
viewModelScope.launch {
_getShopDetailState.value = UiState.Loading
shopDetailRepository.getShopDetail(shopId).onSuccess { shopDetail ->
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
package org.sopt.tabling.presentation.store

import android.content.Intent
import android.os.Bundle
import androidx.activity.viewModels
import org.sopt.tabling.R
import org.sopt.tabling.databinding.ActivityPopularStoreBinding
import org.sopt.tabling.presentation.shopDetail.ShopDetailActivity
import org.sopt.tabling.util.binding.BindingActivity

class PopularStoreActivity :
Expand All @@ -21,7 +23,7 @@ class PopularStoreActivity :
}

private fun initAdapter() {
popularStoreAdapter = PopularStoreAdapter(this)
popularStoreAdapter = PopularStoreAdapter(this, ::moveToShopDetail)
binding.rvPopularStore.adapter = popularStoreAdapter
}

Expand All @@ -30,4 +32,15 @@ class PopularStoreActivity :
popularStoreAdapter.setStoreList(storeList)
}
}

private fun moveToShopDetail(shopId: Long) {
Intent(this@PopularStoreActivity, ShopDetailActivity::class.java).apply {
putExtra(SHOP_ID, shopId)
startActivity(this)
}
}

companion object {
const val SHOP_ID = "shopId"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,31 +6,51 @@ import android.view.ViewGroup
import androidx.recyclerview.widget.RecyclerView
import org.sopt.tabling.data.model.response.ResponsePopularStoreDto
import org.sopt.tabling.databinding.ItemPopularStoreBinding
import org.sopt.tabling.databinding.ItemPopularStoreWithTitleBinding

class PopularStoreAdapter(context: Context) :
RecyclerView.Adapter<PopularStoreAdapter.PopularStoreViewHolder>() {
class PopularStoreAdapter(
private val context: Context,
private val moveToShopDetail: (Long) -> Unit
) : RecyclerView.Adapter<RecyclerView.ViewHolder>() {
private val inflater by lazy { LayoutInflater.from(context) }
private var storeList = listOf<ResponsePopularStoreDto.StoreData>()

inner class PopularStoreViewHolder(val binding: ItemPopularStoreBinding) :
RecyclerView.ViewHolder(binding.root) {
fun onBind(storeData: ResponsePopularStoreDto.StoreData) {
binding.storeData = storeData
}
}
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): RecyclerView.ViewHolder {
return when (viewType) {
POPULAR_STORE_WITH_TITLE -> PopularStoreWithTitleViewHolder(
ItemPopularStoreWithTitleBinding.inflate(inflater, parent, false),
moveToShopDetail
)

override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): PopularStoreViewHolder {
return PopularStoreViewHolder(ItemPopularStoreBinding.inflate(inflater, parent, false))
else -> PopularStoreViewHolder(
ItemPopularStoreBinding.inflate(inflater, parent, false),
moveToShopDetail
)
}
}

override fun getItemCount() = storeList.size

override fun onBindViewHolder(holder: PopularStoreViewHolder, position: Int) {
holder.onBind(storeList[position])
override fun onBindViewHolder(holder: RecyclerView.ViewHolder, position: Int) {
when (holder) {
is PopularStoreWithTitleViewHolder -> holder.onBind(storeList[position])
is PopularStoreViewHolder -> holder.onBind(storeList[position])
}
}

override fun getItemViewType(position: Int): Int = when (position) {
FIRST_POSITION -> POPULAR_STORE_WITH_TITLE
else -> POPULAR_STORE
}

fun setStoreList(storeDataList: List<ResponsePopularStoreDto.StoreData>) {
storeList = storeDataList
notifyDataSetChanged()
}

companion object {
const val FIRST_POSITION = 0
const val POPULAR_STORE_WITH_TITLE = 0
const val POPULAR_STORE = 1
}
}
Loading

0 comments on commit a648331

Please sign in to comment.