-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Mark lesson as completed + refactor * Fix back navigation bug * Remove delay from fake repo * Turn off fakes
- Loading branch information
1 parent
efa94a7
commit 21b88b3
Showing
13 changed files
with
85 additions
and
47 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
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
5 changes: 2 additions & 3 deletions
5
composeApp/src/commonMain/kotlin/ui/screen/lesson/handler/OnBackClickEventHandler.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
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
18 changes: 13 additions & 5 deletions
18
composeApp/src/commonMain/kotlin/ui/screen/lesson/handler/OnFinishClickEventHandler.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,24 +1,32 @@ | ||
package ui.screen.lesson.handler | ||
|
||
import data.lesson.LessonRepository | ||
import domain.SoundUseCase | ||
import ivy.content.SoundsUrls | ||
import navigation.Navigation | ||
import ui.EventHandler | ||
import ui.screen.lesson.LessonEventHandler | ||
import ui.screen.lesson.LessonViewEvent | ||
import ui.screen.lesson.LessonViewModel.LocalState | ||
import ui.screen.lesson.LessonVmContext | ||
import util.Logger | ||
|
||
class OnFinishClickEventHandler( | ||
private val navigation: Navigation, | ||
private val soundUseCase: SoundUseCase | ||
) : | ||
EventHandler<LessonViewEvent.OnFinishClick, LocalState> { | ||
private val soundUseCase: SoundUseCase, | ||
private val lessonRepository: LessonRepository, | ||
private val logger: Logger, | ||
) : LessonEventHandler<LessonViewEvent.OnFinishClick> { | ||
override val eventTypes = setOf(LessonViewEvent.OnFinishClick::class) | ||
|
||
override suspend fun LessonVmContext.handleEvent( | ||
event: LessonViewEvent.OnFinishClick | ||
) { | ||
navigation.navigateBack() | ||
soundUseCase.playSound(SoundsUrls.CompleteLesson) | ||
lessonRepository.markLessonAsCompleted( | ||
course = args.courseId, | ||
lesson = args.lessonId, | ||
).onLeft { errMsg -> | ||
logger.error("Failed to mark lesson as completed because: $errMsg") | ||
} | ||
} | ||
} |
5 changes: 2 additions & 3 deletions
5
composeApp/src/commonMain/kotlin/ui/screen/lesson/handler/OnSoundClickEventHandler.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
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