Skip to content

Commit a1ea658

Browse files
authored
[MERGE] #31 -> develop
[UI/#31] OurTodo / 완료, 미완료 투두리스트 구현
2 parents 0ca4281 + 9e8a2a0 commit a1ea658

30 files changed

+395
-50
lines changed

app/src/main/AndroidManifest.xml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@
5151
android:exported="false"
5252
android:screenOrientation="portrait"/>
5353

54-
5554
<activity
5655
android:name="com.going.presentation.tendencytest.TendencyTestSplashActivity"
5756
android:exported="false"
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
package com.going.domain.entity.response
2+
3+
data class TodoModel(
4+
val todoId: Long,
5+
val title: String,
6+
val endDate: String,
7+
val allocation: List<String>
8+
)
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
package com.going.presentation.todo.name
2+
3+
import android.view.LayoutInflater
4+
import android.view.ViewGroup
5+
import androidx.recyclerview.widget.ListAdapter
6+
import com.going.presentation.databinding.ItemTodoNameBinding
7+
import com.going.ui.extension.ItemDiffCallback
8+
9+
class TodoNameAdapter(
10+
private val isCompleted: Boolean
11+
) : ListAdapter<String, TodoNameViewHolder>(diffUtil) {
12+
13+
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): TodoNameViewHolder {
14+
val binding: ItemTodoNameBinding =
15+
ItemTodoNameBinding.inflate(LayoutInflater.from(parent.context), parent, false)
16+
return TodoNameViewHolder(binding, isCompleted)
17+
}
18+
19+
override fun onBindViewHolder(holder: TodoNameViewHolder, position: Int) {
20+
holder.onBind(getItem(position))
21+
}
22+
23+
companion object {
24+
private val diffUtil = ItemDiffCallback<String>(
25+
onItemsTheSame = { old, new -> old.length == new.length },
26+
onContentsTheSame = { old, new -> old == new },
27+
)
28+
}
29+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
package com.going.presentation.todo.name
2+
3+
import androidx.core.content.ContextCompat
4+
import androidx.recyclerview.widget.RecyclerView
5+
import com.going.presentation.R
6+
import com.going.presentation.databinding.ItemTodoNameBinding
7+
8+
class TodoNameViewHolder(
9+
val binding: ItemTodoNameBinding, private val isCompleted: Boolean
10+
) : RecyclerView.ViewHolder(binding.root) {
11+
12+
private val redColor = ContextCompat.getColor(binding.root.context, R.color.red_500)
13+
private val grayColor = ContextCompat.getColor(binding.root.context, R.color.gray_400)
14+
private val completedColor = ContextCompat.getColor(binding.root.context, R.color.gray_300)
15+
16+
fun onBind(item: String) {
17+
binding.run {
18+
tvTodoName.text = item
19+
if (isCompleted) {
20+
tvTodoName.setTextColor(completedColor)
21+
tvTodoName.setBackgroundResource(R.drawable.shape_rect_2_gray300_line)
22+
} else {
23+
if (item == "김상호") {
24+
tvTodoName.setTextColor(redColor)
25+
tvTodoName.isSelected = true
26+
} else {
27+
tvTodoName.setTextColor(grayColor)
28+
}
29+
}
30+
}
31+
}
32+
33+
}

presentation/src/main/java/com/going/presentation/todo/ourtodo/OurTodoFragment.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class OurTodoFragment() : BaseFragment<FragmentOurTodoBinding>(R.layout.fragment
1919

2020
private val tabTextList = listOf(TAB_UNCOMPLETE, TAB_COMPLETE)
2121

22-
private var _adapter: OurTodoAdapter? = null
22+
private var _adapter: OurTodoFriendAdapter? = null
2323
private val adapter
2424
get() = requireNotNull(_adapter) { getString(R.string.adapter_not_initialized_error_msg) }
2525

@@ -36,7 +36,7 @@ class OurTodoFragment() : BaseFragment<FragmentOurTodoBinding>(R.layout.fragment
3636
}
3737

3838
private fun initAdapter() {
39-
_adapter = OurTodoAdapter()
39+
_adapter = OurTodoFriendAdapter()
4040
binding.rvOurTripFriend.adapter = adapter
4141
adapter.submitList(viewModel.mockParticipantsList)
4242
}
@@ -56,7 +56,7 @@ class OurTodoFragment() : BaseFragment<FragmentOurTodoBinding>(R.layout.fragment
5656
}
5757

5858
private fun setProgressBarStatus() {
59-
binding.progressBarOurTodo.progress = 40
59+
binding.progressBarOurTodo.progress = 62
6060
}
6161

6262
private fun setTabLayout() {

presentation/src/main/java/com/going/presentation/todo/ourtodo/OurTodoAdapter.kt renamed to presentation/src/main/java/com/going/presentation/todo/ourtodo/OurTodoFriendAdapter.kt

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,24 +7,18 @@ import com.going.domain.entity.response.TripParticipantsListModel.TripParticipan
77
import com.going.presentation.databinding.ItemTodoFriendsBinding
88
import com.going.ui.extension.ItemDiffCallback
99

10-
class OurTodoAdapter : ListAdapter<TripParticipantModel, OurTodoViewHolder>(diffUtil) {
10+
class OurTodoFriendAdapter : ListAdapter<TripParticipantModel, OurTodoFriendViewHolder>(diffUtil) {
1111

12-
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): OurTodoViewHolder {
12+
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): OurTodoFriendViewHolder {
1313
val binding: ItemTodoFriendsBinding =
1414
ItemTodoFriendsBinding.inflate(LayoutInflater.from(parent.context), parent, false)
15-
return OurTodoViewHolder(binding)
15+
return OurTodoFriendViewHolder(binding)
1616
}
1717

18-
override fun onBindViewHolder(holder: OurTodoViewHolder, position: Int) {
18+
override fun onBindViewHolder(holder: OurTodoFriendViewHolder, position: Int) {
1919
holder.onBind(getItem(position))
2020
}
2121

22-
fun addList(newItems: List<TripParticipantModel>) {
23-
val currentItems = currentList.toMutableList()
24-
currentItems.addAll(newItems)
25-
submitList(currentItems)
26-
}
27-
2822
companion object {
2923
private val diffUtil = ItemDiffCallback<TripParticipantModel>(
3024
onItemsTheSame = { old, new -> old.participantId == new.participantId },

presentation/src/main/java/com/going/presentation/todo/ourtodo/OurTodoViewHolder.kt renamed to presentation/src/main/java/com/going/presentation/todo/ourtodo/OurTodoFriendViewHolder.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import com.going.domain.entity.response.TripParticipantsListModel.TripParticipan
77
import com.going.presentation.R
88
import com.going.presentation.databinding.ItemTodoFriendsBinding
99

10-
class OurTodoViewHolder(val binding: ItemTodoFriendsBinding) : RecyclerView.ViewHolder(binding.root) {
10+
class OurTodoFriendViewHolder(val binding: ItemTodoFriendsBinding) : RecyclerView.ViewHolder(binding.root) {
1111

1212
fun onBind(item: TripParticipantModel) {
1313
binding.run {

presentation/src/main/java/com/going/presentation/todo/ourtodo/OurTodoViewModel.kt

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package com.going.presentation.todo.ourtodo
22

33
import androidx.lifecycle.ViewModel
4+
import com.going.domain.entity.response.TodoModel
45
import com.going.domain.entity.response.TripParticipantsListModel.TripParticipantModel
56

67
// @HiltViewModel
@@ -15,4 +16,19 @@ class OurTodoViewModel : ViewModel() {
1516
TripParticipantModel(5, "육지민", 100),
1617
TripParticipantModel(6, "칠지민", 100)
1718
)
19+
20+
val mockUncompleteTodoList: List<TodoModel> = listOf(
21+
TodoModel(0,"숙소 예약하기", "2024-01-12", listOf("김상호", "박동민")),
22+
TodoModel(1,"기차 왕복 예약하기", "2024-01-14", listOf("조세연")),
23+
TodoModel(2,"와사비맛 아몬드 먹기", "2024-01-15", listOf("이유빈", "김상호")),
24+
TodoModel(3,"커피 사기", "2024-01-15", listOf("이유빈")),
25+
TodoModel(4,"숙소 예약하기", "2024-01-12", listOf("김상호", "박동민")),
26+
TodoModel(5,"기차 왕복 예약하기", "2024-01-14", listOf("조세연")),
27+
TodoModel(6,"와사비맛 아몬드 먹기", "2024-01-15", listOf("이유빈", "김상호")),
28+
TodoModel(7,"커피 사기", "2024-01-15", listOf("이유빈"))
29+
)
30+
31+
val mockCompleteTodoList: List<TodoModel> = listOf(
32+
TodoModel(0,"숙소 예약하기", "2024-01-12", listOf("김상호", "박동민")),
33+
)
1834
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,39 @@
11
package com.going.presentation.todo.ourtodo.todolist
22

3+
import android.os.Bundle
4+
import android.view.View
5+
import androidx.fragment.app.activityViewModels
36
import com.going.presentation.R
47
import com.going.presentation.databinding.FragmentOurTodoCompleteBinding
8+
import com.going.presentation.todo.ourtodo.OurTodoViewModel
59
import com.going.ui.base.BaseFragment
610
import dagger.hilt.android.AndroidEntryPoint
711

812
@AndroidEntryPoint
913
class OurTodoCompleteFragment() :
1014
BaseFragment<FragmentOurTodoCompleteBinding>(R.layout.fragment_our_todo_complete) {
1115

16+
private var _adapter: OurTodoListAdapter? = null
17+
private val adapter
18+
get() = requireNotNull(_adapter) { getString(R.string.adapter_not_initialized_error_msg) }
19+
20+
private val viewModel by activityViewModels<OurTodoViewModel>()
21+
22+
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
23+
super.onViewCreated(view, savedInstanceState)
24+
25+
setRecyclerView()
26+
}
27+
28+
private fun setRecyclerView() {
29+
_adapter = OurTodoListAdapter(true)
30+
binding.rvOurTodoComplete.adapter = adapter
31+
adapter.submitList(viewModel.mockCompleteTodoList)
32+
}
33+
34+
override fun onDestroyView() {
35+
super.onDestroyView()
36+
_adapter = null
37+
}
38+
1239
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
package com.going.presentation.todo.ourtodo.todolist
2+
3+
import android.view.LayoutInflater
4+
import android.view.ViewGroup
5+
import androidx.recyclerview.widget.ListAdapter
6+
import com.going.domain.entity.response.TodoModel
7+
import com.going.presentation.databinding.ItemOurTodoBinding
8+
import com.going.ui.extension.ItemDiffCallback
9+
10+
class OurTodoListAdapter(
11+
private val isCompleted: Boolean
12+
) : ListAdapter<TodoModel, OurTodoListViewHolder>(diffUtil) {
13+
14+
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): OurTodoListViewHolder {
15+
val binding: ItemOurTodoBinding =
16+
ItemOurTodoBinding.inflate(LayoutInflater.from(parent.context), parent, false)
17+
return OurTodoListViewHolder(binding, isCompleted)
18+
}
19+
20+
override fun onBindViewHolder(holder: OurTodoListViewHolder, position: Int) {
21+
holder.onBind(getItem(position))
22+
}
23+
24+
companion object {
25+
private val diffUtil = ItemDiffCallback<TodoModel>(
26+
onItemsTheSame = { old, new -> old.todoId == new.todoId },
27+
onContentsTheSame = { old, new -> old == new },
28+
)
29+
}
30+
}

0 commit comments

Comments
 (0)