/* * Created by sweetbread * Copyright (c) 2025. All rights reserved. */ package ru.risdeveau.geotracker import android.os.Bundle import androidx.activity.ComponentActivity import androidx.activity.compose.setContent import androidx.activity.enableEdgeToEdge import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.padding import androidx.compose.material3.CircularProgressIndicator import androidx.compose.material3.MaterialTheme import androidx.compose.material3.OutlinedTextField import androidx.compose.material3.Scaffold import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.runtime.LaunchedEffect import androidx.compose.runtime.getValue import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.remember import androidx.compose.runtime.setValue import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.text.TextStyle import androidx.compose.ui.text.font.FontStyle import androidx.compose.ui.text.style.TextDecoration import kotlinx.coroutines.launch import ru.risdeveau.geotracker.ui.theme.GeoTrackerTheme import splitties.resources.appColor import splitties.resources.appStr class MainActivity : ComponentActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) enableEdgeToEdge() setContent { GeoTrackerTheme { Scaffold(modifier = Modifier.fillMaxSize()) { innerPadding -> Box( Modifier .padding(innerPadding) .fillMaxSize()) { var screen by remember { mutableStateOf(Screen.Loading) } when (screen) { Screen.Main -> TODO() Screen.Settings -> { Settings(Modifier.align(Alignment.Center)) } Screen.Loading -> { var loading by remember { mutableStateOf(true) } if (loading) { CircularProgressIndicator(Modifier.align(Alignment.Center)) LaunchedEffect(true) { launch { screen = if (health(SettingsPreferences.url)) Screen.Main else Screen.Settings } } } } } } } } } } } sealed class Screen { object Main : Screen() object Settings : Screen() object Loading : Screen() } @Composable fun Settings(modifier: Modifier = Modifier) { var username by remember { mutableStateOf("") } var url by remember { mutableStateOf("") } Column (modifier = modifier) { OutlinedTextField( value = username, onValueChange = { username = it }, label = { Text(appStr(R.string.username)) } ) OutlinedTextField( value = url, onValueChange = { url = it }, placeholder = { Text("https://geo.example.com", style = TextStyle(color = MaterialTheme.colorScheme.onSurfaceVariant)) }, label = { Text(appStr(R.string.server_url)) } ) } }