Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .idea/compiler.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

31 changes: 18 additions & 13 deletions app/src/main/java/com/example/trackpro/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.activity.result.contract.ActivityResultContracts
import androidx.compose.foundation.background
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
Expand Down Expand Up @@ -96,8 +95,11 @@ import com.example.trackpro.viewModels.VehicleFULLViewModel
import com.example.trackpro.viewModels.VehicleFULLViewModelFactory
import com.example.trackpro.viewModels.VehicleViewModel
import com.example.trackpro.viewModels.VehicleViewModelFactory
import com.example.trackpro.components.pressableRow
import com.example.trackpro.components.pressable
import com.example.trackpro.components.AppCard
import com.example.trackpro.components.SectionLabel
import com.example.trackpro.theme.atSize
import com.example.trackpro.theme.Spacing
import com.example.trackpro.theme.TrackProShapes
import com.example.trackpro.theme.TrackProType
Expand Down Expand Up @@ -317,17 +319,20 @@ class MainActivity : ComponentActivity() {
)
}
composable("drag") {
DragRaceScreen(database, sessionManager, vehicleFULLViewModel)
DragRaceScreen(database, sessionManager, vehicleFULLViewModel, onBack = { navController.popBackStack() })
}
composable("esptest") {
ESPConnectionTestScreen(onNavigateToSettings = { navController.navigate("settings") })
ESPConnectionTestScreen(
onNavigateToSettings = { navController.navigate("settings") },
onBack = { navController.popBackStack() }
)
}
composable(
"track/{trackId}",
arguments = listOf(navArgument("trackId") { type = NavType.LongType })
) { backStackEntry ->
val trackId = backStackEntry.arguments?.getLong("trackId") ?: 0L
TrackScreen(trackId = trackId)
TrackScreen(trackId = trackId, onBack = { navController.popBackStack() })
}
composable("dragsessions") {
DragTimesListView(viewModel = dragSessionViewModel, navController = navController)
Expand All @@ -353,7 +358,7 @@ class MainActivity : ComponentActivity() {
arguments = listOf(navArgument("vehicleid") { type = NavType.LongType })
) { backStackEntry ->
val vehicleId = backStackEntry.arguments?.getLong("vehicleid") ?: 0L
CarViewScreen(vehicleId = vehicleId)
CarViewScreen(vehicleId = vehicleId, onBack = { navController.popBackStack() })
}
composable(
route = "timeattacklistitem/{sessionid}",
Expand All @@ -367,12 +372,12 @@ class MainActivity : ComponentActivity() {
)
}
composable(route = "createvehicle") {
CarCreationScreen(database)
CarCreationScreen(database, onBack = { navController.popBackStack() })
}
composable(route = "timeattack/{vehicleId}/{trackId}") { backStackEntry ->
val vehicleId = backStackEntry.arguments?.getString("vehicleId")?.toLongOrNull() ?: -1L
val trackId = backStackEntry.arguments?.getString("trackId")?.toLongOrNull() ?: -1L
TimeAttackScreenView(vehicleId = vehicleId, trackId = trackId)
TimeAttackScreenView(vehicleId = vehicleId, trackId = trackId, onBack = { navController.popBackStack() })
}
composable(route = "trackandvehicle") {
TrackVehicleSelectorScreen(trackViewModel = trackViewModel, vehicleViewModel, navController)
Expand Down Expand Up @@ -451,7 +456,7 @@ fun MainScreen(
)
Text(
text = "Performance Telemetry",
style = TrackProType.body.copy(fontSize = 11.sp),
style = TrackProType.body.atSize(11.sp),
color = TrackProTheme.colors.textFaint
)
}
Expand Down Expand Up @@ -544,7 +549,7 @@ fun MainScreen(
}
Text(
text = "TRACKPRO",
style = TrackProType.label.copy(fontSize = 13.sp, letterSpacing = 2.sp),
style = TrackProType.label.atSize(13.sp).copy(letterSpacing = 2.sp),
color = TrackProTheme.colors.textPrimary
)
// Spacer to balance the row
Expand Down Expand Up @@ -705,14 +710,14 @@ private fun ActionCard(
val alpha = if (disabled) 0.4f else 1f
val iconSize = if (halfWidth) 14.dp else if (fullWidth) 18.dp else 16.dp
val iconBoxSize = if (halfWidth) 26.dp else if (fullWidth) 34.dp else 30.dp
val titleStyle = if (fullWidth) TrackProType.titleMedium else TrackProType.titleMedium.copy(fontSize = 13.sp)
val titleStyle = if (fullWidth) TrackProType.titleMedium else TrackProType.titleMedium.atSize(13.sp)
val subtitleSize = if (halfWidth) 9.sp else 10.sp
val vertPadding = if (halfWidth) 10.dp else if (fullWidth) 12.dp else 10.dp

AppCard(
modifier = Modifier
.fillMaxWidth()
.then(if (!disabled) Modifier.clickable(onClick = onClick) else Modifier),
.pressable(onClick = onClick, enabled = !disabled),
padding = 0.dp
) {
Box {
Expand Down Expand Up @@ -758,7 +763,7 @@ private fun ActionCard(
)
Text(
text = subtitle,
style = TrackProType.body.copy(fontSize = subtitleSize),
style = TrackProType.body.atSize(subtitleSize),
color = TrackProTheme.colors.textMuted.copy(alpha = alpha),
maxLines = 2,
overflow = TextOverflow.Ellipsis
Expand Down Expand Up @@ -799,7 +804,7 @@ private fun DrawerItem(
Row(
modifier = Modifier
.fillMaxWidth()
.clickable(onClick = onClick)
.pressableRow(onClick = onClick)
.padding(horizontal = 20.dp, vertical = 10.dp),
verticalAlignment = Alignment.CenterVertically,
horizontalArrangement = Arrangement.spacedBy(12.dp)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,9 @@ package com.example.trackpro.screens

import android.annotation.SuppressLint
import android.graphics.Typeface
import androidx.compose.animation.core.FastOutSlowInEasing
import androidx.compose.animation.core.animateFloatAsState
import androidx.compose.animation.core.tween
import androidx.compose.foundation.Canvas
import androidx.compose.foundation.background
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
Expand Down Expand Up @@ -40,12 +37,15 @@ import androidx.compose.ui.unit.sp
import androidx.core.graphics.toColorInt
import com.example.trackpro.TrackProApp
import com.example.trackpro.extrasForUI.TrackProTheme
import com.example.trackpro.components.pressable
import com.example.trackpro.components.AppTopBar
import com.example.trackpro.components.SectionLabel
import com.example.trackpro.components.StatCell
import com.example.trackpro.components.StatCellDivider
import com.example.trackpro.components.StatCellSize
import com.example.trackpro.theme.atSize
import com.example.trackpro.theme.DataVizColors
import com.example.trackpro.theme.Motion
import com.example.trackpro.theme.Spacing
import com.example.trackpro.theme.TrackProType
import com.example.trackpro.managerClasses.JsonReader
Expand All @@ -56,7 +56,10 @@ import kotlin.math.sin

@SuppressLint("MissingPermission")
@Composable
fun ESPConnectionTestScreen(onNavigateToSettings: () -> Unit) {
fun ESPConnectionTestScreen(
onNavigateToSettings: () -> Unit,
onBack: () -> Unit
) {
val context = LocalContext.current
val app = context.applicationContext as TrackProApp

Expand Down Expand Up @@ -104,12 +107,17 @@ fun ESPConnectionTestScreen(onNavigateToSettings: () -> Unit) {
GpsProviderType.PHONE_GPS -> "Phone GPS Mode"
},
accent = if (isConnected) TrackProTheme.colors.accent else TrackProTheme.colors.textFaint,
onBack = onBack,
trailing = {
Text(
text = "Change",
style = TrackProType.label,
color = TrackProTheme.colors.accent,
modifier = Modifier.clickable { onNavigateToSettings() }
// Bare text was the smallest tap target on the screen; give it
// real padding and a press response.
modifier = Modifier
.pressable(onClick = onNavigateToSettings, scale = 0.94f)
.padding(horizontal = Spacing.sm, vertical = 4.dp)
)
}
)
Expand Down Expand Up @@ -250,7 +258,10 @@ fun StyledSpeedometer(
) {
val animatedSpeed by animateFloatAsState(
targetValue = speed,
animationSpec = tween(durationMillis = 600, easing = FastOutSlowInEasing),
// Was tween(600): every GPS tick restarted a fixed ramp from wherever it had
// got to, so a steadily changing speed animated in visible steps. A spring
// re-targets continuously from the current value instead.
animationSpec = Motion.standard(),
label = "speed"
)

Expand Down Expand Up @@ -396,7 +407,7 @@ private fun TelemetryRow(label: String, value: String, textPrimary: Color, textM
Text(label.uppercase(), style = TrackProType.label, color = textMuted)
Text(
value,
style = TrackProType.body.copy(fontSize = 13.sp, fontFamily = androidx.compose.ui.text.font.FontFamily.Monospace),
style = TrackProType.body.atSize(13.sp).copy(fontFamily = androidx.compose.ui.text.font.FontFamily.Monospace),
color = textPrimary
)
}
Expand Down
31 changes: 19 additions & 12 deletions app/src/main/java/com/example/trackpro/screens/SettingsScreen.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
Expand All @@ -27,12 +25,14 @@ import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import com.example.trackpro.TrackProApp
import com.example.trackpro.components.AppCard
import com.example.trackpro.components.AppTopBar
import com.example.trackpro.components.ScreenScaffold
import com.example.trackpro.components.isScrolledUnderChrome
import com.example.trackpro.components.SectionLabel
import com.example.trackpro.components.ToggleChip
import com.example.trackpro.extrasForUI.AppDropdownField
import com.example.trackpro.extrasForUI.TrackProTheme
import com.example.trackpro.models.GpsProviderType
import com.example.trackpro.theme.atSize
import com.example.trackpro.theme.Spacing
import com.example.trackpro.theme.TrackProType

Expand All @@ -49,17 +49,24 @@ fun SettingsScreen(onBack: () -> Unit, onRequestBluetoothPermission: () -> Unit)
val useDarkTheme by app.useDarkTheme.collectAsState()
val useMetric by app.useMetricUnits.collectAsState()

Column(
modifier = Modifier
.fillMaxSize()
.background(TrackProTheme.colors.bgDeep)
) {
AppTopBar(title = "Settings", accent = TrackProTheme.colors.textMuted, onBack = onBack)
val scrollState = rememberScrollState()
val scrolled by scrollState.isScrolledUnderChrome()

ScreenScaffold(
title = "Settings",
accent = TrackProTheme.colors.textMuted,
onBack = onBack,
contentScrolled = scrolled
) { contentPadding ->
Column(
modifier = Modifier
.padding(Spacing.md)
.verticalScroll(rememberScrollState()),
.verticalScroll(scrollState)
.padding(
top = contentPadding.calculateTopPadding() + Spacing.md,
start = Spacing.md,
end = Spacing.md,
bottom = Spacing.md
),
verticalArrangement = Arrangement.spacedBy(Spacing.md)
) {
// --- Section: Hardware & GPS ---
Expand Down Expand Up @@ -252,7 +259,7 @@ private fun GpsRateRow(selectedHz: Int, confirmedHz: Int?, onSelect: (Int) -> Un
if (confirmedHz != null) {
Text(
text = if (confirmedHz == selectedHz) "· confirmed" else "· device at ${confirmedHz}Hz",
style = TrackProType.body.copy(fontSize = 10.sp),
style = TrackProType.body.atSize(10.sp),
// A mismatch between requested and confirmed rate is a real problem
// worth flagging, so this is one of the few places color is earned.
color = if (confirmedHz == selectedHz) TrackProTheme.colors.deltaGood
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,12 @@ import com.example.trackpro.dataClasses.TrackCoordinatesData
import com.example.trackpro.dataClasses.TrackMainData
import com.example.trackpro.dataClasses.LatLonOffset
import com.example.trackpro.extrasForUI.TrackProTheme
import com.example.trackpro.components.Haptic
import com.example.trackpro.components.AppCard
import com.example.trackpro.components.AppTopBar
import com.example.trackpro.components.PrimaryButton
import com.example.trackpro.components.ToggleChip
import com.example.trackpro.theme.atSize
import com.example.trackpro.theme.DataVizColors
import com.example.trackpro.theme.Spacing
import com.example.trackpro.theme.TrackProShapes
Expand Down Expand Up @@ -301,7 +303,7 @@ private fun TrackInfoCard(name: String, country: String, mode: String, onClick:
style = TrackProType.titleMedium,
color = TrackProTheme.colors.textPrimary
)
Text("Mode: ${mode.uppercase()}", style = TrackProType.body.copy(fontSize = 12.sp), color = TrackProTheme.colors.accent)
Text("Mode: ${mode.uppercase()}", style = TrackProType.body.atSize(12.sp), color = TrackProTheme.colors.accent)
}
PrimaryButton(
text = "Edit",
Expand All @@ -320,6 +322,7 @@ private fun MarkSectorButton(count: Int, enabled: Boolean, onClick: () -> Unit)
text = "Mark Sector ${count + 1}",
onClick = onClick,
enabled = enabled,
haptic = Haptic.Confirm,
accent = TrackProTheme.colors.accent,
modifier = Modifier.fillMaxWidth().height(48.dp)
)
Expand Down Expand Up @@ -395,6 +398,7 @@ private fun LiveControls(isRecording: Boolean, onToggle: () -> Unit) {
PrimaryButton(
text = if (isRecording) "Stop Recording" else "Start GPS Recording",
onClick = onToggle,
haptic = Haptic.Confirm,
accent = if (isRecording) TrackProTheme.colors.danger.copy(alpha = 0.18f) else TrackProTheme.colors.bgElevated,
contentColor = if (isRecording) TrackProTheme.colors.danger else TrackProTheme.colors.textPrimary,
modifier = Modifier.fillMaxWidth().height(56.dp)
Expand All @@ -415,6 +419,7 @@ private fun ManualControls(onUndo: () -> Unit, onSave: () -> Unit, canSave: Bool
text = "Save Track",
onClick = onSave,
enabled = canSave,
haptic = Haptic.Confirm,
accent = TrackProTheme.colors.accent,
modifier = Modifier.weight(1f).height(56.dp)
)
Expand Down
Loading
Loading