Skip to content

Commit

Permalink
[MERGE] #211 -> develop
Browse files Browse the repository at this point in the history
[FEAT/#211] 투두 수정뷰 / UI 구현
  • Loading branch information
Marchbreeze authored Mar 6, 2024
2 parents 64ea46f + c296049 commit 30a8bc1
Show file tree
Hide file tree
Showing 38 changed files with 947 additions and 103 deletions.
5 changes: 5 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,11 @@
android:exported="false"
android:screenOrientation="portrait" />

<activity
android:name="com.going.presentation.todo.change.TodoChangeActivity"
android:exported="false"
android:screenOrientation="portrait" />

<activity
android:name="com.going.presentation.setting.SettingActivity"
android:exported="false"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package com.going.data.datasource

import com.going.data.dto.BaseResponse
import com.going.data.dto.NonDataBaseResponse
import com.going.data.dto.request.TodoChangeRequestDto
import com.going.data.dto.request.TodoCreateRequestDto
import com.going.data.dto.response.CheckFriendsResponseDto
import com.going.data.dto.response.MyTripInfoResponseDto
Expand All @@ -27,6 +28,7 @@ interface TodoDataSource {
): NonDataBaseResponse

suspend fun getTodoDetailData(
tripId: Long,
todoId: Long
): BaseResponse<TodoDetailResponseDto>

Expand All @@ -50,4 +52,10 @@ interface TodoDataSource {
tripId : Long
): BaseResponse<CheckFriendsResponseDto>

suspend fun patchTodoData(
tripId: Long,
todoId: Long,
request: TodoChangeRequestDto
): NonDataBaseResponse

}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package com.going.data.datasourceImpl
import com.going.data.datasource.TodoDataSource
import com.going.data.dto.BaseResponse
import com.going.data.dto.NonDataBaseResponse
import com.going.data.dto.request.TodoChangeRequestDto
import com.going.data.dto.request.TodoCreateRequestDto
import com.going.data.dto.response.CheckFriendsResponseDto
import com.going.data.dto.response.MyTripInfoResponseDto
Expand Down Expand Up @@ -35,9 +36,10 @@ class TodoDataSourceImpl @Inject constructor(
todoService.deleteTodo(todoId)

override suspend fun getTodoDetailData(
tripId: Long,
todoId: Long
): BaseResponse<TodoDetailResponseDto> =
todoService.getTodoDetail(todoId)
todoService.getTodoDetail(tripId, todoId)

override suspend fun getMyTripInfo(
tripId: Long
Expand All @@ -64,4 +66,11 @@ class TodoDataSourceImpl @Inject constructor(
): BaseResponse<CheckFriendsResponseDto> =
todoService.getFriendsList(tripId)

override suspend fun patchTodoData(
tripId: Long,
todoId: Long,
request: TodoChangeRequestDto
): NonDataBaseResponse =
todoService.patchTodo(tripId, todoId, request)

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package com.going.data.dto.request

import com.going.domain.entity.request.TodoChangeRequestModel
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable

@Serializable
data class TodoChangeRequestDto(
@SerialName("title")
val title: String,
@SerialName("endDate")
val endDate: String,
@SerialName("allocators")
val allocators: List<Long>,
@SerialName("memo")
val memo: String?,
@SerialName("secret")
val secret: Boolean
)

fun TodoChangeRequestModel.toTodoChangeRequestDto(): TodoChangeRequestDto =
TodoChangeRequestDto(title, endDate, allocators, memo, secret)
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,15 @@ import kotlinx.serialization.Serializable

@Serializable
data class TodoAllocatorResponseDto(
@SerialName("participantId")
val participantId: Long,
@SerialName("name")
val name: String,
@SerialName("isOwner")
val isOwner: Boolean
val isOwner: Boolean,
@SerialName("isAllocated")
val isAllocated: Boolean
) {
fun toTodoAllocatorModel() =
TodoAllocatorModel(name, isOwner)
TodoAllocatorModel(participantId, name, isOwner, isAllocated)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package com.going.data.dto.response

import com.going.domain.entity.response.TodoListAllocatorModel
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable

@Serializable
data class TodoListAllocatorResponseDto(
@SerialName("name")
val name: String,
@SerialName("isOwner")
val isOwner: Boolean
) {
fun toTodoListAllocatorModel() =
TodoListAllocatorModel(name, isOwner)
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.going.data.dto.response

import com.going.domain.entity.response.TodoAllocatorModel
import com.going.domain.entity.response.TodoModel
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable
Expand All @@ -14,10 +13,10 @@ data class TodoResponseDto(
@SerialName("endDate")
val endDate: String,
@SerialName("allocators")
val allocators: List<TodoAllocatorResponseDto>,
val allocators: List<TodoListAllocatorResponseDto>,
@SerialName("secret")
val secret: Boolean
) {
fun toTodoModel() =
TodoModel(todoId, title, endDate, allocators.map { it.toTodoAllocatorModel() }, secret)
TodoModel(todoId, title, endDate, allocators.map { it.toTodoListAllocatorModel() }, secret)
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package com.going.data.repositoryImpl

import com.going.data.datasource.TodoDataSource
import com.going.data.dto.request.toTodoChangeRequestDto
import com.going.data.dto.request.toTodoCreateRequestDto
import com.going.domain.entity.request.TodoChangeRequestModel
import com.going.domain.entity.request.TodoCreateRequestModel
import com.going.domain.entity.response.CheckFriendsModel
import com.going.domain.entity.response.MyTripInfoModel
Expand Down Expand Up @@ -40,10 +42,11 @@ class TodoRepositoryImpl @Inject constructor(
}

override suspend fun getTodoDetail(
tripId: Long,
todoId: Long
): Result<TodoDetailModel> =
runCatching {
todoDataSource.getTodoDetailData(todoId).data.toTodoDetailModel()
todoDataSource.getTodoDetailData(tripId, todoId).data.toTodoDetailModel()
}

override suspend fun getMyTripInfo(
Expand Down Expand Up @@ -81,4 +84,13 @@ class TodoRepositoryImpl @Inject constructor(
todoDataSource.getFriendsList(tripId).data.toCheckFriendsModel()
}

override suspend fun patchTodo(
tripId: Long,
todoId: Long,
request: TodoChangeRequestModel
): Result<Unit> =
runCatching {
todoDataSource.patchTodoData(tripId, todoId, request.toTodoChangeRequestDto())
}

}
12 changes: 11 additions & 1 deletion data/src/main/java/com/going/data/service/TodoService.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package com.going.data.service

import com.going.data.dto.BaseResponse
import com.going.data.dto.NonDataBaseResponse
import com.going.data.dto.request.TodoChangeRequestDto
import com.going.data.dto.request.TodoCreateRequestDto
import com.going.data.dto.response.CheckFriendsResponseDto
import com.going.data.dto.response.MyTripInfoResponseDto
Expand All @@ -11,6 +12,7 @@ import com.going.data.dto.response.TodoResponseDto
import retrofit2.http.Body
import retrofit2.http.DELETE
import retrofit2.http.GET
import retrofit2.http.PATCH
import retrofit2.http.POST
import retrofit2.http.Path
import retrofit2.http.Query
Expand All @@ -35,8 +37,9 @@ interface TodoService {
@Path("todoId") todoId: Long
): NonDataBaseResponse

@GET("api/trips/todos/{todoId}")
@GET("api/trips/{tripId}/todos/{todoId}")
suspend fun getTodoDetail(
@Path("tripId") tripId: Long,
@Path("todoId") todoId: Long
): BaseResponse<TodoDetailResponseDto>

Expand Down Expand Up @@ -65,4 +68,11 @@ interface TodoService {
@Path("tripId") tripId: Long
): BaseResponse<CheckFriendsResponseDto>

@PATCH("api/trips/{tripId}/todos/{todoId}")
suspend fun patchTodo(
@Path("tripId") tripId: Long,
@Path("todoId") todoId: Long,
@Body request: TodoChangeRequestDto
): NonDataBaseResponse

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package com.going.domain.entity.request

data class TodoChangeRequestModel(
val title: String,
val endDate: String,
val allocators: List<Long>,
val memo: String?,
val secret: Boolean
)
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package com.going.domain.entity.response

data class TodoAllocatorModel(
val participantId: Long,
val name: String,
val isOwner: Boolean
)
val isOwner: Boolean,
var isAllocated: Boolean
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package com.going.domain.entity.response

data class TodoListAllocatorModel(
val name: String,
val isOwner: Boolean
)
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ data class TodoModel(
val todoId: Long,
val title: String,
val endDate: String,
val allocators: List<TodoAllocatorModel>,
val allocators: List<TodoListAllocatorModel>,
val secret: Boolean
)
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.going.domain.repository

import com.going.domain.entity.request.TodoChangeRequestModel
import com.going.domain.entity.request.TodoCreateRequestModel
import com.going.domain.entity.response.CheckFriendsModel
import com.going.domain.entity.response.MyTripInfoModel
Expand All @@ -25,6 +26,7 @@ interface TodoRepository {
): Result<Unit>

suspend fun getTodoDetail(
tripId: Long,
todoId: Long
): Result<TodoDetailModel>

Expand All @@ -47,4 +49,10 @@ interface TodoRepository {
suspend fun getFriendsList(
tripId: Long
): Result<CheckFriendsModel>

suspend fun patchTodo(
tripId: Long,
todoId: Long,
request: TodoChangeRequestModel
): Result<Unit>
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ package com.going.presentation.todo.allocator
import android.view.LayoutInflater
import android.view.ViewGroup
import androidx.recyclerview.widget.ListAdapter
import com.going.domain.entity.response.TodoAllocatorModel
import com.going.domain.entity.response.TodoListAllocatorModel
import com.going.presentation.databinding.ItemTodoNameBinding
import com.going.ui.util.ItemDiffCallback

class TodoAllocatorAdapter(
private val isCompleted: Boolean
) : ListAdapter<TodoAllocatorModel, TodoAllocatorViewHolder>(diffUtil) {
) : ListAdapter<TodoListAllocatorModel, TodoAllocatorViewHolder>(diffUtil) {

override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): TodoAllocatorViewHolder {
val inflater by lazy { LayoutInflater.from(parent.context) }
Expand All @@ -23,7 +23,7 @@ class TodoAllocatorAdapter(
}

companion object {
private val diffUtil = ItemDiffCallback<TodoAllocatorModel>(
private val diffUtil = ItemDiffCallback<TodoListAllocatorModel>(
onItemsTheSame = { old, new -> old.name == new.name },
onContentsTheSame = { old, new -> old == new },
)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.going.presentation.todo.allocator

import androidx.recyclerview.widget.RecyclerView
import com.going.domain.entity.response.TodoAllocatorModel
import com.going.domain.entity.response.TodoListAllocatorModel
import com.going.presentation.R
import com.going.presentation.databinding.ItemTodoNameBinding
import com.going.ui.extension.colorOf
Expand All @@ -11,7 +11,7 @@ class TodoAllocatorViewHolder(
private val isCompleted: Boolean
) : RecyclerView.ViewHolder(binding.root) {

fun onBind(item: TodoAllocatorModel) {
fun onBind(item: TodoListAllocatorModel) {
with(binding.tvTodoName) {
text = item.name
when {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package com.going.presentation.todo.change

import android.view.LayoutInflater
import android.view.ViewGroup
import androidx.recyclerview.widget.ListAdapter
import com.going.domain.entity.response.TodoAllocatorModel
import com.going.presentation.databinding.ItemTodoCreateNameBinding
import com.going.ui.util.ItemDiffCallback

class TodoAllocatorAdapter(
private val itemClick: (Int) -> Unit
) : ListAdapter<TodoAllocatorModel, TodoAllocatorViewHolder>(diffUtil) {

override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): TodoAllocatorViewHolder {
val binding: ItemTodoCreateNameBinding =
ItemTodoCreateNameBinding.inflate(LayoutInflater.from(parent.context), parent, false)
return TodoAllocatorViewHolder(binding, itemClick)
}

override fun onBindViewHolder(holder: TodoAllocatorViewHolder, position: Int) {
holder.onBind(getItem(position), position)
}

companion object {
private val diffUtil = ItemDiffCallback<TodoAllocatorModel>(
onItemsTheSame = { old, new -> old.participantId == new.participantId },
onContentsTheSame = { old, new -> old == new },
)
}
}
Loading

0 comments on commit 30a8bc1

Please sign in to comment.