главный экран и экран бронирования
This commit is contained in:
@@ -1,17 +1,21 @@
|
|||||||
package ru.myitschool.work.ui.screen.main
|
package ru.myitschool.work.ui.screen.main
|
||||||
|
|
||||||
|
import android.util.Log
|
||||||
import androidx.compose.foundation.Image
|
import androidx.compose.foundation.Image
|
||||||
import androidx.compose.foundation.layout.*
|
import androidx.compose.foundation.layout.*
|
||||||
import androidx.compose.foundation.lazy.LazyColumn
|
import androidx.compose.foundation.lazy.LazyColumn
|
||||||
import androidx.compose.foundation.lazy.items
|
import androidx.compose.foundation.lazy.items
|
||||||
|
import androidx.compose.foundation.lazy.itemsIndexed
|
||||||
import androidx.compose.material3.*
|
import androidx.compose.material3.*
|
||||||
import androidx.compose.runtime.*
|
import androidx.compose.runtime.*
|
||||||
import androidx.compose.ui.Alignment
|
import androidx.compose.ui.Alignment
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
|
import androidx.compose.ui.platform.testTag
|
||||||
import androidx.compose.ui.res.painterResource
|
import androidx.compose.ui.res.painterResource
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
import androidx.navigation.NavController
|
import androidx.navigation.NavController
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
|
import ru.myitschool.work.core.TestIds
|
||||||
import java.text.SimpleDateFormat
|
import java.text.SimpleDateFormat
|
||||||
import java.util.*
|
import java.util.*
|
||||||
import ru.myitschool.work.ui.nav.BookScreenDestination
|
import ru.myitschool.work.ui.nav.BookScreenDestination
|
||||||
@@ -77,7 +81,9 @@ fun MainScreen(
|
|||||||
// Текстовое поле с ошибкой (main_error)
|
// Текстовое поле с ошибкой (main_error)
|
||||||
Text(
|
Text(
|
||||||
text = errorMessage,
|
text = errorMessage,
|
||||||
color = MaterialTheme.colorScheme.error
|
color = MaterialTheme.colorScheme.error,
|
||||||
|
modifier = Modifier.testTag(TestIds.Main.ERROR)
|
||||||
|
|
||||||
)
|
)
|
||||||
|
|
||||||
Spacer(modifier = Modifier.height(16.dp))
|
Spacer(modifier = Modifier.height(16.dp))
|
||||||
@@ -103,7 +109,7 @@ fun MainScreen(
|
|||||||
Image(
|
Image(
|
||||||
painter = painterResource(id = android.R.drawable.ic_menu_gallery),
|
painter = painterResource(id = android.R.drawable.ic_menu_gallery),
|
||||||
contentDescription = "Фото",
|
contentDescription = "Фото",
|
||||||
modifier = Modifier.size(64.dp)
|
modifier = Modifier.size(64.dp).testTag(TestIds.Main.PROFILE_IMAGE)
|
||||||
)
|
)
|
||||||
|
|
||||||
Spacer(modifier = Modifier.width(16.dp))
|
Spacer(modifier = Modifier.width(16.dp))
|
||||||
@@ -112,7 +118,7 @@ fun MainScreen(
|
|||||||
Text(
|
Text(
|
||||||
text = userName,
|
text = userName,
|
||||||
style = MaterialTheme.typography.titleLarge,
|
style = MaterialTheme.typography.titleLarge,
|
||||||
modifier = Modifier.weight(1f),
|
modifier = Modifier.weight(1f).testTag(TestIds.Main.PROFILE_NAME),
|
||||||
color = MaterialTheme.colorScheme.onSurface
|
color = MaterialTheme.colorScheme.onSurface
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -122,9 +128,12 @@ fun MainScreen(
|
|||||||
userName = ""
|
userName = ""
|
||||||
bookingItems = emptyList()
|
bookingItems = emptyList()
|
||||||
navController.navigate("auth") { popUpTo(0) }
|
navController.navigate("auth") { popUpTo(0) }
|
||||||
}) {
|
},
|
||||||
|
modifier = Modifier.testTag(TestIds.Main.LOGOUT_BUTTON)
|
||||||
|
) {
|
||||||
Text("Выход")
|
Text("Выход")
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Spacer(modifier = Modifier.height(16.dp))
|
Spacer(modifier = Modifier.height(16.dp))
|
||||||
@@ -137,7 +146,8 @@ fun MainScreen(
|
|||||||
// Кнопка обновления (main_refresh_button)
|
// Кнопка обновления (main_refresh_button)
|
||||||
Button(
|
Button(
|
||||||
onClick = { loadData() },
|
onClick = { loadData() },
|
||||||
enabled = !isLoading
|
enabled = !isLoading,
|
||||||
|
modifier = Modifier.testTag(TestIds.Main.REFRESH_BUTTON)
|
||||||
) {
|
) {
|
||||||
if (isLoading) {
|
if (isLoading) {
|
||||||
CircularProgressIndicator(
|
CircularProgressIndicator(
|
||||||
@@ -148,9 +158,11 @@ fun MainScreen(
|
|||||||
Text("Обновить")
|
Text("Обновить")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// кнопка бронирования
|
||||||
Button(
|
Button(
|
||||||
onClick = { navController.navigate(BookScreenDestination) }
|
onClick = { navController.navigate(BookScreenDestination)
|
||||||
|
},
|
||||||
|
modifier = Modifier.testTag(TestIds.Main.ADD_BUTTON)
|
||||||
) {
|
) {
|
||||||
Text("Перейти к бронированию")
|
Text("Перейти к бронированию")
|
||||||
}
|
}
|
||||||
@@ -160,9 +172,13 @@ fun MainScreen(
|
|||||||
|
|
||||||
// Список бронирований
|
// Список бронирований
|
||||||
if (bookingItems.isNotEmpty()) {
|
if (bookingItems.isNotEmpty()) {
|
||||||
LazyColumn(modifier = Modifier.weight(1f)) {
|
LazyColumn(
|
||||||
items(bookingItems) { item ->
|
modifier = Modifier.weight(1f)
|
||||||
|
|
||||||
|
) {
|
||||||
|
itemsIndexed(bookingItems) { index, item ->
|
||||||
// Элемент списка (main_book_pos_{index})
|
// Элемент списка (main_book_pos_{index})
|
||||||
|
Log.d("Nicoly", index.toString())
|
||||||
Card(
|
Card(
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.fillMaxWidth()
|
.fillMaxWidth()
|
||||||
@@ -171,11 +187,12 @@ fun MainScreen(
|
|||||||
containerColor = MaterialTheme.colorScheme.surfaceVariant
|
containerColor = MaterialTheme.colorScheme.surfaceVariant
|
||||||
)
|
)
|
||||||
) {
|
) {
|
||||||
Column(modifier = Modifier.padding(16.dp)) {
|
Column(modifier = Modifier.padding(16.dp).testTag(TestIds.Main.getIdItemByPosition(index))) {
|
||||||
// Дата бронирования (main_item_date)
|
// Дата бронирования (main_item_date)
|
||||||
Text(
|
Text(
|
||||||
text = "Дата: ${item.date}",
|
text = "Дата: ${item.date}",
|
||||||
color = MaterialTheme.colorScheme.onSurfaceVariant
|
color = MaterialTheme.colorScheme.onSurfaceVariant,
|
||||||
|
modifier = Modifier.testTag(TestIds.Main.ITEM_DATE)
|
||||||
)
|
)
|
||||||
|
|
||||||
Spacer(modifier = Modifier.height(4.dp))
|
Spacer(modifier = Modifier.height(4.dp))
|
||||||
@@ -183,7 +200,8 @@ fun MainScreen(
|
|||||||
// Место бронирования (main_item_place)
|
// Место бронирования (main_item_place)
|
||||||
Text(
|
Text(
|
||||||
text = "Место: ${item.place}",
|
text = "Место: ${item.place}",
|
||||||
color = MaterialTheme.colorScheme.onSurfaceVariant
|
color = MaterialTheme.colorScheme.onSurfaceVariant,
|
||||||
|
modifier = Modifier.testTag(TestIds.Main.ITEM_PLACE)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user