diff --git a/features/home/impl/src/main/kotlin/com/tangem/features/home/impl/ui/compose/StoriesScreen.kt b/features/home/impl/src/main/kotlin/com/tangem/features/home/impl/ui/compose/StoriesScreen.kt index 704485cb28..8eab486edb 100644 --- a/features/home/impl/src/main/kotlin/com/tangem/features/home/impl/ui/compose/StoriesScreen.kt +++ b/features/home/impl/src/main/kotlin/com/tangem/features/home/impl/ui/compose/StoriesScreen.kt @@ -43,12 +43,18 @@ internal fun StoriesScreen( var currentStory by remember { mutableStateOf(state.firstStory) } val currentStoryIndex by rememberUpdatedState(newValue = state.stepOf(currentStory)) + LaunchedEffect(currentStoryIndex) { + if (currentStoryIndex < 0) { + currentStory = state.firstStory + } + } + val goToPreviousStory = remember(currentStory, currentStoryIndex) { { currentStory = state.stories[max(0, currentStoryIndex - 1)] } } val goToNextStory = remember(currentStory, currentStoryIndex) { { - currentStory = if (currentStoryIndex < state.stories.lastIndex) { + currentStory = if (currentStoryIndex >= 0 && currentStoryIndex < state.stories.lastIndex) { state.stories[currentStoryIndex + 1] } else { state.firstStory diff --git a/features/home/impl/src/main/kotlin/com/tangem/features/home/impl/ui/compose/StoriesScreenV2.kt b/features/home/impl/src/main/kotlin/com/tangem/features/home/impl/ui/compose/StoriesScreenV2.kt index 3f790b2e79..e3a485d2cd 100644 --- a/features/home/impl/src/main/kotlin/com/tangem/features/home/impl/ui/compose/StoriesScreenV2.kt +++ b/features/home/impl/src/main/kotlin/com/tangem/features/home/impl/ui/compose/StoriesScreenV2.kt @@ -33,12 +33,18 @@ internal fun StoriesScreenV2(state: HomeUM, onGetStartedClick: () -> Unit, modif var currentStory by remember { mutableStateOf(state.firstStory) } val currentStoryIndex by rememberUpdatedState(newValue = state.stepOf(currentStory)) + LaunchedEffect(currentStoryIndex) { + if (currentStoryIndex < 0) { + currentStory = state.firstStory + } + } + val goToPreviousStory = remember(currentStory, currentStoryIndex) { { currentStory = state.stories[max(0, currentStoryIndex - 1)] } } val goToNextStory = remember(currentStory, currentStoryIndex) { { - currentStory = if (currentStoryIndex < state.stories.lastIndex) { + currentStory = if (currentStoryIndex >= 0 && currentStoryIndex < state.stories.lastIndex) { state.stories[currentStoryIndex + 1] } else { state.firstStory diff --git a/features/home/impl/src/main/kotlin/com/tangem/features/home/impl/ui/compose/views/StoriesProgressBar.kt b/features/home/impl/src/main/kotlin/com/tangem/features/home/impl/ui/compose/views/StoriesProgressBar.kt index cc6ea2107c..058d371b74 100644 --- a/features/home/impl/src/main/kotlin/com/tangem/features/home/impl/ui/compose/views/StoriesProgressBar.kt +++ b/features/home/impl/src/main/kotlin/com/tangem/features/home/impl/ui/compose/views/StoriesProgressBar.kt @@ -85,7 +85,7 @@ fun StoriesProgressBar( .let { when (index) { currentStep -> it.fillMaxWidth(progress.value) - in 0..currentStep -> it.fillMaxWidth(fraction = 1f) + in 0 until currentStep -> it.fillMaxWidth(fraction = 1f) else -> it } },