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/#211] 투두 수정뷰 / UI 구현 #232

Merged
merged 26 commits into from
Mar 6, 2024
Merged
Show file tree
Hide file tree
Changes from 23 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
dbd48c0
[ADD/#211] 투두 수정뷰 파일 초기세팅
Marchbreeze Feb 27, 2024
9de8733
Merge branch 'develop' of https://github.com/Team-Going/Going-Android…
Marchbreeze Mar 1, 2024
e9f0384
[UI/#211] 투두 수정 뷰 UI 설정
Marchbreeze Mar 1, 2024
8d6d16c
[FEAT/#211] 투두생성뷰 액티비티 우선 추가
Marchbreeze Mar 1, 2024
70732c9
[MOD/#211] Allocator 모델 분리
Marchbreeze Mar 1, 2024
827086a
[ADD/#211] 투두수정뷰 정보 설정
Marchbreeze Mar 1, 2024
5aefc2d
[ADD/#211] 투두수정뷰 어댑터 설정
Marchbreeze Mar 1, 2024
96ebaf6
[FEAT/#211] 투두수정 조건 설정
Marchbreeze Mar 1, 2024
babdf9b
[ADD/#211] 투두 수정 서버통신 구현
Marchbreeze Mar 1, 2024
eecfb1a
[ADD/#211] 투두 수정 서버통신 구현
Marchbreeze Mar 1, 2024
27956a9
[FEAT/#211] 투두 수정뷰 서버통신 연결
Marchbreeze Mar 1, 2024
4c24c33
[ADD/#211] 투두수정뷰 조회뷰와 연결
Marchbreeze Mar 1, 2024
1da3a46
Merge branch 'develop' of https://github.com/Team-Going/Going-Android…
Marchbreeze Mar 4, 2024
79aef2c
[FIX/#211] 투두 조회 API URL 변경 대응
Marchbreeze Mar 4, 2024
41a6aa7
[FIX/#211] 투두조회뷰 tripId 추가
Marchbreeze Mar 4, 2024
4cc079a
[FIX/#211] 투두수정뷰 tripId 추가
Marchbreeze Mar 4, 2024
e6517e8
Merge branch 'develop' of https://github.com/Team-Going/Going-Android…
Marchbreeze Mar 4, 2024
6a9fb9c
[FIX/#211] 투두조회뷰 이름 리스트 수정
Marchbreeze Mar 4, 2024
ebda70d
[ADD/#211] 투두수정뷰 초기값 설정
Marchbreeze Mar 4, 2024
bd025f1
[FIX/#211] 투두조회뷰 위치 조정
Marchbreeze Mar 5, 2024
281874b
[FEAT/#211] 투두 할당자 비교 설정
Marchbreeze Mar 5, 2024
b45092a
[FIX/#211] 메모 부분 깜빡임 수정
Marchbreeze Mar 5, 2024
12fea0b
[FIX/#211] 투두조회뷰 수정사항 반영
Marchbreeze Mar 5, 2024
84bcb94
[FIX/#211] 액티비티 이동 수정
Marchbreeze Mar 6, 2024
db2966d
[FIX/#211] 수정 완료 시에만 finish() 적용
Marchbreeze Mar 6, 2024
c296049
[ADD/#211] 친구 클릭 시 상세정보 뷰 리스너 설정
Marchbreeze Mar 6, 2024
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
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
Loading