Загрузка данных


package com.example.kuznetsovworking

import android.os.Bundle
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.material3.Button
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.sp

class MainActivity : ComponentActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContent {
            App()
        }
    }
}

@Composable
fun App() {
    // Запоминаем номер экрана: 1, 2 или 3
    val screen = remember { mutableStateOf(1) }

    Column(
        modifier = Modifier.fillMaxSize(),
        horizontalAlignment = Alignment.CenterHorizontally,
        verticalArrangement = Arrangement.Center
    ) {
        // Текст с названием экрана
        Text(
            text = when (screen.value) {
                1 -> "Экран A"
                2 -> "Экран B"
                else -> "Экран C"
            },
            fontSize = 32.sp
        )

        // Кнопка для переключения
        Button(
            onClick = {
                screen.value = when (screen.value) {
                    1 -> 2
                    2 -> 3
                    else -> 1
                }
            }
        ) {
            Text(
                text = when (screen.value) {
                    1 -> "Перейти на B"
                    2 -> "Перейти на C"
                    else -> "Назад на A"
                }
            )
        }
    }
}