-
Notifications
You must be signed in to change notification settings - Fork 1
[Refactor/#136] 홈화면 루틴 완료 로직을 리펙토링 합니다. #137
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
Merged
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
e401a09
Refactor: 루틴관련 모델 프로퍼티 및 클래스 네이밍 변경
wjdrjs00 02db0f7
Refactor: 루틴 완료 토글 로직 상태 호이스팅
wjdrjs00 8d12ab7
Refactor: RoutineItem 파라미터 변경
wjdrjs00 a94e1d5
Chore: DayRoutines -> DailyRoutines 네이밍 변경
wjdrjs00 b0d72a7
Refactor: HomeViewModel 에서 MviViewModel 구현 제거
wjdrjs00 d877e07
Feat: 홈 화면 네비게이션 메소드 정의
wjdrjs00 cffd981
Refactor: FetchWeeklyRoutinesUseCase 파라미터 변경
wjdrjs00 0d93d5f
Feat: 루틴 토글 usecase 로직 추가
wjdrjs00 26efa55
Refactor: 홈 화면 로직 개선 및 리팩토링
wjdrjs00 cba9a67
Refactor: isCompleted를 computed property로 변경
wjdrjs00 18aaba1
Refactor: isCompleted 롤백
wjdrjs00 2e44846
Refactor: FetchWeeklyRoutinesUseCase 인자 수정
wjdrjs00 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
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
13 changes: 13 additions & 0 deletions
13
domain/src/main/java/com/threegap/bitnagil/domain/routine/model/DailyRoutines.kt
This file contains hidden or 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,13 @@ | ||
| package com.threegap.bitnagil.domain.routine.model | ||
|
|
||
| /** | ||
| * 특정 하루("일간")의 루틴 정보. | ||
| * [RoutineSchedule] Map의 '값(value)'으로 사용됩니다. | ||
| * | ||
| * @property routines 해당 날짜에 포함된 [Routine](개별 루틴)의 목록. | ||
| * @property isAllCompleted 해당 날짜의 모든 루틴이 완료되었는지 여부. | ||
| */ | ||
| data class DailyRoutines( | ||
| val routines: List<Routine>, | ||
| val isAllCompleted: Boolean, | ||
| ) |
6 changes: 0 additions & 6 deletions
6
domain/src/main/java/com/threegap/bitnagil/domain/routine/model/DayRoutines.kt
This file was deleted.
Oops, something went wrong.
12 changes: 6 additions & 6 deletions
12
domain/src/main/java/com/threegap/bitnagil/domain/routine/model/Routine.kt
This file contains hidden or 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,16 +1,16 @@ | ||
| package com.threegap.bitnagil.domain.routine.model | ||
|
|
||
| data class Routine( | ||
| val routineId: String, | ||
| val routineName: String, | ||
| val repeatDay: List<DayOfWeek>, | ||
| val id: String, | ||
| val name: String, | ||
| val repeatDays: List<DayOfWeek>, | ||
| val executionTime: String, | ||
| val startDate: String, | ||
| val endDate: String, | ||
| val routineDate: String, | ||
| val routineCompleteYn: Boolean, | ||
| val routineDeletedYn: Boolean, | ||
| val isCompleted: Boolean, | ||
| val isDeleted: Boolean, | ||
| val subRoutineNames: List<String>, | ||
| val subRoutineCompleteYn: List<Boolean>, | ||
| val subRoutineCompletionStates: List<Boolean>, | ||
| val recommendedRoutineType: RecommendedRoutineType?, | ||
| ) |
11 changes: 11 additions & 0 deletions
11
domain/src/main/java/com/threegap/bitnagil/domain/routine/model/RoutineSchedule.kt
This file contains hidden or 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,11 @@ | ||
| package com.threegap.bitnagil.domain.routine.model | ||
|
|
||
| /** | ||
| * 특정 기간(예: 주간, 월간) 동안의 루틴 일정표. | ||
| * | ||
| * @property dailyRoutines 날짜(String, "YYYY-MM-DD")를 key로, | ||
| * 해당 날짜의 루틴 정보([DailyRoutines])를 value로 가지는 Map. | ||
| */ | ||
| data class RoutineSchedule( | ||
| val dailyRoutines: Map<String, DailyRoutines>, | ||
| ) |
6 changes: 6 additions & 0 deletions
6
domain/src/main/java/com/threegap/bitnagil/domain/routine/model/RoutineToggleState.kt
This file contains hidden or 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,6 @@ | ||
| package com.threegap.bitnagil.domain.routine.model | ||
|
|
||
| data class RoutineToggleState( | ||
| val isCompleted: Boolean, | ||
| val subRoutinesIsCompleted: List<Boolean>, | ||
| ) |
5 changes: 0 additions & 5 deletions
5
domain/src/main/java/com/threegap/bitnagil/domain/routine/model/Routines.kt
This file was deleted.
Oops, something went wrong.
This file contains hidden or 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
7 changes: 4 additions & 3 deletions
7
.../src/main/java/com/threegap/bitnagil/domain/routine/usecase/FetchWeeklyRoutinesUseCase.kt
This file contains hidden or 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,12 +1,13 @@ | ||
| package com.threegap.bitnagil.domain.routine.usecase | ||
|
|
||
| import com.threegap.bitnagil.domain.routine.model.Routines | ||
| import com.threegap.bitnagil.domain.routine.model.RoutineSchedule | ||
| import com.threegap.bitnagil.domain.routine.repository.RoutineRepository | ||
| import javax.inject.Inject | ||
|
|
||
| class FetchWeeklyRoutinesUseCase @Inject constructor( | ||
| private val routineRepository: RoutineRepository, | ||
| ) { | ||
| suspend operator fun invoke(startDate: String, endDate: String): Result<Routines> = | ||
| routineRepository.fetchWeeklyRoutines(startDate, endDate) | ||
| suspend operator fun invoke(startDate: String, endDate: String): Result<RoutineSchedule> { | ||
| return routineRepository.fetchWeeklyRoutines(startDate, endDate) | ||
| } | ||
| } |
55 changes: 55 additions & 0 deletions
55
domain/src/main/java/com/threegap/bitnagil/domain/routine/usecase/ToggleRoutineUseCase.kt
This file contains hidden or 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,55 @@ | ||
| package com.threegap.bitnagil.domain.routine.usecase | ||
|
|
||
| import com.threegap.bitnagil.domain.routine.model.RoutineToggleState | ||
| import javax.inject.Inject | ||
|
|
||
| class ToggleRoutineUseCase @Inject constructor() { | ||
|
|
||
| /** | ||
| * 메인 루틴을 토글합니다. | ||
| * 메인 루틴이 토글되면 모든 서브 루틴도 같은 상태로 변경됩니다. | ||
| * | ||
| * @param isCompleted 현재 메인 루틴 완료 상태 | ||
| * @param subRoutineStates 현재 서브 루틴 완료 상태 리스트 | ||
| * @return 토글된 루틴 상태 | ||
| */ | ||
| fun toggleMainRoutine( | ||
| isCompleted: Boolean, | ||
| subRoutineStates: List<Boolean>, | ||
| ): RoutineToggleState { | ||
| val newIsCompleted = !isCompleted | ||
| val newSubRoutineStates = subRoutineStates.map { newIsCompleted } | ||
|
|
||
| return RoutineToggleState( | ||
| isCompleted = newIsCompleted, | ||
| subRoutinesIsCompleted = newSubRoutineStates, | ||
| ) | ||
| } | ||
|
|
||
| /** | ||
| * 특정 서브 루틴을 토글합니다. | ||
| * 모든 서브 루틴이 완료되면 메인 루틴도 자동으로 완료됩니다. | ||
| * | ||
| * @param index 토글할 서브 루틴의 인덱스 | ||
| * @param subRoutineStates 현재 서브 루틴 완료 상태 리스트 | ||
| * @return 토글된 루틴 상태, 잘못된 인덱스인 경우 null | ||
| */ | ||
| fun toggleSubRoutine( | ||
| index: Int, | ||
| subRoutineStates: List<Boolean>, | ||
| ): RoutineToggleState? { | ||
| if (index !in subRoutineStates.indices) return null | ||
|
|
||
| val newState = !subRoutineStates[index] | ||
| val newSubRoutineStates = subRoutineStates.toMutableList().apply { | ||
| this[index] = newState | ||
| } | ||
|
|
||
| val allCompleted = newSubRoutineStates.all { it } | ||
|
|
||
| return RoutineToggleState( | ||
| isCompleted = allCompleted, | ||
| subRoutinesIsCompleted = newSubRoutineStates, | ||
| ) | ||
| } | ||
| } |
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.
Uh oh!
There was an error while loading. Please reload this page.