-
Notifications
You must be signed in to change notification settings - Fork 3
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] MyPage 탭 UI 구현 #22
Changes from all commits
9a3e134
de0b9f6
a5019ac
c8dccef
dfc4d28
0064e32
c10fe57
6d5bb23
a9e478d
325b88c
33251c4
e0725a1
929b325
b08249d
62a9f6c
8732cb2
b6b41dd
9e759a0
c0373b1
73138c8
78423de
46c49d9
634f34b
b47b853
10a0b2b
e5c7c1a
4a8f130
b086762
b77b365
6666b6e
a096373
3262f8d
72e5057
ee8ea90
24a29cb
5ceaf9b
cef2451
838059c
a69582e
4988009
d4639fa
03644a4
21cec54
bbd1445
1125c3f
23ffd57
29d88a2
9014d9a
a24a572
cdb1a0f
75f0bcf
e8a0eae
e1c74b2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package com.puzzling.puzzlingaos.data.model.response | ||
|
||
import kotlinx.serialization.SerialName | ||
import kotlinx.serialization.Serializable | ||
|
||
@Serializable | ||
data class BaseResponse<T>( | ||
@SerialName("status") | ||
val status: Int, | ||
@SerialName("message") | ||
val message: String, | ||
@SerialName("data") | ||
val data: T? = null, | ||
) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package com.puzzling.puzzlingaos.data.model.response // ktlint-disable filename | ||
|
||
import kotlinx.serialization.SerialName | ||
import kotlinx.serialization.Serializable | ||
|
||
@Serializable | ||
data class ResponseMyPageProjectDto( | ||
@SerialName("projectName") | ||
val projectName: String, | ||
@SerialName("startDate") | ||
val startDate: String, | ||
@SerialName("projectId") | ||
val projectId: Int, | ||
) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package com.puzzling.puzzlingaos.data.model.response | ||
|
||
import kotlinx.serialization.SerialName | ||
import kotlinx.serialization.Serializable | ||
|
||
@Serializable | ||
data class ResponseMyRetroListDto( | ||
@SerialName("reviewId") | ||
val reviewId: Int, | ||
@SerialName("reviewDate") | ||
val reviewDate: String, | ||
@SerialName("contents") | ||
val contents: String, | ||
) |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package com.puzzling.puzzlingaos.presentation.home.mypage | ||
|
||
import android.os.Bundle | ||
import android.view.View | ||
import com.puzzling.puzzlingaos.R | ||
import com.puzzling.puzzlingaos.base.BottomSheetDialogFragment | ||
import com.puzzling.puzzlingaos.data.model.response.ResponseMyPageProjectDto | ||
import com.puzzling.puzzlingaos.databinding.FragmentBottomChooseProjectBinding | ||
import com.puzzling.puzzlingaos.presentation.home.mypage.adapter.ChooseProjectAdapter | ||
|
||
class ChooseProjectBottomFragment : | ||
BottomSheetDialogFragment<FragmentBottomChooseProjectBinding>(R.layout.fragment_bottom_choose_project) { | ||
|
||
private val dummyItemList = mutableListOf<ResponseMyPageProjectDto>( | ||
ResponseMyPageProjectDto("Piickle", "2023-07-03", 2), | ||
ResponseMyPageProjectDto("HARA", "2023-07-28", 3), | ||
ResponseMyPageProjectDto("낫투두", "2023-07-12", 4), | ||
ResponseMyPageProjectDto("PEEKABOOK", "2023-07-20", 5), | ||
ResponseMyPageProjectDto("킵고잇", "2023-06-25", 8), | ||
ResponseMyPageProjectDto("킵고잇", "2023-06-25", 8), | ||
) | ||
|
||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { | ||
super.onViewCreated(view, savedInstanceState) | ||
|
||
initAdapter() | ||
} | ||
|
||
private fun initAdapter() { | ||
val chooseProjectAdapter = ChooseProjectAdapter("낫투두") | ||
|
||
binding.rcvMyRetroChooseProject.adapter = chooseProjectAdapter | ||
chooseProjectAdapter.setItemList(dummyItemList) | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package com.puzzling.puzzlingaos.presentation.home.mypage | ||
|
||
import android.os.Bundle | ||
import android.view.View | ||
import androidx.recyclerview.widget.ConcatAdapter | ||
import androidx.recyclerview.widget.LinearLayoutManager | ||
import com.puzzling.puzzlingaos.R | ||
import com.puzzling.puzzlingaos.base.BaseFragment | ||
import com.puzzling.puzzlingaos.data.model.response.ResponseMyPageProjectDto | ||
import com.puzzling.puzzlingaos.databinding.FragmentMyPageBinding | ||
import com.puzzling.puzzlingaos.presentation.home.mypage.adapter.MyProjectAdapter | ||
import com.puzzling.puzzlingaos.presentation.home.mypage.adapter.MyProjectBottomAdapter | ||
import com.puzzling.puzzlingaos.presentation.home.mypage.adapter.MyProjectTopAdapter | ||
|
||
class MyPageFragment : BaseFragment<FragmentMyPageBinding>(R.layout.fragment_my_page) { | ||
|
||
private val dummyItemList = mutableListOf<ResponseMyPageProjectDto>( | ||
ResponseMyPageProjectDto("Piickle", "2023-07-03", 2), | ||
ResponseMyPageProjectDto("HARA", "2023-07-28", 3), | ||
ResponseMyPageProjectDto("낫투두", "2023-07-12", 4), | ||
ResponseMyPageProjectDto("PEEKABOOK", "2023-07-20", 5), | ||
ResponseMyPageProjectDto("킵고잇", "2023-06-25", 8), | ||
ResponseMyPageProjectDto("킵고잇", "2023-06-25", 8), | ||
) | ||
|
||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { | ||
super.onViewCreated(view, savedInstanceState) | ||
|
||
initAdapter() | ||
} | ||
|
||
private fun initAdapter() { | ||
val myProjectAdapter = MyProjectAdapter() | ||
val concatAdapter = | ||
ConcatAdapter(MyProjectTopAdapter("지니"), myProjectAdapter, MyProjectBottomAdapter()) | ||
|
||
with(binding) { | ||
rcvMyPageMain.adapter = concatAdapter | ||
rcvMyPageMain.layoutManager = LinearLayoutManager(activity) | ||
} | ||
myProjectAdapter.submitList(dummyItemList) | ||
|
||
myProjectAdapter.setOnItemClickListener(object : MyProjectAdapter.OnItemClickListener { | ||
override fun onItemClick(v: View, data: ResponseMyPageProjectDto, pos: Int) { | ||
requireActivity().supportFragmentManager.beginTransaction() | ||
.replace(R.id.fcv_main_container, MyRetrospectFragment()).addToBackStack(null) | ||
.commit() | ||
} | ||
}) | ||
} | ||
} |
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -0,0 +1,65 @@ | ||||||
package com.puzzling.puzzlingaos.presentation.home.mypage | ||||||
|
||||||
import android.os.Bundle | ||||||
import android.view.View | ||||||
import androidx.appcompat.app.AppCompatActivity | ||||||
import androidx.recyclerview.widget.ConcatAdapter | ||||||
import androidx.recyclerview.widget.LinearLayoutManager | ||||||
import com.puzzling.puzzlingaos.R | ||||||
import com.puzzling.puzzlingaos.base.BaseFragment | ||||||
import com.puzzling.puzzlingaos.data.model.response.ResponseMyRetroListDto | ||||||
import com.puzzling.puzzlingaos.databinding.FragmentMyRetrospectBinding | ||||||
import com.puzzling.puzzlingaos.presentation.home.mypage.adapter.MyRetroAdapter | ||||||
import com.puzzling.puzzlingaos.presentation.home.mypage.adapter.MyRetroTopAdapter | ||||||
|
||||||
class MyRetrospectFragment : | ||||||
BaseFragment<FragmentMyRetrospectBinding>(R.layout.fragment_my_retrospect) { | ||||||
|
||||||
private val dummyItemList = mutableListOf( | ||||||
ResponseMyRetroListDto(23, "2023-07-12", "여기는 20글자 정도 노출되고,,"), | ||||||
ResponseMyRetroListDto(12, "2023-07-24", "유저가 회고 템플릿에서 가장 첫 번째 인풋창에 입력한 값 노출.. "), | ||||||
ResponseMyRetroListDto(5, "2023-07-27", "여기는18글자정도노출되고나머지부분..."), | ||||||
ResponseMyRetroListDto(7, "2023-07-5", "여기는18글자정도노출되고나머지부분..."), | ||||||
ResponseMyRetroListDto(8, "2023-08-02", "여기는18글자정도노출되고나머지부분..."), | ||||||
ResponseMyRetroListDto(10, "2023-06-22", "여기는18글자정도노출되고나머지부분..."), | ||||||
) | ||||||
|
||||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { | ||||||
super.onViewCreated(view, savedInstanceState) | ||||||
|
||||||
initToolbar() | ||||||
initAdapter() | ||||||
} | ||||||
|
||||||
private fun initToolbar() { | ||||||
val activity = requireActivity() as AppCompatActivity | ||||||
activity.setSupportActionBar(binding.tbMyRetrospectMain) | ||||||
activity.supportActionBar?.apply { | ||||||
setDisplayHomeAsUpEnabled(true) | ||||||
setDisplayShowTitleEnabled(false) | ||||||
} | ||||||
binding.tbMyRetrospectMain.setNavigationOnClickListener { | ||||||
requireActivity().supportFragmentManager.popBackStack() | ||||||
} | ||||||
} | ||||||
|
||||||
private fun initAdapter() { | ||||||
val myRetroAdapter = MyRetroAdapter() | ||||||
val myRetroTopAdapter = MyRetroTopAdapter("Piickle") | ||||||
|
||||||
myRetroAdapter.submitList(dummyItemList) | ||||||
|
||||||
myRetroTopAdapter.setOnItemClickListener(object : MyRetroTopAdapter.OnItemClickListener { | ||||||
override fun onItemClick(v: View, data: String, pos: Int) { | ||||||
val chooseProjectBottomFragment = ChooseProjectBottomFragment() | ||||||
chooseProjectBottomFragment.show(requireActivity().supportFragmentManager, "show") | ||||||
} | ||||||
}) | ||||||
val concatAdapter = ConcatAdapter(myRetroTopAdapter, myRetroAdapter) | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 어댑터명은 해당 뷰의 어떤 부분인지 확실하게 명시해주는게 좋을 것 같아요 ! ex) titleAdapter, contentAdapter There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 추천 감사합니닷 |
||||||
|
||||||
with(binding) { | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
rcvMyRetroMain.adapter = concatAdapter | ||||||
rcvMyRetroMain.layoutManager = LinearLayoutManager(activity) | ||||||
} | ||||||
} | ||||||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
package com.puzzling.puzzlingaos.presentation.home.mypage.adapter | ||
|
||
import android.view.LayoutInflater | ||
import android.view.ViewGroup | ||
import androidx.recyclerview.widget.RecyclerView | ||
import com.puzzling.puzzlingaos.data.model.response.ResponseMyPageProjectDto | ||
import com.puzzling.puzzlingaos.databinding.ItemMyretroAllProjectsBinding | ||
import com.puzzling.puzzlingaos.databinding.ItemMyretroCurrentProjectBinding | ||
|
||
class ChooseProjectAdapter(private val currentProject: String) : | ||
RecyclerView.Adapter<RecyclerView.ViewHolder>() { | ||
|
||
private var itemList = mutableListOf<ResponseMyPageProjectDto>() | ||
|
||
override fun getItemViewType(position: Int): Int { | ||
return when (itemList[position].projectName) { | ||
currentProject -> CURRENT_PROJECT | ||
else -> CHOOSE_PROJECT | ||
} | ||
} | ||
|
||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): RecyclerView.ViewHolder { | ||
when (viewType) { | ||
CURRENT_PROJECT -> { | ||
val binding: ItemMyretroCurrentProjectBinding = | ||
ItemMyretroCurrentProjectBinding.inflate( | ||
LayoutInflater.from(parent.context), | ||
parent, | ||
false, | ||
) | ||
return CurrentProjectViewHolder(binding) | ||
} | ||
else -> { | ||
val binding: ItemMyretroAllProjectsBinding = ItemMyretroAllProjectsBinding.inflate( | ||
LayoutInflater.from(parent.context), | ||
parent, | ||
false, | ||
) | ||
return ChooseProjectViewHolder(binding) | ||
} | ||
} | ||
} | ||
|
||
override fun getItemCount() = itemList.size | ||
|
||
override fun onBindViewHolder(holder: RecyclerView.ViewHolder, position: Int) { | ||
when (holder) { | ||
is CurrentProjectViewHolder -> { | ||
holder.onBind(itemList[position]) | ||
} | ||
is ChooseProjectViewHolder -> { | ||
holder.onBind(itemList[position]) | ||
} | ||
} | ||
} | ||
|
||
class CurrentProjectViewHolder(private val binding: ItemMyretroCurrentProjectBinding) : | ||
RecyclerView.ViewHolder(binding.root) { | ||
fun onBind(item: ResponseMyPageProjectDto) { | ||
binding.tvMyRetroProjectName.text = item.projectName | ||
} | ||
} | ||
|
||
class ChooseProjectViewHolder(private val binding: ItemMyretroAllProjectsBinding) : | ||
RecyclerView.ViewHolder(binding.root) { | ||
fun onBind(item: ResponseMyPageProjectDto) { | ||
binding.tvMyRetroProjectName.text = item.projectName | ||
} | ||
} | ||
|
||
fun setItemList(newItemList: MutableList<ResponseMyPageProjectDto>) { | ||
itemList = newItemList | ||
notifyDataSetChanged() | ||
} | ||
|
||
companion object { | ||
const val CURRENT_PROJECT = 0 | ||
const val CHOOSE_PROJECT = 1 | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
package com.puzzling.puzzlingaos.presentation.home.mypage.adapter | ||
|
||
import android.view.LayoutInflater | ||
import android.view.View | ||
import android.view.ViewGroup | ||
import androidx.recyclerview.widget.ListAdapter | ||
import androidx.recyclerview.widget.RecyclerView | ||
import com.puzzling.puzzlingaos.data.model.response.ResponseMyPageProjectDto | ||
import com.puzzling.puzzlingaos.databinding.ItemMyProjectBinding | ||
import com.puzzling.puzzlingaos.util.ItemDiffCallback | ||
import java.text.SimpleDateFormat | ||
import java.util.* | ||
|
||
class MyProjectAdapter() : | ||
ListAdapter<ResponseMyPageProjectDto, MyProjectAdapter.MyProjectViewHolder>( | ||
diffCallback, | ||
) { | ||
|
||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): MyProjectViewHolder { | ||
val binding: ItemMyProjectBinding = | ||
ItemMyProjectBinding.inflate(LayoutInflater.from(parent.context), parent, false) | ||
return MyProjectViewHolder(binding) | ||
} | ||
|
||
override fun onBindViewHolder(holder: MyProjectViewHolder, position: Int) { | ||
return holder.onBind(currentList[position]) | ||
} | ||
|
||
private var listener: OnItemClickListener? = null | ||
|
||
inner class MyProjectViewHolder(private val binding: ItemMyProjectBinding) : | ||
RecyclerView.ViewHolder(binding.root) { | ||
|
||
fun onBind(item: ResponseMyPageProjectDto) { | ||
val now = Date() | ||
val startDate = | ||
SimpleDateFormat("yyyy-MM-dd", Locale.getDefault()).parse(item.startDate) | ||
val timeDiff = (now.time - startDate.time) / (24 * 60 * 60 * 1000) | ||
|
||
with(binding) { | ||
tvMyPageProjectName.text = item.projectName | ||
if (timeDiff < 0) { | ||
tvMyPageStartDate.text = "D - ${kotlin.math.abs(timeDiff - 1)}" | ||
} else { | ||
tvMyPageStartDate.text = "D + $timeDiff" | ||
} | ||
} | ||
|
||
if (bindingAdapterPosition != RecyclerView.NO_POSITION) { | ||
binding.btnMyPageAllRetrospect.setOnClickListener { | ||
listener?.onItemClick(itemView, item, bindingAdapterPosition) | ||
} | ||
} | ||
} | ||
} | ||
|
||
interface OnItemClickListener { | ||
fun onItemClick(v: View, data: ResponseMyPageProjectDto, pos: Int) | ||
} | ||
|
||
fun setOnItemClickListener(listener: OnItemClickListener) { | ||
this.listener = listener | ||
} | ||
|
||
companion object { | ||
private val diffCallback = | ||
ItemDiffCallback<ResponseMyPageProjectDto>( | ||
onContentsTheSame = { old, new -> old == new }, | ||
onItemsTheSame = { old, new -> old == new }, | ||
) | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package com.puzzling.puzzlingaos.presentation.home.mypage.adapter | ||
|
||
import android.view.LayoutInflater | ||
import android.view.ViewGroup | ||
import androidx.recyclerview.widget.RecyclerView | ||
import com.puzzling.puzzlingaos.databinding.ItemBottomLogoutBinding | ||
|
||
class MyProjectBottomAdapter() : | ||
RecyclerView.Adapter<MyProjectBottomAdapter.BottomViewHolder>() { | ||
|
||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): BottomViewHolder { | ||
val binding: ItemBottomLogoutBinding = | ||
ItemBottomLogoutBinding.inflate(LayoutInflater.from(parent.context), parent, false) | ||
return BottomViewHolder(binding) | ||
} | ||
|
||
override fun getItemCount(): Int { | ||
return 1 | ||
} | ||
|
||
override fun onBindViewHolder(holder: BottomViewHolder, position: Int) { | ||
} | ||
|
||
class BottomViewHolder(private val binding: ItemBottomLogoutBinding) : | ||
RecyclerView.ViewHolder(binding.root) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
p3) 되도록이면 데이터를 갖는 리스트는 뷰모델에 넣어주세용 !
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
앗 더미데이터라고 걍 아무데나 넣었네용... 머쓱머쓱