-
Notifications
You must be signed in to change notification settings - Fork 2
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
휴지통 화면, 보드 복구 API, 루트노드 일치화 #284
Merged
Merged
Changes from all commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
56a2857
chore(#279): string 값 추가
jaehan4707 32801cf
feat(#279): RestoreBoardResponse,Request 추가
jaehan4707 1adf498
design(#279): 휴지통 보드 item 추가
jaehan4707 46c5a35
feat(#280): RecycleBinUiState 추가
jaehan4707 51d1114
feat(#280): RecycleBinUiEvent 추가
jaehan4707 109b3b0
feat(#280): safeArgs spaceId 추가
jaehan4707 ebad712
feat(#280): RecycleBinViewModel 생성
jaehan4707 63843f5
feat(#280): RecycleBinFragment 구현
jaehan4707 25c1b55
design(#279): RecycleBinFragment.xml 구현
jaehan4707 ab25636
feat(#280): 사이드바 휴지통 클릭 이벤트 처리
jaehan4707 380593e
feat(#280): restoreBoard 추가
jaehan4707 263187e
feat(#280): getBoard 수정 isDeleted 분기 처리
jaehan4707 52d4fc2
refactor(#280): ListAdpater DiffUtil 수정
jaehan4707 f1d7ae8
design(#272): refresh 아이콘 추가
jaehan4707 c52de04
design(#272): BoardList 새로고침 아이콘 변경
jaehan4707 40ac98a
refactor(#282): setBoardId->setBoard, CrdtTree 생성자 추가
jaehan4707 1c65d54
style(#282): ktlint 적용
jaehan4707 7b3a43f
fix(#247): joinBoard safeArgs 추가
jaehan4707 1ba1ef3
feat(#247): 루트노드 이름 보드이름으로 바꾸기
jaehan4707 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
8 changes: 8 additions & 0 deletions
8
.../src/main/java/boostcamp/and07/mindsync/data/network/request/board/RestoreBoardRequest.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,8 @@ | ||
package boostcamp.and07.mindsync.data.network.request.board | ||
|
||
import kotlinx.serialization.Serializable | ||
|
||
@Serializable | ||
data class RestoreBoardRequest( | ||
val boardId: String, | ||
) |
10 changes: 10 additions & 0 deletions
10
...rc/main/java/boostcamp/and07/mindsync/data/network/response/board/RestoreBoardResponse.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,10 @@ | ||
package boostcamp.and07.mindsync.data.network.response.board | ||
|
||
import kotlinx.serialization.Serializable | ||
|
||
@Serializable | ||
data class RestoreBoardResponse( | ||
val statusCode: Int, | ||
val message: String, | ||
val error: String? = null, | ||
) |
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
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
43 changes: 43 additions & 0 deletions
43
AOS/app/src/main/java/boostcamp/and07/mindsync/ui/recyclebin/RecycleBinFragment.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,10 +1,53 @@ | ||
package boostcamp.and07.mindsync.ui.recyclebin | ||
|
||
import androidx.fragment.app.viewModels | ||
import androidx.navigation.fragment.findNavController | ||
import androidx.navigation.fragment.navArgs | ||
import boostcamp.and07.mindsync.R | ||
import boostcamp.and07.mindsync.data.model.Board | ||
import boostcamp.and07.mindsync.databinding.FragmentRecycleBinBinding | ||
import boostcamp.and07.mindsync.ui.base.BaseFragment | ||
import boostcamp.and07.mindsync.ui.boardlist.BoardClickListener | ||
import boostcamp.and07.mindsync.ui.boardlist.BoardListAdapter | ||
import boostcamp.and07.mindsync.ui.boardlist.BoardListFragmentDirections | ||
import dagger.hilt.android.AndroidEntryPoint | ||
|
||
@AndroidEntryPoint | ||
class RecycleBinFragment : BaseFragment<FragmentRecycleBinBinding>(R.layout.fragment_recycle_bin) { | ||
private val recycleBinViewModel: RecycleBinViewModel by viewModels() | ||
private val boardListAdapter = BoardListAdapter() | ||
private val args: RecycleBinFragmentArgs by navArgs() | ||
|
||
override fun initView() { | ||
setBinding() | ||
setBoardRestoreButton() | ||
recycleBinViewModel.setSpace(args.spaceId) | ||
} | ||
|
||
private fun setBinding() { | ||
binding.vm = recycleBinViewModel | ||
binding.rvRecyclebinBoard.adapter = boardListAdapter | ||
boardListAdapter.setBoardClickListener( | ||
object : BoardClickListener { | ||
override fun onClick(board: Board) { | ||
findNavController().navigate( | ||
BoardListFragmentDirections.actionBoardListFragmentToMindMapFragment( | ||
boardId = board.id, | ||
boardName = board.name, | ||
), | ||
) | ||
} | ||
|
||
override fun onCheckBoxClick(board: Board) { | ||
recycleBinViewModel.selectBoard(board) | ||
} | ||
}, | ||
) | ||
} | ||
|
||
private fun setBoardRestoreButton() { | ||
binding.btnRecyclebinRestore.setOnClickListener { | ||
recycleBinViewModel.restoreBoard() | ||
} | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
AOS/app/src/main/java/boostcamp/and07/mindsync/ui/recyclebin/RecycleBinUiEvent.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,7 @@ | ||
package boostcamp.and07.mindsync.ui.recyclebin | ||
|
||
sealed class RecycleBinUiEvent { | ||
data object Success : RecycleBinUiEvent() | ||
|
||
data class Error(val message: String) : RecycleBinUiEvent() | ||
} |
9 changes: 9 additions & 0 deletions
9
AOS/app/src/main/java/boostcamp/and07/mindsync/ui/recyclebin/RecycleBinUiState.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 boostcamp.and07.mindsync.ui.recyclebin | ||
|
||
import boostcamp.and07.mindsync.data.model.Board | ||
|
||
data class RecycleBinUiState( | ||
val spaceId: String = "", | ||
val boards: List<Board> = listOf(), | ||
val selectBoards: List<Board> = listOf(), | ||
) |
84 changes: 84 additions & 0 deletions
84
AOS/app/src/main/java/boostcamp/and07/mindsync/ui/recyclebin/RecycleBinViewModel.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,84 @@ | ||
package boostcamp.and07.mindsync.ui.recyclebin | ||
|
||
import androidx.lifecycle.ViewModel | ||
import androidx.lifecycle.viewModelScope | ||
import boostcamp.and07.mindsync.data.model.Board | ||
import boostcamp.and07.mindsync.data.repository.boardlist.BoardListRepository | ||
import dagger.hilt.android.lifecycle.HiltViewModel | ||
import kotlinx.coroutines.CoroutineExceptionHandler | ||
import kotlinx.coroutines.flow.MutableSharedFlow | ||
import kotlinx.coroutines.flow.MutableStateFlow | ||
import kotlinx.coroutines.flow.SharedFlow | ||
import kotlinx.coroutines.flow.StateFlow | ||
import kotlinx.coroutines.flow.collectLatest | ||
import kotlinx.coroutines.flow.update | ||
import kotlinx.coroutines.launch | ||
import javax.inject.Inject | ||
|
||
@HiltViewModel | ||
class RecycleBinViewModel | ||
@Inject | ||
constructor( | ||
private val boardListRepository: BoardListRepository, | ||
) : ViewModel() { | ||
private val _uiState = MutableStateFlow(RecycleBinUiState()) | ||
val uiState: StateFlow<RecycleBinUiState> = _uiState | ||
private val _uiEvent = MutableSharedFlow<RecycleBinUiEvent>() | ||
val uiEvent: SharedFlow<RecycleBinUiEvent> = _uiEvent | ||
|
||
private val coroutineExceptionHandler = | ||
CoroutineExceptionHandler { _, throwable -> | ||
viewModelScope.launch { | ||
_uiEvent.emit(RecycleBinUiEvent.Error(throwable.message.toString())) | ||
} | ||
} | ||
|
||
fun setSpace(spaceId: String) { | ||
_uiState.update { boardUiState -> | ||
boardUiState.copy( | ||
spaceId = spaceId, | ||
) | ||
} | ||
getBoards() | ||
} | ||
|
||
fun getBoards() { | ||
viewModelScope.launch(coroutineExceptionHandler) { | ||
boardListRepository.getBoard(_uiState.value.spaceId, true).collectLatest { boards -> | ||
_uiState.update { boardUiState -> | ||
boardUiState.copy(boards = boards) | ||
} | ||
_uiEvent.emit(RecycleBinUiEvent.Success) | ||
} | ||
} | ||
} | ||
|
||
fun selectBoard(selectBoard: Board) { | ||
_uiState.update { boardUiState -> | ||
val newSelectBoards = | ||
boardUiState.boards.toMutableList().filter { board -> board.isChecked } | ||
boardUiState.copy( | ||
selectBoards = newSelectBoards, | ||
) | ||
} | ||
} | ||
|
||
fun restoreBoard() { | ||
viewModelScope.launch(coroutineExceptionHandler) { | ||
val newBoards = uiState.value.boards.toMutableList() | ||
val newSelectBoards = uiState.value.selectBoards.toMutableList() | ||
_uiState.value.selectBoards.map { board -> | ||
boardListRepository.restoreBoard(board.id).collectLatest { | ||
newBoards.remove(board) | ||
newSelectBoards.remove(board) | ||
} | ||
} | ||
_uiState.update { boardUiState -> | ||
boardUiState.copy( | ||
boards = newBoards, | ||
selectBoards = newSelectBoards, | ||
) | ||
} | ||
} | ||
} | ||
} |
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,5 @@ | ||
<vector android:height="24dp" android:tint="#000000" | ||
android:viewportHeight="24" android:viewportWidth="24" | ||
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android"> | ||
<path android:fillColor="@android:color/white" android:pathData="M17.65,6.35C16.2,4.9 14.21,4 12,4c-4.42,0 -7.99,3.58 -7.99,8s3.57,8 7.99,8c3.73,0 6.84,-2.55 7.73,-6h-2.08c-0.82,2.33 -3.04,4 -5.65,4 -3.31,0 -6,-2.69 -6,-6s2.69,-6 6,-6c1.66,0 3.14,0.69 4.22,1.78L13,11h7V4l-2.35,2.35z"/> | ||
</vector> |
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
빼먹은 부분 수정해주셔서 감사합니다..ㅠㅠ
선배로 여길게요