diff --git a/presentation/src/main/java/com/nto/presentation/composable/cards/VisitCard.kt b/presentation/src/main/java/com/nto/presentation/composable/cards/VisitCard.kt index 576aef3..6088ac4 100644 --- a/presentation/src/main/java/com/nto/presentation/composable/cards/VisitCard.kt +++ b/presentation/src/main/java/com/nto/presentation/composable/cards/VisitCard.kt @@ -6,7 +6,6 @@ import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Row 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.layout.width @@ -65,7 +64,7 @@ fun VisitCard(data: VisitCardDTO, modifier: Modifier = Modifier) { ) Spacer(modifier = Modifier.height(10.dp)) Text( - text = stringResource(if (data.isCode) R.string.qr_login_label else R.string.card_login_label), + text = stringResource(if (data.isCode) R.string.label_qr_login else R.string.label_card_login), style = NTOTheme.typography.displaySmall, fontSize = 12.sp, color = NTOTheme.colors.disabledText diff --git a/presentation/src/main/java/com/nto/presentation/screens/profileScreen/ProfileScreen.kt b/presentation/src/main/java/com/nto/presentation/screens/profileScreen/ProfileScreen.kt index 91a50bf..170576d 100644 --- a/presentation/src/main/java/com/nto/presentation/screens/profileScreen/ProfileScreen.kt +++ b/presentation/src/main/java/com/nto/presentation/screens/profileScreen/ProfileScreen.kt @@ -6,7 +6,6 @@ import androidx.compose.foundation.border import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.Column -import androidx.compose.foundation.layout.PaddingValues import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.Spacer import androidx.compose.foundation.layout.fillMaxSize @@ -19,12 +18,11 @@ import androidx.compose.foundation.lazy.LazyColumn import androidx.compose.foundation.lazy.items import androidx.compose.foundation.shape.CircleShape import androidx.compose.foundation.shape.RoundedCornerShape -import androidx.compose.material.icons.Icons -import androidx.compose.material.icons.automirrored.filled.ExitToApp import androidx.compose.material3.Icon import androidx.compose.material3.IconButton import androidx.compose.material3.Text import androidx.compose.runtime.Composable +import androidx.compose.runtime.collectAsState import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.draw.clip @@ -37,7 +35,6 @@ import androidx.compose.ui.unit.sp import androidx.hilt.navigation.compose.hiltViewModel import androidx.navigation.NavController import androidx.navigation.compose.rememberNavController -import com.nto.data.models.cards.VisitCardDTO import com.nto.presentation.R import com.nto.presentation.composable.DecoratedButton import com.nto.presentation.composable.cards.VisitCard @@ -50,6 +47,8 @@ fun ProfileScreen( modifier: Modifier = Modifier, viewModel: ProfileViewModel = hiltViewModel(), ) { + val state = viewModel.state.collectAsState().value + Column( modifier = modifier.background(NTOTheme.colors.primaryBackground) ) { @@ -80,7 +79,7 @@ fun ProfileScreen( contentAlignment = Alignment.Center ) { IconButton(modifier = Modifier.size(25.dp), onClick = { - //TODO + viewModel.admin(navController) }) { Icon( painter = painterResource(R.drawable.icon_admin), @@ -99,7 +98,7 @@ fun ProfileScreen( contentAlignment = Alignment.Center ) { IconButton(modifier = Modifier.size(25.dp), onClick = { - //TODO + viewModel.option(navController) }) { Icon( painter = painterResource(R.drawable.icon_options), @@ -118,7 +117,7 @@ fun ProfileScreen( contentAlignment = Alignment.Center ) { IconButton(modifier = Modifier.size(25.dp), onClick = { - //TODO + viewModel.logout(navController) }) { Icon( painter = painterResource(R.drawable.icon_logout), @@ -151,23 +150,23 @@ fun ProfileScreen( .padding(10.dp) ) { Text( - "Левченко", + state.secondName, style = NTOTheme.typography.displaySmall, fontWeight = FontWeight.Bold ) Text( - "Егор", + state.firstName, style = NTOTheme.typography.displaySmall, fontWeight = FontWeight.Bold ) Text( - "Ростиславович", + state.thirdName, style = NTOTheme.typography.displaySmall, fontWeight = FontWeight.Bold ) Spacer(modifier = Modifier.height(10.dp)) Text( - "Senior UI/UX Designer", + state.job, style = NTOTheme.typography.placeholder, color = TextGray ) @@ -185,32 +184,30 @@ fun ProfileScreen( horizontalArrangement = Arrangement.SpaceBetween ) { Text( - "Последний вход:", style = NTOTheme.typography.placeholder, fontSize = 12.sp + stringResource(R.string.lablel_last_visit), + style = NTOTheme.typography.placeholder, + fontSize = 12.sp ) Text( - "24 января 20:01", style = NTOTheme.typography.placeholder, fontSize = 12.sp + state.lastOpen, style = NTOTheme.typography.placeholder, fontSize = 12.sp ) } Spacer(modifier = Modifier.height(20.dp)) Text( - "Посещения", + stringResource(R.string.lablel_visits), style = NTOTheme.typography.displaySmall, fontWeight = FontWeight.Bold ) Spacer(modifier = Modifier.height(10.dp)) - val test = mutableListOf( - VisitCardDTO("Кабинет 207", "id: 129008", "24 января 20:01"), - VisitCardDTO("Кабинет 207", "id: 129008", "24 января 20:01"), - VisitCardDTO("Кабинет 207", "id: 129008", "24 января 20:01") - ) + LazyColumn(verticalArrangement = Arrangement.spacedBy(10.dp)) { - items(test) { item -> + items(state.visits) { item -> VisitCard(item) } } } DecoratedButton( - "Сканировать код", + stringResource(R.string.lablel_scan), false, modifier = Modifier .padding(10.dp) diff --git a/presentation/src/main/java/com/nto/presentation/screens/profileScreen/ProfileState.kt b/presentation/src/main/java/com/nto/presentation/screens/profileScreen/ProfileState.kt index 0e40570..e6f467e 100644 --- a/presentation/src/main/java/com/nto/presentation/screens/profileScreen/ProfileState.kt +++ b/presentation/src/main/java/com/nto/presentation/screens/profileScreen/ProfileState.kt @@ -1,8 +1,12 @@ package com.nto.presentation.screens.profileScreen +import com.nto.data.models.cards.VisitCardDTO + data class ProfileState( - val firstName: String, - val secondName: String, - val thirdName: String, - val lastOpen: String + val firstName: String = "", + val secondName: String = "", + val thirdName: String = "", + val lastOpen: String = "", + val job: String = "", + val visits: List = listOf() ) diff --git a/presentation/src/main/java/com/nto/presentation/screens/profileScreen/ProfileViewModel.kt b/presentation/src/main/java/com/nto/presentation/screens/profileScreen/ProfileViewModel.kt index 6f51cb8..a63d918 100644 --- a/presentation/src/main/java/com/nto/presentation/screens/profileScreen/ProfileViewModel.kt +++ b/presentation/src/main/java/com/nto/presentation/screens/profileScreen/ProfileViewModel.kt @@ -3,10 +3,30 @@ package com.nto.presentation.screens.profileScreen import androidx.lifecycle.ViewModel import androidx.navigation.NavController import dagger.hilt.android.lifecycle.HiltViewModel +import kotlinx.coroutines.flow.MutableStateFlow +import kotlinx.coroutines.flow.StateFlow +import kotlinx.coroutines.flow.asStateFlow import javax.inject.Inject @HiltViewModel class ProfileViewModel @Inject constructor() : ViewModel() { + private val _state = MutableStateFlow(ProfileState()) + + val state: StateFlow + get() = _state.asStateFlow() + + fun admin(navController: NavController){ + //TODO + } + + fun option(navController: NavController){ + //TODO + } + + fun logout(navController: NavController){ + //TODO + } + fun scan(navController: NavController) { //TODO } diff --git a/presentation/src/main/res/values/strings.xml b/presentation/src/main/res/values/strings.xml index cd78983..386c2a1 100644 --- a/presentation/src/main/res/values/strings.xml +++ b/presentation/src/main/res/values/strings.xml @@ -8,6 +8,9 @@ example@mail.com ********** Профиль - Вход по коду - Вход по карте + Вход по коду + Вход по карте + Последний вход: + Посещения + Сканировать код \ No newline at end of file