-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[FEAT/#75] μμ, λ§μ΄ ν¬λ μ‘°ν, μμ±, μμ / μλ²ν΅μ ꡬν
- Loading branch information
Showing
42 changed files
with
827 additions
and
243 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
package com.going.ui.extension | ||
|
||
enum class EnumUiState { | ||
SUCCESS, FAILURE, LOADING, EMPTY | ||
LOADING, SUCCESS, FAILURE, EMPTY | ||
} |
21 changes: 19 additions & 2 deletions
21
data/src/main/java/com/going/data/datasource/TodoDataSource.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,30 @@ | ||
package com.going.data.datasource | ||
|
||
import com.going.data.dto.BaseResponse | ||
import com.going.data.dto.NonDataBaseResponse | ||
import com.going.data.dto.request.TodoCreateRequestDto | ||
import com.going.data.dto.response.TodoDetailResponseDto | ||
import com.going.data.dto.response.TodoResponseDto | ||
|
||
interface TodoDataSource { | ||
|
||
suspend fun getTodoListData( | ||
tripId: Long, | ||
category: String, | ||
progress: String, | ||
progress: String | ||
): BaseResponse<List<TodoResponseDto>> | ||
} | ||
|
||
suspend fun postToCreateTodoData( | ||
tripId: Long, | ||
request: TodoCreateRequestDto | ||
): NonDataBaseResponse<Unit> | ||
|
||
suspend fun deleteTodoData( | ||
todoId: Long | ||
): NonDataBaseResponse<Unit> | ||
|
||
suspend fun getTodoDetailData( | ||
todoId: Long | ||
): BaseResponse<TodoDetailResponseDto> | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
data/src/main/java/com/going/data/dto/request/TodoCreateRequestDto.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.TodoCreateRequestModel | ||
import kotlinx.serialization.SerialName | ||
import kotlinx.serialization.Serializable | ||
|
||
@Serializable | ||
data class TodoCreateRequestDto( | ||
@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 TodoCreateRequestModel.toTodoCreateRequestDto(): TodoCreateRequestDto = | ||
TodoCreateRequestDto(title, endDate, allocators, memo, secret) |
22 changes: 22 additions & 0 deletions
22
data/src/main/java/com/going/data/dto/response/TodoDetailResponseDto.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package com.going.data.dto.response | ||
|
||
import com.going.domain.entity.response.TodoDetailModel | ||
import kotlinx.serialization.SerialName | ||
import kotlinx.serialization.Serializable | ||
|
||
@Serializable | ||
data class TodoDetailResponseDto( | ||
@SerialName("title") | ||
val title: String, | ||
@SerialName("endDate") | ||
val endDate: String, | ||
@SerialName("allocators") | ||
val allocators: List<TodoResponseDto.TodoAllocatorResponseDto>, | ||
@SerialName("memo") | ||
val memo: String, | ||
@SerialName("secret") | ||
val secret: Boolean | ||
) { | ||
fun toTodoDetailModel(): TodoDetailModel = | ||
TodoDetailModel(title, endDate, allocators.map { it.toTodoAllocatorModel() }, memo, secret) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 9 additions & 0 deletions
9
domain/src/main/kotlin/com/going/domain/entity/request/TodoCreateRequestModel.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package com.going.domain.entity.request | ||
|
||
data class TodoCreateRequestModel( | ||
val title: String, | ||
val endDate: String, | ||
val allocators: List<Long>, | ||
val memo: String?, | ||
val secret: Boolean | ||
) |
9 changes: 9 additions & 0 deletions
9
domain/src/main/kotlin/com/going/domain/entity/response/TodoDetailModel.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package com.going.domain.entity.response | ||
|
||
data class TodoDetailModel( | ||
val title: String, | ||
val endDate: String, | ||
val allocators: List<TodoAllocatorModel>, | ||
val memo: String, | ||
val secret: Boolean | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
100 changes: 100 additions & 0 deletions
100
presentation/src/main/java/com/going/presentation/todo/detail/PrivateDetailActivity.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
package com.going.presentation.todo.detail | ||
|
||
import android.os.Bundle | ||
import androidx.activity.viewModels | ||
import androidx.lifecycle.flowWithLifecycle | ||
import androidx.lifecycle.lifecycleScope | ||
import com.going.presentation.R | ||
import com.going.presentation.databinding.ActivityPrivateDetailBinding | ||
import com.going.presentation.todo.detail.PublicDetailActivity.Companion.EXTRA_TODO_ID | ||
import com.going.ui.base.BaseActivity | ||
import com.going.ui.extension.EnumUiState | ||
import com.going.ui.extension.setOnSingleClickListener | ||
import com.going.ui.extension.toast | ||
import dagger.hilt.android.AndroidEntryPoint | ||
import kotlinx.coroutines.flow.launchIn | ||
import kotlinx.coroutines.flow.onEach | ||
|
||
@AndroidEntryPoint | ||
class PrivateDetailActivity : | ||
BaseActivity<ActivityPrivateDetailBinding>(R.layout.activity_private_detail) { | ||
|
||
private val viewModel by viewModels<PrivateDetailViewModel>() | ||
|
||
private var todoId: Long = 0 | ||
|
||
override fun onCreate(savedInstanceState: Bundle?) { | ||
super.onCreate(savedInstanceState) | ||
|
||
initViewModel() | ||
initBackBtnClickListener() | ||
initDeleteBtnClickListener() | ||
initModBtnClickListener() | ||
getTodoId() | ||
setDetailData() | ||
observeTodoDetailState() | ||
observeTodoDeleteState() | ||
} | ||
|
||
private fun initViewModel() { | ||
binding.vm = viewModel | ||
} | ||
|
||
private fun initBackBtnClickListener() { | ||
binding.btnMyTodoDetailBack.setOnSingleClickListener { | ||
finish() | ||
} | ||
} | ||
|
||
private fun initDeleteBtnClickListener() { | ||
binding.btnMyTodoDetailDelete.setOnSingleClickListener { | ||
viewModel.deleteTodoFromServer(todoId) | ||
} | ||
} | ||
|
||
private fun initModBtnClickListener() { | ||
binding.btnMyTodoDetailMod.setOnSingleClickListener { | ||
toast(getString(R.string.will_be_update)) | ||
} | ||
} | ||
|
||
private fun getTodoId() { | ||
todoId = intent.getLongExtra(EXTRA_TODO_ID, 0) | ||
} | ||
|
||
private fun setDetailData() { | ||
viewModel.getTodoDetailFromServer(todoId) | ||
} | ||
|
||
private fun observeTodoDetailState() { | ||
viewModel.todoDetailState.flowWithLifecycle(lifecycle).onEach { state -> | ||
when (state) { | ||
EnumUiState.LOADING -> return@onEach | ||
|
||
EnumUiState.SUCCESS -> return@onEach | ||
|
||
EnumUiState.FAILURE -> toast(getString(R.string.server_error)) | ||
|
||
EnumUiState.EMPTY -> return@onEach | ||
} | ||
}.launchIn(lifecycleScope) | ||
} | ||
|
||
private fun observeTodoDeleteState() { | ||
viewModel.todoDeleteState.flowWithLifecycle(lifecycle).onEach { state -> | ||
when (state) { | ||
EnumUiState.LOADING -> return@onEach | ||
|
||
EnumUiState.SUCCESS -> { | ||
toast(getString(R.string.todo_delete_toast)) | ||
finish() | ||
} | ||
|
||
EnumUiState.FAILURE -> toast(getString(R.string.server_error)) | ||
|
||
EnumUiState.EMPTY -> return@onEach | ||
} | ||
}.launchIn(lifecycleScope) | ||
} | ||
|
||
} |
Oops, something went wrong.