feat: add simple navigation
This commit is contained in:
@@ -10,6 +10,7 @@ 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
|
||||
@@ -38,14 +39,27 @@ class MainActivity : ComponentActivity() {
|
||||
Modifier
|
||||
.padding(innerPadding)
|
||||
.fillMaxSize()) {
|
||||
var loading by remember { mutableStateOf(true) }
|
||||
var screen by remember { mutableStateOf<Screen>(Screen.Loading) }
|
||||
|
||||
if (loading) {
|
||||
CircularProgressIndicator(Modifier.align(Alignment.Center))
|
||||
LaunchedEffect(true) {
|
||||
launch {
|
||||
if (!health(SettingsPreferences.url)) {
|
||||
Settings()
|
||||
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
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -60,6 +74,7 @@ class MainActivity : ComponentActivity() {
|
||||
sealed class Screen {
|
||||
object Main : Screen()
|
||||
object Settings : Screen()
|
||||
object Loading : Screen()
|
||||
}
|
||||
|
||||
@Composable
|
||||
@@ -68,7 +83,7 @@ fun Settings(modifier: Modifier = Modifier) {
|
||||
var url by remember { mutableStateOf("") }
|
||||
|
||||
|
||||
Box (modifier = modifier) {
|
||||
Column (modifier = modifier) {
|
||||
OutlinedTextField(
|
||||
value = username,
|
||||
onValueChange = { username = it },
|
||||
|
||||
Reference in New Issue
Block a user