-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
…le-list-cell-edit Feature/#99 timetable list cell edit
- Loading branch information
Showing
41 changed files
with
1,112 additions
and
283 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
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,7 +1,17 @@ | ||
package com.suwiki.core.ui.extension | ||
|
||
import android.content.Context | ||
import android.content.pm.PackageInfo | ||
import androidx.core.content.pm.PackageInfoCompat | ||
|
||
internal inline fun <T> T.runIf(condition: Boolean, run: T.() -> T) = if (condition) { | ||
run() | ||
} else { | ||
this | ||
} | ||
|
||
val Context.versionCode: Long | ||
get() { | ||
val pi: PackageInfo = packageManager.getPackageInfo(packageName, 0) | ||
return PackageInfoCompat.getLongVersionCode(pi) | ||
} |
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
7 changes: 3 additions & 4 deletions
7
...timetable/src/main/java/com/suwiki/domain/timetable/usecase/DeleteTimetableCellUseCase.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,16 +1,15 @@ | ||
package com.suwiki.domain.timetable.usecase | ||
|
||
import com.suwiki.core.common.runCatchingIgnoreCancelled | ||
import com.suwiki.core.model.timetable.Timetable | ||
import com.suwiki.core.model.timetable.TimetableCell | ||
import com.suwiki.domain.timetable.repository.TimetableRepository | ||
import javax.inject.Inject | ||
|
||
class DeleteTimetableCellUseCase @Inject constructor( | ||
private val timetableRepository: TimetableRepository, | ||
) { | ||
suspend operator fun invoke(cell: TimetableCell): Result<Unit> = runCatchingIgnoreCancelled { | ||
timetableRepository.deleteTimetableCell( | ||
cell = cell, | ||
) | ||
suspend operator fun invoke(cell: TimetableCell): Result<Timetable> = runCatchingIgnoreCancelled { | ||
timetableRepository.deleteTimetableCell(cell = cell) | ||
} | ||
} |
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
13 changes: 13 additions & 0 deletions
13
...imetable/src/main/java/com/suwiki/domain/timetable/usecase/GetTimetableCellTypeUseCase.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,13 @@ | ||
package com.suwiki.domain.timetable.usecase | ||
|
||
import com.suwiki.core.common.runCatchingIgnoreCancelled | ||
import com.suwiki.domain.timetable.repository.TimetableRepository | ||
import javax.inject.Inject | ||
|
||
class GetTimetableCellTypeUseCase @Inject constructor( | ||
private val timetableRepository: TimetableRepository, | ||
) { | ||
suspend operator fun invoke() = runCatchingIgnoreCancelled { | ||
timetableRepository.getTimetableCellType() | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
...imetable/src/main/java/com/suwiki/domain/timetable/usecase/SetTimetableCellTypeUseCase.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,13 @@ | ||
package com.suwiki.domain.timetable.usecase | ||
|
||
import com.suwiki.core.common.runCatchingIgnoreCancelled | ||
import com.suwiki.domain.timetable.repository.TimetableRepository | ||
import javax.inject.Inject | ||
|
||
class SetTimetableCellTypeUseCase @Inject constructor( | ||
private val timetableRepository: TimetableRepository, | ||
) { | ||
suspend operator fun invoke(type: String) = runCatchingIgnoreCancelled { | ||
timetableRepository.setTimetableCellType(type) | ||
} | ||
} |
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
38 changes: 0 additions & 38 deletions
38
feature/timetable/src/main/java/com/suwiki/feature/timetable/addcell/AddCellContract.kt
This file was deleted.
Oops, something went wrong.
48 changes: 48 additions & 0 deletions
48
...ure/timetable/src/main/java/com/suwiki/feature/timetable/celleditor/CellEditorContract.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,48 @@ | ||
package com.suwiki.feature.timetable.celleditor | ||
|
||
import com.suwiki.core.model.timetable.TimetableCellColor | ||
import com.suwiki.core.model.timetable.TimetableDay | ||
import com.suwiki.feature.timetable.navigation.argument.CellArgument | ||
import com.suwiki.feature.timetable.navigation.argument.CellEditorArgument | ||
import kotlinx.collections.immutable.PersistentList | ||
import kotlinx.collections.immutable.persistentListOf | ||
import kotlinx.collections.immutable.toPersistentList | ||
|
||
data class CellEditorState( | ||
val lectureName: String = "", | ||
val professorName: String = "", | ||
val cellStateList: PersistentList<CellState> = persistentListOf(CellState()), | ||
val selectedTimetableCellColor: TimetableCellColor = TimetableCellColor.GRAY_DARK, | ||
) | ||
|
||
data class CellState( | ||
val location: String = "", | ||
val day: TimetableDay = TimetableDay.MON, | ||
val startPeriod: String = "", | ||
val endPeriod: String = "", | ||
) | ||
|
||
internal fun CellArgument.toState() = CellState( | ||
location = location, | ||
day = day, | ||
startPeriod = startPeriod, | ||
endPeriod = endPeriod, | ||
) | ||
|
||
internal fun CellEditorArgument.toState() = CellEditorState( | ||
lectureName = name, | ||
professorName = professorName, | ||
cellStateList = cellList.map { it.toState() }.toPersistentList(), | ||
selectedTimetableCellColor = timetableCellColor, | ||
) | ||
|
||
sealed interface CellEditorSideEffect { | ||
data object PopBackStack : CellEditorSideEffect | ||
data class HandleException(val throwable: Throwable) : CellEditorSideEffect | ||
data class ShowToast(val msg: String) : CellEditorSideEffect | ||
data object ShowAddSuccessCellToast : CellEditorSideEffect | ||
data object ShowEditSuccessCellToast : CellEditorSideEffect | ||
data object ShowNeedLectureNameToast : CellEditorSideEffect | ||
data object ShowNeedProfessorNameToast : CellEditorSideEffect | ||
data object ShowNeedLocationToast : CellEditorSideEffect | ||
} |
Oops, something went wrong.