Selaa lähdekoodia

Imported library for horizontal pager on welcome screen, app starts with splash screen then navigate to welcome screen after 2 sec delay

Khubaib 7 kuukautta sitten
vanhempi
commit
8e0100ebfa

+ 3 - 3
app/src/main/java/com/fastest/pass/splash/presentation/components/SplashScreen.kt

@@ -19,9 +19,9 @@ import com.fastest.pass.splash.presentation.viewmodels.SplashViewModel
 @Composable
 fun SplashScreen(viewModel: SplashViewModel) {
 
-    LaunchedEffect(key1 = true) {
-        viewModel.checkAuthentication()
-    }
+//    LaunchedEffect(key1 = true) {
+//        viewModel.checkAuthentication()
+//    }
 
     Box(
         modifier = Modifier

+ 5 - 3
app/src/main/java/com/fastest/pass/splash/presentation/ui/SplashFragment.kt

@@ -35,9 +35,11 @@ class SplashFragment : Fragment() {
         return ComposeView(requireActivity()).apply {
             setContent {
 
-                viewModel.navigateToLogin.value?.let {
-                    viewModel.navigateTo(SplashRoute.OpenLogin)
-                }
+//                viewModel.navigateToLogin.value?.let {
+//                    viewModel.navigateTo(SplashRoute.OpenWelcome)
+//                }
+
+                viewModel.checkAuthentication()
 
                 FastestPassTheme {
                     SplashScreen(viewModel)

+ 2 - 2
app/src/main/java/com/fastest/pass/splash/presentation/viewmodels/SplashViewModel.kt

@@ -24,8 +24,8 @@ class SplashViewModel @Inject constructor(var splashUseCase: SplashUseCase) : Vi
     fun checkAuthentication() {
         viewModelScope.launch {
             delay(2000)
-//            navigateTo(SplashRoute.OpenLogin)
-            _navigateToLogin.value = true
+            navigateTo(SplashRoute.OpenWelcome)
+//            _navigateToLogin.value = true
         }
     }
 

+ 3 - 3
app/src/main/java/com/fastest/pass/welcome/presentation/ui/component/WelcomeScreen.kt

@@ -16,8 +16,6 @@ import androidx.compose.foundation.layout.navigationBars
 import androidx.compose.foundation.layout.padding
 import androidx.compose.foundation.layout.width
 import androidx.compose.foundation.layout.windowInsetsPadding
-import androidx.compose.foundation.pager.HorizontalPager
-import androidx.compose.foundation.pager.rememberPagerState
 import androidx.compose.material3.Text
 import androidx.compose.runtime.Composable
 import androidx.compose.ui.Alignment
@@ -33,7 +31,9 @@ import com.fastest.pass.R
 import com.fastest.pass.ui.theme.Gray_Splash
 import com.fastest.pass.ui.theme.Welcome_BG
 import com.fastest.pass.welcome.domain.model.Welcome
+import com.google.accompanist.pager.HorizontalPager
 import com.google.accompanist.pager.HorizontalPagerIndicator
+import com.google.accompanist.pager.rememberPagerState
 
 enum class ClickType {
     LOGIN_CLICK,
@@ -77,7 +77,7 @@ fun WelcomeTutorial(onClick: (ClickType) -> Unit) {
         Box(modifier = Modifier.fillMaxSize()) {
 
             HorizontalPager(
-//                count = pages.size,
+                count = pages.size,
                 state = pagerState,
                 modifier = Modifier.fillMaxSize()
             ) { page ->