-
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.
* Refactor and improve auto-scrolling * Improve lesson text * WIP: Content * Ensure IDs uniqueness * WIP: Content * Finish lesson * Multiple choice question "Select all" UI fix * Fixes * Lesson fixes * Improve question * Improve Lesson card
- Loading branch information
1 parent
1613993
commit 78ac972
Showing
12 changed files
with
424 additions
and
75 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
52 changes: 52 additions & 0 deletions
52
composeApp/src/commonMain/kotlin/ui/screen/lesson/composable/LessonAutoScroll.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,52 @@ | ||
package ui.screen.lesson.composable | ||
|
||
import androidx.compose.foundation.layout.Spacer | ||
import androidx.compose.foundation.layout.height | ||
import androidx.compose.foundation.lazy.LazyListScope | ||
import androidx.compose.foundation.lazy.LazyListState | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.runtime.LaunchedEffect | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.unit.dp | ||
import component.ScreenType.* | ||
import component.screenType | ||
import kotlinx.collections.immutable.ImmutableList | ||
import kotlinx.coroutines.delay | ||
import ui.screen.lesson.LessonItemViewState | ||
import ui.screen.lesson.OpenQuestionItemViewState | ||
import ui.screen.lesson.QuestionItemViewState | ||
|
||
@Composable | ||
fun AutoScrollEffect( | ||
listState: LazyListState, | ||
items: ImmutableList<LessonItemViewState>, | ||
) { | ||
val itemsCount = items.size | ||
LaunchedEffect(itemsCount) { | ||
if (itemsCount >= 2 && !items[itemsCount - 2].isQuestion()) { | ||
// ensure auto scrolls works for images that are loading | ||
repeat(4) { | ||
listState.animateScrollToItem(items.lastIndex) | ||
delay(200) | ||
} | ||
} | ||
} | ||
} | ||
|
||
fun LazyListScope.autoScrollEmptySpace() { | ||
item("empty_space") { | ||
Spacer( | ||
Modifier.height( | ||
when (screenType()) { | ||
Mobile, Tablet -> 32.dp | ||
Desktop -> 136.dp | ||
} | ||
) | ||
) | ||
} | ||
} | ||
|
||
private fun LessonItemViewState.isQuestion(): Boolean = when (this) { | ||
is QuestionItemViewState, is OpenQuestionItemViewState -> true | ||
else -> false | ||
} |
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
Oops, something went wrong.