|
@@ -55,7 +55,7 @@ import androidx.compose.ui.text.style.TextAlign
|
|
|
import androidx.compose.ui.unit.dp
|
|
|
import androidx.compose.ui.unit.sp
|
|
|
import androidx.navigation.NavHostController
|
|
|
-import com.example.oscellamobile.R
|
|
|
+import coil.compose.rememberAsyncImagePainter
|
|
|
import com.example.oscellamobile.domain.utlis.Constant
|
|
|
import com.example.oscellamobile.models.Game
|
|
|
import com.google.accompanist.systemuicontroller.rememberSystemUiController
|
|
@@ -63,21 +63,50 @@ import io.github.jan.supabase.postgrest.from
|
|
|
import kotlinx.coroutines.Dispatchers
|
|
|
import kotlinx.coroutines.delay
|
|
|
import kotlinx.coroutines.withContext
|
|
|
-import org.intellij.lang.annotations.JdkConstants.HorizontalAlignment
|
|
|
import kotlin.math.cos
|
|
|
import kotlin.math.sin
|
|
|
+import com.example.oscellamobile.R
|
|
|
+import com.example.oscellamobile.models.Company
|
|
|
+import coil.compose.AsyncImagePainter
|
|
|
+import coil.compose.rememberAsyncImagePainter
|
|
|
+import coil.request.ImageRequest
|
|
|
+import coil.size.Size
|
|
|
+import org.intellij.lang.annotations.JdkConstants
|
|
|
+
|
|
|
+
|
|
|
+val kdamFontFamily = FontFamily(Font(R.font.kdam))
|
|
|
+val playfairdisplay = FontFamily(Font(R.font.playfair))
|
|
|
+val caveat = FontFamily(Font(R.font.caveat))
|
|
|
+val ibmplexmono = FontFamily(Font(R.font.ibm))
|
|
|
|
|
|
+val gradientButton = Brush.linearGradient(
|
|
|
+ colors = listOf(
|
|
|
+ Color(0xFFE71D36),
|
|
|
+ Color(0xFFFF9F1C)
|
|
|
+ ),
|
|
|
+ start = Offset(30f, 30f),
|
|
|
+ end = Offset(200f, 200f)
|
|
|
+)
|
|
|
+
|
|
|
+val gradientBox = Brush.linearGradient(
|
|
|
+ colors = listOf(
|
|
|
+ Color(0xFFFDFFFC),
|
|
|
+ Color(0xFF2EC4B6)
|
|
|
+ ),
|
|
|
+ start = Offset(0f, 0f)
|
|
|
+)
|
|
|
|
|
|
@Composable
|
|
|
fun MainWindow(navController: NavHostController) {
|
|
|
|
|
|
var games by remember { mutableStateOf<List<Game>>(listOf()) }
|
|
|
+ var сompany by remember { mutableStateOf<List<Company>>(listOf()) }
|
|
|
|
|
|
LaunchedEffect(Unit) {
|
|
|
withContext(Dispatchers.IO) {
|
|
|
try {
|
|
|
- games = Constant.supabase.from("Game")
|
|
|
- .select().decodeList<Game>()
|
|
|
+ сompany = Constant.supabase.from("Company").select().decodeList<Company>()
|
|
|
+ games = Constant.supabase.from("Game").select().decodeList<Game>()
|
|
|
games.forEach { Game ->
|
|
|
Log.d("C", Game.name_game)
|
|
|
}
|
|
@@ -89,34 +118,12 @@ fun MainWindow(navController: NavHostController) {
|
|
|
|
|
|
val systemUiController = rememberSystemUiController()
|
|
|
|
|
|
- // Automatically hide the status bar when the composable is first displayed
|
|
|
LaunchedEffect(Unit) {
|
|
|
- systemUiController.isStatusBarVisible = false // Hide the status bar by default
|
|
|
- delay(5000) // Keep it visible for 5 seconds (if needed, you can adjust this)
|
|
|
- systemUiController.isStatusBarVisible = false // Ensure it stays hidden
|
|
|
+ systemUiController.isStatusBarVisible = false
|
|
|
+ delay(5000)
|
|
|
+ systemUiController.isStatusBarVisible = false
|
|
|
}
|
|
|
|
|
|
- val gradientButton = Brush.linearGradient(
|
|
|
- colors = listOf(
|
|
|
- Color(0xFFE71D36),
|
|
|
- Color(0xFFFF9F1C)
|
|
|
- ),
|
|
|
- start = Offset(30f, 30f),
|
|
|
- end = Offset(200f, 200f)
|
|
|
- )
|
|
|
-
|
|
|
- val gradientBox = Brush.linearGradient(
|
|
|
- colors = listOf(
|
|
|
- Color(0xFFFDFFFC),
|
|
|
- Color(0xFF2EC4B6)
|
|
|
- ),
|
|
|
- start = Offset(0f, 0f)
|
|
|
- )
|
|
|
-
|
|
|
- val kdamFontFamily = FontFamily(Font(R.font.kdam))
|
|
|
- val playfairdisplay = FontFamily(Font(R.font.playfair))
|
|
|
- val caveat = FontFamily(Font(R.font.caveat))
|
|
|
- val ibmplexmono = FontFamily(Font(R.font.ibm))
|
|
|
Canvas(
|
|
|
modifier = Modifier
|
|
|
.fillMaxWidth()
|
|
@@ -146,7 +153,7 @@ fun MainWindow(navController: NavHostController) {
|
|
|
Spacer(modifier = Modifier.width(145.dp))
|
|
|
Image(
|
|
|
painter = painterResource(id = R.drawable.personall),
|
|
|
- contentDescription = "Описание изображения",
|
|
|
+ contentDescription = "Описание изображения",
|
|
|
modifier = Modifier.size(90.dp)
|
|
|
)
|
|
|
}
|
|
@@ -234,235 +241,268 @@ fun MainWindow(navController: NavHostController) {
|
|
|
Spacer(Modifier.width(10.dp))
|
|
|
}
|
|
|
Spacer(Modifier.height(100.dp))
|
|
|
-
|
|
|
LazyColumn {
|
|
|
items(
|
|
|
games,
|
|
|
key = { Game -> Game.id },
|
|
|
- ) { Game->
|
|
|
- Card(
|
|
|
- modifier = Modifier
|
|
|
- .padding(20.dp, 0.dp, 20.dp, 0.dp)
|
|
|
- .background(color = Color(0xFFFDFFFC), shape = RoundedCornerShape(15.dp)),
|
|
|
- ) {
|
|
|
- Row {
|
|
|
- Spacer(Modifier.width(10.dp))
|
|
|
+ ) { film ->
|
|
|
+ GameItem(
|
|
|
+ game = film,
|
|
|
+ company = сompany
|
|
|
+ )
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+@Composable
|
|
|
+ fun GameItem(
|
|
|
+ game: Game,
|
|
|
+ company: List<Company>,
|
|
|
+ ) {
|
|
|
+ val imageState = rememberAsyncImagePainter(
|
|
|
+ model = ImageRequest.Builder(LocalContext.current).data(game.picture)
|
|
|
+ .size(Size.ORIGINAL).build()
|
|
|
+ ).state
|
|
|
+
|
|
|
+ Card(
|
|
|
+ modifier = Modifier
|
|
|
+ .padding(20.dp, 10.dp)
|
|
|
+ .background(color = Color(0xFFFDFFFC), shape = RoundedCornerShape(15.dp)),
|
|
|
+ ) {
|
|
|
+ Row {
|
|
|
+ Spacer(Modifier.width(10.dp))
|
|
|
+ Column {
|
|
|
+ val companyId = game.company
|
|
|
+ val companyy = company.find { it.id == companyId }
|
|
|
+ if (company != null) {
|
|
|
+ Text(
|
|
|
+ "${companyy?.name_company}",
|
|
|
+ fontSize = 20.sp,
|
|
|
+ fontFamily = kdamFontFamily,
|
|
|
+ color = Color(0xFF2EC4B6)
|
|
|
+ )
|
|
|
+ Text(
|
|
|
+ text = "Фэнтези",
|
|
|
+ fontSize = 12.sp,
|
|
|
+ fontFamily = kdamFontFamily,
|
|
|
+ color = Color(0xFFE71D36)
|
|
|
+ )
|
|
|
+ Spacer(Modifier.width(20.dp))
|
|
|
Column {
|
|
|
Text(
|
|
|
- text = "Hoyoverse",
|
|
|
- fontSize = 20.sp,
|
|
|
- fontFamily = kdamFontFamily,
|
|
|
- color = Color(0xFF2EC4B6)
|
|
|
- )
|
|
|
- Text(
|
|
|
- text = "Фэнтези",
|
|
|
- fontSize = 12.sp,
|
|
|
+ text = "Основные метки:",
|
|
|
+ fontSize = 14.sp,
|
|
|
fontFamily = kdamFontFamily,
|
|
|
- color = Color(0xFFE71D36)
|
|
|
+ color = Color(0xFF7F807E)
|
|
|
)
|
|
|
- Spacer(Modifier.width(20.dp))
|
|
|
- Column {
|
|
|
- Text(
|
|
|
- text = "Основные метки:",
|
|
|
- fontSize = 14.sp,
|
|
|
- fontFamily = kdamFontFamily,
|
|
|
- color = Color(0xFF7F807E)
|
|
|
+ Column(
|
|
|
+ Modifier.padding(10.dp)
|
|
|
+ ) {
|
|
|
+ Box(
|
|
|
+ modifier = Modifier
|
|
|
+ .width(107.dp)
|
|
|
+ .height(22.dp)
|
|
|
+ .background(
|
|
|
+ color = Color(0xFF2EC4B6),
|
|
|
+ shape = RoundedCornerShape(20.dp)
|
|
|
+ ),
|
|
|
+ contentAlignment = Alignment.Center
|
|
|
)
|
|
|
- Column(
|
|
|
- Modifier.padding(10.dp)
|
|
|
- ) {
|
|
|
- Box(
|
|
|
- modifier = Modifier
|
|
|
- .width(107.dp)
|
|
|
- .height(22.dp)
|
|
|
- .background(
|
|
|
- color = Color(0xFF2EC4B6),
|
|
|
- shape = RoundedCornerShape(20.dp)
|
|
|
- ),
|
|
|
- contentAlignment = Alignment.Center
|
|
|
- )
|
|
|
- {
|
|
|
- Text(
|
|
|
- text = "Пошаговая",
|
|
|
- color = Color(0xFFFDFFFC),
|
|
|
- fontFamily = caveat,
|
|
|
- fontSize = 20.sp
|
|
|
- )
|
|
|
- }
|
|
|
- Spacer(Modifier.height(7.dp))
|
|
|
- Box(
|
|
|
- modifier = Modifier
|
|
|
- .width(107.dp)
|
|
|
- .height(22.dp)
|
|
|
- .background(
|
|
|
- color = Color(0xFF2EC4B6),
|
|
|
- shape = RoundedCornerShape(20.dp)
|
|
|
- ),
|
|
|
- contentAlignment = Alignment.Center
|
|
|
- )
|
|
|
- {
|
|
|
- Text(
|
|
|
- text = "Ролевая",
|
|
|
- color = Color(0xFFFDFFFC),
|
|
|
- fontFamily = caveat,
|
|
|
- fontSize = 20.sp
|
|
|
- )
|
|
|
- }
|
|
|
- Spacer(Modifier.height(7.dp))
|
|
|
- Box(
|
|
|
- modifier = Modifier
|
|
|
- .width(107.dp)
|
|
|
- .height(22.dp)
|
|
|
- .background(
|
|
|
- color = Color(0xFF2EC4B6),
|
|
|
- shape = RoundedCornerShape(20.dp)
|
|
|
- ),
|
|
|
- contentAlignment = Alignment.Center
|
|
|
+ {
|
|
|
+ Text(
|
|
|
+ text = "Пошаговая",
|
|
|
+ color = Color(0xFFFDFFFC),
|
|
|
+ fontFamily = caveat,
|
|
|
+ fontSize = 20.sp
|
|
|
)
|
|
|
- {
|
|
|
- Text(
|
|
|
- text = "Стратегия",
|
|
|
- color = Color(0xFFFDFFFC),
|
|
|
- fontFamily = caveat,
|
|
|
- fontSize = 20.sp
|
|
|
- )
|
|
|
- }
|
|
|
}
|
|
|
- }
|
|
|
- }
|
|
|
- Column {
|
|
|
- Row {
|
|
|
- Spacer(Modifier.width(45.dp))
|
|
|
+ Spacer(Modifier.height(7.dp))
|
|
|
Box(
|
|
|
modifier = Modifier
|
|
|
- .width(130.dp)
|
|
|
- .height(30.dp)
|
|
|
- .border(
|
|
|
- BorderStroke(2.dp, Color(0x80B0B0B0)),
|
|
|
- shape = RoundedCornerShape(15.dp)
|
|
|
- )
|
|
|
+ .width(107.dp)
|
|
|
+ .height(22.dp)
|
|
|
+ .background(
|
|
|
+ color = Color(0xFF2EC4B6),
|
|
|
+ shape = RoundedCornerShape(20.dp)
|
|
|
+ ),
|
|
|
+ contentAlignment = Alignment.Center
|
|
|
)
|
|
|
{
|
|
|
Text(
|
|
|
- text = "Избранное: 23",
|
|
|
- fontSize = 16.sp,
|
|
|
- fontFamily = playfairdisplay,
|
|
|
- color = Color(0xFFFF9F1C),
|
|
|
- modifier = Modifier.align(Alignment.Center)
|
|
|
+ text = "Ролевая",
|
|
|
+ color = Color(0xFFFDFFFC),
|
|
|
+ fontFamily = caveat,
|
|
|
+ fontSize = 20.sp
|
|
|
)
|
|
|
}
|
|
|
- val size = 31.dp
|
|
|
-
|
|
|
- var isOrange by remember { mutableStateOf(false) }
|
|
|
-
|
|
|
- val buttonColor = if (isOrange) Color(0xFFFF9F1C) else Color.Gray
|
|
|
-
|
|
|
- Canvas(
|
|
|
+ Spacer(Modifier.height(7.dp))
|
|
|
+ Box(
|
|
|
modifier = Modifier
|
|
|
- .size(30.dp)
|
|
|
- .clickable(onClick = { isOrange = !isOrange })
|
|
|
- ) {
|
|
|
- drawStar(
|
|
|
- center = center,
|
|
|
- radius = size.toPx() / 2,
|
|
|
- color = buttonColor
|
|
|
+ .width(107.dp)
|
|
|
+ .height(22.dp)
|
|
|
+ .background(
|
|
|
+ color = Color(0xFF2EC4B6),
|
|
|
+ shape = RoundedCornerShape(20.dp)
|
|
|
+ ),
|
|
|
+ contentAlignment = Alignment.Center
|
|
|
+ )
|
|
|
+ {
|
|
|
+ Text(
|
|
|
+ text = "Стратегия",
|
|
|
+ color = Color(0xFFFDFFFC),
|
|
|
+ fontFamily = caveat,
|
|
|
+ fontSize = 20.sp
|
|
|
)
|
|
|
}
|
|
|
}
|
|
|
- Row {
|
|
|
- Spacer(Modifier.width(10.dp))
|
|
|
- Text(
|
|
|
- Game.name_game,
|
|
|
- fontSize = 20.sp,
|
|
|
- fontFamily = kdamFontFamily,
|
|
|
- color = Color(0xFF7F807E),
|
|
|
- )
|
|
|
- Spacer(Modifier.width(10.dp))
|
|
|
- Text(
|
|
|
- text = "16+",
|
|
|
- fontSize = 20.sp,
|
|
|
- fontFamily = kdamFontFamily,
|
|
|
- color = Color(0xFFE71D36),
|
|
|
- )
|
|
|
- }
|
|
|
- Image(
|
|
|
- painter = painterResource(id = R.drawable.test),
|
|
|
- contentDescription = "Описание изображения",
|
|
|
- modifier = Modifier
|
|
|
- .width(300.dp)
|
|
|
- .height(138.dp)
|
|
|
- )
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
- Column {
|
|
|
- Box(
|
|
|
- modifier = Modifier
|
|
|
- .fillMaxWidth()
|
|
|
- .padding(5.dp)
|
|
|
- .background(brush = gradientBox, shape = RoundedCornerShape(10.dp))
|
|
|
- ) {
|
|
|
- Text(
|
|
|
- text = "История начинается с того, что два члена экипажа «Звёздного экспресса», Март 7 и Дань Хэн, доставляют редкие реликвии Герте, хозяйке космической станции. Внезапно рейнджеры пустоты из " +
|
|
|
- "Легиона Антиматерии атакуют Космическую станцию и нападают на людей. К счастью, " +
|
|
|
- "Март 7 и Дань Хэн, а также ведущий исследователь Аста " +
|
|
|
- "и начальник службы безопасности Арлан смогли отбиться от них.",
|
|
|
- textAlign = TextAlign.Center,
|
|
|
- fontSize = 9.sp,
|
|
|
- fontFamily = ibmplexmono
|
|
|
- )
|
|
|
- }
|
|
|
- Spacer(modifier = Modifier.height(5.dp))
|
|
|
- }
|
|
|
- Row(
|
|
|
- modifier = Modifier
|
|
|
- .height(60.dp),
|
|
|
-
|
|
|
- ) {
|
|
|
+ }
|
|
|
+ Column {
|
|
|
+ Row {
|
|
|
+ Spacer(Modifier.width(45.dp))
|
|
|
Box(
|
|
|
modifier = Modifier
|
|
|
.width(130.dp)
|
|
|
- .height(40.dp)
|
|
|
- .padding(5.dp, 5.dp, 0.dp, 0.dp)
|
|
|
+ .height(30.dp)
|
|
|
.border(
|
|
|
BorderStroke(2.dp, Color(0x80B0B0B0)),
|
|
|
shape = RoundedCornerShape(15.dp)
|
|
|
- ),
|
|
|
+ )
|
|
|
)
|
|
|
{
|
|
|
Text(
|
|
|
- text = "Просмотры: 199",
|
|
|
- fontSize = 15.sp,
|
|
|
+ text = if (game.favourites == null) {
|
|
|
+ "Избранное: 0"
|
|
|
+ } else {
|
|
|
+ "Избранное: ${game.favourites}"
|
|
|
+ },
|
|
|
+ fontSize = 16.sp,
|
|
|
fontFamily = playfairdisplay,
|
|
|
- color = Color(0xFFE71D36),
|
|
|
+ color = Color(0xFFFF9F1C),
|
|
|
modifier = Modifier.align(Alignment.Center)
|
|
|
)
|
|
|
}
|
|
|
- Spacer(modifier = Modifier.width(70.dp))
|
|
|
- Button(
|
|
|
- onClick = { /*TODO*/ }, modifier = Modifier
|
|
|
- .background(
|
|
|
- color = Color(0xFFE71D36),
|
|
|
- shape = RoundedCornerShape(20.dp)
|
|
|
- ),
|
|
|
- colors = ButtonDefaults.buttonColors(
|
|
|
- containerColor = Color.Transparent
|
|
|
- )
|
|
|
+ val size = 31.dp
|
|
|
+
|
|
|
+ var isOrange by remember { mutableStateOf(false) }
|
|
|
+
|
|
|
+ val buttonColor = if (isOrange) Color(0xFFFF9F1C) else Color.Gray
|
|
|
+
|
|
|
+ Canvas(
|
|
|
+ modifier = Modifier
|
|
|
+ .size(30.dp)
|
|
|
+ .clickable(onClick = { isOrange = !isOrange })
|
|
|
) {
|
|
|
- Text(
|
|
|
- text = "Подробности",
|
|
|
- textAlign = TextAlign.Center,
|
|
|
- fontFamily = playfairdisplay,
|
|
|
- fontSize = 16.sp,
|
|
|
- color = Color(0xFFFDFFFC)
|
|
|
+ drawStar(
|
|
|
+ center = center,
|
|
|
+ radius = size.toPx() / 2,
|
|
|
+ color = buttonColor
|
|
|
)
|
|
|
}
|
|
|
}
|
|
|
+ Row(
|
|
|
+ modifier = Modifier.fillMaxWidth(),
|
|
|
+ horizontalArrangement = Arrangement.Center,
|
|
|
+ verticalAlignment = Alignment.CenterVertically
|
|
|
+ ) {
|
|
|
+ Text(
|
|
|
+ game.name_game,
|
|
|
+ fontSize = 20.sp,
|
|
|
+ fontFamily = kdamFontFamily,
|
|
|
+ color = Color(0xFF7F807E),
|
|
|
+ )
|
|
|
+ Spacer(Modifier.width(10.dp))
|
|
|
+ Text(
|
|
|
+ text = "16+",
|
|
|
+ fontSize = 20.sp,
|
|
|
+ fontFamily = kdamFontFamily,
|
|
|
+ color = Color(0xFFE71D36),
|
|
|
+ )
|
|
|
+ }
|
|
|
+ if (imageState is AsyncImagePainter.State.Success) {
|
|
|
+ {
|
|
|
+ }
|
|
|
+ Image(
|
|
|
+ painter = imageState.painter,
|
|
|
+ contentDescription = "Описание изображения",
|
|
|
+ modifier = Modifier
|
|
|
+ .width(300.dp)
|
|
|
+ .height(138.dp)
|
|
|
+ )
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ Column {
|
|
|
+ Box(
|
|
|
+ modifier = Modifier
|
|
|
+ .fillMaxWidth()
|
|
|
+ .padding(5.dp)
|
|
|
+ .background(brush = gradientBox, shape = RoundedCornerShape(10.dp))
|
|
|
+ ) {
|
|
|
+ Text(
|
|
|
+ game.short_description,
|
|
|
+ fontSize = 9.sp,
|
|
|
+ textAlign = TextAlign.Center,
|
|
|
+ fontFamily = ibmplexmono
|
|
|
+ )
|
|
|
+ }
|
|
|
+ Spacer(modifier = Modifier.height(5.dp))
|
|
|
+ }
|
|
|
+ Row(
|
|
|
+ modifier = Modifier
|
|
|
+ .height(60.dp),
|
|
|
+
|
|
|
+ ) {
|
|
|
+ Box(
|
|
|
+ modifier = Modifier
|
|
|
+ .width(130.dp)
|
|
|
+ .height(40.dp)
|
|
|
+ .padding(5.dp, 5.dp, 0.dp, 0.dp)
|
|
|
+ .border(
|
|
|
+ BorderStroke(2.dp, Color(0x80B0B0B0)),
|
|
|
+ shape = RoundedCornerShape(15.dp)
|
|
|
+ ),
|
|
|
+ )
|
|
|
+ {
|
|
|
+ Text(
|
|
|
+ text = if (game.views == null) {
|
|
|
+ "Просмотры: 0"
|
|
|
+ } else {
|
|
|
+ "Просмотры: ${game.views}"
|
|
|
+ },
|
|
|
+ fontSize = 15.sp,
|
|
|
+ fontFamily = playfairdisplay,
|
|
|
+ color = Color(0xFFE71D36),
|
|
|
+ modifier = Modifier.align(Alignment.Center)
|
|
|
+ )
|
|
|
+ }
|
|
|
+ Spacer(modifier = Modifier.width(70.dp))
|
|
|
+ Button(
|
|
|
+ onClick = { /*TODO*/ }, modifier = Modifier
|
|
|
+ .background(
|
|
|
+ color = Color(0xFFE71D36),
|
|
|
+ shape = RoundedCornerShape(20.dp)
|
|
|
+ ),
|
|
|
+ colors = ButtonDefaults.buttonColors(
|
|
|
+ containerColor = Color.Transparent
|
|
|
+ )
|
|
|
+ ) {
|
|
|
+ Text(
|
|
|
+ text = "Подробности",
|
|
|
+ textAlign = TextAlign.Center,
|
|
|
+ fontFamily = playfairdisplay,
|
|
|
+ fontSize = 16.sp,
|
|
|
+ color = Color(0xFFFDFFFC)
|
|
|
+ )
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
-}
|
|
|
+
|
|
|
|
|
|
fun DrawScope.drawStar(center: Offset, radius: Float, color: Color) {
|
|
|
val path = androidx.compose.ui.graphics.Path()
|