|
@@ -1,35 +1,28 @@
|
|
|
package com.fastest.pass.login.presentation.components
|
|
|
|
|
|
-import android.content.Intent
|
|
|
-import android.location.Location
|
|
|
-import android.util.Log
|
|
|
import androidx.compose.foundation.Image
|
|
|
import androidx.compose.foundation.background
|
|
|
import androidx.compose.foundation.border
|
|
|
import androidx.compose.foundation.clickable
|
|
|
import androidx.compose.foundation.layout.Arrangement
|
|
|
import androidx.compose.foundation.layout.Box
|
|
|
-import androidx.compose.foundation.layout.BoxScope
|
|
|
import androidx.compose.foundation.layout.Column
|
|
|
import androidx.compose.foundation.layout.ColumnScope
|
|
|
import androidx.compose.foundation.layout.Row
|
|
|
import androidx.compose.foundation.layout.Spacer
|
|
|
-import androidx.compose.foundation.layout.fillMaxHeight
|
|
|
import androidx.compose.foundation.layout.fillMaxSize
|
|
|
import androidx.compose.foundation.layout.fillMaxWidth
|
|
|
import androidx.compose.foundation.layout.height
|
|
|
-import androidx.compose.foundation.layout.navigationBarsPadding
|
|
|
import androidx.compose.foundation.layout.padding
|
|
|
import androidx.compose.foundation.layout.size
|
|
|
import androidx.compose.foundation.layout.statusBarsPadding
|
|
|
import androidx.compose.foundation.layout.width
|
|
|
import androidx.compose.foundation.shape.RoundedCornerShape
|
|
|
+import androidx.compose.foundation.text.ClickableText
|
|
|
import androidx.compose.foundation.text.KeyboardActions
|
|
|
import androidx.compose.foundation.text.KeyboardOptions
|
|
|
-import androidx.compose.material.icons.Icons
|
|
|
import androidx.compose.material3.Button
|
|
|
import androidx.compose.material3.ButtonDefaults
|
|
|
-import androidx.compose.material3.Icon
|
|
|
import androidx.compose.material3.IconButton
|
|
|
import androidx.compose.material3.MaterialTheme
|
|
|
import androidx.compose.material3.Surface
|
|
@@ -45,18 +38,14 @@ import androidx.compose.ui.Alignment
|
|
|
import androidx.compose.ui.Modifier
|
|
|
import androidx.compose.ui.draw.clip
|
|
|
import androidx.compose.ui.focus.FocusManager
|
|
|
-import androidx.compose.ui.graphics.Color
|
|
|
import androidx.compose.ui.graphics.ColorFilter
|
|
|
-import androidx.compose.ui.graphics.Shape
|
|
|
-import androidx.compose.ui.graphics.vector.ImageVector
|
|
|
-import androidx.compose.ui.platform.LocalContext
|
|
|
import androidx.compose.ui.platform.LocalFocusManager
|
|
|
import androidx.compose.ui.platform.LocalSoftwareKeyboardController
|
|
|
import androidx.compose.ui.platform.SoftwareKeyboardController
|
|
|
import androidx.compose.ui.res.colorResource
|
|
|
import androidx.compose.ui.res.painterResource
|
|
|
import androidx.compose.ui.res.stringResource
|
|
|
-import androidx.compose.ui.res.vectorResource
|
|
|
+import androidx.compose.ui.text.AnnotatedString
|
|
|
import androidx.compose.ui.text.input.ImeAction
|
|
|
import androidx.compose.ui.text.input.KeyboardType
|
|
|
import androidx.compose.ui.text.input.PasswordVisualTransformation
|
|
@@ -64,13 +53,16 @@ import androidx.compose.ui.text.input.VisualTransformation
|
|
|
import androidx.compose.ui.text.style.TextAlign
|
|
|
import androidx.compose.ui.unit.dp
|
|
|
import androidx.compose.ui.unit.sp
|
|
|
-import androidx.lifecycle.viewmodel.compose.viewModel
|
|
|
-import androidx.navigation.NavHostController
|
|
|
import com.fastest.pass.R
|
|
|
-import kotlinx.coroutines.launch
|
|
|
+
|
|
|
+enum class ClickType {
|
|
|
+ SIGNUP_CLICK,
|
|
|
+ FORGOT_PASSWORD_CLICK,
|
|
|
+ GO_BACK
|
|
|
+}
|
|
|
|
|
|
@Composable
|
|
|
-fun LoginScreen() {
|
|
|
+fun LoginScreen(clickType: (ClickType) -> Unit) {
|
|
|
Box(
|
|
|
modifier = Modifier
|
|
|
.background(colorResource(id = R.color.blue_login))
|
|
@@ -83,14 +75,18 @@ fun LoginScreen() {
|
|
|
.padding(top = 0.dp)
|
|
|
.statusBarsPadding()
|
|
|
) {
|
|
|
- ShowHeaderLogin(text = stringResource(R.string.login))
|
|
|
- ShowWelcomeText()
|
|
|
+ ShowHeaderLogin(text = stringResource(R.string.login)) { clickType ->
|
|
|
+ clickType(clickType)
|
|
|
+ }
|
|
|
+ ShowWelcomeText(R.string.enter_master_password, R.string.login) { clickType ->
|
|
|
+ clickType(clickType)
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@Composable
|
|
|
-fun ColumnScope.ShowHeaderLogin(text: String) {
|
|
|
+fun ColumnScope.ShowHeaderLogin(text: String, clickType: (ClickType) -> Unit) {
|
|
|
Row(
|
|
|
modifier = Modifier
|
|
|
.align(Alignment.Start)
|
|
@@ -99,7 +95,9 @@ fun ColumnScope.ShowHeaderLogin(text: String) {
|
|
|
verticalAlignment = Alignment.CenterVertically
|
|
|
) {
|
|
|
IconButton(
|
|
|
- onClick = {},
|
|
|
+ onClick = {
|
|
|
+ clickType.invoke(ClickType.GO_BACK)
|
|
|
+ },
|
|
|
modifier = Modifier
|
|
|
.padding(start = 30.dp)
|
|
|
.size(24.dp, 24.dp)
|
|
@@ -127,7 +125,12 @@ fun ColumnScope.ShowHeaderLogin(text: String) {
|
|
|
}
|
|
|
|
|
|
@Composable
|
|
|
-fun ColumnScope.ShowWelcomeText() {
|
|
|
+fun ColumnScope.ShowWelcomeText(
|
|
|
+ masterPasswordText: Int,
|
|
|
+ buttonText: Int,
|
|
|
+ isFromLogin: Boolean = true,
|
|
|
+ clickType: (ClickType) -> Unit
|
|
|
+) {
|
|
|
val keyboardController = LocalSoftwareKeyboardController.current
|
|
|
val focusManager = LocalFocusManager.current
|
|
|
|
|
@@ -152,7 +155,7 @@ fun ColumnScope.ShowWelcomeText() {
|
|
|
.padding(start = 30.dp, top = 35.dp)
|
|
|
)
|
|
|
Text(
|
|
|
- text = stringResource(id = R.string.enter_master_password),
|
|
|
+ text = stringResource(id = masterPasswordText),
|
|
|
color = colorResource(id = R.color.gray_splash),
|
|
|
style = MaterialTheme.typography.displayLarge.copy(
|
|
|
fontSize = 18.sp
|
|
@@ -168,9 +171,13 @@ fun ColumnScope.ShowWelcomeText() {
|
|
|
Spacer(modifier = Modifier.height(20.dp))
|
|
|
PasswordTextField(keyboardController, focusManager)
|
|
|
Spacer(modifier = Modifier.height(25.dp))
|
|
|
- LoginButton()
|
|
|
- ForgotPasswordText()
|
|
|
- CreateAccountText()
|
|
|
+ LoginButton(buttonText = buttonText)
|
|
|
+ if (isFromLogin) {
|
|
|
+ ForgotPasswordText()
|
|
|
+ CreateAccountText { clickType ->
|
|
|
+ clickType(clickType)
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -267,7 +274,7 @@ fun ColumnScope.PasswordTextField(
|
|
|
.background(color = colorResource(id = R.color.transparent)),
|
|
|
shape = RoundedCornerShape(16.dp),
|
|
|
placeholder = {
|
|
|
- Text(text = "Enter password",
|
|
|
+ Text(text = "Master password",
|
|
|
color = colorResource(id = R.color.gray_splash))
|
|
|
},
|
|
|
// label = {
|
|
@@ -331,7 +338,7 @@ fun ColumnScope.PasswordTextField(
|
|
|
}
|
|
|
|
|
|
@Composable
|
|
|
-fun ColumnScope.LoginButton() {
|
|
|
+fun ColumnScope.LoginButton(buttonText: Int) {
|
|
|
Button(
|
|
|
modifier = Modifier
|
|
|
.padding(start = 30.dp, end = 30.dp,)
|
|
@@ -349,7 +356,7 @@ fun ColumnScope.LoginButton() {
|
|
|
)
|
|
|
{
|
|
|
Text(
|
|
|
- text = stringResource(R.string.login),
|
|
|
+ text = stringResource(id = buttonText),
|
|
|
style = MaterialTheme.typography.bodyMedium.copy(
|
|
|
fontSize = 20.sp,
|
|
|
color = colorResource(id = R.color.white)
|
|
@@ -375,7 +382,7 @@ fun ColumnScope.ForgotPasswordText() {
|
|
|
}
|
|
|
|
|
|
@Composable
|
|
|
-fun ColumnScope.CreateAccountText() {
|
|
|
+fun ColumnScope.CreateAccountText(clickType: (ClickType) -> Unit) {
|
|
|
Row(
|
|
|
modifier = Modifier
|
|
|
.fillMaxWidth()
|
|
@@ -394,14 +401,17 @@ fun ColumnScope.CreateAccountText() {
|
|
|
modifier = Modifier
|
|
|
)
|
|
|
Spacer(modifier = Modifier.width(3.dp))
|
|
|
- Text(
|
|
|
- text = stringResource(id = R.string.create_account),
|
|
|
- color = colorResource(id = R.color.sky_green),
|
|
|
+ ClickableText(
|
|
|
+ text = AnnotatedString(stringResource(id = R.string.create_account)),
|
|
|
+ onClick = {
|
|
|
+ clickType.invoke(ClickType.SIGNUP_CLICK)
|
|
|
+ },
|
|
|
style = MaterialTheme.typography.displayLarge.copy(
|
|
|
- fontSize = 16.sp
|
|
|
+ fontSize = 16.sp,
|
|
|
+ lineHeight = 25.sp,
|
|
|
+ color = colorResource(id = R.color.sky_green),
|
|
|
),
|
|
|
- lineHeight = 25.sp,
|
|
|
- modifier = Modifier
|
|
|
+ modifier = Modifier,
|
|
|
)
|
|
|
}
|
|
|
}
|