Merge remote-tracking branch 'origin/nikolays'
This commit is contained in:
commit
6ab14a31a0
@ -51,7 +51,11 @@ class LoginViewModel @Inject constructor(private val useCase: LoginUseCase, @App
|
||||
}
|
||||
if (result.successful) {
|
||||
Dispatchers.Main {
|
||||
navController.navigate(Destinations.Profile)
|
||||
navController.navigate(Destinations.Profile) {
|
||||
popUpTo<Destinations.Login>() {
|
||||
inclusive = true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -72,7 +72,7 @@ fun ProfileScreen(
|
||||
|
||||
LaunchedEffect(state.isUnauthorized) {
|
||||
if (state.isUnauthorized) {
|
||||
viewModel.logout(navController)
|
||||
navController.navigate(Destinations.Login)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,11 +1,18 @@
|
||||
package com.nto.presentation.screens.scanResult
|
||||
|
||||
import androidx.compose.foundation.BorderStroke
|
||||
import androidx.compose.foundation.Image
|
||||
import androidx.compose.foundation.gestures.snapping.SnapPosition
|
||||
import androidx.compose.foundation.layout.Arrangement
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.Spacer
|
||||
import androidx.compose.foundation.layout.fillMaxSize
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.foundation.layout.height
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.shape.RoundedCornerShape
|
||||
import androidx.compose.material3.ButtonDefaults
|
||||
import androidx.compose.material3.OutlinedButton
|
||||
import androidx.compose.material3.Scaffold
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
@ -13,10 +20,20 @@ import androidx.compose.runtime.collectAsState
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.graphics.DefaultShadowColor
|
||||
import androidx.compose.ui.res.painterResource
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.text.font.FontWeight
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.compose.ui.unit.sp
|
||||
import androidx.hilt.navigation.compose.hiltViewModel
|
||||
import androidx.navigation.NavController
|
||||
import com.nto.data.utils.Destinations
|
||||
import com.nto.presentation.R
|
||||
import com.nto.presentation.theme.NTOTheme
|
||||
import com.nto.presentation.theme.playfair
|
||||
import com.nto.presentation.theme.raleway
|
||||
|
||||
@Composable
|
||||
fun ScanResultScreen(
|
||||
@ -25,7 +42,37 @@ fun ScanResultScreen(
|
||||
viewModel: ScanResultViewModel = hiltViewModel()
|
||||
) {
|
||||
val state by viewModel.state.collectAsState()
|
||||
Scaffold { paddingValues ->
|
||||
Scaffold(bottomBar = {
|
||||
val buttonColor = when (state) {
|
||||
ScanResultState.Success -> NTOTheme.colors.button
|
||||
ScanResultState.Error -> NTOTheme.colors.buttonAdmin
|
||||
ScanResultState.Warning -> NTOTheme.colors.warning
|
||||
}
|
||||
OutlinedButton(
|
||||
onClick = {
|
||||
navController.navigate(Destinations.Profile) {
|
||||
popUpTo<Destinations.Scan> {
|
||||
inclusive = true
|
||||
}
|
||||
}
|
||||
},
|
||||
shape = RoundedCornerShape(10.dp),
|
||||
colors = ButtonDefaults.outlinedButtonColors(
|
||||
contentColor = buttonColor,
|
||||
containerColor = Color.Transparent
|
||||
),
|
||||
border = BorderStroke(width = 2.dp, color = buttonColor),
|
||||
modifier = Modifier.padding(horizontal = 24.dp, vertical = 32.dp)
|
||||
.fillMaxWidth()
|
||||
.height(62.dp)
|
||||
) {
|
||||
Text(
|
||||
text = stringResource(R.string.close),
|
||||
fontSize = 14.sp,
|
||||
fontWeight = FontWeight.SemiBold
|
||||
)
|
||||
}
|
||||
}) { paddingValues ->
|
||||
Column(
|
||||
Modifier
|
||||
.padding(paddingValues)
|
||||
@ -42,7 +89,27 @@ fun ScanResultScreen(
|
||||
}
|
||||
), contentDescription = ""
|
||||
)
|
||||
Text(text = "Код отсканирован")
|
||||
Text(
|
||||
text = stringResource(R.string.code_scanned),
|
||||
fontFamily = playfair,
|
||||
fontSize = 36.sp,
|
||||
color = NTOTheme.colors.primaryText
|
||||
)
|
||||
Spacer(Modifier.height(8.dp))
|
||||
Text(
|
||||
text = stringResource(
|
||||
when (state) {
|
||||
ScanResultState.Success -> R.string.code_scanned_success
|
||||
ScanResultState.Error -> R.string.code_scanned_error
|
||||
ScanResultState.Warning -> R.string.code_scanned_warning
|
||||
}
|
||||
),
|
||||
fontSize = 20.sp,
|
||||
fontWeight = FontWeight.Medium,
|
||||
color = NTOTheme.colors.primaryText,
|
||||
fontFamily = raleway
|
||||
)
|
||||
Spacer(Modifier.height(60.dp))
|
||||
}
|
||||
}
|
||||
}
|
@ -8,6 +8,7 @@ import dagger.hilt.android.lifecycle.HiltViewModel
|
||||
import kotlinx.coroutines.flow.MutableStateFlow
|
||||
import kotlinx.coroutines.flow.asStateFlow
|
||||
import javax.inject.Inject
|
||||
import kotlin.random.Random
|
||||
|
||||
@HiltViewModel
|
||||
class ScanResultViewModel @Inject constructor(
|
||||
@ -19,6 +20,12 @@ class ScanResultViewModel @Inject constructor(
|
||||
|
||||
init {
|
||||
// TODO: create method to scan qr on server
|
||||
_state.value = when (Random.nextInt(0, 3)) {
|
||||
0 -> ScanResultState.Success
|
||||
1 -> ScanResultState.Error
|
||||
2 -> ScanResultState.Warning
|
||||
else -> ScanResultState.Warning
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -11,6 +11,7 @@ val Background = Color(0xFFFEFBFF)
|
||||
val Green = Color(0xFF738D73)
|
||||
val GreenDisabled = Color(0xFFCAD5CA)
|
||||
val Error = Color(0xFFD28989)
|
||||
val Warning = Color(0xFFCFC37F)
|
||||
|
||||
@Immutable
|
||||
data class AppColors(
|
||||
@ -24,6 +25,7 @@ data class AppColors(
|
||||
val buttonDisabled: Color,
|
||||
val buttonAdmin: Color,
|
||||
val tint: Color,
|
||||
val warning: Color,
|
||||
|
||||
)
|
||||
|
||||
@ -39,7 +41,8 @@ val LocalAppColors = staticCompositionLocalOf {
|
||||
button = Color.Unspecified,
|
||||
buttonDisabled = Color.Unspecified,
|
||||
buttonAdmin = Color.Unspecified,
|
||||
tint = Color.Unspecified
|
||||
tint = Color.Unspecified,
|
||||
warning = Color.Unspecified
|
||||
)
|
||||
}
|
||||
|
||||
@ -53,5 +56,6 @@ val extendedColor = AppColors(
|
||||
button = Green,
|
||||
buttonDisabled = GreenDisabled,
|
||||
buttonAdmin = Error,
|
||||
tint = Color.Black
|
||||
tint = Color.Black,
|
||||
warning = Warning
|
||||
)
|
@ -1,4 +1,25 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<string name="app_name">presentation</string>
|
||||
<string name="app_name">SKUF Company</string>
|
||||
<string name="action_login">Sign in</string>
|
||||
<string name="text_login">Login</string>
|
||||
<string name="text_password">Password</string>
|
||||
<string name="greeting_login_description">Sign to your account to continue</string>
|
||||
<string name="greeting_login">Sign in</string>
|
||||
<string name="title_profile">Profile</string>
|
||||
<string name="label_qr_login">Enter by code</string>
|
||||
<string name="label_card_login">Enter by card</string>
|
||||
<string name="label_last_visit">Last visit:</string>
|
||||
<string name="label_visits">Visits</string>
|
||||
<string name="label_scan">Scan QR</string>
|
||||
<string name="label_tester">Tester</string>
|
||||
<string name="label_developer">Developer</string>
|
||||
<string name="label_designer">Designer</string>
|
||||
<string name="label_analyst">Analytics</string>
|
||||
<string name="label_administrator">Administrator</string>
|
||||
<string name="code_scanned">Code scanned</string>
|
||||
<string name="code_scanned_success">Success</string>
|
||||
<string name="code_scanned_error">Enter was cancelled</string>
|
||||
<string name="code_scanned_warning">Something went wrong</string>
|
||||
<string name="close">Close</string>
|
||||
</resources>
|
@ -1,5 +1,5 @@
|
||||
<resources>
|
||||
<string name="app_name">presentation</string>
|
||||
<string name="app_name">СКУД</string>
|
||||
<string name="action_login">Войти</string>
|
||||
<string name="text_login">Логин</string>
|
||||
<string name="text_password">Пароль</string>
|
||||
@ -18,4 +18,9 @@
|
||||
<string name="label_designer">Дизайнер</string>
|
||||
<string name="label_analyst">Аналитик</string>
|
||||
<string name="label_administrator">Администратор</string>
|
||||
<string name="code_scanned">Код отсканирован</string>
|
||||
<string name="code_scanned_success">Успешно</string>
|
||||
<string name="code_scanned_error">Вход был отменён</string>
|
||||
<string name="code_scanned_warning">Что-то пошло не так</string>
|
||||
<string name="close">Закрыть</string>
|
||||
</resources>
|
Loading…
x
Reference in New Issue
Block a user