Start with no cars so the first one is added on purpose.

This commit is contained in:
RallyBlock committed 2026-10-22 21:11:56 -07:00
1 parent a164d9c135
commit 13451a9955
8 files changed
+90 -37

No files matched your search

@@ -150,8 +150,15 @@ fun HomeScreen(
IconButton(onClick = onSettings) {
Icon(Icons.Filled.Settings, contentDescription = "Car")
}
IconButton(onClick = onNewNight) {
Icon(Icons.Filled.Add, contentDescription = "New race night")
IconButton(
onClick = {
if (state.cars.isEmpty()) viewModel.addCar(onSettings) else onNewNight()
},
) {
Icon(
Icons.Filled.Add,
contentDescription = if (state.cars.isEmpty()) "Add a car" else "New race night",
)
}
},
)
@@ -166,6 +173,9 @@ fun HomeScreen(
modifier = Modifier.fillMaxSize(),
contentPadding = padding,
) {
if (state.cars.isEmpty()) {
item { EmptyGarage(onAddCar = { viewModel.addCar(onSettings) }) }
} else {
item {
HomeHeader(
profile = state.profile,
@@ -193,6 +203,7 @@ fun HomeScreen(
NightCard(night, onClick = { onOpenNight(night.night.id) })
}
}
}
}
}
}
@@ -283,6 +294,29 @@ private fun HomeHeader(
}
}
@Composable
private fun EmptyGarage(onAddCar: () -> Unit) {
Column(Modifier.padding(horizontal = 16.dp, vertical = 12.dp)) {
Text(
"No car yet",
style = MaterialTheme.typography.titleLarge,
)
Text(
"Add a car to start a log. Each car gets its own 8-digit token.",
color = MaterialTheme.colorScheme.onSurfaceVariant,
modifier = Modifier.padding(top = 8.dp),
)
Button(
onClick = onAddCar,
modifier = Modifier
.fillMaxWidth()
.padding(top = 16.dp),
) {
Text("Add a car")
}
}
}
@Composable
private fun EmptyNights() {
Column(Modifier.padding(horizontal = 16.dp, vertical = 12.dp)) {
@@ -366,3 +400,4 @@ private fun CarMark() {
)
}
}
@@ -200,7 +200,7 @@ fun SettingsScreen(onBack: () -> Unit) {
)
},
bottomBar = {
if (viewModel.ready) {
if (viewModel.ready && viewModel.carId != 0L) {
PitActionButton(
text = if (viewModel.saving) "Saving…" else "Save",
onClick = { viewModel.save(onBack) },
@@ -215,6 +215,20 @@ fun SettingsScreen(onBack: () -> Unit) {
}
} else {
PitScroll(padding) {
if (viewModel.carId == 0L) {
Text(
"Add a car before you log a night. Pressures are PSI and tire heat is °F.",
color = MaterialTheme.colorScheme.onSurfaceVariant,
)
OutlinedButton(
onClick = viewModel::addCar,
modifier = Modifier
.fillMaxWidth()
.padding(top = 12.dp),
) {
Text("Add a car")
}
} else {
Text(
"New race nights start with this car. Pressures are PSI and tire heat is °F.",
color = MaterialTheme.colorScheme.onSurfaceVariant,
@@ -276,6 +290,7 @@ fun SettingsScreen(onBack: () -> Unit) {
) {
Text("Add a car")
}
}
SectionLabel("Add a car from a token")
WordsField(
label = "Token from another phone",