forked from Olympic/NTO-2025-Android-TeamTask
upload
This commit is contained in:
155
app/src/main/java/ru/myitschool/work/ui/Composables.kt
Normal file
155
app/src/main/java/ru/myitschool/work/ui/Composables.kt
Normal file
@@ -0,0 +1,155 @@
|
||||
package ru.myitschool.work.ui
|
||||
|
||||
import androidx.compose.foundation.Image
|
||||
import androidx.compose.foundation.layout.RowScope
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.shape.RoundedCornerShape
|
||||
import androidx.compose.material3.Button
|
||||
import androidx.compose.material3.ButtonDefaults
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.material3.TextField
|
||||
import androidx.compose.material3.TextFieldDefaults
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.runtime.setValue
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.graphics.Color
|
||||
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 ru.myitschool.work.R
|
||||
import ru.myitschool.work.ui.theme.Gray
|
||||
import ru.myitschool.work.ui.theme.Typography
|
||||
|
||||
@Composable
|
||||
fun BaseText24(
|
||||
text: String,
|
||||
modifier: Modifier = Modifier,
|
||||
color: Color = Color.Unspecified,
|
||||
textAlign: TextAlign = TextAlign.Left
|
||||
) {
|
||||
Text(
|
||||
text = text,
|
||||
fontSize = 24.sp,
|
||||
style = _root_ide_package_.ru.myitschool.work.ui.theme.Typography.bodyLarge,
|
||||
modifier = modifier,
|
||||
color = color,
|
||||
textAlign = textAlign
|
||||
)
|
||||
}
|
||||
|
||||
@Composable
|
||||
fun Logo() {
|
||||
Image(
|
||||
painter = painterResource(R.drawable.logo),
|
||||
contentDescription = "Logo",
|
||||
modifier = Modifier.padding(top = 40.dp, bottom = 60.dp)
|
||||
)
|
||||
}
|
||||
|
||||
@Composable
|
||||
fun BaseText16(
|
||||
text: String,
|
||||
modifier: Modifier = Modifier,
|
||||
color: Color = Color.Unspecified
|
||||
) {
|
||||
Text(
|
||||
text = text,
|
||||
style = _root_ide_package_.ru.myitschool.work.ui.theme.Typography.bodySmall,
|
||||
fontSize = 16.sp,
|
||||
color = color,
|
||||
modifier = modifier
|
||||
)
|
||||
}
|
||||
|
||||
@Composable
|
||||
fun BaseText12(
|
||||
modifier: Modifier = Modifier,
|
||||
text: String,
|
||||
color: Color = Color.Unspecified,
|
||||
) {
|
||||
Text(
|
||||
text = text,
|
||||
style = _root_ide_package_.ru.myitschool.work.ui.theme.Typography.bodySmall,
|
||||
fontSize = 12.sp,
|
||||
color = color,
|
||||
modifier = modifier,
|
||||
)
|
||||
}
|
||||
|
||||
@Composable
|
||||
fun BaseInputText(
|
||||
placeholder: String= "",
|
||||
modifier: Modifier = Modifier
|
||||
) {
|
||||
|
||||
var textState by remember { mutableStateOf("") }
|
||||
|
||||
TextField(
|
||||
value = textState,
|
||||
onValueChange = {
|
||||
textState = it
|
||||
},
|
||||
shape = RoundedCornerShape(16.dp),
|
||||
placeholder = {
|
||||
_root_ide_package_.ru.myitschool.work.ui.BaseText16(
|
||||
text = placeholder,
|
||||
color = _root_ide_package_.ru.myitschool.work.ui.theme.Gray
|
||||
)
|
||||
},
|
||||
textStyle = _root_ide_package_.ru.myitschool.work.ui.theme.Typography.bodySmall.copy(fontSize = 16.sp),
|
||||
colors = TextFieldDefaults.colors(
|
||||
focusedIndicatorColor = Color.Transparent,
|
||||
unfocusedIndicatorColor = Color.Transparent,
|
||||
disabledIndicatorColor = Color.Transparent,
|
||||
errorIndicatorColor = Color.Transparent
|
||||
),
|
||||
singleLine = true,
|
||||
modifier = modifier
|
||||
)
|
||||
}
|
||||
|
||||
@Composable
|
||||
fun BaseText20(
|
||||
text: String,
|
||||
color: Color = Color.Unspecified,
|
||||
style: TextStyle = _root_ide_package_.ru.myitschool.work.ui.theme.Typography.bodySmall,
|
||||
) {
|
||||
Text(
|
||||
text = text,
|
||||
style = style,
|
||||
fontSize = 20.sp,
|
||||
modifier = Modifier.padding(7.dp),
|
||||
color = color
|
||||
)
|
||||
}
|
||||
|
||||
@Composable
|
||||
fun BaseButton(
|
||||
text: String,
|
||||
btnColor: Color,
|
||||
btnContentColor: Color,
|
||||
onClick: () -> Unit,
|
||||
icon: @Composable RowScope.() -> Unit = {},
|
||||
modifier: Modifier = Modifier.fillMaxWidth()
|
||||
) {
|
||||
Button(
|
||||
onClick = onClick,
|
||||
colors = ButtonDefaults.buttonColors(
|
||||
containerColor = btnColor,
|
||||
contentColor = btnContentColor,
|
||||
disabledContainerColor = btnColor,
|
||||
disabledContentColor = btnContentColor
|
||||
),
|
||||
modifier = modifier,
|
||||
shape = RoundedCornerShape(16.dp),
|
||||
) {
|
||||
icon()
|
||||
_root_ide_package_.ru.myitschool.work.ui.BaseText20(text = text)
|
||||
}
|
||||
}
|
||||
@@ -3,4 +3,4 @@ package ru.myitschool.work.ui.nav
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
@Serializable
|
||||
data object AuthScreenDestination: AppDestination
|
||||
data object AuthScreenDestination: ru.myitschool.work.ui.nav.AppDestination
|
||||
@@ -3,4 +3,4 @@ package ru.myitschool.work.ui.nav
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
@Serializable
|
||||
data object BookScreenDestination: AppDestination
|
||||
data object BookScreenDestination: ru.myitschool.work.ui.nav.AppDestination
|
||||
@@ -3,4 +3,4 @@ package ru.myitschool.work.ui.nav
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
@Serializable
|
||||
data object MainScreenDestination: AppDestination
|
||||
data object MainScreenDestination: ru.myitschool.work.ui.nav.AppDestination
|
||||
@@ -29,7 +29,8 @@ fun AppNavHost(
|
||||
startDestination = AuthScreenDestination,
|
||||
) {
|
||||
composable<AuthScreenDestination> {
|
||||
AuthScreen(navController = navController)
|
||||
AuthScreen(
|
||||
navController = navController)
|
||||
}
|
||||
composable<MainScreenDestination> {
|
||||
Box(
|
||||
|
||||
@@ -30,68 +30,126 @@ import androidx.lifecycle.viewmodel.compose.viewModel
|
||||
import androidx.navigation.NavController
|
||||
import ru.myitschool.work.R
|
||||
import ru.myitschool.work.core.TestIds
|
||||
import ru.myitschool.work.ui.BaseButton
|
||||
import ru.myitschool.work.ui.BaseInputText
|
||||
import ru.myitschool.work.ui.BaseText12
|
||||
import ru.myitschool.work.ui.BaseText24
|
||||
import ru.myitschool.work.ui.Logo
|
||||
import ru.myitschool.work.ui.nav.MainScreenDestination
|
||||
import ru.myitschool.work.ui.theme.Blue
|
||||
import ru.myitschool.work.ui.theme.Red
|
||||
import ru.myitschool.work.ui.theme.White
|
||||
|
||||
|
||||
@Composable
|
||||
fun AuthScreen(
|
||||
viewModel: AuthViewModel = viewModel(),
|
||||
navController: NavController
|
||||
) {
|
||||
val state by viewModel.uiState.collectAsState()
|
||||
|
||||
LaunchedEffect(Unit) {
|
||||
viewModel.actionFlow.collect {
|
||||
navController.navigate(MainScreenDestination)
|
||||
}
|
||||
}
|
||||
|
||||
Column(
|
||||
modifier = Modifier
|
||||
.fillMaxSize()
|
||||
.padding(all = 24.dp),
|
||||
horizontalAlignment = Alignment.CenterHorizontally,
|
||||
verticalArrangement = Arrangement.Center
|
||||
.padding(20.dp)
|
||||
.fillMaxSize(),
|
||||
horizontalAlignment = Alignment.CenterHorizontally
|
||||
) {
|
||||
Text(
|
||||
Logo()
|
||||
|
||||
BaseText24(
|
||||
text = stringResource(R.string.auth_title),
|
||||
style = MaterialTheme.typography.headlineSmall,
|
||||
textAlign = TextAlign.Center
|
||||
)
|
||||
when (val currentState = state) {
|
||||
is AuthState.Data -> Content(viewModel, currentState)
|
||||
is AuthState.Loading -> {
|
||||
CircularProgressIndicator(
|
||||
modifier = Modifier.size(64.dp)
|
||||
|
||||
Column(
|
||||
modifier = Modifier.padding(vertical = 20.dp)
|
||||
) {
|
||||
BaseInputText(
|
||||
placeholder = stringResource(R.string.auth_label),
|
||||
modifier = Modifier.fillMaxWidth()
|
||||
)
|
||||
|
||||
BaseText12(
|
||||
text = "Недействительный код сотрудника",
|
||||
color = Red,
|
||||
modifier = Modifier
|
||||
.padding(
|
||||
start = 10.dp,
|
||||
top = 5.dp,
|
||||
bottom = 0.dp
|
||||
)
|
||||
.fillMaxWidth()
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
BaseButton(
|
||||
text = stringResource(R.string.auth_sign_in),
|
||||
onClick = {},
|
||||
btnColor = Blue,
|
||||
btnContentColor = White
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun Content(
|
||||
viewModel: AuthViewModel,
|
||||
state: AuthState.Data
|
||||
) {
|
||||
var inputText by remember { mutableStateOf("") }
|
||||
Spacer(modifier = Modifier.size(16.dp))
|
||||
TextField(
|
||||
modifier = Modifier.testTag(TestIds.Auth.CODE_INPUT).fillMaxWidth(),
|
||||
value = inputText,
|
||||
onValueChange = {
|
||||
inputText = it
|
||||
viewModel.onIntent(AuthIntent.TextInput(it))
|
||||
},
|
||||
label = { Text(stringResource(R.string.auth_label)) }
|
||||
)
|
||||
Spacer(modifier = Modifier.size(16.dp))
|
||||
Button(
|
||||
modifier = Modifier.testTag(TestIds.Auth.SIGN_BUTTON).fillMaxWidth(),
|
||||
onClick = {
|
||||
viewModel.onIntent(AuthIntent.Send(inputText))
|
||||
},
|
||||
enabled = true
|
||||
) {
|
||||
Text(stringResource(R.string.auth_sign_in))
|
||||
}
|
||||
}
|
||||
|
||||
//@Composable
|
||||
//fun AuthScreen(
|
||||
// viewModel: AuthViewModel = viewModel(),
|
||||
// navController: NavController
|
||||
//) {
|
||||
// val state by viewModel.uiState.collectAsState()
|
||||
//
|
||||
// LaunchedEffect(Unit) {
|
||||
// viewModel.actionFlow.collect {
|
||||
// navController.navigate(MainScreenDestination)
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// Column(
|
||||
// modifier = Modifier
|
||||
// .fillMaxSize()
|
||||
// .padding(all = 24.dp),
|
||||
// horizontalAlignment = Alignment.CenterHorizontally,
|
||||
// verticalArrangement = Arrangement.Center
|
||||
// ) {
|
||||
// Text(
|
||||
// text = stringResource(R.string.auth_title),
|
||||
// style = MaterialTheme.typography.headlineSmall,
|
||||
// textAlign = TextAlign.Center
|
||||
// )
|
||||
// when (val currentState = state) {
|
||||
// is AuthState.Data -> Content(viewModel, currentState)
|
||||
// is AuthState.Loading -> {
|
||||
// CircularProgressIndicator(
|
||||
// modifier = Modifier.size(64.dp)
|
||||
// )
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
//
|
||||
//@Composable
|
||||
//private fun Content(
|
||||
// viewModel: AuthViewModel,
|
||||
// state: AuthState.Data
|
||||
//) {
|
||||
// var inputText by remember { mutableStateOf("") }
|
||||
// Spacer(modifier = Modifier.size(16.dp))
|
||||
// TextField(
|
||||
// modifier = Modifier.testTag(TestIds.Auth.CODE_INPUT).fillMaxWidth(),
|
||||
// value = inputText,
|
||||
// onValueChange = {
|
||||
// inputText = it
|
||||
// viewModel.onIntent(AuthIntent.TextInput(it))
|
||||
// },
|
||||
// label = { Text(stringResource(R.string.auth_label)) }
|
||||
// )
|
||||
// Spacer(modifier = Modifier.size(16.dp))
|
||||
// Button(
|
||||
// modifier = Modifier.testTag(TestIds.Auth.SIGN_BUTTON).fillMaxWidth(),
|
||||
// onClick = {
|
||||
// viewModel.onIntent(AuthIntent.Send(inputText))
|
||||
// },
|
||||
// enabled = true
|
||||
// ) {
|
||||
// Text(stringResource(R.string.auth_sign_in))
|
||||
// }
|
||||
//}
|
||||
@@ -9,3 +9,11 @@ val Pink80 = Color(0xFFEFB8C8)
|
||||
val Purple40 = Color(0xFF6650a4)
|
||||
val PurpleGrey40 = Color(0xFF625b71)
|
||||
val Pink40 = Color(0xFF7D5260)
|
||||
|
||||
val Blue = Color(0xFF004BFF)
|
||||
|
||||
val Gray = Color(0xFF777777)
|
||||
|
||||
val White = Color(0xFFFFFFFF)
|
||||
|
||||
val Red = Color(0xFFFF4D4D)
|
||||
@@ -2,19 +2,34 @@ package ru.myitschool.work.ui.theme
|
||||
|
||||
import androidx.compose.material3.Typography
|
||||
import androidx.compose.ui.text.TextStyle
|
||||
import androidx.compose.ui.text.font.Font
|
||||
import androidx.compose.ui.text.font.FontFamily
|
||||
import androidx.compose.ui.text.font.FontWeight
|
||||
import androidx.compose.ui.unit.sp
|
||||
import ru.myitschool.work.R
|
||||
|
||||
// Set of Material typography styles to start with
|
||||
val Typography = Typography(
|
||||
bodyLarge = TextStyle(
|
||||
fontFamily = FontFamily.Default,
|
||||
fontWeight = FontWeight.Normal,
|
||||
fontSize = 16.sp,
|
||||
lineHeight = 24.sp,
|
||||
letterSpacing = 0.5.sp
|
||||
|
||||
val MontserratFontFamily = FontFamily(
|
||||
Font(R.font.montserrat_bold, FontWeight.Bold),
|
||||
Font(R.font.montserrat_medium, FontWeight.Medium),
|
||||
Font(R.font.montserrat_semibold, weight = FontWeight.SemiBold)
|
||||
)
|
||||
|
||||
val Typography = Typography(
|
||||
bodySmall = TextStyle(
|
||||
fontFamily = MontserratFontFamily,
|
||||
fontWeight = FontWeight.Medium,
|
||||
),
|
||||
bodyMedium = TextStyle(
|
||||
fontFamily = MontserratFontFamily,
|
||||
fontWeight = FontWeight.SemiBold,
|
||||
),
|
||||
bodyLarge = TextStyle(
|
||||
fontFamily = MontserratFontFamily,
|
||||
fontWeight = FontWeight.Bold,
|
||||
),
|
||||
|
||||
/* Other default text styles to override
|
||||
titleLarge = TextStyle(
|
||||
fontFamily = FontFamily.Default,
|
||||
|
||||
21
app/src/main/res/drawable/logo.xml
Normal file
21
app/src/main/res/drawable/logo.xml
Normal file
@@ -0,0 +1,21 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="53dp"
|
||||
android:height="99dp"
|
||||
android:viewportWidth="53"
|
||||
android:viewportHeight="99">
|
||||
<path
|
||||
android:pathData="M33.501,13.467V35.047H52.507C52.507,24.867 44.587,16.26 33.501,13.467Z"
|
||||
android:fillColor="#004BFF"/>
|
||||
<path
|
||||
android:pathData="M0.267,61.92C0.267,72.08 8.187,80.713 19.274,83.507V61.92H0.267Z"
|
||||
android:fillColor="#004BFF"/>
|
||||
<path
|
||||
android:pathData="M52.781,61.92C52.507,46.767 36.027,41.173 28.594,39.6C25.087,38.84 18.814,36.933 19.007,33.713V13.44C8.621,16.053 -0.293,24.873 0.007,35.473C1.714,53.393 19.207,55.613 29.341,58.88C32.581,60.153 33.861,61.78 33.781,63.333V83.513C44.041,80.993 52.901,72.16 52.781,61.92Z"
|
||||
android:fillColor="#004BFF"/>
|
||||
<path
|
||||
android:pathData="M26.374,85.92C22.941,85.92 20.047,84.867 19.234,83.54L26.374,98.3L33.754,83.513C32.714,84.813 29.821,85.92 26.374,85.92Z"
|
||||
android:fillColor="#004BFF"/>
|
||||
<path
|
||||
android:pathData="M26.661,13.467C29.821,13.467 32.467,12.407 32.467,10.8V2.62C32.467,1.32 29.801,0 26.661,0C23.221,0 20.601,1.053 20.601,2.667V10.813C20.574,12.14 23.221,13.467 26.661,13.467Z"
|
||||
android:fillColor="#004BFF"/>
|
||||
</vector>
|
||||
BIN
app/src/main/res/font/montserrat_bold.ttf
Normal file
BIN
app/src/main/res/font/montserrat_bold.ttf
Normal file
Binary file not shown.
BIN
app/src/main/res/font/montserrat_medium.ttf
Normal file
BIN
app/src/main/res/font/montserrat_medium.ttf
Normal file
Binary file not shown.
BIN
app/src/main/res/font/montserrat_semibold.ttf
Normal file
BIN
app/src/main/res/font/montserrat_semibold.ttf
Normal file
Binary file not shown.
Reference in New Issue
Block a user