Skip to content
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

Merged
merged 53 commits into from
Jul 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
9a3e134
[MOVE/#5] InvitationCode 패키지 위치 이동
gaeun5744 Jul 12, 2023
de0b9f6
[RENAME/#5] et -> edt, toolbar -> tb 컨벤션 수정
gaeun5744 Jul 12, 2023
a5019ac
[RENAME/#11] Fragment name 수정
gaeun5744 Jul 12, 2023
c8dccef
[MOVE/#11] MyPageFragment 패키지 이동
gaeun5744 Jul 12, 2023
dfc4d28
[ADD/#11] 배경 drawable 생성
gaeun5744 Jul 12, 2023
0064e32
[ADD/#11] 로그아웃 string 추가
gaeun5744 Jul 12, 2023
c10fe57
[ADD/#11] MyPageFragment UI 구현
gaeun5744 Jul 12, 2023
6d5bb23
[ADD/#11] recyclerview item 구현
gaeun5744 Jul 12, 2023
a9e478d
[RENAME/#11] id naming 수정
gaeun5744 Jul 12, 2023
325b88c
[FIX/#11] 코드리뷰 반영
gaeun5744 Jul 12, 2023
33251c4
[ADD/#11] 내 회고 뷰 toolbar 생성
gaeun5744 Jul 13, 2023
e0725a1
[FIX/#5] 중복된 lifecycleOwner 제거
gaeun5744 Jul 13, 2023
929b325
[FEAT/#11] 내 회고 default view 구현
gaeun5744 Jul 13, 2023
b08249d
[FIX/#11] rcv height 수정
gaeun5744 Jul 13, 2023
62a9f6c
[FEAT/#5] 정규식 공백 허용
gaeun5744 Jul 13, 2023
8732cb2
[DELETE/#11] manifest activity 제거
gaeun5744 Jul 13, 2023
b6b41dd
[ADD/#11] BaseResponse 생성
gaeun5744 Jul 13, 2023
9e759a0
[ADD/#11] BottomAdapter 생성
gaeun5744 Jul 13, 2023
c0373b1
[FIX/#11] margin 수정
gaeun5744 Jul 13, 2023
73138c8
[FIX/#11] textView id 추가
gaeun5744 Jul 13, 2023
78423de
[FIX/#11] activity -> fragment 로 수정
gaeun5744 Jul 13, 2023
46c49d9
[ADD/#11] ResponseMyPageProjectDto.kt 생성
gaeun5744 Jul 13, 2023
634f34b
[ADD/#11] MyProjectAdapter.kt 생성
gaeun5744 Jul 13, 2023
b47b853
[ADD/#11] toolbar margin 추가
gaeun5744 Jul 13, 2023
10a0b2b
[FEAT/#11] 마이페이지 회고 리스트 Adapter 연결
gaeun5744 Jul 13, 2023
e5c7c1a
[FEAT/#11] TopAdapter item 구현
gaeun5744 Jul 13, 2023
4a8f130
[FEAT/#11] concatAdapter을 이용해 adapter 연결
gaeun5744 Jul 13, 2023
b086762
[FIX/#11] ktlint 적용
gaeun5744 Jul 13, 2023
b77b365
[FEAT/#11] BottomAdapter을 이용한 로그아웃 구현
gaeun5744 Jul 13, 2023
6666b6e
[FEAT/#11] 날짜 계산을 통한 디데이 구현
gaeun5744 Jul 13, 2023
a096373
[FEAT/#11] 내 회고 조회 UI 구현
gaeun5744 Jul 13, 2023
3262f8d
[RENAME/#11] adapter 패키지로 옮김 & 파일명 수정
gaeun5744 Jul 13, 2023
72e5057
[ADD/#11] view id 추가
gaeun5744 Jul 13, 2023
ee8ea90
[ADD/#11] ResponseMyRetroListDto.kt 생성
gaeun5744 Jul 13, 2023
24a29cb
[ADD/#11] 내 회고 Adapter 생성
gaeun5744 Jul 13, 2023
5ceaf9b
[FEAT/#11] 내 회고 UI 구현
gaeun5744 Jul 13, 2023
cef2451
[FEAT/#11] recyclerview 버튼 클릭시 fragment 전환 구현
gaeun5744 Jul 13, 2023
838059c
[FIX/#11] 어댑터 잘못 연결된거 수정
gaeun5744 Jul 14, 2023
a69582e
[ADD/#11] 필요한 drawable 추가
gaeun5744 Jul 14, 2023
4988009
[ADD/#11] bottomSheet 프로젝트 default UI 구현
gaeun5744 Jul 14, 2023
d4639fa
[FEAT/#5] 초대코드 뷰 ViewModelFactory.kt 임시 적용
gaeun5744 Jul 14, 2023
03644a4
[FIX] manifest & string git 충돌 해결
gaeun5744 Jul 14, 2023
21cec54
[FIX/#5] git 충돌 해결
gaeun5744 Jul 14, 2023
bbd1445
[RENAME/#11] layout 이름 변경
gaeun5744 Jul 14, 2023
1125c3f
[ADD/#11] ChooseProjectBottomFragment.kt 생성
gaeun5744 Jul 14, 2023
23ffd57
[ADD/#11] ChooseProjectAdapter.kt 생성
gaeun5744 Jul 14, 2023
29d88a2
[ADD/#11] view id 추가
gaeun5744 Jul 14, 2023
9014d9a
[ADD/#11] view id 추가
gaeun5744 Jul 14, 2023
a24a572
[FEAT/#11] bottomSheet내 recyclerview 구현
gaeun5744 Jul 14, 2023
cdb1a0f
[FEAT/#11] 버튼 클릭시 bottomSheet 생성 구현
gaeun5744 Jul 14, 2023
75f0bcf
[FIX/#11] text default 패딩 제거
gaeun5744 Jul 14, 2023
e8a0eae
[UI/#11] bottomSheet background 적용
gaeun5744 Jul 14, 2023
e1c74b2
Merge pull request #2 from gaeun5744/feature/#11-myView-myPage
gaeun5744 Jul 14, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".presentation.invitationCode.InvitationCodeActivity"
android:windowSoftInputMode="adjustPan"
android:exported="true"/>
<activity
android:name=".presentation.register.RegisterActivity"
android:windowSoftInputMode="adjustPan"
Expand Down
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>(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

p3) 되도록이면 데이터를 갖는 리스트는 뷰모델에 넣어주세용 !

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

앗 더미데이터라고 걍 아무데나 넣었네용... 머쓱머쓱

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)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

어댑터명은 해당 뷰의 어떤 부분인지 확실하게 명시해주는게 좋을 것 같아요 ! ex) titleAdapter, contentAdapter

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

추천 감사합니닷


with(binding) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
with(binding) {
with(binding.rcvMyRetroMain) {

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)
}
Loading
Loading