blegh fuck google

This commit is contained in:
Artemis 2025-03-07 14:39:18 +01:00
parent 3e2c8cb301
commit 4adbb69c37
4 changed files with 64 additions and 15 deletions

View file

@ -13,9 +13,9 @@ import androidx.navigation.compose.NavHost
import androidx.navigation.compose.composable
import androidx.navigation.compose.currentBackStackEntryAsState
import androidx.navigation.compose.rememberNavController
import dagger.hilt.android.AndroidEntryPoint
import pet.catcomm.ui.compose.BottomBar
import pet.catcomm.ui.compose.Peers
import pet.catcomm.ui.compose.SettingsPanel
import pet.catcomm.ui.compose.TopBar
import pet.catcomm.ui.theme.CatCommTheme
@ -34,12 +34,14 @@ fun CatCommApp() {
val navController = rememberNavController()
val currentBackStack by navController.currentBackStackEntryAsState()
val currentCCDestination = currentBackStack?.destination
val currentCCBackStackDestination = currentBackStack?.destination
val currentCCDestination =
navBarTabs.find { tab -> tab.route == currentCCBackStackDestination?.route }
CatCommTheme {
Scaffold(
topBar = {
TopBar()
TopBar(tabTitle = currentCCDestination?.label)
},
bottomBar = {
BottomBar(
@ -73,7 +75,7 @@ fun CatCommNavHost(
Peers()
}
composable(route = Settings.route) {
// TODO
SettingsPanel()
}
}
}

View file

@ -12,20 +12,20 @@ import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import androidx.lifecycle.compose.collectAsStateWithLifecycle
import androidx.lifecycle.viewmodel.compose.viewModel
import kotlinx.coroutines.delay
import kotlinx.coroutines.flow.map
import pet.catcomm.ui.theme.CatCommTheme
import pet.catcomm.ui.viewmodel.DataStoreViewModel
@Composable
fun Peer(name: String, modifier: Modifier = Modifier) {
Card(
modifier = modifier.padding(vertical = 4.dp, horizontal = 8.dp).fillMaxWidth(),
modifier = modifier
.padding(vertical = 4.dp, horizontal = 8.dp)
.fillMaxWidth(),
colors = CardDefaults.cardColors(
containerColor = MaterialTheme.colorScheme.primaryContainer
)
@ -58,8 +58,8 @@ fun Peers(
}
LazyColumn(modifier = modifier.padding(vertical = 4.dp)) {
items(items = listOf("nyx", "1686a", "8098", username.value)) {
name -> Peer(name = name)
items(items = listOf("nyx", "1686a", "8098", username.value)) { name ->
Peer(name = name)
}
}
}

View file

@ -0,0 +1,49 @@
package pet.catcomm.ui.compose
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.material3.Text
import androidx.compose.material3.TextField
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.saveable.rememberSaveable
import androidx.compose.runtime.setValue
import androidx.compose.ui.Modifier
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
@Composable
fun SettingsPanel(
modifier: Modifier = Modifier
) {
var usernameState by rememberSaveable { mutableStateOf("") }
Column(
modifier = modifier
.fillMaxWidth()
.padding(8.dp)
) {
TextField(
value = usernameState,
onValueChange = { new -> usernameState = new },
modifier = modifier.fillMaxWidth(),
label = { Text("Username") },
placeholder = { Text("i mean, you??") },
)
}
}
@Preview(showBackground = true, widthDp = 180)
@Composable
fun SettingsTextFieldPreview() {
Row(
modifier = Modifier.padding(16.dp)
) {
TextField(
value = "",
onValueChange = {},
)
}
}

View file

@ -1,25 +1,23 @@
package pet.catcomm.ui.compose
import androidx.compose.foundation.layout.padding
import androidx.annotation.StringRes
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
import androidx.compose.material3.TopAppBar
import androidx.compose.material3.TopAppBarDefaults
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import pet.catcomm.R
@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun TopBar(
modifier: Modifier = Modifier
@StringRes tabTitle: Int? = null,
) {
TopAppBar(
title = { Text(stringResource(R.string.app_name)) },
title = { Text(stringResource(tabTitle ?: R.string.app_name)) },
colors = TopAppBarDefaults.topAppBarColors(
containerColor = MaterialTheme.colorScheme.primary,
titleContentColor = MaterialTheme.colorScheme.onPrimary,
@ -30,5 +28,5 @@ fun TopBar(
@Preview(showBackground = true, widthDp = 180, heightDp = 120)
@Composable
fun TopBarPreview() {
TopBar(modifier = Modifier.padding(8.dp))
TopBar()
}