|
@@ -0,0 +1,188 @@
|
|
|
+package com.fastest.pass.welcome.presentation.ui.component
|
|
|
+
|
|
|
+import androidx.compose.foundation.Image
|
|
|
+import androidx.compose.foundation.background
|
|
|
+import androidx.compose.foundation.clickable
|
|
|
+import androidx.compose.foundation.layout.Arrangement
|
|
|
+import androidx.compose.foundation.layout.Box
|
|
|
+import androidx.compose.foundation.layout.Column
|
|
|
+import androidx.compose.foundation.layout.Row
|
|
|
+import androidx.compose.foundation.layout.Spacer
|
|
|
+import androidx.compose.foundation.layout.WindowInsets
|
|
|
+import androidx.compose.foundation.layout.fillMaxSize
|
|
|
+import androidx.compose.foundation.layout.fillMaxWidth
|
|
|
+import androidx.compose.foundation.layout.height
|
|
|
+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.material.Text
|
|
|
+import androidx.compose.runtime.Composable
|
|
|
+import androidx.compose.ui.Alignment
|
|
|
+import androidx.compose.ui.Modifier
|
|
|
+import androidx.compose.ui.graphics.Color
|
|
|
+import androidx.compose.ui.res.colorResource
|
|
|
+import androidx.compose.ui.res.painterResource
|
|
|
+import androidx.compose.ui.text.TextStyle
|
|
|
+import androidx.compose.ui.text.style.TextAlign
|
|
|
+import androidx.compose.ui.unit.dp
|
|
|
+import androidx.compose.ui.unit.sp
|
|
|
+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,
|
|
|
+ SIGNUP_CLICK
|
|
|
+}
|
|
|
+
|
|
|
+@Composable
|
|
|
+fun WelcomeTutorial(onClick: (ClickType) -> Unit) {
|
|
|
+ val pagerState = rememberPagerState()
|
|
|
+ val pages = listOf(
|
|
|
+ Welcome(
|
|
|
+ "Welcome to LockMyPass",
|
|
|
+ R.drawable.welcome_1,
|
|
|
+ "LockMyPass securely stores, synchronizes, \nand manages your passwords and personal \ndata across all your devices.",
|
|
|
+ ),
|
|
|
+ Welcome(
|
|
|
+ "Never forget again",
|
|
|
+ R.drawable.welcome_2,
|
|
|
+ "With just one master password, you can \naccess all the websites you use.",
|
|
|
+ ),
|
|
|
+ Welcome(
|
|
|
+ "Trusted and secure",
|
|
|
+ R.drawable.welcome_3,
|
|
|
+ "Your vault is secured with top-tier security \nmeasures. It's so secure that even we\n cannot access your passwords.",
|
|
|
+ )
|
|
|
+ )
|
|
|
+
|
|
|
+ Column(
|
|
|
+ modifier = Modifier
|
|
|
+ .fillMaxWidth()
|
|
|
+ .windowInsetsPadding(WindowInsets.navigationBars) // Adds space for system navigation
|
|
|
+ ) {
|
|
|
+ Row(
|
|
|
+ modifier = Modifier
|
|
|
+ .fillMaxWidth()
|
|
|
+ .height(75.dp)
|
|
|
+ .background(colorResource(id = R.color.gray_splash))
|
|
|
+ ) { }
|
|
|
+
|
|
|
+ Box(modifier = Modifier.fillMaxSize()) {
|
|
|
+
|
|
|
+ HorizontalPager(
|
|
|
+ count = pages.size,
|
|
|
+ state = pagerState,
|
|
|
+ modifier = Modifier.fillMaxSize()
|
|
|
+ ) { page ->
|
|
|
+
|
|
|
+ WelcomePage(
|
|
|
+ title = pages[page].title,
|
|
|
+ description = pages[page].description,
|
|
|
+ imageRes = pages[page].image,
|
|
|
+ page
|
|
|
+ ) { type ->
|
|
|
+ onClick(type)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // Pager Indicator
|
|
|
+ HorizontalPagerIndicator(
|
|
|
+ pagerState = pagerState,
|
|
|
+ modifier = Modifier
|
|
|
+ .align(Alignment.BottomCenter)
|
|
|
+ .padding(vertical = 25.dp),
|
|
|
+ activeColor = Color.White,
|
|
|
+ inactiveColor = Gray_Splash
|
|
|
+ )
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+@Composable
|
|
|
+fun WelcomePage(
|
|
|
+ title: String,
|
|
|
+ description: String,
|
|
|
+ imageRes: Int,
|
|
|
+ page: Int,
|
|
|
+ onClick: (ClickType) -> Unit
|
|
|
+) {
|
|
|
+ Box(
|
|
|
+ modifier = Modifier
|
|
|
+ .fillMaxSize()
|
|
|
+ .background(Welcome_BG)
|
|
|
+ ) {
|
|
|
+ Column(modifier = Modifier.align(Alignment.Center)) {
|
|
|
+ Text(
|
|
|
+ text = title,
|
|
|
+ style = TextStyle(fontSize = 24.sp, textAlign = TextAlign.Center),
|
|
|
+ color = Gray_Splash,
|
|
|
+ modifier = Modifier.fillMaxWidth()
|
|
|
+ )
|
|
|
+
|
|
|
+ Spacer(Modifier.height(120.dp))
|
|
|
+ // Image at the Center
|
|
|
+ Image(
|
|
|
+ painter = painterResource(id = imageRes),
|
|
|
+ contentDescription = null,
|
|
|
+ modifier = Modifier
|
|
|
+ .padding(horizontal = 20.dp)
|
|
|
+ .fillMaxWidth()
|
|
|
+ .height(250.dp)
|
|
|
+
|
|
|
+ )
|
|
|
+ Spacer(Modifier.height(120.dp))
|
|
|
+ // Description at the Bottom
|
|
|
+ Text(
|
|
|
+ text = description,
|
|
|
+ style = TextStyle(fontSize = 15.sp, textAlign = TextAlign.Center),
|
|
|
+ color = Gray_Splash,
|
|
|
+ textAlign = TextAlign.Center,
|
|
|
+ modifier = Modifier
|
|
|
+ .fillMaxWidth()
|
|
|
+
|
|
|
+ )
|
|
|
+ if (page == 2) {
|
|
|
+ Spacer(Modifier.height(50.dp))
|
|
|
+ Row(
|
|
|
+ verticalAlignment = Alignment.CenterVertically,
|
|
|
+ horizontalArrangement = Arrangement.Center,
|
|
|
+ modifier = Modifier
|
|
|
+ .fillMaxWidth()
|
|
|
+ .padding(vertical = 10.dp)
|
|
|
+ ) {
|
|
|
+ Text(
|
|
|
+ text = "LOG IN",
|
|
|
+ style = TextStyle(fontSize = 18.sp),
|
|
|
+ color = Gray_Splash,
|
|
|
+ modifier = Modifier.clickable {
|
|
|
+ onClick.invoke(ClickType.LOGIN_CLICK)
|
|
|
+ }
|
|
|
+ )
|
|
|
+ Spacer(modifier = Modifier.width(8.dp)) // Add spacing between "Login" and "|"
|
|
|
+ Text(
|
|
|
+ text = "|",
|
|
|
+ style = TextStyle(fontSize = 18.sp),
|
|
|
+ color = Gray_Splash
|
|
|
+ )
|
|
|
+ Spacer(modifier = Modifier.width(8.dp)) // Add spacing between "|" and "SignUp"
|
|
|
+ Text(
|
|
|
+ text = "SIGN UP",
|
|
|
+ style = TextStyle(fontSize = 18.sp),
|
|
|
+ color = Gray_Splash,
|
|
|
+ modifier = Modifier.clickable {
|
|
|
+ onClick.invoke(ClickType.SIGNUP_CLICK)
|
|
|
+ }
|
|
|
+ )
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|