Compare commits

..

1 Commits

Author SHA1 Message Date
timklge
bf8a588020
Add profile selection dialog (#54)
All checks were successful
Build / build (push) Successful in 4m38s
* Setup BASE_URL ci config

* Add profile selection dialog

* Update changelog

* Enable pipeline for all branches

* Fix BASE_URL

* Add readme info

* Update button styling

* Only use profile selection dialog to input new profiles

* Update button colors
2025-05-29 19:56:54 +02:00
2 changed files with 47 additions and 33 deletions

View File

@ -18,6 +18,7 @@ import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.foundation.text.KeyboardOptions
import androidx.compose.foundation.verticalScroll
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.Add
import androidx.compose.material.icons.filled.Build
import androidx.compose.material.icons.filled.Close
import androidx.compose.material.icons.filled.Delete
@ -25,6 +26,7 @@ import androidx.compose.material.icons.filled.Done
import androidx.compose.material3.AlertDialog
import androidx.compose.material3.Button
import androidx.compose.material3.Card
import androidx.compose.material3.CardDefaults
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.FilledTonalButton
import androidx.compose.material3.Icon
@ -262,10 +264,29 @@ fun DetailScreen(isCreating: Boolean, reminder: Reminder, onSubmit: (updatedRemi
)
}
Row(verticalAlignment = Alignment.CenterVertically) {
Switch(checked = isActive, onCheckedChange = { isActive = it})
Spacer(modifier = Modifier.width(10.dp))
Text("Is Active")
Column(modifier = Modifier.fillMaxWidth()) {
if (enabledRideProfiles.isEmpty()) {
Text("Enabled for all profiles")
} else {
Text("Enabled for profiles:")
enabledRideProfiles.forEach { profileName ->
Row(
modifier = Modifier
.fillMaxWidth()
.padding(vertical = 4.dp),
verticalAlignment = Alignment.CenterVertically,
horizontalArrangement = Arrangement.SpaceBetween
) {
Text(profileName)
FilledTonalButton(onClick = {
enabledRideProfiles = enabledRideProfiles.toMutableSet().apply { remove(profileName) }
}) {
Icon(Icons.Default.Delete, contentDescription = "Delete profile")
}
}
}
}
}
FilledTonalButton(modifier = Modifier
@ -273,9 +294,15 @@ fun DetailScreen(isCreating: Boolean, reminder: Reminder, onSubmit: (updatedRemi
.height(60.dp), onClick = {
rideProfileDialogVisible = true
}) {
Icon(Icons.Default.Build, contentDescription = "Change Ride Profiles", modifier = Modifier.size(20.dp))
Icon(Icons.Default.Build, contentDescription = "Change Profiles", modifier = Modifier.size(20.dp))
Spacer(modifier = Modifier.width(5.dp))
Text("Ride Profiles: ${if (enabledRideProfiles.isEmpty()) "All" else enabledRideProfiles.joinToString(", ")}")
Text("Limit to Profile")
}
Row(verticalAlignment = Alignment.CenterVertically) {
Switch(checked = isActive, onCheckedChange = { isActive = it})
Spacer(modifier = Modifier.width(10.dp))
Text("Is Active")
}
FilledTonalButton(modifier = Modifier
@ -331,6 +358,7 @@ fun DetailScreen(isCreating: Boolean, reminder: Reminder, onSubmit: (updatedRemi
.fillMaxWidth()
.padding(10.dp),
shape = RoundedCornerShape(10.dp),
colors = CardDefaults.cardColors(containerColor = MaterialTheme.colorScheme.surface)
) {
Column(
modifier = Modifier
@ -339,28 +367,6 @@ fun DetailScreen(isCreating: Boolean, reminder: Reminder, onSubmit: (updatedRemi
horizontalAlignment = Alignment.CenterHorizontally,
verticalArrangement = Arrangement.spacedBy(10.dp)
) {
if (enabledRideProfiles.isEmpty()) {
Text("All profiles enabled")
} else {
Column(modifier = Modifier.fillMaxWidth()) {
enabledRideProfiles.forEach { profileName ->
Row(
modifier = Modifier
.fillMaxWidth()
.padding(vertical = 4.dp),
verticalAlignment = Alignment.CenterVertically,
horizontalArrangement = Arrangement.SpaceBetween
) {
Text(profileName)
FilledTonalButton(onClick = {
enabledRideProfiles = enabledRideProfiles.toMutableSet().apply { remove(profileName) }
}) {
Icon(Icons.Default.Delete, contentDescription = "Delete profile")
}
}
}
}
}
OutlinedTextField(
value = newProfileName,
@ -373,18 +379,23 @@ fun DetailScreen(isCreating: Boolean, reminder: Reminder, onSubmit: (updatedRemi
onClick = {
if (newProfileName.isNotBlank()) {
enabledRideProfiles = enabledRideProfiles.toMutableSet().apply { add(newProfileName) }
newProfileName = "" // Clear the text field
newProfileName = ""
rideProfileDialogVisible = false
}
},
modifier = Modifier.fillMaxWidth()
modifier = Modifier.fillMaxWidth().height(60.dp)
) {
Icon(Icons.Default.Add, contentDescription = "Add Profile")
Spacer(modifier = Modifier.width(5.dp))
Text("Add Profile")
}
FilledTonalButton(
onClick = { rideProfileDialogVisible = false },
modifier = Modifier.fillMaxWidth()
modifier = Modifier.fillMaxWidth().height(60.dp)
) {
Icon(Icons.Default.Close, contentDescription = "Cancel Editing")
Spacer(modifier = Modifier.width(5.dp))
Text("Close")
}
}
@ -399,6 +410,7 @@ fun DetailScreen(isCreating: Boolean, reminder: Reminder, onSubmit: (updatedRemi
.fillMaxWidth()
.padding(10.dp),
shape = RoundedCornerShape(10.dp),
colors = CardDefaults.cardColors(containerColor = MaterialTheme.colorScheme.surface)
) {
Column(modifier = Modifier
.padding(5.dp)
@ -443,6 +455,7 @@ fun DetailScreen(isCreating: Boolean, reminder: Reminder, onSubmit: (updatedRemi
.fillMaxWidth()
.padding(10.dp),
shape = RoundedCornerShape(10.dp),
colors = CardDefaults.cardColors(containerColor = MaterialTheme.colorScheme.surface)
) {
Column(modifier = Modifier
.padding(5.dp)
@ -478,6 +491,7 @@ fun DetailScreen(isCreating: Boolean, reminder: Reminder, onSubmit: (updatedRemi
.fillMaxWidth()
.padding(10.dp),
shape = RoundedCornerShape(10.dp),
colors = CardDefaults.cardColors(containerColor = MaterialTheme.colorScheme.surface)
) {
Column(modifier = Modifier
.padding(5.dp)