mirror of
https://github.com/whyorean/AuroraStore.git
synced 2025-12-23 22:27:55 -05:00
compose: onboarding: Switch to a simple enum class
Signed-off-by: Aayush Gupta <aayushgupta219@gmail.com>
This commit is contained in:
@@ -30,15 +30,15 @@ import androidx.hilt.lifecycle.viewmodel.compose.hiltViewModel
|
||||
import com.aurora.store.R
|
||||
import com.aurora.store.compose.composable.PageIndicator
|
||||
import com.aurora.store.compose.preview.PreviewTemplate
|
||||
import com.aurora.store.compose.ui.onboarding.navigation.ExtraScreen
|
||||
import com.aurora.store.compose.ui.onboarding.navigation.OnboardingPage
|
||||
import com.aurora.store.viewmodel.onboarding.OnboardingViewModel
|
||||
import kotlinx.coroutines.launch
|
||||
|
||||
@Composable
|
||||
fun OnboardingScreen(viewModel: OnboardingViewModel = hiltViewModel()) {
|
||||
val pages = listOfNotNull(
|
||||
ExtraScreen.Welcome,
|
||||
ExtraScreen.Permissions
|
||||
OnboardingPage.WELCOME,
|
||||
OnboardingPage.PERMISSIONS
|
||||
)
|
||||
|
||||
ScreenContent(
|
||||
@@ -49,7 +49,7 @@ fun OnboardingScreen(viewModel: OnboardingViewModel = hiltViewModel()) {
|
||||
|
||||
@Composable
|
||||
private fun ScreenContent(
|
||||
pages: List<ExtraScreen> = emptyList(),
|
||||
pages: List<OnboardingPage> = emptyList(),
|
||||
onFinishOnboarding: () -> Unit = {}
|
||||
) {
|
||||
val pagerState = rememberPagerState { pages.size }
|
||||
@@ -80,8 +80,8 @@ private fun ScreenContent(
|
||||
verticalAlignment = Alignment.Top
|
||||
) { page ->
|
||||
when (pages[page]) {
|
||||
ExtraScreen.Welcome -> WelcomePage()
|
||||
ExtraScreen.Permissions -> PermissionsPage()
|
||||
OnboardingPage.WELCOME -> WelcomePage()
|
||||
OnboardingPage.PERMISSIONS -> PermissionsPage()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -146,7 +146,7 @@ private fun ScreenContent(
|
||||
private fun OnboardingScreenPreview() {
|
||||
PreviewTemplate {
|
||||
ScreenContent(
|
||||
pages = listOf(ExtraScreen.Welcome, ExtraScreen.Permissions)
|
||||
pages = listOf(OnboardingPage.WELCOME, OnboardingPage.PERMISSIONS)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,27 +0,0 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2025 The Calyx Institute
|
||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
*/
|
||||
|
||||
package com.aurora.store.compose.ui.onboarding.navigation
|
||||
|
||||
import android.os.Parcelable
|
||||
import androidx.navigation3.runtime.NavKey
|
||||
import kotlinx.parcelize.Parcelize
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
/**
|
||||
* Extra destinations for onboarding
|
||||
*
|
||||
* All of these destinations are child destinations of onboarding screen are shown inside it.
|
||||
*/
|
||||
@Parcelize
|
||||
@Serializable
|
||||
sealed class ExtraScreen : NavKey, Parcelable {
|
||||
|
||||
@Serializable
|
||||
data object Welcome : ExtraScreen()
|
||||
|
||||
@Serializable
|
||||
data object Permissions : ExtraScreen()
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2025 Aurora OSS
|
||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
*/
|
||||
|
||||
package com.aurora.store.compose.ui.onboarding.navigation
|
||||
|
||||
enum class OnboardingPage {
|
||||
WELCOME,
|
||||
PERMISSIONS,
|
||||
}
|
||||
Reference in New Issue
Block a user